November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
Hi,
The suggested solution is:
- Run the Workflow to make sure the cart is calcuated correctly and coupon is applied.
- Get all the coupons:
foreach (OrderForm form in CartHelper.Cart.OrderForms)
{
foreach (var discount in form.Discounts.Cast
{
AddToDiscountList(discount);
}
foreach (LineItem item in form.LineItems)
{
foreach (var discount in item.Discounts.Cast
{
AddToDiscountList(discount);
}
}
foreach (Shipment shipment in form.Shipments)
{
foreach (var discount in shipment.Discounts.Cast
{
AddToDiscountList(discount);
}
}
}
- Then check if the discount list contain the any discont with DiscountCode equals the coupon code. If not, then coupon code is not valid, and you can display information for the user.
Regards.
/Q
Hi,
I completely forgot to update this thread on whether or not this worked, but here's the result:
In order to validate coupon code do the following:
1) Add coupon to cart
2) Validate cart
3) Run Quan Mai's code from above to check whether or not the coupon was actually added.
And it works like a charm!
Thanks :)
Hi,
In the checkout process of our commerce site, there's a textbox for submitting a coupon code. If you add a valid coupon code, the code is added to the MarketingProfileContext, the CartValidate workflow is run, and the cart is updated with the discount.
The problem arises if you submit a coupon code that is not valid. At the moment, the user receives no notification of the coupon being invalid, the cart just refreshes without any changes.
Ideally, I would like to check whether or not a coupon code is valid before adding it to the MarketingProfileContext and running the CartValidate workflow. Any ideas how this could be done?
Another solution would be to notify the user after the workflow is run, but that requires retrieving some sort of result from the CalculateDiscountActivity. Is that possible?
Thanks in advance!
Karoline