You may want to apply a discount code automatically at checkout rather than have your customers provide the discount code on their end. You can accomplish this in ReCharge using custom code on the cart page. This guide provides advice on setting up an automatic discount at checkout. It should be used as a reference in order for you, your team, or a recommended third-party developer to accomplish.
Before you start
- The ReCharge checkout will not work with Shopify's automatic discounts and can cause duplicate discounts at checkout if applied. To accomplish automatic discounts on your subscription products, you will need to implement custom code.
- You will need to create a discount code in ReCharge before implementing any customizations.
- This feature will require advanced Shopify liquid, and possibly HTML and JavaScript knowledge. This is not part of ReCharge's standard turnkey solution.
- This feature is not supported by ReCharge as per our design policy since it requires custom coding.
- This customization works with fixed amount, percentage, or shipping discount codes.
- This implementation does not work if the discount code is set to apply one subscription per customer as this setting relies on the email address of the customer which is not submitted on the cart page. If you require this set-up, you would need to use the API and apply the discount code post-purchase.
General implementation
To add an automatic discount code, you would need to pass the discount code in the URL. Using Shopify Liquid/JavaScript, you could add custom code that will read the items in the cart, determine which discount to pass, and then modifies the URL to pass the discount code in the URL.
You would need to edit your Shopify Theme code and use JavaScript logic to change and redirect the URL by appending discount={{CODE NAME}}
at the end of the checkout URL.
An example checkout URL:
/r/checkout?myshopify_domain=bootstrap dev.myshopify.com&cart_token=5566cd50a07c3c944f9b4d42524f5f98&discount=HALFOFF
The redirection to the checkout page happens within the file subscription-cart-footer.liquid, so you would have your JavaScript append the discount to the URL on the redirect.