Identifying coupon code entry in OrderCarrier.OrderDiscounts

If I have an orderCarrier with two discounts where I got one from a coupon code and the other from for example order total being above a certain amount, then I can find my coupon code in CampaignInfo and the discount amounts in the two entries in OrderDiscounts. But how do I know which entry in OrderDiscounts is the one from the coupon code?

Litium version: 7.4.2

There might be (much) simpler way, than the first one I can think of… but in case there is not:

I think… every orderdiscount has a reference to a CampaignId if its from a campaign.
If you fetch the campaigns for each discount, you can look for the campaign that has discount code condition… and if you need to check for the used campaign code. you can look in that conditions list of campaigncodes to see if the one in CampaignInfo is present…something like that maybe?

another way… might be to clone the ordercarrier… add the campaigncode… and check which campaign is added to orderdiscount… as a test… sort of the way litium adds the campaigncode to see if its valid?

Do you need to match to the specific voucher code or just see which discount is from a voucher code?

The OrderDiscount entry has a property DiscountDescription that will be set to “Voucher”.

Like Martin said, you could fetch the campaign and inspect its ConditionInfo to see if it has a VoucherCodeCondition and from there get the voucher codes.

conditionInfo.GetData<VoucherCodeCondition.Data>()

But if it’s a single use code and you’re checking after the order is placed, the used code will have been removed from the list.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.