@Liquid_xPert_SJ I am now pursuing two solutions, as the approach of hiding the unavailable variants only works partially.
- 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:
Show More
{% 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 -%}
{{- ‘products.product.variant_sold_out_or_unavailable’ | t -}}
{%- endcapture -%}
{%- if picker_type == ‘swatch’ -%}
{%- capture help_text -%}
{{ value | escape }}
{{ 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’ -%}
{%- elsif picker_type == ‘dropdown’ or picker_type == ‘swatch_dropdown’ -%}
{%- endif -%}
{%- endfor -%}
- 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!