Shopify themes, liquid, logos, and UX
I was given code to add the number of colors a product is available in the Dawn theme BUT it also displays swatches which I don't want. I asked the coder to remove it and this is what I got back.
If you don't want swatches you can just remove the line with the image or have that option in the no swatches section. you are welcome. good luck!
I'm no coder and I can't see the word IMAGES in this code anywhere. Can someone please point out what I should be removing please. Thank you
the sample url given to me to see the code below is https://makeoutstore.com/collections/one-pieces
{% if product_card_product.options contains 'Pattern'
or product_card_product.options contains 'Color'
or product_card_product.options contains 'Drawing'
or product_card_product.options contains 'Number'
%}
{%- assign pattern_label = 'pattern,Pattern,color,Color,Colour,colour,Drawing,drawing,number,Number' | split: ',' -%}
{%- for option in product_card_product.options_with_values -%}
{%- assign downcased_option = option.name | downcase -%}
{%- if pattern_label contains downcased_option -%}
{%- assign variant_option = 'option' | append: forloop.index -%}
<div class="design-count-swatches">
{%- for value in option.values -%}
{%- for variant in product_card_product.variants -%}
{%- if variant[variant_option] == value -%}
{%- assign handle_value = value | handleize -%}
{% assign prodcard_variant_pattern_values = prodcard_variant_pattern_values | append: handle_value | append: ':' %}
{%- endif -%}
{%- endfor -%}
{% if product_card_product.options contains 'Pattern' or product_card_product.options contains 'Color'%}
<img src="{{ handle_value | append: '.gif' | asset_url }}" alt="{{ value }}" width="16" height="16" />
{% endif %}
{%- endfor -%}
{%- endif -%}
{% assign prodcard_variant_pattern_values_unique = prodcard_variant_pattern_values | split: ':' | uniq | join: ',' %}
{% assign prodcard_variant_pattern_values_unique = prodcard_variant_pattern_values_unique | split: "," %}
{%- endfor -%}
</div>
{%- if prodcard_variant_pattern_values_unique.size > 1 -%}
<span class="product_card_count">{{prodcard_variant_pattern_values_unique.size }}
{% if product_card_product.options contains 'Pattern'%}Patterns{% endif %}
{% if product_card_product.options contains 'Number'%}Numbers{% endif %}
{% if product_card_product.options contains 'Drawing'%}Drawings{% endif %}
{% if product_card_product.options contains 'Color'%}Colors{% endif %}
Available</span>
{%- endif -%}
{%- endif -%}
Solved! Go to the solution
This is an accepted solution.
Hi @ebon
The only image reference here is under img which is this line:
<img src="{{ handle_value | append: '.gif' | asset_url }}" alt="{{ value }}" width="16" height="16" />
Try removing that and see if that works.
Should that help answer your query, we always appreciate liking & marking an as answer to let the community find quality solutions faster. Thanks!
This is an accepted solution.
Hi @ebon
The only image reference here is under img which is this line:
<img src="{{ handle_value | append: '.gif' | asset_url }}" alt="{{ value }}" width="16" height="16" />
Try removing that and see if that works.
Should that help answer your query, we always appreciate liking & marking an as answer to let the community find quality solutions faster. Thanks!
It worked. Thank you so much.
Are you ready to take your business to the next level? Look no further than the latest ...
By SarahF_Shopify Apr 15, 2024We’re keeping the ball rolling to make sure you’re always ahead of the game. So buckle ...
By JasonH Apr 8, 2024Portrait of Stephen positioned next to an image of planet Earth, with the Stephen's World ...
By JasonH Mar 18, 2024