If Product Tag Contains shipping_message on Cart Page Add Shipping Message - Maingate
How it works
The code works by checking if a product has a tag that contains with shipping_message. If it does then it removes 'shipping_message' from the message and prints everything after on that product's cart page.Add Tag to Product
Open a product and from the backend of Shopify and add a tag to product. Start the tag with 'shipping_message' then after that add message to display. For example: 'shipping_message NOTE: This product will not ship until after Christmas'Create Snippet
shipping_cart_message.liquid
Create a snippet named shipping_cart_message.liquid and paste the following code.<div class="product-tags">
{% for tag in i.product.tags %}
{% assign t_checker = tag %}
{% if t_checker contains 'shipping_message' %}
{% if found == false %}
{% assign found = true %}
{% endif %}
{% endif %}
{% if found %}
<div class="product_shipping_message" style="background: red; padding: 4px;">
{{ t_checker | remove: 'shipping_message' }}
</div>
{% endif %}
{% assign found = false %}
{% endfor %}
</div>
cart.liquid
set found variable to false.
Open cart.liquid and paste the following code at the top of the file.{% assign found = false %}
Include shipping_cart_message
after <h4>{{ i.product.title | link_to: i.url }}</h4> Add the following code:{% include 'shipping_cart_message' %}
NOTE: The code can be added anywhere as long as it is inside the {% for i in cart.items %} loop.