All things Shopify and commerce
Hi Shopify Community,
I'm facing an issue with my shopify store's product page. I want a unique variant selection option for my products.
The thing is that I want my product page to have conditional variants option enabled. There are 2 variant selection options on the page. The first one is the region which has options (US,EU) and the second selection option is Bed Sizing and type. The bed sizes for US are in inches and the sizes for EU are in cm.
I want a code which helps me to connect the related US and EU variants to each other and hide the other corresponding variants which are not available for the region. I'm attaching the URL of the product page so that you can easily navigate it and let me know if anyone has a solution.
Remember, I only need a code.
Hello @farrukhirfan07,
Follow these steps:
First, create your product in Shopify.
In the Shopify product editor:
Go to Online Store → Themes → Edit Code.
Search for the file product-variant-options.liquid and open it.
Replace its content with the following code:
{% unless option_disabled %}
<option
id="{{ input_id }}"
class="{% if option_disabled %}unavailable{% else %}available{% endif %}"
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 -%}
{{- 'products.product.value_unavailable' | t: option_value: value -}}
{%- else -%}
{{- value -}}
{%- endif %}
</option>
{% endunless %}
Open the base.css file in your theme.
Scroll to the bottom and add this CSS:
.product .unavailable {
display: none;
}
Hi devmont-digital,
Glad that you have identified the issue and provided a solution for it. I had already done the first 3 steps and was in need of the code which you have provided in Steps 4 and 5. I appreciate that.
Unfortunately, the issue remains persistent even after entering these 2 code snippets to the respective files. Now, the unavailable variants are hidden but on selecting the other region variant option (i.e. EU) the product shows sold out instead of the Preorder button (which I've connected via an application named EZ PreOrder). You can see it through the URL again. If you think that I can use a code for having Preorder button you can help me out with that too. I'm all in for that solution too.
Let me clear that this store works on manufacturing after receiving X preorders so we don't have a stock available in store for the variants.
What approach should I try now in order to resolve this issue? I really appreciate you assisting me on this one and I'm looking forward to hear from you again!
Go to the variants you have created for the EU, select them all, and click on Bulk Edit.
Then, click on Columns, checkmark "Continue selling when out of stock", and then apply the checkmark to all product variants.
This will remove the "Sold Out" button.
All the variants already have this option enabled. Still it shows sold out.
As I told I've used an app for adding the preorder button in which the condition automatically sets all variants Continue selling when out of stock as enabled. Should I remove the app then? Can you provide a code for setting the preorder button instead of add to cart.
Yes, the Preorder button can be implemented using custom code, and you can remove the app.
<input id="pre-order" type="hidden" name="properties[Type]" value="Pre Order">
Hey Community 👋 Did you know that March 15th is National Everything You Think Is W...
By JasonH Apr 1, 2025Discover how to increase the efficiency of commerce operations with Shopify Academy's l...
By Jacqui Mar 26, 2025Shopify and our financial partners regularly review and update verification requiremen...
By Jacqui Mar 14, 2025