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...

1 Response

  1. Grant Parks says:

    I’m stuck. My ReferralCandy discount codes are “once per customer”. And this from the ReCharge doc is preventing me from auto-populating the discount during checkout using your method: “This implementation does not work if the discount code is set to apply once 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.” https://support.rechargepayments.com/hc/en-us/articles/360008682454-Apply-discount-code-to-checkout-automatically

Leave a Reply

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