# Woo Dynamic Data Tree

> Full reference for product, cart, and selector dynamic data exposed by Woo docs and components.

<!-- Sources: src/Woo/ProductDynamicData.php; src/Support/EtchImageData.php; src/Woo/CartItemsDynamicSource.php; src/Woo/CartViewModel.php; src/Woo/CartItemTitleFormatter.php; src/Woo/WooSelectorDynamicSource.php; src/Components/Woo/AttributeSelector/AttributeSelector.php; src/Patterns/Testing/TestWooProductList/TestWooProductList.php; src/Patterns/Testing/TestSingleWooProductTemplate/TestSingleWooProductTemplate.php; src/Testing/E2E/Woo/WooScenarioProvider.php; tests/e2e/components/woo/behavior.spec.ts -->

# Woo Dynamic Data Tree

Woo product dynamic data is exposed under `omewoo` on Etch post data when the post is a Woo product.

Use the same tree with different prefixes depending on context:

| Context | Prefix |
| --- | --- |
| Product archive or product loop | `{item.omewoo...}` |
| Single product template | `{this.omewoo...}` |

The examples below use `{this.omewoo...}`. In a product loop, replace `this` with `item`.

## Product Tree

| Expression | Type | Meaning |
| --- | --- | --- |
| `{this.omewoo.productType}` | string | Woo product type, such as `simple` or `variable`. |
| `{this.omewoo.productId}` | number | Woo product ID. |
| `{this.omewoo.priceText}` | string | Formatted current product price text. |
| `{this.omewoo.stockStatus}` | string | Woo stock status. |
| `{this.omewoo.available}` | boolean | `true` when the product is purchasable and in stock. |
| `{this.omewoo.product.id}` | number | Product identity ID. |
| `{this.omewoo.product.type}` | string | Product identity type. Use this for `AddToCartForm.product.product_type`. |
| `{this.omewoo.product.sku}` | string | Product SKU. |
| `{this.omewoo.product.name}` | string | Product display name. |

The top-level values are convenience aliases. The grouped objects are the more descriptive structure.

## Price Tree

| Expression | Type | Meaning |
| --- | --- | --- |
| `{this.omewoo.price.currencyCode}` | string | Store currency code. |
| `{this.omewoo.price.currencySymbol}` | string | Decoded store currency symbol. |
| `{this.omewoo.price.raw}` | string | Raw Woo price. |
| `{this.omewoo.price.regular}` | string | Raw regular price. |
| `{this.omewoo.price.sale}` | string | Raw sale price. |
| `{this.omewoo.price.text}` | string | Formatted price text. |

The demo archive and single-product patterns use `{item.omewoo.price.text}` and `{this.omewoo.price.text}` for visible price copy.

## Media Tree

| Expression | Type | Meaning |
| --- | --- | --- |
| `{this.omewoo.media.image.id}` | number | Attachment ID, or `0` when no attachment is available. |
| `{this.omewoo.media.image.url}` | string | Full image URL. |
| `{this.omewoo.media.image.alt}` | string | Attachment alt text, falling back to product or variant name. |
| `{this.omewoo.media.image.title}` | string | Attachment title. |
| `{this.omewoo.media.image.caption}` | string | Attachment caption. |
| `{this.omewoo.media.image.description}` | string | Attachment description. |
| `{this.omewoo.media.image.filename}` | string | Image filename. |
| `{this.omewoo.media.image.srcset}` | string | WordPress image `srcset`. |
| `{this.omewoo.media.image.width}` | number | Full image width. |
| `{this.omewoo.media.image.height}` | number | Full image height. |
| `{this.omewoo.media.image.filesize}` | number | Attachment filesize when available. |
| `{this.omewoo.media.image.mime_type}` | string | Attachment MIME type. |
| `{this.omewoo.media.image.sizes.full.url}` | string | Full-size URL when WordPress provides it. |
| `{this.omewoo.media.image.sizes.full.width}` | number | Full-size width. |
| `{this.omewoo.media.image.sizes.full.height}` | number | Full-size height. |

`sizes` is keyed by registered WordPress image size names. Common keys include `thumbnail`, `medium`, `large`, and `full`, but the available keys depend on the site.

## Purchase Tree

| Expression | Type | Meaning |
| --- | --- | --- |
| `{this.omewoo.purchase.available}` | boolean | Product can be purchased and is in stock. |
| `{this.omewoo.purchase.purchasable}` | boolean | Woo says the product is purchasable. |
| `{this.omewoo.purchase.inStock}` | boolean | Woo says the product is in stock. |
| `{this.omewoo.purchase.stockStatus}` | string | Woo stock status. |

`AddToCartForm` uses these values through its availability props. If the product is unavailable, the form disables its submit controls at runtime.

## Attribute Tree

Variable products expose variation attributes under `omewoo.attributes`. Simple products intentionally expose an empty array.

Loop target:

```etch
{#loop this.omewoo.attributes as attribute}
  ...
{/loop}
```

Each `attribute` row has this shape:

| Expression | Type | Meaning |
| --- | --- | --- |
| `{attribute.key}` | string | Store API variation attribute key, such as `attribute_pa_color`. |
| `{attribute.taxonomy}` | string | Woo taxonomy or local attribute name, such as `pa_color`. |
| `{attribute.label}` | string | Human-readable attribute label. |
| `{attribute.required}` | boolean | Current implementation marks variation attributes as required. |
| `{attribute.options}` | array | Selectable option rows for `AttributeSelector`. |

`AttributeSelector` expects the whole attribute object:

```etch
<OmeWooAttributeSelector target='{{"attribute":{attribute}}}' />
```

## Attribute Option Tree

Inside an attribute, options are available as `attribute.options`. `AttributeSelector` loops this tree internally through `props.target.attribute.options`, but authors can also inspect it in custom loops.

| Expression | Type | Meaning |
| --- | --- | --- |
| `{option.label}` | string | Option display label. |
| `{option.value}` | string | Option slug sent as the selected variation value. |
| `{option.variationId}` | number | Variation ID when a single-attribute product can map the option to one variant; otherwise `0`. |
| `{option.priceText}` | string | Variant price text when available from a single-attribute variant. |
| `{option.available}` | boolean | Whether the mapped option is available. |
| `{option.stockStatus}` | string | Mapped variant stock status. |
| `{option.image}` | object | Image payload using the same image shape as `media.image`. |

Runtime copies option availability into `data-ome-available`, `data-ome-unavailable`, and `data-ome-stock-status` so unavailable variation choices can disable the parent form.

## Variant Tree

Variable products expose all variation payloads under `omewoo.variants`. Simple products intentionally expose an empty array.

| Expression | Type | Meaning |
| --- | --- | --- |
| `{variant.id}` | number | Variation product ID. |
| `{variant.label}` | string | Label built from selected variation attribute values. |
| `{variant.sku}` | string | Variation SKU. |
| `{variant.priceText}` | string | Formatted variation price text. |
| `{variant.regularPrice}` | string | Raw regular variation price. |
| `{variant.available}` | boolean | Variation can be purchased and is in stock. |
| `{variant.stockStatus}` | string | Variation stock status. |
| `{variant.product.id}` | number | Variation identity ID. |
| `{variant.product.type}` | string | Variation product type. |
| `{variant.product.sku}` | string | Variation SKU from the nested identity object. |
| `{variant.product.name}` | string | Variation display name. |
| `{variant.price.*}` | object | Same price tree as product `omewoo.price`. |
| `{variant.media.image.*}` | object | Same image tree as product `omewoo.media.image`. |
| `{variant.purchase.*}` | object | Same purchase tree as product `omewoo.purchase`. |
| `{variant.attributes.attribute_pa_color}` | string | Selected value for a variation attribute key. Actual keys depend on the product. |
| `{variant.image.*}` | object | Legacy flat image alias retained for existing dynamic-data consumers. |

The variation `attributes` object is keyed by Store API variation attribute names. For taxonomy attributes this is typically `attribute_pa_{slug}`.

## Common Product Bindings

| Use case | Product loop | Single product |
| --- | --- | --- |
| Product ID | `{item.id}` or `{item.omewoo.productId}` | `{this.id}` or `{this.omewoo.productId}` |
| Product type | `{item.omewoo.product.type}` | `{this.omewoo.product.type}` |
| Product image URL | `{item.omewoo.media.image.url}` | `{this.omewoo.media.image.url}` |
| Product image alt | `{item.omewoo.media.image.alt}` | `{this.omewoo.media.image.alt}` |
| Product price | `{item.omewoo.price.text}` | `{this.omewoo.price.text}` |
| Variation attributes loop | `item.omewoo.attributes` | `this.omewoo.attributes` |

Use `item` inside loops and `this` on single product templates. If `this.omewoo.attributes` is empty in preview, confirm the preview product is a variable product.

## Related Cart Source Trees

These are not under `omewoo`, but they are the other Woo dynamic sources authors can target directly.

### `cartItems`

Loop target:

```etch
{#loop cartItems as item}
  ...
{/loop}
```

| Expression | Type | Meaning |
| --- | --- | --- |
| `{item.key}` | string | Woo cart item key. |
| `{item.productId}` | number | Product ID. |
| `{item.title}` | string | Composed title, including selected variation labels when present. |
| `{item.productTitle}` | string | Parent product title. |
| `{item.titleParts}` | array | Title parts used to compose `title`. |
| `{item.attributes}` | array | Selected cart item attribute rows. |
| `{item.quantity}` | number | Cart item quantity. |
| `{item.url}` | string | Product permalink. |
| `{item.priceRaw}` | string | Raw unit price. |
| `{item.priceText}` | string | Formatted unit price text. |
| `{item.subtotalRaw}` | string | Raw line subtotal. |
| `{item.subtotalText}` | string | Formatted line subtotal text. |
| `{item.media.image.*}` | object | Current item image payload. |
| `{item.image.*}` | object | Legacy flat image alias retained for existing dynamic-data consumers. |

Each `item.attributes` row has:

| Expression | Type | Meaning |
| --- | --- | --- |
| `{attribute.key}` | string | Attribute taxonomy key. |
| `{attribute.name}` | string | Human-readable attribute name. |
| `{attribute.taxonomy}` | string | Attribute taxonomy. |
| `{attribute.value}` | string | Human-readable selected attribute value. |

### `cartSummary`

| Expression | Type | Meaning |
| --- | --- | --- |
| `{cartSummary.item_count}` | number | Sum of cart quantities. |
| `{cartSummary.line_count}` | number | Number of cart lines. |
| `{cartSummary.state}` | string | `has-items` or `empty`. |

### `cartTotals`

| Expression | Type | Meaning |
| --- | --- | --- |
| `{cartTotals.total_price}` | string | Raw final total. |
| `{cartTotals.totalPriceText}` | string | Formatted final total. |
| `{cartTotals.total_items}` | string | Raw subtotal/items total. |
| `{cartTotals.totalItemsText}` | string | Formatted subtotal/items total. |
| `{cartTotals.total_discount}` | string | Raw discount total. |
| `{cartTotals.totalDiscountText}` | string | Formatted discount total. |
| `{cartTotals.total_shipping}` | string | Raw shipping total. |
| `{cartTotals.totalShippingText}` | string | Formatted shipping total. |
| `{cartTotals.total_tax}` | string | Raw tax total. |
| `{cartTotals.totalTaxText}` | string | Formatted tax total. |

### `cartCoupons`

| Expression | Type | Meaning |
| --- | --- | --- |
| `{coupon.code}` | string | Applied coupon code. |

## Related Selector Source Trees

### `shippingRates`

Loop target:

```etch
{#loop shippingRates as rate}
  ...
{/loop}
```

| Expression | Type | Meaning |
| --- | --- | --- |
| `{rate.key}` | string | Package-aware key in `{package_id}:{rate_id}` form. |
| `{rate.package_id}` | number | Shipping package index or package ID. |
| `{rate.rate_id}` | string | Raw Woo shipping rate ID. |
| `{rate.name}` | string | Shipping rate label. |
| `{rate.description}` | string | Shipping rate description. |
| `{rate.price}` | string | Raw shipping cost. |
| `{rate.priceText}` | string | Formatted shipping cost. |
| `{rate.selected}` | boolean | Whether Woo currently has the rate selected for the package. |

### `paymentMethods`

Loop target:

```etch
{#loop paymentMethods as method}
  ...
{/loop}
```

| Expression | Type | Meaning |
| --- | --- | --- |
| `{method.id}` | string | Payment gateway ID. |
| `{method.label}` | string | Payment gateway label. |
| `{method.description}` | string | Payment gateway description. |
| `{method.selected}` | boolean | Whether Woo currently has this gateway selected. |

Only enabled simple gateways are included. Gateways with custom embedded fields are skipped by this source.
