๐Ÿ›’ PrestaShop integration

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.

How it works

  1. embed.js injects the 3D configurator as an iframe on your product pages.
  2. When the customer clicks add-to-cart inside the configurator, the widget emits an add_to_cart event to your page.
  3. The built-in PwaiEmbed.handlers.prestashop() handler posts the item to the PrestaShop cart via the AJAX cart controller (controller=cart).

Step 1 โ€” Install the snippet in your theme

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>
The embedded widget requires a Pro plan or higher. On Free/Essentiel plans the widget shows an upgrade notice and your customers use your hosted configurator page instead.

Step 2 โ€” Map your products (no automatic import)

Unlike Shopify and WooCommerce, there is no automatic product import for PrestaShop โ€” a sync brings back 0 products. Map products manually instead:

  1. Tenant workspace โ†’ Products โ†’ edit your 3D product โ†’ External catalog link.
  2. Set SKU / reference to the PrestaShop product reference (must be identical on both sides โ€” this is what data-sku / /api/resolve matches).
  3. Set External product id to the PrestaShop id_product โ€” this is what the cart handler posts as id_product.

Automatic add-to-cart

PwaiEmbed.handlers.prestashop(options) registers a handler that, for each add_to_cart event:

  1. Reads m.product.external_product_id. If it is missing it logs a warning and does nothing โ€” the product must be mapped.
  2. Reads the CSRF token from input[name=static_token] on your page (rendered by standard PrestaShop themes) and appends it as token if present.
  3. Sends POST /index.php (with cookies) with these form fields:
FieldContent
controllercart
add1
actionupdate
ajaxtrue
id_productThe mapped PrestaShop product id
qtym.quantity
customization[flare_config_id]Saved configuration id โ€” the link to production on the PrintWearAI side
tokenValue of input[name=static_token], if found on the page
  1. Redirects to /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 โ€ฆ
});

FAQ & common pitfalls

See also: Embed widget ยท Webhooks ยท Custom site (API)