Hi,
I input below the code in my main.product.liquid for make sold out variant to be disable.
{%- for variant in product.variants -%}
{% if value == variant.title %}
{% if variant.available == false %}disabled{% endif %}
{% endif %}
{%- endfor -%}
But I use “Notify me when back in stock”, So I want to make this sold out variant be clickable.
Is it possible to change? Here is my preview below :
https://itsdcode.jp/products/am2231st007?variant=43596727288026
Btw, I’m using dawn theme version 7.0.1, not 8.0, since we edit some codes.
Thank you so much.
Hello @Ianlee221 ,
We are OneCommerce - an eCommerce Solution Platform.
The code you provided disables the sold-out variant by adding the “disabled” attribute to the option element if the variant is not available. To make the sold-out variant clickable, you will need to modify this code. Here’s an updates:
{% if variant.available %}
{% else %}
{% endif %}
{% endfor %}```
Hope these can helps, don’t be hesitate to contact us if you have any further questions. Please hit the Like Button or mark this as Accepted Solution to let us know, it encourage us a lot.
Regards,
OneCommerce team.
Hi!
Thank you for your reply. I’ve tried but below the error keep pop-up.
[Liquid syntax error (line 510): ‘endfor’ is not a valid delimiter for if tags. use endif]
Could you please look at the code which I modified?
{%- for variant in product.variants -%}
{% if value == variant.title %}
{% if variant.available %} {{ variant.title }} - {{ variant.price | money }} {% else %} {{ variant.title }} - {{ ‘products.product.sold_out’ | t }} {% endif %} {% endfor %}
If this is wrong, could you please give me the correct code?
Thank you!
Hello @Ianlee221 ,
It’s the GemPages Support Team and we are glad to assist you today!
You could please try changing the code like that:
{%- for variant in product.variants -%}
{% if value == variant.title %}
{% if variant.available %} {% else %} {% endif %}
{% endif %}
{% endfor %}
Let us know how it works for you.
Best regards,
GemPages Support Team
Hi @GemPages Thank you for your reply.
I’ve tried the code but unfortunately it isn’t worked well..