[Improvement] Allow to check if option values are passed

Short description of issue

This feature would allow advanced use case such as having no variant selected on page load

Reproduction steps

Hello,

Some merchants have a use case where, on page load, no variant is pre-selected (this is useful especially for clothing brands where having a default selected option can cause incorrect variant being selected). In the past, such solution could be achieved by using the {{ product.selected_variant }}. On page load (eg.: /products/foo) this drop would be nil so it could be used as a condition to not show any selected value.

As soon as the buyer selects an option, the variant property is set in the URL which, if the page is reloaded, allows to keep the selected options.

However, since the variant increase count, developers must now re-load the section using an array of option_values. The problem is that there is no way to know, in Liquid, if the request contains option_values attribute.

Additional info

To replicate a similar effect now, we would need to be able to detect when the product is rendered without any option_values. Initially, I thought that when passing option_values, then {{ product.selected_variant }} would no longer be null, but this is not the case.

I suggest a new product drop “{{ product.selected_option_values }}” that would return an array of product_option_value drops in the URL.

Thanks!

What type of topic is this

Feature request

1 Like