Shopify色板即使未激活也显示在收藏页上

时间:2019-12-17 03:03:07

标签: javascript shopify

它们未显示在产品页面上,但仍显示在收藏页面上。我相信答案就在这段代码中(我对JavaScript一无所知,但要弄清楚这一点。)感谢您的任何帮助。

<ul class="swatches color">
    {%- for option in product.options -%}
        {%- if option == 'Color' or option == 'COLOR' or option == 'Colour' -%}
            {%- assign index = forloop.index0 -%}
            {%- assign colorlist = '' -%}
            {%- assign color = '' -%}
            {%- if product.variants.size > 1 -%}
                {%- for variant in product.variants -%}
                    {%- capture color -%}{{ variant.options[index] }}{%- endcapture -%}
                    {%- unless colorlist contains color -%}

                        {%- assign text = color | handleize -%}
                        {%- if settings.color_type == "color" -%}
                            <li class="swatch {{settings.color_size}} {{settings.color_style}}{% if variant.image == null %} noImg{% endif %}" title="{{color}}" style="background-color:{{color | replace: ' ', '' | handle}};" {% if variant.image != null %}rel="{{ variant.image.src | product_img_url: grid_image_width }}"{% endif %}></li>
                        {%- elsif settings.color_type == "image" -%}
                            <li class="swatch {{settings.color_size}} {{settings.color_style}}{% if variant.image == null %} noImg{% endif %}" title="{{color}}" style="background-color:{{color | replace: ' ', '' | handle}};background-image:url({{ text | append: '.png' | file_url | split: "?" | first }});" {% if variant.image != null %}rel="{{ variant.image.src | product_img_url: grid_image_width }}"{% endif %}>
                              <a href="{{variant.url}}">&nbsp;</a>
                            </li>
                        {%- elsif variant.image != null -%}
                            <li class="swatch {{settings.color_size}} {{settings.color_style}}{% if variant.image == null %} noImg{% endif %}" title="{{color}}" style="background-image:url({{ variant.image.src | product_img_url: '75x75'}});" rel="{{ variant.image.src | product_img_url: grid_image_width }}">
                              <a href="{{variant.url}}">&nbsp;</a>
                            </li>
                        {%- endif -%}
                        {%- assign colorlist = colorlist | join: ',' -%}
                        {%- assign colorlist = colorlist | append: ',' | append: color -%}
                        {%- assign colorlist = colorlist | split: ',' -%}
  {%comment%}
                        {%- capture tempList -%}{{ colorlist | append: color | append: '|' }}{%- endcapture -%}
                        {%- assign colorlist = tempList -%}
  {%endcomment%}
                    {%- endunless -%}
                {%- endfor -%}
            {%- endif -%}
        {%- endif -%}
    {%- endfor -%}
</ul>

0 个答案:

没有答案