Shopify themes, liquid, logos, and UX
Hi there,
I want to ask that how i can hide single vartiant label/button from my product page. As you can in screen shot i have different sizes for this jacket but i have only one color and fabric option for this product. So i want hide them from all product which has one variant. i am ussing free dawn theme version 13.0.1.
Solved! Go to the solution
This is an accepted solution.
{% if variant_count <= 1 %} hide_single_variant{% endif %}
.hide_single_variant {
display: none !important;
}
@i_hussain Please always provide store url and password if have when seeking for the help so we can help you!
Sorry, I didn’t share it because it was mention that not to share password. And how can i share password in public forum. here is the URL: https://039dfb-a6.myshopify.com/
@i_hussain I was asking for the store front-end password if have i don't require back-end admin side password!
Sorry, i am new on shopify so i don't have any idea about it. Can you please tell me where i can find front end URL and password so, i can share with you.
If you only have one variant, you should not add any options. This way product with one variant will be created.
I have to add them to appear on google merchant otherwise it will show errors in google merchant, and i saw few solution around internet but those are not working properly.
@i_hussain If we hide from the front-end then how Google Merchant Center will fetch your variant Color and Material in their Feed?
Google always used data feed, so thats why i want it in backend but not dont want show fromt-end
@i_hussain Then I suggest to don't create color and material variant and instead of this you can create Metafield options to add the color and material so your variant options will not show on the front-end without changing the existing code.
How can i use meta-field? Is it like we used to create in collections?
@i_hussain Please follow the below steps to hide the variant that has only one option. Let me know whether it is helpful for you.
{% assign variant_count = option.values | size %}
{% if variant_count > 1 %}
{%- endif -%}
It's Working, But there is another problem i saw after adding this code, as you can see in screenshot, when you click on variation its saying item is unavailable. you can check live product here https://039dfb-a6.myshopify.com/products/attack-on-titan-scouting-legion-leather-jacket
@i_hussain Yes it will create an error because variant option is hide so without selecting the all variant options will not able to add to cart the product. The flow work like select Size option > Color option > Material option if all are the selected then add to cart button works well! Hiding the variants will create a problem for the flow functionality and google merchant too!
So, that is no solution for this? 😥
@i_hussain I suggest to don't create color and material variant and instead of this you can create Metafield options to add the color and material so your variant options will not show on the front-end without changing the existing code.
This is an accepted solution.
{% if variant_count <= 1 %} hide_single_variant{% endif %}
.hide_single_variant {
display: none !important;
}
i tried it, it's not working at all.
@i_hussain Please check the variable declaration code "{% assign variant_count = option.values | size %}" is there in the "product-variant-picker.liquid" file below the line "{%- for option in product.options_with_values -%}" as mentioned in the step 4. Let me know whether it is working for you or not.
sorry, i forget to keep this code {% assign variant_count = option.values | size %}, i just updated code again and now its working properly.
Thank you so Much 😊
please could you guide me on how to do the same for my store. I'm using free turbo theme version 3.01 - there isn't a file in my edit code section called "product-variant-picker.liquid" file. TIA
As 2024 wraps up, the dropshipping landscape is already shifting towards 2025's trends....
By JasonH Nov 27, 2024Hey Community! It’s time to share some appreciation and celebrate what we have accomplis...
By JasonH Nov 14, 2024In today’s interview, we sat down with @BSS-Commerce to discuss practical strategies f...
By JasonH Nov 13, 2024