Developer forum

Forum » Development » Order.OnAfterGenerateOrderXmlArgs

Order.OnAfterGenerateOrderXmlArgs

Martin Moen
Reply

I'm following the "Gold membership" example here:
https://doc.dynamicweb.com/documentation-9/integration/integration-framework-old-structure/extensibility/live-integration-notifications

I can successfully add a node to the xml, and it is sent to BC as expected. The field I'm sending is having an impact on price calculcation, so the response to the request can result in different prices. This works whenever I add products, or change quantity, etc.

But if I dont change anything on the order, just adding a new value to the XML document the request is not beeing sent, and the cart is using the cached prices.
How can I make sure that the cart is beeing calculcated in BC whenever my custom value is changed?

I tried to add these:
Services.Orders.ForcePriceRecalculation();
Services.Orders.ClearCachedPrices();
Services.Orders.RemoveOrderCache();

Inside the subscriber, but it does not help. The cart is not sent to BC unless quantity or something like that is changed.
Need help!


Replies

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply
This post has been marked as an answer

I think it's the hash calculation from OrderHandler in Live Integration:

var requestXml = new OrderXmlGenerator().GenerateOrderXml(settings, order, xmlGeneratorSettings, logger);
xmlGeneratorSettings.GenerateXmlForHash = true;
var requestXmlForHash = new OrderXmlGenerator().GenerateOrderXml(settings, order, xmlGeneratorSettings, logger);

if (createOrder && settings.SaveCopyOfOrderXml && liveIntegrationSubmitType == SubmitType.LiveOrderOrCart)
{
    SaveCopyOfXml(order.Id, requestXml, logger);
}

// calculate current hash
string currentHash = Helpers.CalculateHash(requestXmlForHash);

// get last hash
string lastHash = GetLastOrderHash(settings);

if (!string.IsNullOrEmpty(lastHash) && lastHash == currentHash)
{
    // no changes to order
    Diagnostics.ExecutionTable.Current.Add("DynamicwebLiveIntegration.OrderHandler.UpdateOrder END");
    return true;
}

// save this hash for next calls
SaveOrderHash(settings, currentHash);

This means that if your order data doesn't change, the XML remains the same and its hash therefore stays the same and then the order isn't sent to the ERP. Can you modify a custom order field also and make sure that "AddOrderLineFieldsToRequest" is turned on?

Imar

Votes for this answer: 1
 
Martin Moen
Reply

Thanks Imar. Looks like you are correct. I modified a custom order field, and it recalculated as I wanted :)

 

You must be logged in to post in the forum