What's your biggest current challenge? Have your say in Community Polls along the right column.
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.

Re: Cannot find the requiresComponents field on the variants? (Cart Transform function API)

Cannot find the requiresComponents field on the variants? (Cart Transform function API)

jam_chan
Shopify Partner
927 23 190

I'm trying to implement customized bundles using the Cart Transform Function API. From this page, it mentions that if the parent variant can't be purchased without components, then you must mark the parent bundles with the requiresComponents attribute to true.

 

But I can't find the requiresComponents field on the parent variants. I try to view this variant json by the link: https://admin.shopify.com/store/my-store/products/8599060644139/variants/46643412402475.json

 

But the field doesn't appear. Also, I try to view the variant object with Python API and it's the same. The field doesn't exist on the variants.

 

Is this requiresComponents field effective now?

BYOB - Build Your Own Bundles, SPO - SEO App to research keywords & edit social link preview
Replies 2 (2)

Tuckey
Shopify Partner
10 2 9

Hi Jam_chan,

 

I came across this question while developing my own cart bundling function, as I was also confused when viewing that page from the docs. 

 

You should be able to set the required attribute using the below mutation via the Shopify GraphiQL App(or any other GraphQL interface):

mutation {
  productVariantUpdate(input: {id: "gid://shopify/ProductVariant/IDGOESHERE", requiresComponents: true}) {
    productVariant {
      id
      requiresComponents
    }
    userErrors {
      field
      message
    }
  }
}

 

jam_chan
Shopify Partner
927 23 190

I can create a new variant with Graphql. The requiresComponents is also included in the mutation. But the field is not found on the variant object after running the mutation

BYOB - Build Your Own Bundles, SPO - SEO App to research keywords & edit social link preview