Skip to main content

Data Context and Dynamic Sources

Woo docs use the same data names that the code uses. This page explains where those names come from and when to use them.

Product Context

ProductDynamicData::extend_post_data() adds an omewoo object to Etch post dynamic data when the current post is a Woo product.

ExpressionUse
{item.omewoo.*}Product archive or product loop card.
{this.omewoo.*}Single product template.
{item.id} or {this.id}Product ID for AddToCartForm.product.product_id.
{item.omewoo.product.type} or {this.omewoo.product.type}Product type for AddToCartForm.product.product_type.
{item.omewoo.attributes} or {this.omewoo.attributes}Variation attribute loop for AttributeSelector.

Product dynamic data includes product identity, price text, media, purchase availability, variation payloads, variation attributes, and option availability. See Woo Dynamic Data Tree for the full field-by-field reference for this.omewoo, item.omewoo, cart sources, and selector sources.

Cart Dynamic Sources

CartItemsDynamicSource registers four source keys when the block tree contains cart-aware components or expressions:

SourceShape
cartItemsCart item rows with key, productId, title fields, attributes, quantity, URL, price text, subtotal text, and image data.
cartSummaryitem_count, line_count, and state where state is has-items or empty.
cartTotalsTotal fields for subtotal/items, discount, shipping, tax, and final price.
cartCouponsApplied coupon rows with code.

The source registration is lazy. A page that does not render cart components does not register cart sources for that request.

Cart Item Hydration

CartItems renders one authored row template. Server render and runtime both hydrate the row's atoms:

Atom markerData field
data-ome-woo-cart-item-field="image"Product image URL, srcset, and alt text with authored fallback.
data-ome-woo-cart-item-field="title"Product title or composed variant title.
data-ome-woo-cart-item-field="priceText"Unit price text.
data-ome-woo-cart-item-field="subtotalText"Line subtotal text.
data-ome-woo-cart-item-quantityQuantity input value and cart item key.
data-ome-woo-cart-item-removeRemove button cart item key.
data-ome-woo-cart-attribute-listSelected variation attributes cloned from the attribute template.

This is why cart item atoms are meaningful only inside a cart item row or an order summary row.

Selector Sources

WooSelectorDynamicSource registers selector rows while blocks render:

SourceUsed by
shippingRatesShippingMethodSelector rows.
paymentMethodsPaymentMethodSelector rows and runtime config.

Shipping rates use package-aware values. The row value is {package_id}:{rate_id}, while the hidden input keeps the raw Woo rate ID and package-specific input name. This lets Woo distinguish rates across packages.

Payment methods only include enabled simple gateways. Gateways with custom fields are skipped by get_simple_payment_methods(), because this selector renders simple radio/select choices rather than gateway-specific embedded forms.

Checkout Field Schema

CheckoutFieldSchema::build() reads Woo countries, checkout fields, locale overrides, states, and store defaults. The runtime uses that schema to:

  • Render country options.
  • Switch state between select, text, and hidden modes.
  • Apply Woo labels, required flags, hidden flags, field types, autocomplete, and priorities.
  • Validate rendered fields before Store API submit.

Address forms still expose copy props, but use_woo_defaults: true keeps Woo's field copy as the default source.

Dynamic Data Examples

Product archive:

{#loop products as item}
<OmeWooAddToCartForm product='{{"product_id":"{item.id}","product_type":"{item.omewoo.product.type}"}}'>
{#slot default}
<OmeWooAddToCartButton behavior='{{"mode":"counter","trigger":"form_submit"}}' />
{/slot}
</OmeWooAddToCartForm>
{/loop}

Single product:

{#loop this.omewoo.attributes as attribute}
<OmeWooAttributeSelector target='{{"attribute":{attribute}}}' />
{/loop}