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

Member since: 2012

I wanted to use coupons for the cart and line items in the cart. I am looking at documentation: :

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
  • Member since: 2011

    You should be using:


    orderForm has to be IOrderForm,



    #151633 Aug 01, 2016 15:56
  • Member since: 2012

    Thanks Quan!

    P.S. Documentation needs to be updated.

    #151634 Aug 01, 2016 16:18
  • Member since: 2014

    Documentation updated -- Thanks Maris!

    #151637 Aug 01, 2016 17:57

    I have same problem with discount code.

    I have written the code in this form

      var OrderForm = (IOrderForm)cart.OrderForms[0];

    The cupon code is not visible in commerce manager .

    It is showing none

    #175462 Feb 21, 2017 14:32
  • Member since: 2012

    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

    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);

    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
  • Member since: 2011

    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