Loading…
Loading…
Complete guide to querying WooCommerce Product Bundles via GraphQL - bundle products, bundled items, and pricing.
This guide covers all bundle product query capabilities provided by WooGraphQL Pro.
query GetBundleProduct($id: ID!) { product(id: $id, idType: DATABASE_ID) { ... on BundleProduct { id databaseId name slug description shortDescription image { sourceUrl } } } }
Bundle products support min/max pricing for display:
query GetBundlePricing($id: ID!) { product(id: $id, idType: DATABASE_ID) { ... on BundleProduct { # Minimum bundle price (all items at min quantity) priceMin: price(context: MIN) regularPriceMin: regularPrice(context: MIN) salePriceMin: salePrice(context: MIN) # Maximum bundle price (all items at max quantity) priceMax: price(context: MAX) regularPriceMax: regularPrice(context: MAX) salePriceMax: salePrice(context: MAX) } } }
query GetBundleConfig($id: ID!) { product(id: $id, idType: DATABASE_ID) { ... on BundleProduct { # Size constraints minBundleSize maxBundleSize # Display options layout groupMode addToCartFormLocation editableInCart } } }
Bundled items are accessed via a connection with edge data:
query GetBundledItems($id: ID!) { product(id: $id, idType: DATABASE_ID) { ... on BundleProduct { bundleItems { edges { # Edge data (bundle-specific configuration) bundledItemId title description optional pricedIndividually hiddenInCart hiddenInOrder # Quantity settings minQuantity maxQuantity defaultQuantity # Pricing discount # The actual product node { id databaseId name price ... on VariableProduct { variations { nodes { id name price } } } } } } } } }
| Field | Type | Description |
|---|---|---|
bundledItemId | Int | Unique ID within the bundle |
title | String | Display title (may differ from product name) |
description | String | Bundle-specific description |
optional | Boolean | Whether the item is optional |
pricedIndividually | Boolean | Whether the item adds to bundle price |
hiddenInCart | Boolean | Hide in cart display |
hiddenInOrder | Boolean | Hide in order display |
minQuantity | Int | Minimum quantity allowed |
maxQuantity | Int | Maximum quantity allowed |
defaultQuantity | Int | Default quantity |
discount | String | Discount applied to this item |
| Field | Type | Description |
|---|---|---|
id | ID! | Global Relay ID |
databaseId | Int! | WordPress database ID |
name | String | Product name |
slug | String | URL slug |
description | String | Full description |
shortDescription | String | Short description |
| Field | Type | Description |
|---|---|---|
price(context: ProductBundleMinMaxEnum) | String | Bundle price |
regularPrice(context: ProductBundleMinMaxEnum) | String | Regular bundle price |
salePrice(context: ProductBundleMinMaxEnum) | String | Sale bundle price |
| Field | Type | Description |
|---|---|---|
minBundleSize | Int | Minimum number of items required |
maxBundleSize | Int | Maximum number of items allowed |
layout | String | Display layout |
groupMode | String | Grouping mode |
addToCartFormLocation | String | Form location |
editableInCart | Boolean | Allow editing in cart |
query GetBundleProducts($first: Int = 12) { products(first: $first, where: { type: BUNDLE }) { nodes { ... on BundleProduct { id name price(context: MIN) priceMax: price(context: MAX) image { sourceUrl } bundleItems { edges { node { name } } } } } } }
query GetBundleProductsPaginated($first: Int, $after: String) { products(first: $first, after: $after, where: { type: BUNDLE }) { pageInfo { hasNextPage endCursor } nodes { ... on BundleProduct { id name price(context: MIN) } } } }
A comprehensive query for a bundle product page:
query GetFullBundleProduct($id: ID!) { product(id: $id, idType: DATABASE_ID) { ... on BundleProduct { # Identity id databaseId name slug description shortDescription # Media image { sourceUrl altText } galleryImages { nodes { sourceUrl } } # Pricing priceMin: price(context: MIN) priceMax: price(context: MAX) regularPriceMin: regularPrice(context: MIN) regularPriceMax: regularPrice(context: MAX) # Configuration minBundleSize maxBundleSize layout editableInCart # Stock stockStatus stockQuantity # Bundled items bundleItems { edges { bundledItemId title description optional pricedIndividually minQuantity maxQuantity defaultQuantity discount node { id databaseId name slug price stockStatus image { sourceUrl } # Handle variable products ... on VariableProduct { variations { nodes { id databaseId name price stockStatus attributes { nodes { name value } } } } attributes { nodes { name options variation } } } } } } # Related products related { nodes { id name } } } } }
function formatBundlePrice(product: BundleProduct): string { const minPrice = product.priceMin; const maxPrice = product.priceMax; if (minPrice === maxPrice) { return minPrice; } return `${minPrice} - ${maxPrice}`; }
function formatBundlePriceFrom(product: BundleProduct): string { return `From ${product.priceMin}`; }
addBundleToCart mutation