Try our conversational search powered by Generative AI!

Get current order group subtotal (with discounts applied) in custom discount promotion



I am developing a custom shipping discount promotion and I need to get the current sub total of the order group with discounts applied so I can pass that to GetStatusForSpendAmountPromotion. My order can have multiple order forms so I need the totals of all these after a line item or order level discount has already been fulfilled.

I have tried affected entries, but that is just for the order form and I have also tried context.OrderGroup.GetAllForms().Sum(f => f.GetSubTotal(Currency.USD).Amount) but that doesnt include the discount in it.

Thanks for any help,


Edited, Jun 27, 2018 22:03

Normally the answer would be "OrderGroup.GetTotal()", but in this case things are a lot trickier.

First off. The PromotionEngine processes promotions on OrderForm-level. So if you look at OrderGroup total for a promotion it may be applied to several OrderForms. (Depending on your setup) This also means that the "context" that you have access to in your PromotionProcessor is recreated for every OrderForm passed into the PromotionEngine.

But more importantly, the discounts aren't actually set on the various components until after everything has been evaluated. Not until after that would something like OrderGroup.GetTotal() give you the value that you're looking for.

While the promotion engine is running your PromotionProcessor code it has access to context.CurrentOrderFormTotal which can be used to Evaluate promotions that work with a specific "OrderTotal". But again, the order total referenced when creating promotions is actually the orderform total.

I don't really have a good solution for you for this beyond creating your own promotion engine, but that can get very complicated and is usually not recommended.

Edited, Jun 28, 2018 1:52

Thanks for the input Jafet. I think I can use context.CurrentOrderFormTotal if I assume some things about the orders.

Jun 28, 2018 15:00
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.