I am trying to edit the ajax-cart-template.liquid to achieve so each item will show the tags..
I am trying to get everytime user add item to cart, we show an item related to it based on the tags. and I used
{% for item in cart.items %}{% for tag in item.product.tags %}{{ tag }}, {% endfor %}{% endfor %}
but some how the products are not listing based on every user click add to cart?
is there any way to solve this?
thank you
2
Answers
anyway guys, I fixed it by working through the shopify ajax api that handles the output into adding tags
You have to build a machine for this. If you are adding items to the cart in Ajax then clearly you have the item. Now you can assess the tags. If the tags meet some criteria for you, you can use the Ajax API to GET products that match your criteria. Now render them. Obviously this is not a beginner level project.
If instead you are using the form submit, then you have the product added to cart, and its tags, so now you can loop through some related products collection looking for the matching criteria.
All in all, this Question of yours is related (no pun intended) to code written over ten years ago, by many people. Examine the old Shopify docs/forums for solutions and you’re likely to copy and paste your way to glory.