November Happy Hour will be moved to Thursday December 5th.

New Promotions: How to set cupon code on a cart and line items in the cart.

Vote:
 

I wanted to use coupons for the cart and line items in the cart. I am looking at documentation: http://world.episerver.com/documentation/Items/Developers-Guide/Episerver-Commerce/9/Marketing/coupons/ :

If set, a matching coupon code must be supplied for the order, or the promotion is not applied.

But I am unable to find any description how to "supply coupon code for the order".

Tried to add it "old" way by adding OrderFormDiscount on OrderForm:

orderForm.Discounts.Add(new OrderFormDiscount {DiscountCode = cuponCode});

But it didn't have any effect.

#151632
Aug 01, 2016 15:32
Vote:
 

You should be using:

orderForm.CouponCodes.Add(couponCode);

orderForm has to be IOrderForm,

Regards,

/Q

#151633
Aug 01, 2016 15:56
Vote:
 

Thanks Quan!

P.S. Documentation needs to be updated.

#151634
Aug 01, 2016 16:18
Vote:
 

Documentation updated -- Thanks Maris!

#151637
Aug 01, 2016 17:57
Vote:
 

I have same problem with discount code.

I have written the code in this form

  var OrderForm = (IOrderForm)cart.OrderForms[0];
                    //
                    OrderForm.CouponCodes.Add("CuponCode");
                    cart.OrderForms.AcceptChanges();

The cupon code is not visible in commerce manager .

It is showing none

#175462
Feb 21, 2017 14:32
Vote:
 

Coupon codes are visible in CM only if discount is applied by this code. Otherwise the code gets removed.

#175463
Feb 21, 2017 14:40
Vote:
 

Another thing, is there any relation between (discount code ,shipment)  and with this code

                PurchaseOrder POChek = OrderContext.Current.GetPurchaseOrder(orderNumber);
                PurchaseOrder POChek12 = OrderStatusManager.HoldOrder(POChek);
                POChek12.AcceptChanges();

When i am using this code the discount code is being visible.

But if i remove this code the code is not being visible.

#175464
Feb 21, 2017 14:44
Vote:
 

I don't think they are related. However, as a general rule, you should not try to mix APIs - the old (concrete classes) with the new ones (abstraction interfaces). That can result in some unexpected behavior. We recommend that from the time you load an order to the time you save it, you should only use only kind of APIs.

Also, the older version of Commerce Manager has some limitation regarding support the new promotion system and the new abstraction APIs. I would suggest to upgrade to the latest one (10.3) instead.

#175479
Feb 21, 2017 16:22
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.