Add a variant fixed bundle
A variant fixed bundle is a bundle that's configured at the variant level. This guide shows you how to add a variant fixed bundle using the productVariantRelationshipBulkUpdate mutation.
What you'll learn
Anchor link to section titled "What you'll learn"In this tutorial, you'll learn how to do the following tasks:
- Use the GraphQL Admin API to create a product with variants
- Associate components to variants
- Delete components in a bundle
Requirements
Anchor link to section titled "Requirements"- You've created a Partner account.
- You've created a development store.
You've created an app that uses Shopify CLI 3.49.5 or higher. If you previously installed Shopify CLI, then make sure that you're using the latest version.
If you plan to create a UI for your extension, then start with the Remix app template.
You've installed Node.js 16 or higher.
You've installed your app on the development store.
Your app can make authenticated requests to the GraphQL Admin API.
Your app has the
write_products
access scope. Learn how to configure your access scopes using Shopify CLI.
How it works
Anchor link to section titled "How it works"A variant fixed bundle is modeled as a variant associated with other component variants using the productVariantComponents
relationship.
The bundle parent variant's price determines the price, while the inventory of each component's variants determines the bundle inventory. This is the same for product fixed bundles.
A variant has a productVariantComponents
field that determines the bundles' components. Two bundle variants can have the same components.
The following diagram shows an example of a product variant ("The Hair and Skin Bundle") that models a bundle and contains two components: "Natural Shampoo 50 ml" and "Coconut Conditioner". The bundle is modeled by creating a variant, associating the variant with components, and assigning a quantity of one to each component.
Limitations and considerations
Anchor link to section titled "Limitations and considerations"- A bundle can have up to 30 components.
- After an app has assigned components to a bundle, only that app can manage the components of the bundle.
- Nested bundles aren't supported. A bundle can't have components and be part of another bundle simultaneously.
Step 1: Create a product with variants
Anchor link to section titled "Step 1: Create a product with variants"To create a product with variants, you can run the productCreate
mutation.
The following example creates a product with a single variant modelling a bundle.
Step 2: Associate components to variants
Anchor link to section titled "Step 2: Associate components to variants"After creating the product variant, you need to associate the components of a bundle. To do that, you can run the productVariantRelationshipBulkUpdate
mutation.
If the variant is associated with components, then the attribute productVariant.requiresComponents
returns true
.
The following example associates two components, a Shampoo variant and a Soap variant, with a quantity of one to the product variant created in the previous step.
- Learn how to use the
productVariantRelationshipBulkUpdate
mutation.