Skip to content

Design the preorder widget with an AI agent

design_preorder: templates, preview, draft, apply and rollback for STOQ's storefront preorder widget, with server-side cleaning of agent HTML and CSS.

BetaAPI v2 is in public beta: endpoints, fields and behaviour can change before general availability. See the changelog

Last updated

design_preorder is an MCP store tool that lets an agent restyle the preorder widget STOQ’s app embed draws on the product page: button and badge colours, the disclaimer box (HTML), the ship-date and limited-quantity lines, the progress bar, the countdown, the payment options, and CSS for STOQ’s own elements. It writes only settings the widget already reads, plus one block of the shop’s custom CSS. It never writes theme code; for Liquid sections or headless code use design_theme.

It is enabled per shop (the design_preorder feature flag). The same actions are in the API v2 catalog under /preorders/design and /preorders/offers/:id/design.

action API v2 What it does
templates GET /preorders/design/templates The guide, the components (CSS classes and the fields that drive each one), the {{ placeholders }} the storefront fills, and starting templates: minimal_ship_date, brand_badge, deposit_explainer, countdown_launch, dark, rtl, limited_quantity.
preview POST /preorders/offers/:id/design/preview Checks and cleans a design, lists the changes against what is live, and returns preview_html. Writes nothing.
save_draft POST /preorders/offers/:id/design/drafts The same checks, saved as a draft; returns draft_id.
apply POST /preorders/offers/:id/design/drafts/:draft_id/apply Writes the draft, all or nothing. Live on the storefront after this.
rollback POST /preorders/offers/:id/design/rollback Restores exactly what the last apply replaced. Call it again to undo the one before. Pass design_id so a retry is safe: a design already rolled back is left alone (already_rolled_back: true), and one that is no longer the live design is refused with conflict. Refuses with conflict if those settings changed since apply, unless force: true.
history GET /preorders/offers/:id/design The applied design, the design CSS block and recent drafts.
{
"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; }"
}

Only the fields you send change. The sections are widget (button, disclaimer, badge), countdown, limits (display_style, limit_text, show_icons, progress_bar), shipping.timeline and payments.show_payment_widget, each checked by the same rules as its section PATCH. Dates, prices, limits and terms are not design fields: change them with their own actions. Send locale to write the texts in another language.

  • HTML fields (disclaimer_text, limit_text, shipping_text) keep formatting tags only: p br span strong b em i u s small sub sup mark abbr ul ol li div a bdi bdo time, with class dir lang title style (and href target rel on links). Links may go to the shop’s own pages, mailto: or tel:. Scripts, event handlers, javascript: and data: URLs, images, iframes, SVG, forms, comments and outside links are removed, and the response lists what was removed. Plain-text fields (button, badge, countdown and progress-bar texts) lose all markup. Limits: 2,000 characters for HTML, 200 for text.
  • CSS is refused, not rewritten. Each selector must end on a STOQ element (.restock-rocket-*, .preorder-*, .countdown-*, .stoq-*). Only plain rules, optionally inside one @media block, with colour, background, border, spacing, font, text and flex/grid layout properties. Nothing that could hide, move or cover the add-to-cart, Preorder or checkout button is allowed: no display: none, opacity, visibility, position, z-index, offsets, transform, filter, clip, mask, pointer-events, negative margins, overflow or max-height, and no font size under 10px. No url(), var(), @import, @font-face or @keyframes. Limits: 8,000 characters and 60 rules.

The design CSS sits in its own block of the shop’s custom CSS (/* stoq-design:preorder start */ … end), so the merchant’s own rules and back-in-stock styling are never touched, and it applies to every preorder offer in the shop. The storefront sets the widget’s colours inline from the settings, so use the colour settings where they exist and add !important to CSS that must win over them.

Was this page helpful?

Still stuck? Ask Quinn or chat with support