Hey people,
Looking for a workaround to
{%- assign variant = variant | default: product.selected_or_first_available_variant -%}
I have a shoe which has multiple colors and sizes. Unfortunately this line keeps returning a variant that is sold out even though there are other variants that are still in stock.
Has anyone encountered this issue before and have a workaround?
Hi @jasonpxf see the docs https://shopify.dev/docs/api/liquid/objects/product#product-selected_or_first_available_variant
If the store uses variants that are selected in the URL variant parameter that should be respected and some other affordance should be used to get customers to select instock variants.
otherwise use first_available_variant and it’s rules https://shopify.dev/docs/api/liquid/objects/product#product-first_available_variant
Also take a look at the UX in the screenshot, multiple variants are sold out so there’s no way from the description to even know what size is even selected or returned by the code. (though it should be 7)