Loading…
Loading…
Complete guide to querying WooCommerce Composite Products via GraphQL - components, scenarios, pricing, and configuration options.
This guide covers all composite product query capabilities provided by WooGraphQL Pro.
query GetCompositeProduct($id: ID!) { product(id: $id, idType: DATABASE_ID) { ... on CompositeProduct { id databaseId name slug description shortDescription image { sourceUrl } } } }
query GetCompositeConfig($id: ID!) { product(id: $id, idType: DATABASE_ID) { ... on CompositeProduct { # Layout and display layout addToCartFormLocation shopPriceCalculation # Behavior editableInCart virtualComposite soldIndividuallyContext } } }
Components are the building blocks of composite products:
query GetCompositeComponents($id: ID!) { product(id: $id, idType: DATABASE_ID) { ... on CompositeProduct { components { # Identity id componentId title slug description thumbnail { sourceUrl } # Options configuration queryType optional # Display settings optionsStyle paginationStyle showSortingOptions showFilteringOptions # Quantity constraints minQuantity maxQuantity defaultQuantity # Pricing pricedIndividually discount shippedIndividually # Behavior optionsSelectAction } } } }
Get available products for a component:
query GetComponentOptions($id: ID!) { product(id: $id, idType: DATABASE_ID) { ... on CompositeProduct { components { componentId title # Available options queryOptions { nodes { id databaseId name slug price stockStatus image { sourceUrl } # Handle variable products ... on VariableProduct { variations { nodes { id databaseId name price stockStatus attributes { nodes { name value } } } } } } } # Default selection defaultOption { id name price } } } } }
| Field | Type | Description |
|---|---|---|
id | ID! | Global Relay ID |
componentId | Int! | Component ID for mutations |
title | String | Display title |
slug | String | URL-safe identifier |
description | String | Component description |
thumbnail | MediaItem | Associated image |
queryType | CompositeProductComponentOptionsTypeEnum | Products or Categories |
queryOptions | ProductConnection | Available product options |
defaultOption | Product | Default selected product |
optional | Boolean | Whether component is optional |
optionsStyle | CompositeProductComponentOptionStyleEnum | Display style |
paginationStyle | CompositeProductComponentPaginationStyleEnum | Pagination method |
showSortingOptions | Boolean | Show sort controls |
showFilteringOptions | Boolean | Show filter controls |
attributeFilters | [Taxonomy] | Available attribute filters |
minQuantity | Int | Minimum quantity |
maxQuantity | Int | Maximum quantity |
defaultQuantity | Int | Default quantity |
pricedIndividually | Boolean | Add to base price |
discount | String | Applied discount percentage |
shippedIndividually | Boolean | Ship separately |
optionsSelectAction | CompositeProductComponentOptionSelectActionEnum | Selection behavior |
Scenarios enable conditional logic for components and options:
query GetCompositeScenarios($id: ID!) { product(id: $id, idType: DATABASE_ID) { ... on CompositeProduct { scenarios { id scenarioId name description enabled # Conditions configuration { component { componentId title } componentOptions { nodes { id name } } optionsModifier } # Actions actions { actionId isActive hiddenComponents { componentId title } hiddenOptions { component { componentId } componentOptions { nodes { id name } } } } } } } }
| Field | Type | Description |
|---|---|---|
component | CompositeProductComponent | Component being observed |
componentOptions | ProductConnection | Products triggering the scenario |
optionsModifier | CompositeProductScenarioConditionCompareEnum | Match type: IS, IS_NOT, IS_ANY |
| Field | Type | Description |
|---|---|---|
actionId | String! | Action identifier |
isActive | Boolean | Whether action is enabled |
hiddenComponents | [CompositeProductComponent] | Components to hide |
hiddenOptions | [CompositeProductScenarioConfiguration] | Options to hide |
| 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 |
|---|---|---|
layout | CompositeProductLayoutEnum | Display layout |
addToCartFormLocation | CompositeProductFormLocationEnum | Form placement |
shopPriceCalculation | CompositeProductShopPriceCalcOptions | Catalog price display |
editableInCart | Boolean | Allow cart editing |
virtualComposite | Boolean | Force virtual contents |
soldIndividuallyContext | CompositeProductSoldIndividuallyContextEnum | Sold individually scope |
| Value | Description |
|---|---|
STACKED | All components on one page |
PROGRESSIVE | Sequential component selection |
STEPPED | Multi-page wizard layout |
COMPONENTIZED | Component-based page groups |
query GetCompositeProducts($first: Int = 12) { products(first: $first, where: { type: COMPOSITE }) { nodes { ... on CompositeProduct { id name price image { sourceUrl } layout components { title optional } } } } }
query GetCompositeProductsPaginated($first: Int, $after: String) { products(first: $first, after: $after, where: { type: COMPOSITE }) { pageInfo { hasNextPage endCursor } nodes { ... on CompositeProduct { id name price } } } }
A comprehensive query for a composite product page:
query GetFullCompositeProduct($id: ID!) { product(id: $id, idType: DATABASE_ID) { ... on CompositeProduct { # Identity id databaseId name slug description shortDescription # Media image { sourceUrl altText } galleryImages { nodes { sourceUrl } } # Pricing price regularPrice salePrice # Configuration layout addToCartFormLocation editableInCart shopPriceCalculation # Stock stockStatus stockQuantity # Components with full details components { id componentId title description thumbnail { sourceUrl } # Options queryType optional optionsStyle paginationStyle # Quantities minQuantity maxQuantity defaultQuantity # Pricing pricedIndividually discount # Default and available options defaultOption { id databaseId name price } queryOptions { nodes { id databaseId name slug price stockStatus image { sourceUrl } ... on VariableProduct { variations { nodes { id databaseId name price stockStatus attributes { nodes { name value } } } } attributes { nodes { name options variation } } } } } } # Scenarios for conditional logic scenarios { scenarioId name enabled configuration { component { componentId } componentOptions { nodes { id } } optionsModifier } actions { actionId isActive hiddenComponents { componentId } } } # Related products related { nodes { id name } } } } }
Components have detailed visibility settings:
query GetComponentVisibility($id: ID!) { product(id: $id, idType: DATABASE_ID) { ... on CompositeProduct { components { componentId title # What to show for selected products selectionDetailVisibility # Where to show subtotals subtotalVisibility } } } }
| Value | Description |
|---|---|
HIDE_TITLE | Hide product title |
HIDE_DESCRIPTION | Hide product description |
HIDE_THUMBNAIL | Hide product image |
HIDE_PRICE | Hide product price |
DISABLE_ADDONS | Disable product add-ons |
| Value | Description |
|---|---|
SINGLE_PRODUCT_SUMMARY | Show on product page |
CART_AND_CHECKOUT | Show in cart/checkout |
ORDER_DETAILS | Show in order history |
addCompositeToCart mutation