How do I figure out which individual products belong to a product bundle?

How do I figure out which individual products belong to a bundled product?

The bundle would be created by the native shopify bundle app. Is there a way to use the graphql api to figure out what the children individual products are?

Also, is there a way to figure out the product is a bundle to begin with?

You could look into the product metafields and determine if there’s a metafield with a value indicating that it is a component of a bundle.

Hi Alfredo!

Great questions! Here’s how you can work with Shopify’s GraphQL API to identify bundled products and their components:

1. How to tell if a product is a bundle

Shopify’s GraphQL Admin API exposes a field on the Product object called hasVariantsThatRequiresComponents. If this field is true, the product is a bundle (created by the native Bundles app).

Example query:

{
  product(id: "gid://shopify/Product/1234567890") {
    id
    title
    hasVariantsThatRequiresComponents
  }
}

If hasVariantsThatRequiresComponents is true, this product is a bundle.


2. How to get the individual products (components) in a bundle

For bundle products, you can use the bundleComponents field on the Product object. This field returns the list of components (i.e., the individual products and their quantities) that make up the bundle.

Example query:

{
  product(id: "gid://shopify/Product/1234567890") {
    id
    title
    hasVariantsThatRequiresComponents
    bundleComponents {
      product {
        id
        title
      }
      quantity
    }
  }
}

This will return the list of products included in the bundle, along with their quantities.

Docs:

Hope this helps! Let me know if you have any more questions.