How to apply discount code to checkout automatically in ReCharge app

Sell Online With Shopify
Trusted by millions of businesses worldwide
Sign up for a free trial and enjoy 3 months of Shopify for $1/month on select plans.

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.

Looking for Shopify Experts?

Hura Apps can help you take your store to the next level

Our team of experienced designers and developers can help you create a beautiful, high-converting Shopify store that will drive sales and increase customer satisfaction. From custom design to app development and optimization, we have the skills and expertise to help you achieve your eCommerce goals.

Get in touch

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 *