Then you will need to either set the free gift to be $0, or make an automatic discount code that will make it $0 which means customers will not be able to use other discounts.
Hi @jayanetty , can you instruct how to add free product when the customers purchase specific group of product?
Thank you for your blog!
Quick question. Iʻm not on the Plus plan but got the code (Follow this, https://jayanetty.com/blog/give-free-product-using-shopify-script-editor/) to work by making the price $0. BUT, when I tested the code I noticed that if the price in the cart falls below my threshold-$100 in my case- the FREE product remains in the cart. Is there a way to prevent this?
thx.
~steve
Hi @steve79 Glad that helped. Yes there is a way to prevent it.
Add this to the else condition.
cartUpdates = { {{ variant_id }}: 0 }
and wrap the whole code inside a session key. This is to break the loop.
So basically, remove the session key whenever a href/button is clicked, and add the session key when the script is run once. Hope this helps
@steve79 wrote:Quick question. Iʻm not on the Plus plan but got the code (Follow this, https://jayanetty.com/blog/give-free-product-using-shopify-script-editor/) to work by making the price $0. BUT, when I tested the code I noticed that if the price in the cart falls below my threshold-$100 in my case- the FREE product remains in the cart. Is there a way to prevent this?
You need to try and evaluate what the final price would be BEFORE you actually apply the discount then skip it when it's below your threshold.
User | Count |
---|---|
9 | |
7 | |
5 | |
5 | |
5 |