Need some direction,
I sell a mix of used products which is an issue with shopify being able to distinguish on the product page between a new item and used item.
I am using the following tags: used, new
I have then grabbed some old code I found in the community to display the product detials which renders on the page for this snippet as "Item Condition: Pre-Owned"
{% assign attribute_keyword = 'used' %} {% assign marker = ':' %} {% assign found = false %} {% for tag in product.tags %} {% if tag contains attribute_keyword %} {% if found == false %} {% assign found = true %}<p id="product-layout"> Item Condition: <u>Pre-Owned</u> {% endif %} {{ tag | remove: attribute_keyword | replace_first: marker, ': '| append: '' }} {% endif %} {% if found and forloop.last %}</p>{% endif %} {% endfor %}
I feel like there is a cleaner way of doing this as I need to also include the same code using "new" which would look like this and display on the page as "Item Condition: New"
{% assign attribute_keyword = 'new' %} {% assign marker = ':' %} {% assign found = false %} {% for tag in product.tags %} {% if tag contains attribute_keyword %} {% if found == false %} {% assign found = true %}<p id="product-layout"> Item Condition: <u>New</u> {% endif %} {{ tag | remove: attribute_keyword | replace_first: marker, ': '| append: '' }} {% endif %} {% if found and forloop.last %}</p>{% endif %} {% endfor %}
Because I have two return policies based upon the item, I need to do the same thing with the tags "return" and "noreturn" which would render as Return Policy: 14 Days or Return Policy: No Return.
Any help with getting these two separate line items addressed so they cleanly display on page without code bugs & minimal code would be GREATLY appreciated!!!! I need the return policy to show up directly under the new/used condition statement.
My Demo-page is here if you want to see the "used" tag in action & where I plan to place and style it:
Solved! Go to the solution
User | Count |
---|---|
28 | |
17 | |
17 | |
12 | |
12 |