Design a custom preorder widget with Claude
Worked recipe: have an AI agent restyle the preorder button, badge, disclaimer, ship-date line and countdown with design_preorder: templates, preview, save a draft, apply, and roll back. Every call, a real design with CSS, and how to check it on the storefront.
Last updated
For: merchants and agencies who want the preorder widget on the product page to match the brand, and who work through an AI agent (Claude or another MCP client) instead of the theme editor.
Goal: the preorder button, badge, disclaimer box, ship-date line and countdown restyled to a design you approved, live on the storefront, with one call that puts it back.
This recipe is for STOQ’s own widget, drawn by the STOQ app embed. For code in your own theme section or a headless storefront, use the theme-code path instead: Preorder badge, button and notify-me on a headless storefront reads STOQ’s data and builds a widget in your code (the design_theme tool writes the starter). The two don’t overlap: design_preorder never writes theme code, and design_theme never changes how STOQ’s widget looks.
Before you start
Section titled “Before you start”- Credentials: an MCP client signed in to the store with OAuth (see MCP), or the store’s API key.
- Plan: none beyond what the offer needs. Writing the design is one write per apply.
- An offer: a preorder offer that exists. Get its id in step 1.
- Theme: STOQ’s app embed must be on, or nothing draws the widget.
- The merchant: when the merchant clearly asked for the change and
previewis clean (noremoved, nowarnings, consistent withoffer_facts),save_draftandapplyright away and confirm what is live. Show the preview and ask for a yes first when the request is open-ended or unclear, orpreviewremoved, refused or warned about part of it.applychanges the live storefront.
1. Pick the offer
Section titled “1. Pick the offer”{ "tool": "execute_read", "arguments": { "method": "GET", "path": "/preorders/offers", "params": { "per_page": 25 } } }Keep the id of the offer you are restyling. A design applies to the offer’s widget; the design CSS applies to every preorder offer in the store.
2. Read the templates and the components
Section titled “2. Read the templates and the components”{ "tool": "design_preorder", "arguments": { "action": "templates" } }The answer has the guide, the components (each STOQ element’s CSS class and the settings that drive it), the {{ placeholders }} the storefront fills in, and starting templates: minimal_ship_date, brand_badge, deposit_explainer, countdown_launch, dark, rtl and limited_quantity. Start from the closest template, or pass template_id to read one.
3. Preview a design
Section titled “3. Preview a design”{ "tool": "design_preorder", "arguments": { "action": "preview", "offer_id": "<offer_id>", "design": { "widget": { "button": { "custom_colors_enabled": true, "background_color": "#1a73e8", "text_color": "#ffffff" }, "badge": { "show_badge": true, "badge_text": "Preorder", "background_color": "#1a73e8" }, "disclaimer": { "show_disclaimer": true, "disclaimer_text": "<strong>Reserve yours with a deposit.</strong><br>Pay the rest when it ships." } }, "shipping": { "timeline": { "show_shipping_text": true, "shipping_text": "Ships {{ date }}" } }, "css": ".restock-rocket-preorder-badge { border-radius: 999px !important; }" } }}A preview writes nothing. It returns the cleaned design, what was removed, warnings, changes against what is live, the offer_facts the texts are filled from, and preview_html to show the merchant. A design the checks refuse comes back as an error whose keys are design.<path>; read the path, fix that field and preview again.
The colours and texts above are examples: send only the fields the merchant asked for, and write texts that are true for this offer (read its ship date and payment option first; offer_facts in the answer shows what the texts are filled from). Only the fields you send change. The sections are widget (button, disclaimer, badge), countdown, limits, shipping.timeline and payments.show_payment_widget, plus css. Dates, prices, limits and terms are not design fields; change them with their own actions (see Change the deposit or ship date across an offer).
What gets cleaned or refused:
- HTML in the text fields keeps formatting tags and links to the store’s own pages only. Scripts, event handlers, images, iframes and outside links are removed, and
removedlists them. - CSS is refused, not rewritten. Each selector must end on a STOQ element (
.restock-rocket-*,.preorder-*,.countdown-*,.stoq-*), and nothing may hide, move or cover the add-to-cart or Preorder button (nodisplay: none,opacity,position,z-index,transform,url()orvar()). The Preorder button can only be recoloured, with at least 3:1 contrast. - The design CSS lives in its own marked block of the store’s custom CSS, so the merchant’s own rules are never touched.
4. Save it as a draft
Section titled “4. Save it as a draft”{ "tool": "design_preorder", "arguments": { "action": "save_draft", "offer_id": "<offer_id>", "template_id": "brand_badge", "design": { "widget": { "badge": { "show_badge": true, "badge_text": "Preorder", "background_color": "#1a73e8" } } } } }Send the design you previewed (shortened here). Same checks as the preview. The answer has a draft_id. Drafts change nothing on the storefront.
5. Apply it
Section titled “5. Apply it”When the merchant has asked for the change and preview is clean (or after showing the preview and getting their yes when the request was unclear or preview had removals/warnings):
{ "tool": "design_preorder", "arguments": { "action": "apply", "offer_id": "<offer_id>", "draft_id": "<draft_id>" } }The draft is written all or nothing. The answer has applied (the offer’s design as saved) and changes_written.
6. Roll back if it is wrong
Section titled “6. Roll back if it is wrong”{ "tool": "design_preorder", "arguments": { "action": "rollback", "offer_id": "<offer_id>" } }This restores exactly what the last apply replaced (restored, now_current), and calling it again undoes the one before. If those settings changed since the apply, it refuses with conflict and lists what changed; send force: true only if the merchant agrees to overwrite those changes. { "action": "history", "offer_id": "<offer_id>" } shows the applied design, the design CSS block and recent drafts.
If it fails
Section titled “If it fails”| Code | What happened | What to do |
|---|---|---|
auth_, auth_ |
No credential, or not a current one | Reconnect the MCP client or send the store’s API key |
not_ |
The offer or draft id is wrong or from another store | Read the offers again (step 1) and use that id |
invalid_ |
A design field is not allowed, or CSS was refused | Read the design. in the error, fix that field and preview again |
conflict |
A rollback found settings changed since the apply | Read history, ask the merchant, then force: true only with their yes |
If the tool is missing from the tool list, it may not be turned on yet (ask STOQ support), or reconnect the MCP client: the list is read when the client connects. There is no error code for that.
Check it worked
Section titled “Check it worked”- Read the applied design back:
{ "tool": "design_preorder", "arguments": { "action": "history", "offer_id": "<offer_id>" } }.currentis the design you applied, andcss_blockholds your CSS. - Open a variant on the offer on the live store, in a private window so no cached copy shows. The button and badge have your colours, the disclaimer reads your text, and the line under the button shows the ship date. STOQ publishes the change in the background, so allow a minute.
- Check the Preorder button still adds to the cart and the cart shows the preorder item.
- To undo it, run step 6 and reload; the widget goes back to what it was.
Thanks for letting us know.
Still stuck? Ask Quinn or chat with support