Ask a Dev
Extension > Creating Custom Coupons on the Fly
over 3 years ago by Learning Experience Team(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:
- Add an existing coupon code to the
string[] CouponCodes
, then call the base functionalityfunc(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. - 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 acouponID
, which is looking at coupons that already exist, but you do not have to give a validcouponID
if you don't want to. If you give it a validcouponID,
the only thing that it will do is show that a coupon was used on this order in the UI.