London Dev Meetup Rescheduled! Due to unavoidable reasons, the event has been moved to 21st May. Speakers remain the same—any changes will be communicated. Seats are limited—register here to secure your spot!

Report Coupon/Voucher usage

Vote:
 

How Can I retrieve the following Information about coupons/vouchers?

Coupons have been redeemed.

Order Number where the coupon was redeemed.

I am on Latest Commerce Version.

#260150
Aug 05, 2021 13:46
Vote:
 

Hi Khan,

The coupon code does exist for the save PO in OrderFormEx.

SELECT * FROM OrderFormEx where Epi_CouponCodes  IS NOT NULL 

So we can retrieve the PO + Coupon Codes with this way:

var pos = _orderRepository.Load<IPurchaseOrder>(CustomerContext.Current.CurrentContactId);
var couponsWithOrders = new Dictionary<string, string>();
foreach (var po in pos)
{
    List<string> couponList = new List<string>();
    foreach (var form in po.Forms)
    {
          couponList.AddRange(form.CouponCodes);
     }
    couponsWithOrders.Add(po.OrderNumber, string.Join(",", couponList.Select(x=>x)?.ToList()));
}
#260152
Aug 05, 2021 14:58
Vote:
 

I am quite sure this is one of the recipe in my second book that you purchased :)

#260158
Aug 05, 2021 19:49
Vote:
 

:)

It was the very custom thing I guess,
IContentLoader, IPromotionService and PromotionInformationRepository helped, but I had to record Coupon Usages my self

#260350
Edited, Aug 09, 2021 15:09
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* 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.