How to apply discount code to checkout automatically in ReCharge app

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.

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:

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.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *