Hello, I'm having an issue with a bit of code.
Two of my products were displaying the Shop Pay Installments message twice
The code was:
<div {{ block.shopify_attributes }}>
{%- form 'product', product, id: 'product-form-installment', class: 'installment caption-large' -%}
<input type="hidden" name="id" value="{{ product.selected_or_first_available_variant.id }}">
{% for tag in product.tags %}
{% unless product.tags contains 'pro table' %}
{{ form | payment_terms }}
{% endunless %}
{% endfor %}
{%- endform -%}
</div>
As a temp fix I've just removed to clean up the site a bit.
Now I know it's the {% unless product.tags contains 'pro table' %} causing the issue but I'm not sure why it would display twice when none of the products have any "Pro table" tags.
I would still like the shop pay message to display on all of my products but obviously only once.
Any help or guidance to create an exclusion would be greatly appreciated.
I think that The for loop cause the message to show 2 times as you probably have 2 tags.
try this as replacement of the {%for - end for%} piece.
<!--Convert the tags into a string by joining them with COMMA--> {% assign productTags = product.tags | join: ', ' %} <!--Now Check for the desired tag name--> {% if productTags contains 'Pro table' %} Okay.. I found the tag {% else %} <!--Tag not found :( -->
{{ form | payment_terms }}
{% endif %}
User | RANK |
---|---|
36 | |
35 | |
15 | |
12 | |
10 |