Skip to main content
Scripts running on the product page — a design tool, an upload service, your own code — can talk to the configurator directly. Read what the customer has chosen, write into it, react to changes, and block add-to-cart until your own step is complete. Everything here is draft state. The price that gets charged is always recomputed and signed on our servers at add-to-cart, so this API is open by design: a script can only produce a correctly priced cart line, or a refusal.

Getting the element

Wait for ready (or check that po.state is not null) before reading — the option set may still be loading when your script runs.

Reading

Both state and schema hand back copies, so mutating what you read never affects the configurator. state.price carries total, quantity, unitPrice, the summary lines, and unavailable. While unavailable is true the job can’t be added to the cart, and unavailableReason says why: "combination" when the merchant has ruled the combination out, "formula" when a formula price rule has no price for this size or quantity.

Writing

Writes go through exactly the same validation and pricing path as a customer’s click. Unknown fields or invalid values are ignored with a console warning — never an exception, so a partner script cannot break the product page.

Quantities

A quantity is stored as the number it is priced at: snapped to the field’s step and kept within its minimum and maximum. Writing 333 to a field sold in steps of 25 stores 325, and state.selections and the next change event report 325, so read the value back rather than assuming the one you wrote. A quantity per option field (a size run) answers with a map of counts, keyed by the field’s option ids. Write the whole map; a 0 clears an option, and an unknown option id refuses the write:
po.field("quantity") returns the quantity field currently in play: the visible one when several take turns, and a quantity per option field when that is what the product uses.

Reacting to changes

Every event carries the source tag of the write that caused it and a changed list of what moved. Tag your writes and ignore your own echoes — that is all loop prevention takes. Writing a value that is already set emits nothing at all.

Gating add-to-cart

Named holds let several integrations gate independently without fighting each other. The button re-enables only when every hold is released.
While a hold is active the Add to cart button is disabled and your message shows beside it. Validation, by contrast, never disables the button — clicking an incomplete form scrolls to what is missing, which is how customers discover it.

Events

ready and change carry a plain object in event.detail. The older submit, invalid and unconfigured events pre-date this API and carry an array — read event.detail[0] for those.
The live demo exposes the element as window.po. Open your browser console there and try the calls above against a real configurator.