I’ve been doing Shopify development for a little while now and my client has a specific need that I haven’t found in the app store yet.
It needs to:
- Create two discount tiers based on total value of the cart (e.g. 10% off cart total more than $40 & 5% off cart total more than $80)
- Work only in the following two scenarios:
- Customer is NOT logged in
- Customer is logged in, but customer.tags DOES NOT contain ‘wholesale’
- App preferably does not use coupons to alter price
- It must work in a modal sliding AJAX cart
So I’m thinking that it’s about time I dive into making my first app, but I’m wondering how I should go about it and how difficult this will be for a first-time app. So far I’m well-versed in Shopify in general, Liquid, CSS, JavaScript & jQuery. However I don’t have any experience with APIs (maybe I do and I just don’t know I’ve used an API before).
What are some references I should look at before I start? In your experience, if you were starting this over again, how would you approach it?
Thanks in advance!
2
Answers
Turns out you don't need to create an app to automatically apply a discount (I did put "preferably no discount codes", but my solution uses them after all).
Following this guide, you can automatically apply a discount by dynamically modifying the form action, adding a query string.
It might not be the most elegant solution, but it works as needed for this job!
I will give you some advice. Stop. All that you speak of there is a holy hell mess to do. But wait! There is an elegant way. All your client needs to do is go on Shopify Plus. With that, those needs are met in less than 5 minutes of Script Editor code. Seriously. And that code will work perfect, and never break.
Whereas if you attempt to do what you are trying to do, all the best to you. You will spend hours and hours and hours and your code will be a fragile mess, subject to breaking, and in the end, being a pain. But hey, go for it anyway!! A good exercise in crazy for you.
In other words, I would NEVER bother doing this. It is not worth it.