Apply Discount Code to Checkout Automatically

Warning: 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 documentation is meant to be used as a reference in order for you, your team, or a recommended third-party developer to accomplish.

You could pass a discount via URL with some liquid/JavaScript code that reads the items in the cart, determines which discount to pass, and then modifies the URL to pass the discount in the URL.You will need to edit your theme's code and use JavaScript logic to change and redirect the URL accordingly by appending discount={{CODE NAME}} at the end of the checkout URL like the following example and the discount will then be automatically applied.

/r/checkout?myshopify_domain=bootstrap-dev.myshopify.com&cart_token=5566cd50a07c3c944f9b4d42524f5f98<b style="background-color: initial;">&discount=HALFOFF

The redirection to the checkout page happens on the file subscription-cart-footer.liquid, so you would have your JavaScript append the discount to the URL on the redirect.

Note: This feature does not work if the discount code is configured to only apply Once Per Customer, since that would match by email. If the discount is automatically applied, there is no email and this does not apply. If you must have One Per Customer enabled, then the best solution to fit your needs would require a totally custom built system that applies discounts to orders post-purchase. This would require access to our API.

Still stuck? How can we help? Still stuck? How can we help?