Do you want to reward your customers for paying by PayNow?
Use the code below to input under Theme Editor > Functions.php to create an auto generated voucher for your customers who pay by PayNow.
Click on the code image for clearer view.
Note that in order for this to work, you need to only select PayNow payment for your HitPay Payment Gateway, and use other payment gateways for other payment methods.
Step 1: Input a code to Add coupon code to order confirmation email for Paynow payment method
Make sure you have changed your payment method title to “HitPay Payment Gateway” (see line 59 of code).
To confirm, go to WooCommerce > Settings > Payment.
Select the HitPay Payment Gateway and check the Title. You may either copy your own title into this code or change your title to “HitPay Payment Gateway” for this to work.
Step 2: Auto Generate the Coupon Code
In this code, it follows the “If rule” at line 59. It happens only IF the payment method is “HitPay Payment Gateway”, which is your payment gateway to facilitate PayNow payments.
So, if customers use PayNow payments, this code will run.
It will automatically create a discount coupon that has the following rules:
Not applicable for individual use, meaning it can be passed on to anyone to use (line 74)
Not limited to any products (line 75)
Does not exclude any products (line 76)
Usage limit of 1 time only (line 77)
Expires 6 months after creation (line 78)
Applies before tax (line 79)
Is not a free shipping coupon (line 80)
Line 81 code for “echo” means this line will be shown to your customers in their order confirmation email. You can edit this line however you want, but do not change these 2 names “$amount” and “$coupon_code”.
Step 3: Add text for PAYNOW Coupon incentives at Checkout Page
You need to add a text to inform your customers about this reward should they choose to pay by PayNow.
To edit the text line, simply change what’s after “echo” at line 89 in the example above.
Step 4: Inform selected customers about PayNow Coupon at Thank you page
After a customer has made payment by PayNow, he will be directed to the Thank you page on your website.
You should include a line to inform him to look out for his coupon code in his order confirmation email.
Again, feel free to rephrase the line by editting the part after “echo” in line 97.