I want to add specific tags to my cart page that contain a prefix.
For example the prefix is ‘BT!’ and the tag might be ‘BT!IPA’ or ‘BT!Stout’.
How can I display the tag ‘IPA’ removing ‘BT!’ or ‘Stout’ removing ‘BT!’ to the cart page?
I am using the minimal theme. My site is www.craftlinebeers.com.
Any help would be greatly appreciated. Thanks.
Is anyone able to help me?
I’m happy to explain further my requirements if I haven’t been clear enough.
Thanks.
Hello , @alxandrws
Do you want to display the product tags on cart page ?
Yes on the cart next to the can size as below:
I only want to display specific tags though and remove the prefixes as described in my original message.
Many thanks.
Hello ,
You can add code like this anywhere inside cart items for loop.
Something like this:-
{% for item in cart.items %}
{% for tag in item.product.tags %}
{% if tag contains ‘BT!’ %}
Tag = {{tag | split:‘!’ | last}}
{% endif %}
{% endfor %}
{% endfor %}
Thank you! That worked, I just tweaked a bit to get desired result.
{% for tag in item.product.tags %}
{% if tag contains ‘BT!’ %}
{{tag | split:‘!’ | last}}
{% endif %}
{% endfor %}