Bundles in Hydrogen
This recipe adds special styling for product bundles on your Hydrogen storefront. Customers will see badges and relevant cover images for bundles when they're viewing product and collection pages.
In this recipe you'll make the following changes:
- Set up the Shopify Bundles app in your Shopify admin and create a new product bundle.
- Update the GraphQL fragments to query for bundles to identify bundled products.
- Update the product and collection templates to display badges on product listings, update the copy for the cart buttons, and display bundle-specific information on product and collection pages.
- Update the cart line item template to display the bundle badge as needed.
Anchor to RequirementsRequirements
To use product bundles, you need to install a bundles app in your Shopify admin. In this recipe, we'll use the Shopify Bundles app.
Anchor to IngredientsIngredients
New files added to the template by this recipe.
File | Description |
---|---|
app/components/BundleBadge.tsx | A badge displayed on bundle product listings. |
app/components/BundledVariants.tsx | A component that wraps the variants of a bundle product in a single product listing. |
Anchor to Step 1: Set up the Shopify Bundles appStep 1: Set up the Shopify Bundles app
-
Install the Shopify Bundles app in your Shopify admin.
-
Make sure your store meets the eligibility requirements.
-
From the Bundles page, create a new bundle.
Anchor to Step 2: Create the BundleBadge componentStep 2: Create the Bundle Badge component
Create a new BundleBadge component to be displayed on bundle product listings.
File
Anchor to Step 3: Create a new BundledVariants componentStep 3: Create a new Bundled Variants component
Create a new BundledVariants
component that wraps the variants of a bundle product in a single product listing.
File
Anchor to Step 4: Query bundle pricing for recommended productsStep 4: Query bundle pricing for recommended products
Add maxVariantPrice
to the RecommendedProducts
query's product fields.
Anchor to Step 5: Show bundled products on the product pageStep 5: Show bundled products on the product page
- Add the
requiresComponents
field to theProduct
fragment, which is used to identify bundled products. - Pass the
isBundle
flag to theProductImage
component.
File
Anchor to Step 6: Detect bundles in collection listingsStep 6: Detect bundles in collection listings
Like the previous step, use the requiresComponents
field to detect if the product item is a bundle.
Anchor to Step 7: Identify bundles in the cartStep 7: Identify bundles in the cart
Use the requiresComponents
field to determine if a cart line item is a bundle.
Anchor to Step 8: Show bundle badges in the cartStep 8: Show bundle badges in the cart
If a product is a bundle, show the BundleBadge
component in the cart line item.
If a product is a bundle, update the text of the product button.
Anchor to Step 10: Show bundle badges on product imagesStep 10: Show bundle badges on product images
If a product is a bundle, show the BundleBadge
component in the ProductImage
component.
Anchor to Step 11: Show bundle badges on product cardsStep 11: Show bundle badges on product cards
If a product is a bundle, show the BundleBadge
component in the ProductItem
component.
File
Anchor to Step 12: Position bundle badges on imagesStep 12: Position bundle badges on images
Make sure the bundle badge is positioned relative to the product image.
Anchor to Next stepsNext steps
- Test your implementation by going to your store and adding a bundle to the cart. Make sure that the bundle's badge appears on the product page and in the cart.
- (Optional) Place a test order to see how orders for bundles appear in your Shopify admin.