Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
I am hoping this is just a simple line of code.
I want to add a specific product to the cart if another product is in it.
If {product has tag "Station"} is in cart
Add {product x}
Solved! Go to the solution
This is an accepted solution.
Hello seangerke,
By using below code first you can find that if the particular product is in cart:-
{% for item in cart.items %} {% if item.product.id == "8223550921" %} <div><h1>Some text here!</h1> </div> <br> {% endif %} {% endfor %}
One you find the product then by using ajax we can add the another product to cart.
This is an accepted solution.
Hello seangerke,
By using below code first you can find that if the particular product is in cart:-
{% for item in cart.items %} {% if item.product.id == "8223550921" %} <div><h1>Some text here!</h1> </div> <br> {% endif %} {% endfor %}
One you find the product then by using ajax we can add the another product to cart.
Hi. I'm trying to do something similar.
I want to have it so that if a particular product is in the cart it costs $10.
if any additional products are added to the cart, the price becomes 0.
Is this possible? It's just for one product.
Thanks!
Hm, I use locksmith on another site, didn't know it could do that. I do like that app and the customer service.
Thanks. Wonder if something less expensive can do it too...
Will test the code.
{% for item in cart.items %}
{% if item.product.id == "29056231440487" %}
jQuery.post('/cart/update.js',
{
quantity:1,
id: 6619002634270
});
This is what I came up with but still not working. Am I adding the wrong IDs? First picture goes to the top, 2nd pic is reference to product I want added.
Were you able to solve this? I'm trying to do something similar - some of our products ship in two boxes so I want to automatically add a second product to the cart when other specific products are added. The call to actually add a product to the cart isn't working for me either.
I got distracted since it wasn't a priority. If you figure it out, let me know. If I figure it out, I'll let you know.
jess
Another solution that doesn't require coding or editing liquid files is Gifter, which is an app that does this for you. It also lets you apply discounts, and create more complex rules.
There's a free trial here: https://apps.shopify.com/gifter-cart-auto-include
Looking for same solution. I do came across this app https://bit.ly/3zD2VXb
But this doesnt work upto mark. sometimes it works sometimes doesnt.
Is there any alternative you guys came up with?
I ultimately went with an app. I use Ultimate Special Offers. It's been great and Alex is really nice when you need help.
That's great app. But i think there are better functionality app than that
check them for auto add-to-cart: Easygift cart bot
check them for upsell/cross sell popup immediately after pressing add to cart: product page upsell
Hey Community! As the holiday season unfolds, we want to extend heartfelt thanks to a...
By JasonH Dec 6, 2024Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024Hey Community! It’s time to share some appreciation and celebrate what we have accomplis...
By JasonH Nov 14, 2024