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.
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.
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.