-
-
Notifications
You must be signed in to change notification settings - Fork 121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Missing CartItem Variation Field in Cart Query #284
Comments
@hwsiew If you don't have a product attribute assigned to the variation meaning set to Product Attributes without a variation are meant to be descriptive only, otherwise it should be assigned to a variation, so inventory can be kept on the item. |
Hi @kidunot89, customer will still need to choose one for the 'Any' attribute. So how can i get the field for the cart item? In this case, e.g. the 'Color' attribute is set to 'Any', how do i get the field if customer chose 'Green'? Like the one in woocommerce cart page, the cart item selected attributes can be listed down even for the 'Any' attribute. |
@hwsiew Then you should use the |
Hi @kidunot89, thanks for the prompt reply. This is the variable product setting. Each variation has 3 attributes. Among these attributes, |
@hwsiew That is correct. You can obtaining the options for the color field by queries |
@kidunot89, Yup, it has been set to |
@hwsiew I said parent product, not parent attributes. I also cannot stress enough that you are using both product variations and product attributes in a way they are not designed for. |
@kidunot89, I think i get your point. By the current design, they are correct. Rather than saying this is a bug, i would say an enhancement for wp-graphql-woocommerce/includes/type/object/class-cart-type.php Lines 299 to 307 in 01df7b8
However, according to WC, CartItem.variation is more likely a taxonomy-ish key-value pair as follow. Notice that, even though color attribute is set to
Related portion of WC code -> |
Describe the bug
There are cases where product variation's attributes can be set to 'Any' instead of particular selection as shown below. Currently, to query cart items with variable product, one can only get the attribute variation from product (e.g. ProductVariation ). This will work provided all attributes in variation product is set to specific value, for instance, the Pattern and Size attributes in the following attachment. However, if one of the attribute is set to 'Any', in this case the 'Color'. product variation for that attribute (i.e Color) will return empty string. There is no field available to query CartItem's variation for now.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
To be able to display selected attributes for CartItem like in the woocommerce cart page.
The text was updated successfully, but these errors were encountered: