Skip to main content

Cart State and Notices

This family renders global cart feedback: item count and cart notices. Both can be used outside a cart page.

Components

Component keyRole
OmeWooCartCountDisplays the current cart item quantity and state.
OmeWooCartNoticesRenders Store API and Woo cart notices as safe text.

CartCount

CartCount subscribes to WooCartStore and displays cartSummary.item_count. It sets:

StateMeaning
emptyCart has no lines.
has-itemsCart has one or more lines.

It is useful in product archive headers, single product templates, mini-cart indicators, and cart pages.

CartNotices

CartNotices is a runtime notice region. It renders notices from cart actions:

SourceTypical action
add-to-cartProduct add failed.
quantityQuantity update failed.
removeRemove item failed.
couponApply or remove coupon failed.
shippingShipping rate selection failed.
stock or variationWoo Store API product constraints.

Messages are normalized and rendered as text, so Woo error content is not injected as HTML.

Props

ComponentPropMeaning
Cart noticespreview.show_in_builderShows a sample notice in Etch builder preview.
Cart noticespreview.notice_typePreview notice type: error, success, info, or warning.
Cart noticesaccessibility.aria_labelAccessible label for the notice region.
Cart noticesaccessibility.live_regionLive region politeness, defaulting to polite.

CartCount is mostly display and styling; its runtime content comes from the cart store.

Scenario Coverage

ScenarioCovered behavior
cart_count_add_to_cartCount changes from 0 to 1 after add.
out_of_stock_cart_noticeOut-of-stock add renders cart notice as text with error type and code.
lifecycle_add_to_cartNative add-to-cart validation can block mutation and render a Woo notice.
cart_couponsInvalid coupon renders cart notice without encoded text leaking into display.