Apply an automatic discount to an abandoned checkout recovery email

You can automatically apply a discount to your Abandoned checkout recovery emails which send a pre-filled cart to your customer to let customers quickly complete their checkout at a discounted price – they will only need to enter payment details.

Before you begin

  1. First you'll need to create a percentage discount code or a monetary discount code according to the type of promotion you want to offer.

  2. Make sure to keep a copy of the discount code for your reference. You generate the discount code when creating the discount, it looks something like this:

    Auto discount email1
  3. Verify that your Abandoned Checkout Recovery emails are configured to your liking on the Checkout page.

Edit the abandoned checkout recovery notification

  1. Under the 'Template' column, click Abandoned checkout:

    Abandoned checkout list

  2. Find the line that includes:

    <td class="button__cell"><a href="{{ url }}" class="button__text">Complete your purchase</a></td>

    And the line that includes {{ shop.url }}:

    Abandoned checkout replace

  3. Copy the code snippet below:

    {% if url contains '?' %}
      {{ url | append: '&discount=ABC' }}
      {% else %}
      {{ url | append: '?discount=ABC' }}
    {% endif %}
  4. Paste the code snippet to replace {{ url }}, and {{ shop.url }}.

  5. Replace ABC in the example above with your discount code, for example WelcomeBack.

  6. Click Save.

Now all abandoned checkout recovery emails will have urls ending in discount=ABC and that discount will be applied to their checkout automatically. Make sure you have set up your discount code in order for it to apply properly.


If the customer had manually entered any other discount code when beginning their checkout, that discount code will be replaced by your new discount code ABC using this method.

Want to discuss this page?

Visit the Shopify Community

Ready to start selling online with Shopify?

Try it free