Commerce Version 11.2.1CMS Version 10.10.4
We've come across an issue that once a PurchaseOrder has been created, should any changes get made to the LineItems prior to a payment capture, on Save of the PO to then ProcessPayments, the PO re-runs the Promotions and changes the expected Totals.
To give some background on what is happening:
Order is updated - this occurs when ERP notifies of order shipping and will include updates
If the PurchaseOrder originally had an OrderPromotion applied to it (automatic, no coupon code needed), when we save the PO in step 4 above, the Order Promotion will be re-run. As we've updated the prices, the 20% order discount that exists gets executed a 2nd time and therefore we end up with a lower Capture amount.
I want to somehow disable all Promotions that may exist against the PO.
I've tried the following:
Removing the Promotions
Temporarily exclude the Entry items
I've tried other combinations with PromotionInformation / PromotionData objects that are in the Promotions collection, but this doesn't seem to have much affect.
Any tips out there.?
Regardless if the promotion engine is run or not, wont the ERP update that contained 1 less line item change the price for the order? Or if it changes the shipping fee, you still have the base problem that the cost for the user changed behind the scenes.
Generally I think your problem is that you are running your promotions on purchase orders. I don't see a scenario where you would want to evaluate all the promotions against a created purchase order. When the user clicks on the final "buy" button, you convert the cart to a purchase order. And promotions have already been applied to the cart (given that you run promotions), so the applied promotions are still in the purchaseorder.
Am I sort of making sense in your case or have I misunderstood stomething?
Yes, the ERP update changes the total order cost, but the update provides the Tax / Shipping / Order Total costs which then get rewritten to the PO. At this point, the user has already bought the order, so we know longer are using Cart, but a PO.
The issue is that when we update the values and save the PO, the Order Promotion is running again and reducing the total order cost, changing it from what ERP provided. This then means the amount we Capture is different to what the PO should be. I'm also not actually running the Promotion processor, it just appears to be running on save.
So I'm trying to understand why it re-applies this promotion and how to prevent it.
Do you use any workflow when the ERP calls your server with updated order information?
I'm not specifically calling any, the update happens on _orderRepository.Save(po)
After that, we then do po.ProcessPayments()
orderRepository.Save shouldn't run the promotions. It will calculate the totals however, but not run promotions. Hm. You sure you don't have any code in that path that in turn runs promotions?