theme-scripts icon indicating copy to clipboard operation
theme-scripts copied to clipboard

Theme product-form variants() returns "error: is empty" if used on a product that has no variant options

Open adrianocr opened this issue 6 years ago • 1 comments

I get it... the product has no variants so it shouldn't return a variant object. But I think it should return null so we can check for that easily. Or alternatively, return the equivalent of {{ product.selected_or_first_available_variant.id }} which defaults to the default option in products without variants.

This is in slate starter theme if that matters. Standard product.liquid page and the only code changes I made to /scripts/sections/product.js was to add window.variantId = productForm.variants() to the onLoad method and to the onFormOptionChange method so the variant ID would always be globally available.

adrianocr avatar May 30 '19 21:05 adrianocr

I commented on the related issue: https://github.com/Shopify/theme-scripts/issues/91#issuecomment-517408590

tms320c avatar Aug 01 '19 18:08 tms320c