scottyzen / woonuxt

Static e-commerce powered by WooCommerce & Nuxt
https://woonuxt.com
GNU General Public License v3.0
574 stars 139 forks source link

Default variation not respected #141

Closed jrusi closed 3 months ago

jrusi commented 4 months ago

Hi,

I have a product with default variation setup to: attribute1 = "1 day" attribute2 = "Choose option" attribute3 = "Choose option"

I want to be sure the user will make a choice before putting the product into the cart - "add to cart" button has to be disabled when opening product page until user makes the choice for all attributes. In WooNuxt I have attributes already selected and what is worse all the attributes are visible for this product even the ones not setup as variation in Woocommerce. For example I have setup variation only with value for attribute1 = "1 day" but I can see on the product page all the possible values ("1 day", "1 hour", "3 hours").

Similar issue described here: https://github.com/wp-graphql/wp-graphql-woocommerce/issues/557

I found the default values in: product(id: $id, idType: DATABASE_ID) { ... on VariableProduct { name variations { edges { node { attributes { nodes { label name value } } } } } } } Is there any easy fix?

scottyzen commented 3 months ago

Hi @jrusi

I just pushed a fix for this. The default variation is now respected.

Also, if there are no defaults set, the first of each attribute is selected. IMO I think that is better than having the user select the first option for each attribute.