Personal Discount
HomeShopifyWooCommerce and Magento
  • What is Personal Discount?
  • Personal Discount for Shopify
    • How does Personal Discount work?
    • Frequently Asked Questions
    • Configure discount
    • Integrate Personal Discount with your Email Service Provider
      • Shopify notifications
        • How to send an order confirmation email with a discount code in Shopify?
        • How to include a discount code in Shopify abandoned cart notification
        • How to send a unique discount code to customers who create an account?
        • How to send a discount code only if a specific product has been purchased?
      • Shopify Email
      • Mailchimp
        • How to set up an automated welcome email in Mailchimp
        • How to set up an abandoned cart email in Mailchimp?
        • Send unique coupons from Mailchimp to customers who bought a specific product
        • How to display a discount code as an image in a Mailchimp message
        • Create a link to apply discount automatically
        • Connect to Mailchimp
        • How to create a birthday campaign with a discount code using Mailchimp
      • AWeber
        • Reward new subscribers with a discount code using AWeber
      • ActiveCampaign
        • How to add a unique discount code to welcome emails in ActiveCampaign
        • How to create a recover abandoned carts campaign with a unique discount code via ActiveCampaign?
        • How to encourage customers to buy more from your shop with Personal Discount and ActiveCampaign?
      • Campaigner
        • How to integrate Personal Discount and Campaigner to send welcome emails with a discount code
      • Campaign Monitor
        • How to send automated welcome emails with discount codes using Campaign Monitor
      • ConvertKit
        • How to create a welcome campaign with ConvertKit
        • How to create a follow up on purchases automation with ConvertKit
      • iContact
        • Increase your newsletter audience using the iContact welcome campaign with a discount code
      • Klaviyo
        • Send a discount code for new subscribers using Klaviyo
        • Create an abandoned cart recovery campaign with Klaviyo
        • How to create a post-purchase campaign to increase customers' loyalty using Klaviyo
        • How to create a Happy Birthday campaign using Klaviyo
      • MailerLite
        • How to welcome new subscribers with a discount code using MailerLite
        • How to create a recover abandoned carts campaign with MailerLite
        • How to create Follow up on purchases campaign with MailerLite
      • Omnisend
        • How to create welcome new subscribers automation with Omnisend
        • Recover abandoned carts using Omnisend with Personal Discount
        • How to create Follow up on purchases campaign using Omnisend
      • Ontraport
        • How to send welcome emails with discount codes for new subscribers via Ontraport?
      • OrderlyEmails
      • SendGrid
        • How to send welcome discount with SendGrid?
      • Sendinblue
      • Vitals
        • How to create a pop-up and include a discount code in welcome emails with the Vitals app
    • Use cases
      • Offer a free product to your newsletter subscribers
      • How to create a link to the checkout with a discount code applied in the Shopify store?
    • Troubleshooting
      • Why my Shopify discount code doesn't work?
      • My Shopify customer's discount code was applied, but it shouldn't
      • Customer eligibility is not respected
      • Some of my subscribers in Klaviyo don't have a discount code generated in Personal Discount
      • Mailchimp is not sending emails with discount codes
      • Discount codes are not appearing in the emails sent by Mailchimp
      • I have received << Test discount code >> instead of real discount code in the Mailchimp test message
      • Contact us
  • WooCommerce and Magento
    • Add a Mailchimp pop-up to your WooCommerce store
    • Apply a coupon code via URL in WooCommerce
    • Create a Cart Price Rule in Magento 2.x
    • Create an Access Token in Magento 2.x
    • Send unique coupons to new email subscribers using Mailchimp
    • Send unique coupons for your subscribers birthday
    • Frequently Asked Questions
Powered by GitBook
On this page

Was this helpful?

  1. Personal Discount for Shopify
  2. Integrate Personal Discount with your Email Service Provider
  3. Shopify notifications

How to send a discount code only if a specific product has been purchased?

Using Personal Discount, you can add a unique discount code to the order confirmation email that Shopify sends after every purchase. However, you may want to offer a discount based on certain conditions. For example, you may want to send a coupon code only if a customer purchased a specific SKU.

Normally, Personal Discount gives you a code snippet like below to insert in the order confirmation email template:

<div style="text-align: center; margin: 20px">
    <a href="https://render.personaldiscount.me/discount/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/apply?email={{email}}">
        <img src="https://render.personaldiscount.me/discount/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/image?email={{email}}" alt="Discount Code">
    </a>
</div>

To send a coupon only if a particular item was purchased, you need to add two lines above and to lines below the code snippet:

{% for line in line_items %}
{% if line.sku == "A123" %}
<div style="text-align: center; margin: 20px">
     <a href="https://render.personaldiscount.me/discount/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/apply?email={{email}}">
         <img src="https://render.personaldiscount.me/discount/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/image?email={{email}}" alt="Discount Code">
    </a>
</div>
{% endif %}
{% endfor %}

Please note that you need to replace A123 with the SKU of the product that you want to target.

The order confirmation email will now include a discount code only if the SKU has been added to the order. Other customers who have not purchased the specific item won't receive the discount.

PreviousHow to send a unique discount code to customers who create an account?NextShopify Email

Last updated 2 years ago

Was this helpful?