Shopify themes, liquid, logos, and UX
Hi Guys, so basically I want a non app way (Code Only) to hide variants that has 0 stock (Sold-out variants) or would never have that variant.
I'm using the free 'Studio' theme. If anyone can point me in a direction or could assist I would greatly appreciate it.
I did look at this first but apparently this is for legacy themes:
https://help.shopify.com/en/manual/online-store/themes/themes-by-shopify/vintage-themes/customizing-...
Regards,
Andre
Solved! Go to the solution
This is an accepted solution.
please refer to the below code add that code into your base.css file
Online Store > Edit Code > Theme Files > Assets > base.css file place the code at the very bottom.
.js.product-form__input.product-form__input--pill input.disabled + label {
display: none;
}
Thanks
This is an accepted solution.
please refer to the below code add that code into your base.css file
Online Store > Edit Code > Theme Files > Assets > base.css file place the code at the very bottom.
.js.product-form__input.product-form__input--pill input.disabled + label {
display: none;
}
Thanks
This was simple and so quick! Thank you very much! 😀
no problem dont feel hesitate to reach out for further any issue.
This actually worked, I'm beyond thrilled! I did it to my Dawn theme and it's perfection, thank you so much!
Hi @Liquid_xPert_SJ, how do I hide variants that are out of stock?
My store URL is https://poney-malaysia.myshopify.com/
@HWei which theme you are using
I'm currently using Impulse v7.5.0
Hi HWei,
Try .variant-input-wrap label.disabled {
display:none;
}
Where should I include the code in?
On others themes where i could put this code to hide sold out variants because i dont have base.css file on my theme.(agile theme) thanks!
Hi @StefanosJNT
Please add this code to your theme.css file to do that
.product-form__input input[type=radio].disabled+label {
display: none !important;
}
- Helpful? Like and Accept solution! or Buy me coffee
- Ryviu - Reviews & QA app: Collect product reviews, import reviews from AliExpress, Amazon, Etsy, Walmart, Shopee, Dhgate and CSV.
- Lookfy Gallery: Lookbook Image: Easy and fast to create Photo Gallery, Lookbook, Shop The Look.
- Ryviu: Aliexpress Reviews - AliExpress Reviews Importer, one-click import aliexpress reviews, export reviews to CSV file.
- Reelfy‑Shoppable Videos+Reels: Create shoppable videos to engage customers and drive more sales.
- Enjoy 1 month of Shopify for $1. Sign up now.
thank you for your fast reply, it worked but unlucky its shows the SOLD OUT badge even the products arend sold out
i fixed this by moving color thats available 1st. Could you also help me on how can i show the original price next to the reduced price in the collection list and not only in the product page.. thank you very much!!
@Dan-From-Ryviu unfortunately, I don't have base.css or theme.css in my shopify instance, but I'm trying to hide the variant. Can you advise on where else I might be able to place the code?
Hi @idasports
Could you share your store URL?
- Helpful? Like and Accept solution! or Buy me coffee
- Ryviu - Reviews & QA app: Collect product reviews, import reviews from AliExpress, Amazon, Etsy, Walmart, Shopee, Dhgate and CSV.
- Lookfy Gallery: Lookbook Image: Easy and fast to create Photo Gallery, Lookbook, Shop The Look.
- Ryviu: Aliexpress Reviews - AliExpress Reviews Importer, one-click import aliexpress reviews, export reviews to CSV file.
- Reelfy‑Shoppable Videos+Reels: Create shoppable videos to engage customers and drive more sales.
- Enjoy 1 month of Shopify for $1. Sign up now.
@Liquid_xPert_SJ Works great with pills, but is there also a version working with variant selector Dropdown menu?
@ASTools hi yes there is also please share the url
Hello Liquid_xPert_SJ thank you very much for your answer.
again briefly to the problem. We would like to switch from Dawn 7 to Dawn 15. Since we sell some products with a large number of variants, the selection of variants via pills is not very straightforward for some items. Almost all of our products have two options: diameter and spiral length.
In Dawn 7 we were able to hide the non existing variants via a script in the code. For this we used this script from github: https://gist.github.com/jonathanmoore/c0e0e503aa732bf1c05b7a7be4230c61
This script no longer works as planned in Dawn 15. Although the new version shows -not available behind variants, the variant selection2 with the spiral length does not automatically jump to the first really existing variant as soon as the diameter is changed. So it looks like the article is out of stock instead of not existing in this variant configuration.
Currently the shop is still running with Dawn Version7 until we get the problem with the variant selection under control, or until the variant selection2 at least automatically jumps to the first available or really existing variant when changing the first variant...
Nevertheless, here is the URL to our shop (currently still Dawn7):
www.as-toolstore.de
...Maybe it is possible to customise the product-variant-options.liquid so non-existing variants are not rendered in the drop down menu....
@Liquid_xPert_SJ I am now pursuing two solutions, as the approach of hiding the unavailable variants only works partially.
1. iIwas able to change the product-variant-options.liquid so that only existing variants are rendered. This works, but sometimes the selection automatically jumps back to the first available variant. Seems like the selected variant is not saved for some reason. See product-variant-options.liquid code below:
{% comment %}
Renders product variant options
Accepts:
- product: {Object} product object.
- option: {Object} current product_option object.
- block: {Object} block object.
- picker_type: {String} type of picker to dispay
Usage:
{% render 'product-variant-options',
product: product,
option: option,
block: block
picker_type: picker_type
%}
{% endcomment %}
{%- liquid
assign product_form_id = 'product-form-' | append: section.id
-%}
{%- for value in option.values -%}
{%- liquid
assign swatch_focal_point = null
if value.swatch.image
assign image_url = value.swatch.image | image_url: width: 50
assign swatch_value = 'url(' | append: image_url | append: ')'
assign swatch_focal_point = value.swatch.image.presentation.focal_point
elsif value.swatch.color
assign swatch_value = 'rgb(' | append: value.swatch.color.rgb | append: ')'
else
assign swatch_value = null
endif
assign option_disabled = true
if value.available
assign option_disabled = false
endif
-%}
{%- capture input_id -%}
{{ section.id }}-{{ option.position }}-{{ forloop.index0 -}}
{%- endcapture -%}
{%- capture input_name -%}
{{ option.name }}-{{ option.position }}
{%- endcapture -%}
{%- capture input_dataset -%}
data-product-url="{{ value.product_url }}"
data-option-value-id="{{ value.id }}"
{%- endcapture -%}
{%- capture label_unavailable -%}
<span class="visually-hidden label-unavailable">
{{- 'products.product.variant_sold_out_or_unavailable' | t -}}
</span>
{%- endcapture -%}
{%- if picker_type == 'swatch' -%}
{%- capture help_text -%}
<span class="visually-hidden">{{ value | escape }}</span>
{{ label_unavailable }}
{%- endcapture -%}
{%
render 'swatch-input',
id: input_id,
name: input_name,
value: value | escape,
swatch: value.swatch,
product_form_id: product_form_id,
checked: value.selected,
visually_disabled: option_disabled,
shape: block.settings.swatch_shape,
help_text: help_text,
additional_props: input_dataset
%}
{%- elsif picker_type == 'button' -%}
<input
type="radio"
id="{{ input_id }}"
name="{{ input_name }}"
value="{{ value | escape }}"
form="{{ product_form_id }}"
{% if value.selected %}
checked
{% endif %}
{% if option_disabled %}
class="disabled"
{% endif %}
{{ input_dataset }}
>
<label for="{{ input_id }}">
{{ value -}}
{{ label_unavailable }}
</label>
{%- elsif picker_type == 'dropdown' or picker_type == 'swatch_dropdown' -%}
<option
id="{{ input_id }}"
value="{{ value | escape }}"
{% if value.selected %}
selected="selected"
{% endif %}
{% if swatch_value and picker_type == 'swatch_dropdown' %}
data-option-swatch-value="{{ swatch_value }}"
{% if swatch_focal_point %}
data-option-swatch-focal-point="{{ swatch_focal_point }}"
{% endif %}
{% endif %}
{{ input_dataset }}
>
{% if option_disabled -%}
{% comment %}{{- 'products.product.value_unavailable' | t: option_value: value -}}{% endcomment %}
{{- 'products.product.not_exist' | t: option_value: value -}}
{%- else -%}
{{- value -}}
{%- endif %}
</option>
{%- endif -%}
{%- endfor -%}
2. so I have now used the default product-variant-options.liquid and have only adjusted the text for non-existent variants so that it is clear to customers that this combination does not exist. However, the selection of dropdown menu2 does not automatically jump to the first really available / existing variant as soon as menu1 is changed...
I could live with variant 2 for the moment, but I would prefer the variant with hidden variants because of the user-friendliness.
The shop is now online with Dawn15!
@ASTools ok i will get back to you with a solution.
@ASTools extremely sorry i forget to get-back to you, so you want to hide only unavailable variants right? even if they are in the combinations of multiple variants? correct?
Any updates on this? ... I am trying to hide out-of-stock variants with our Impulse theme but none of the solutions above have worked 😞
Hi @peterbange
You can try to add this code to your theme.liquid file, after <head> in Online Store > Themes > click "..." in the current theme > Edit code and check
<style>
.product-single__meta .variant__button-label.disabled { display: none !important; }
</style>
- Helpful? Like and Accept solution! or Buy me coffee
- Ryviu - Reviews & QA app: Collect product reviews, import reviews from AliExpress, Amazon, Etsy, Walmart, Shopee, Dhgate and CSV.
- Lookfy Gallery: Lookbook Image: Easy and fast to create Photo Gallery, Lookbook, Shop The Look.
- Ryviu: Aliexpress Reviews - AliExpress Reviews Importer, one-click import aliexpress reviews, export reviews to CSV file.
- Reelfy‑Shoppable Videos+Reels: Create shoppable videos to engage customers and drive more sales.
- Enjoy 1 month of Shopify for $1. Sign up now.
Worked great! Thanks 🙏
You are very welcome!
- Helpful? Like and Accept solution! or Buy me coffee
- Ryviu - Reviews & QA app: Collect product reviews, import reviews from AliExpress, Amazon, Etsy, Walmart, Shopee, Dhgate and CSV.
- Lookfy Gallery: Lookbook Image: Easy and fast to create Photo Gallery, Lookbook, Shop The Look.
- Ryviu: Aliexpress Reviews - AliExpress Reviews Importer, one-click import aliexpress reviews, export reviews to CSV file.
- Reelfy‑Shoppable Videos+Reels: Create shoppable videos to engage customers and drive more sales.
- Enjoy 1 month of Shopify for $1. Sign up now.
Hey Im using the spotlight theme and i need to hide sold out variants too. Can you help me? thanks
Ok so this code works for dawn perfectly. My only issue is that, say a customer looks for in my case, Size 7. But size 7 is out of stock. The product still displays in the filtered options but then when you click on the product that size 7 is out of stock. This is an issue for me as customers call me annoyed. Is there a way to fix this?
If you look at the images displayed you will see my issue
This works! Amazing. Finally.
Any idea how to get it to also auto select one of the available options when people switch one variant, etc.
Hi, do you have an solution for theme "Debutify 3" maybe?
Would be great! Thanks a lot
Hi @AndreBotha
Please share your store URL please
- Helpful? Like and Accept solution! or Buy me coffee
- Ryviu - Reviews & QA app: Collect product reviews, import reviews from AliExpress, Amazon, Etsy, Walmart, Shopee, Dhgate and CSV.
- Lookfy Gallery: Lookbook Image: Easy and fast to create Photo Gallery, Lookbook, Shop The Look.
- Ryviu: Aliexpress Reviews - AliExpress Reviews Importer, one-click import aliexpress reviews, export reviews to CSV file.
- Reelfy‑Shoppable Videos+Reels: Create shoppable videos to engage customers and drive more sales.
- Enjoy 1 month of Shopify for $1. Sign up now.
Did all the solutions above and still can't seem to get it working.
I am using the current version of Dawn and here is the link
@Micki_Angeles it's depends on the theme file structure and the requirements what you are looking for.
Please add this code to theme.liquid file, after <head> in Online Store > Themes > Edit code
<style>
.product-form__input--pill input[type=radio]:disabled+label,
.product-form__input--pill input[type=radio].disabled+label {
display: none !important;
}
</style>
- Helpful? Like and Accept solution! or Buy me coffee
- Ryviu - Reviews & QA app: Collect product reviews, import reviews from AliExpress, Amazon, Etsy, Walmart, Shopee, Dhgate and CSV.
- Lookfy Gallery: Lookbook Image: Easy and fast to create Photo Gallery, Lookbook, Shop The Look.
- Ryviu: Aliexpress Reviews - AliExpress Reviews Importer, one-click import aliexpress reviews, export reviews to CSV file.
- Reelfy‑Shoppable Videos+Reels: Create shoppable videos to engage customers and drive more sales.
- Enjoy 1 month of Shopify for $1. Sign up now.
Hello this solution was great thanks, however I'm now having the issue where a 'sold out' badge appears each time I change the size - my first varient, (before selecting the second variant) Can anyone advice on how to hide this please
Starting a B2B store is a big undertaking that requires careful planning and execution. W...
By JasonH Sep 23, 2024By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024