November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
Hi Pierre,
Take a look here in Foundation. In that example, it's creating a PromotionEngineSettings object with an empty constructor. If you look at that class, there is another contructor that you can pass a RequestFulfillmentStatus enum. I am wondering if you were to set that to the value All and then looked at the results that come back, if the RewardDescription for the failed items will have more info about why it failed? There is a property on RewareDescription called Description that is intended for debugging, but, may be helpful in getting the info you need. I hope this helps!
-John
Hi Pierre,
I think this is not straight forward to show the reason for the customer why the coupon code is not working using the promotion engine. Here are some steps which I used in my current project to display a meaning full message if the coupon code does not work.
Create an OrderGroup Extension class and retrieve already applied coupon code on the cart and match to the supplied coupon code if it matches then return message e.g. 'The supplied coupon code already applied'
/// <summary>
/// Gets the applied coupon codes for the first order form.
/// </summary>
public static ICollection<string> GetCouponCodes(this IOrderGroup orderGroup)
{
return orderGroup?.GetFirstForm()?.CouponCodes;
}
public bool AddCouponCode(ICart cart, string couponCode)
{
var couponCodes = cart.GetCouponCodes();
if (couponCodes != null && couponCodes.Contains(couponCode))
return false;
couponCodes?.Add(couponCode);
var couponApplied =
cart.ApplyDiscounts(_promotionEngine, new PromotionEngineSettings())
.Where(r => r.Status == FulfillmentStatus.Fulfilled)
.Select(c => c.Promotion?.Coupon?.Code)
.Where(i => i != null)
.Any(c => c.Equals(couponCode, StringComparison.OrdinalIgnoreCase));
if (!couponApplied)
{
couponCodes?.Remove(couponCode);
}
return couponApplied;
}
Thanks,
Thanks for your answer. Yeah i think i'll have to make my own logic for this.
The main thing i was after was to check if the customer had already applied the coupon in a previous order, for a coupon that has a redemption limit of 1 per customer.
That piece of work has been set aside for now, but will get back to it eventually :)
The redemption limit will not work for an anonymous user, because how you identify the same user added promo code in the incognito window for the same product or item.
But for the logged-in user, we can traverse all purchase orders (using own custom logic) to check the same coupon code is not applied previously or get the count as redemption limit before applying coupon code on the cart.
Hi all,
We have some promotions on our website to which i am going to add some redemption limits (1 per customer).
That is all working fine, just one thing that i feel is missing (maybe it is just me not able to find it).
When a discount code is applied to the cart, it eventually fails because it is not applicable, that can be for many reasons (redemption limits, invalid code, no entries in the cart related to that discount code, etc...)
I use :
ICart.ApplyDiscounts()
Is there any way to get the reason why the code could not be applied ?
This way i could display a meaningful message to the customer.