Hello,
I want to display a message “Please select price:” on the product page only if the product has variants.
How can this be implemented, Can anyone please help?
Thanks in Advance.
Hello,
I want to display a message “Please select price:” on the product page only if the product has variants.
How can this be implemented, Can anyone please help?
Thanks in Advance.
Hello @MinuSak
From the current variant, this would tell you how many variants a product has:
{{variant.product.variants | size}}
From the current product, this would also tell you the variants a product has:
{{product.variants | size}}
You can use that in your logic like this:
{{variant.product.variants | size}} > 1
or..
{{product.variant.product.variants | size}} > 1
If you would like further assistance, please let me know.
You can go to the file product-template.liquid and add the code:
{% unless product.has_only_default_variant %}
Please select price:
{% endunless %}
This code will help you check if the product has variant or not.
Hope it clear to you.
Thank you, but it says - Liquid syntax error: Unexpected character { in “{{ product.variant.product.variants | size }} > 1”
i used this as code
{%- if {{ product.variant.product.variants | size }} > 1 -%}
Thank you so much, it worked…