Hi everyone,
I’m trying to set up automated discounts for repeat customers on my Shopify store. Specifically:
- 15% discount for customers on their second order, and
- 20% discount for customers on their third order.
I’ve managed to create customer segments and discount codes, but I’m facing trouble automating the process so that these discounts apply automatically at checkout without requiring customers to enter a code manually.
Does anyone know how to achieve this with Shopify’s built-in features without an app/plugin? I’ve attached screenshots of discount section for better understanding below.
Your guidance would be greatly appreciated!
Thank you!
Automatic Discount:
Hi Sufi_sab,
Sorry, but this isn’t directly possible using built-in automatic discounts. Automatic discounts simply cannot query customer segments.
One workaround you have is to:
- Create discount codes (not automatic discounts) that are linked to your customer segments
- Using Liquid, conditionally add JavaScript code to your site that applies these discounts to the cart (using the /discount/CODE) endpoint, based on the customer’s order count.
Here’s a sample code snippet:
However, this approach has some glaring flaws:
- It requires the customer to be logged into an account. Otherwise, the Liquid
customer
object is nil
- Since you can’t run custom JS in the Shopify checkout (unless you’re on Plus), they will have to log in before reaching the checkout
- There is no error handling. The /discount/CODE endpoint is not really an API and will not return an error response if the discount cannot be applied to the cart. For example, if you visit mysite dot com/discount/THISCODEDOESNOTEXIST, all that happens is that you’ll get directed to the home page, which is what also would happen if you had provided a code that actually existed. You can try using the AJAX Cart API to check if the discount has been applied, however, as a workaround.
I know that you mentioned you’re not looking to use an app, but if the above workaround doesn’t meet your needs… Just let me know, and I’ll be happy to reply with instructions on how to easily set up discounts based on customer order counts in our app, Regios Discounts.
Hope this helps,
Tobe
Hello,
Our app Stack Discounts Ninja will do exactly what you need.
For basic requirements you need, after installation, enable the app.
Then you need to create an Automatic Campaign, and select customer segments:
Now add your two discounts under this campaign. Thanks.