
Referral promo codes
You can give users discount coupons to attract friends and acquaintances.
What happens after a referral coupon is bound to an order is up to you. Use the mspcOnBindCouponToOrder plugin event. There is an example plugin that shows how to add your logic after an order is created with a referral coupon.
Setup
Create a promotion with the
Referralcheckbox.Go to the
Couponstab and clickGenerate. This generates one promo code per user that they can use to attract referrals.On the profile page or where you want to show the referrer's coupon data, call the
mspcRefCouponsnippet. You can use pagination to show orders for this promo code:
[[!pdoPage?
&element=`mspcRefCoupon`
&limit=`2`
]]
[[!+page.nav]]You can hide the order list by excluding it from the tpl template:
[[!mspcRefCoupon
&tpl=`@INLINE <p><b>Referral promo code</b>: {$coupon}</p><p><b>Usage count</b>: {$orders_count}</p>`
]]When the user opens the profile page they will see something like:
Appearance is configured via the tpl and tplOrder parameters.
tpl placeholders
coupon— coupon codecoupon_id— coupon idorders_count— order count for this couponorders— order list built fromtplOrder
tplOrder placeholders
order_id— order iddiscount_amount— discount amountuser_id— id of user who placed the ordercreatedon— order creation dateorder_num— order numberorder_cost— total order cost including deliveryorder_cart_cost— order cost without deliveryusername— customer usernamefullname— customer full nameemail— customer emailphone— customer phonestatus_name— current order status namestatus_description— current order status description

