Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
Hi!
So I am experiencing an issue where my product shows as unavailable (despite being available) once a variant is selected. I contacted Shopify and they told me when they tried a different theme (from my customized Brooklyn theme) it worked fine. After turning off all apps it still had the error. They said it had to be in my theme's code. I tried older versions of the products template page in code area and also rolled back the whole theme, too, but no luck.
I found that my default product template had no issues running that page (when I switched to it in the product settings). I decided to start from that point and did a side-by-side compare of the code (in VS Code) for both my problem template and the default template that apparently works. I deleted all the code in problem template in Shopify code area and pasted the default template code into it. Then I cut and pasted the differing parts of my problem template's code into that template, refreshing and checking my product page's frontend with each new addition to see which piece of code was breaking it.
I narrowed my issue down to this one chunk of script for swatches below:
{% if option.name == 'Color' %}
<div class="selector-wrapper js product-form__item swatch-container">
{%- assign optName = 'options' | append: forloop.index -%}
{%- assign option_values = [optName] | default: option.values -%}
{%- for value in option_values -%}
<label class="swatch">
<input id="SingleOptionSelector-1" class="single-option-selector single-option-selector-{{section.id}} product-form__input" name="{{ option.name }}" type="radio" value="{{ value | escape }}" data-name="{{ option.name }}" data-index="option1" {% if option.selected_value == value %} checked="checked" {% endif %}>
<span class="swatch-{{value | split: ' ' | first | downcase }}"><i>{{ value | escape }}</i></span>
</label>
{% endfor %}
</div>
{% else %}
What I don't understand is that it works perfectly fine for other products with no issues. Just for two of my products, each of which only have one color versus the working products, which have several colors.
Could someone have a look at this and let me know if anything stands out for them?
I appreciate any help you can give me toward a solution.
Hi @nuwud,
Please send your site and if your site is password protected, please send me the password. I will check it.
I'd love to give you access, but this is a client site and they would not want that.
Hi @nuwud,
It will be difficult for anyone to check bugs through just one piece of code for an entire function.
So sorry I can't help you more.
Any luck getting this sorted? Having a similar problem.
Hey Community! As the holiday season unfolds, we want to extend heartfelt thanks to a...
By JasonH Dec 6, 2024Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024Hey Community! It’s time to share some appreciation and celebrate what we have accomplis...
By JasonH Nov 14, 2024