πŸ”Œ Embed widget (1 line)

The PrintWearAI widget integrates on any web page with a single line of code.

Basic snippet

<script src="https://printwearai.com/embed.js"
        data-key="YOUR_KEY"
        data-sku="JERSEY-001"></script>

Paste this snippet where you want the configurator to appear. The widget mounts an inline iframe into a container (#pwai-configurator by default, or the element you set with data-target). Copy the ready-made snippet from Tenant workspace β†’ Integration.

Available data-* attributes

AttributeTypeDefaultDescription
data-keystringβ€”Required. Your public embed key fk_… (Tenant workspace β†’ Integration).
data-productstringβ€”Product slug β†’ opens straight on that model. If absent, the configurator opens on the product picker (category tabs + product grid).
data-skustringβ€”External SKU. Resolved against the product's SKU / reference field via /api/resolve.
data-autodetectbooltrueAuto-detects the SKU from the page (Shopify, schema.org, meta). Set "false" on custom sites.
data-targetstring#pwai-configuratorCSS selector of the container that hosts the iframe.
data-heightnumber700Iframe height in px (auto-grows via resize messages).
data-localestringautoISO language: en, fr, es, de, it.
data-configstringβ€”Reopen a previously saved configuration by its id.
data-no-consentboolfalseSet "true" if your site already handles cookie consent.

SKU auto-detection

The widget automatically recognizes the product in 7 cases:

  1. Explicit data-sku
  2. Global variable window.PWAI_PRODUCT
  3. Meta tag <meta name="pwai:sku" content="...">
  4. Shopify Analytics (ShopifyAnalytics.meta.product)
  5. JSON-LD application/ld+json with @type: Product
  6. Single-product microformat (data-product-id)
  7. Open Graph product:retailer_item_id

Choose your own container

<div id="pwai-configurator"></div>
<script src="https://printwearai.com/embed.js"
        data-key="YOUR_KEY"
        data-sku="JERSEY-001"
        data-target="#pwai-configurator"></script>

The configurator always mounts as an inline iframe inside the target element. To open it as a modal or on click, mount it into a container you show/hide yourself (see the cart callback below and the custom site guide).

Open on the product picker

Omit data-product/data-sku (and set data-autodetect="false") to open the configurator on its choice screen: your brand header, category tabs (per sport) and a product grid. Great for a generic β€œDesign yours” button.

Cart add callback

On custom sites there is no automatic add-to-cart (that is built in for Shopify/WooCommerce/PrestaShop). Register your own handler with PwaiEmbed.onAddToCart():

PwaiEmbed.onAddToCart(function (m) {
  // m.config_id                β†’ saved configuration id (keep it: links to production)
  // m.product.name             β†’ product name
  // m.product.flare_id         β†’ internal PrintWearAI id
  // m.quantity                 β†’ quantity
  // m.sizes                    β†’ { "M": 3, "L": 2, ... } size breakdown
  // m.customization.thumbnail  β†’ preview image URL
  // m.customization.patron_svg β†’ production pattern SVG (raw)
  // m.customization.config     β†’ full raw design config
  // m.bat.zones                β†’ [{zone, color, pantone, gradient, pattern}] named zones
  // m.share_token / m.export_url / m.bat_url β†’ server-side design links
  //   (the design is auto-saved server-side, even for guests)
  // m.sku                      β†’ SKU if any
  console.log('Added to cart:', m);
  // β†’ push it into your own cart flow here
});

Design saved callback (no purchase)

Visitors can save a design without ordering (no account needed). Your page gets notified β€” perfect for lead capture and follow-up:

PwaiEmbed.onDesignSaved(function (m) {
  // m.config_id    β†’ saved design id (reopen later with data-config)
  // m.share_token  β†’ public token
  // m.export_url   β†’ server-side JSON export (config, preview, texts, colors)
  // m.bat_url      β†’ printable proof page (bon Γ  tirer)
  // m.thumbnail    β†’ preview image
  console.log('Design saved:', m);
});

Your backend also receives the design.saved webhook with the same links, plus guest_email when provided.

Security

The data-key key is public: it can appear in the HTML without risk. It gives no read/write access to your private data β€” only the right to launch a configurator linked to your tenant. For sensitive operations (order creation, reading stats), use the REST API with a secret key.