Have your say in Community Polls: What was/is your greatest motivation to start your own business?
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Storefront API: Return the Values of Product Option Values?

Storefront API: Return the Values of Product Option Values?

BWid55
Shopify Partner
13 0 4

If I have a product that has options of "Size" with "Small, Medium, and Large" and "Color" with "Blue, Red, Yellow, White, and Black" 

 

I want to return: "Size - Small, Medium, Large" and "Color - Blue, Red, Yellow, White, Black".

 

I have been able to return the product option and all variant combinations with the below code.

 

This returns: "Size, Color" and "Small, Blue" - "Small, Red" - "Small, Yellow" - "Small, White" - "Small, Black" - "Medium, Blue" - "Medium, Red" - "Medium, Yellow" - "Medium, White" - "Medium, Black" - "Large, Blue" - "Large, Red" - "Large, Yellow" - "Large, White" - "Large, Black".

 

Is there any way to return the first response instead of the second?

 

 

 

 

    {
      productByHandle(handle: "${productHandle}") {
        options{
          name
        }
        variants(first: 50) {
          edges {
            node {
              selectedOptions{
                name
              }
            }
          }
        }
      }
    }

 

 

 

 

Replies 0 (0)