Back to All

Extension > Creating Custom Coupons on the Fly

(edited)

From Russell:

Q: Do we need to call SaveCoupon from couponService or not while creating a custom coupon and applying it on the order on the fly? Also, does adding a newly created coupon mean that only its couponCode should be added to the string[] of the orderCoupons object?

A: When using the ProcessCouponHook. You have two options:

  1. Add an existing coupon code to the string[] CouponCodes, then call the base functionality func(request). If you use this method, the coupon code has already been set up in the system and will determine its discount amount. You are just adding to the order automatically.
  2. Build your own Discount. Sometimes you want to build a discount that is different for everyone. In this case, you will run the base functionality and develop your OrderCoupon object. Using this method, you can create the discount amount very custom per person and order. This object asks for a couponID, which is looking at coupons that already exist, but you do not have to give a valid couponID if you don't want to. If you give it a valid couponID, the only thing that it will do is show that a coupon was used on this order in the UI.