You should be using:
orderForm.CouponCodes.Add(couponCode);
orderForm has to be IOrderForm,
Regards,
/Q
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
Coupon codes are visible in CM only if discount is applied by this code. Otherwise the code gets removed.
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.
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.
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:
But it didn't have any effect.