How to integrate the PrintWearAI configurator on a PrestaShop 1.7+ store: theme snippet, automatic add-to-cart via the cart controller, and product mapping.
embed.js injects the 3D configurator as an iframe on your product pages.add_to_cart event to your page.PwaiEmbed.handlers.prestashop() handler posts the item to the PrestaShop cart via the AJAX cart controller (controller=cart).Add the snippet to your product template (child theme templates/catalog/product.tpl, or a "custom HTML" module). Passing the product reference via data-sku is the most reliable way to tell the widget which product the page shows:
<div id="pwai-configurator" data-sku="{$product.reference}"></div>
<script src="https://printwearai.com/embed.js"
data-key="fk_YOUR_KEY"
defer></script>
<script>
document.addEventListener('DOMContentLoaded', function () {
PwaiEmbed.handlers.prestashop(); // automatic PrestaShop cart
});
</script>
data-key is your public embed key (fk_โฆ), found in your workspace โ Integration. It is required โ the widget only reads data-key.window.PWAI_PRODUCT, a <meta name="pwai:sku"> tag, data-sku / data-product-id on the container, or JSON-LD Product markup if your theme outputs it. The data-sku attribute above covers all standard themes.data-height (default 700), data-locale (fr/en/es/de/it), data-product (force a catalog slug), data-autodetect="false", data-no-consent="true".Unlike Shopify and WooCommerce, there is no automatic product import for PrestaShop โ a sync brings back 0 products. Map products manually instead:
data-sku / /api/resolve matches).id_product โ this is what the cart handler posts as id_product.PwaiEmbed.handlers.prestashop(options) registers a handler that, for each add_to_cart event:
m.product.external_product_id. If it is missing it logs a warning and does nothing โ the product must be mapped.input[name=static_token] on your page (rendered by standard PrestaShop themes) and appends it as token if present.POST /index.php (with cookies) with these form fields:| Field | Content |
|---|---|
controller | cart |
add | 1 |
action | update |
ajax | true |
id_product | The mapped PrestaShop product id |
qty | m.quantity |
customization[flare_config_id] | Saved configuration id โ the link to production on the PrintWearAI side |
token | Value of input[name=static_token], if found on the page |
/panier (disable with { redirect: false } โ see pitfalls below if your cart lives at another URL).Prefer full control (e.g. product combinations, custom cart URL, storing the thumbnail)? Register your own callback instead of the built-in handler:
PwaiEmbed.onAddToCart(function (m) {
// m.config_id, m.quantity, m.sizes,
// m.product.external_product_id, m.customization.thumbnail โฆ
});
data-key missing โ you wrote data-embed-key; the widget only reads data-key./panier but my cart is at another URL โ the built-in redirect targets /panier. Call PwaiEmbed.handlers.prestashop({ redirect: false }) and redirect yourself, or use PwaiEmbed.onAddToCart(fn).external_product_id. Set the PrestaShop id_product in Products โ External catalog link.input[name=static_token] on the page. Make sure your theme renders it (standard themes do), or add the item yourself via PwaiEmbed.onAddToCart(fn).customization[flare_config_id] is not stored on the order โ PrestaShop only persists customization fields declared on the product. Add a text customization field to the product (or a small module) if you need the config id on the order line; the id is always available in your PrintWearAI workspace โ Orders regardless.external_product_id. Map the product.PwaiEmbed.handlers.prestashop() (or PwaiEmbed.onAddToCart(fn)).id_product only, without id_product_attribute. For combination-level control, use PwaiEmbed.onAddToCart(fn).See also: Embed widget ยท Webhooks ยท Custom site (API)