Drupal Commerce Guide d'installation
Ajoutez un assistant chat à votre Drupal Commerce boutique avec synchronisation automatique des produits.
Vous êtes dans le guide d'installation développeur. Vous cherchez un aperçu de ce que Emporiqa offre à votre Drupal Commerce boutique ? Voir la page d'intégration.
Démarrage rapide
Pour les propriétaires de boutique. Installez, configurez, synchronisez — avec des captures d'écran étape par étape.
DémarrerDocumentation développeur
Pour les développeurs. Architecture, commandes Drush, payload webhook et hooks alter.
LireDémarrage rapide
Installez le module, collez deux identifiants, lancez une synchronisation. Votre widget de chat est en direct sur votre boutique.
Ce qu'il vous faut
- Accès administrateur à votre site Drupal (10.3+ ou 11.x) avec Drupal Commerce installé
- Un compte Emporiqa — créer un compte gratuit si vous n'en avez pas encore
- Quelques minutes de travail pratique (la synchronisation s'exécute en arrière-plan)
First, install and enable the module. Pull it in with Composer from drupal.org, then enable it via Drush:
composer require drupal/emporiqa
drush en emporiqa
Or use Extend → Install new module in the admin UI. On install, the module auto-detects your product fields and creates the Emporiqa display mode.
Entrez vos identifiants
Allez à Configuration → Services web → Emporiqa (/admin/config/services/emporiqa). Collez votre ID de boutique et Secret de connexion — les deux proviennent de votre tableau de bord Emporiqa sous Paramètres de boutique → Intégration. Enregistrez le formulaire.
Configurez les paramètres de synchronisation
Toujours sur l'onglet Paramètres, développez la section Paramètres de synchronisation. Confirmez que Synchroniser les produits et Synchroniser les pages sont activés, choisissez quelles Langues activées inclure dans les payloads webhook, et restreignez éventuellement les Types de produits à synchroniser (laissez tout décochés pour synchroniser tous les types de produits).
Vérifiez le mappage des champs de produit
Développez la section Mappage des champs de produit. Le module détecte automatiquement vos champs de catégorie, marque, image, stock et variation lors de l'installation — confirmez que les bons champs ont été choisis. Si vous utilisez le module Commerce Stock, les niveaux de stock sont lus automatiquement. Enregistrez le formulaire après tout changement.
Activez le mode d'affichage Emporiqa
Les pages sont synchronisées à l'aide des modes d'affichage natifs de Drupal. Pour chaque type de contenu que vous voulez synchroniser en tant que page, allez à Structure → Types de contenu → [Votre type] → Gérer l'affichage, ouvrez l'onglet Emporiqa, et glissez les champs que vous voulez inclure (p. ex. Body) dans la zone active. Enregistrez. La sortie rendue de cet affichage devient le contenu de la page envoyé à Emporiqa.
Lancez la synchronisation initiale
Ouvrez l'onglet Synchronisation sur la page de paramètres (/admin/config/services/emporiqa/sync). Cliquez d'abord sur Tester la connexion, puis sur Synchroniser tout pour envoyer tous les produits et pages. Une barre de progression par lot affiche les éléments qui passent. Les catalogues plus importants prennent quelques minutes.
Vérifiez le widget de chat
Ouvrez votre vitrine. La bulle de chat apparaît dans le coin inférieur droit. Cliquez dessus, posez une question sur un produit et regardez le vendeur répondre à partir de votre catalogue.
C'est en direct
- Les nouveaux produits et pages se synchronisent automatiquement lorsque vous les enregistrez
- Les clients peuvent poser des questions sur les produits, les politiques et leurs commandes
- Ajouter au panier dans le chat ; les clients procèdent au paiement de votre boutique
Need to customize sync behavior, add tier prices, or integrate with a custom ERP?
See Developer DocsDeveloper Documentation
Architecture, configuration reference, Drush commands, webhook payload schema, and alter hooks.
Architecture
The module listens to entity CRUD hooks (hook_entity_insert, hook_entity_update, hook_entity_delete) for Commerce products, variations, and configured node types. Events are pushed onto a dedicated Drupal queue worker and delivered to Emporiqa asynchronously, so saving a product completes locally while the webhook delivery runs in the background.
All translations and channels for a single product or page consolidate into one webhook event. Variations cascade up: editing a variation triggers a parent product re-sync so search always sees the full catalog state. Conversion tracking is handled by an event subscriber on Commerce order state transitions (OrderCompleteSubscriber).
Webhook delivery retries up to 3 times on transient errors (HTTP 429, 502, 503, 504) and network failures, with linear backoff between attempts. The queue is processed by Drupal's cron — if the queue grows past 10,000 items, a warning is logged (typically meaning the webhook endpoint is unreachable or cron isn't running).
Requirements
| Drupal | 10.3+ or 11.x |
| Drupal Commerce | 2.40+ or 3.x (commerce_product required) |
| PHP | 8.1 or higher |
| Emporiqa account | Free Emporiqa account ($25 credit on signup) |
Configuration Reference
All settings live at Configuration → Web services → Emporiqa (/admin/config/services/emporiqa). The Sync tab lives at /admin/config/services/emporiqa/sync. The administer emporiqa permission is required.
Connection Settings
| Setting | Description |
|---|---|
| Store ID | Your unique store identifier from the Emporiqa dashboard. |
| Connection Secret | Shared secret used for HMAC-SHA256 signing of webhook and order tracking requests. |
| Webhook URL | Emporiqa webhook endpoint. Default works for most stores. |
Sync Settings
Most stores don't need to change these.
| Setting | Description |
|---|---|
| Sync Products | Enable/disable Commerce product synchronization. |
| Sync Pages | Enable/disable node synchronization as pages. |
| Languages | Which Drupal languages to sync. The module consolidates translations into one payload per entity. |
| Product Types | Which Commerce product types to sync. |
| Content Types | Which node content types to sync as pages (via the Emporiqa display mode). |
| Order Transitions | Commerce order transitions that trigger conversion tracking. Default: place. |
| Batch Size | Items per webhook request during full sync (1-100). |
Field Auto-detection
On install, the module auto-detects your product fields (category, brand, images, stock, attributes) from the Commerce product and variation entity schemas. The mappings are stored in config and can be adjusted on the settings form.
Page Sync via Display Modes
Pages are synced using Drupal's native display modes — no custom code needed. The module creates an Emporiqa display on install and enables it for common content types (page, article).
- Go to Structure → Content types → [Your type] → Manage display.
- Enable the Emporiqa tab.
- Drag the fields you want synced into that display.
The rendered output of the Emporiqa display becomes the page content sent to the webhook. Different content types can expose different fields, all configured through Drupal's admin — no module code touched. The same approach works for product descriptions when the Emporiqa display is enabled on a product type.
Always-on capabilities
- Cart operations — add, update, and remove items from inside the chat via
/emporiqa/api/cart/*. Checkout happens on your Commerce checkout page; the widget redirects when the customer is ready. - Conversion tracking — chat sessions linked to completed Commerce orders for revenue attribution.
- Multi-store mapping — each Commerce store can be assigned a channel via
hook_emporiqa_channels_alter.
Features
Real-time Webhooks
Products and pages sync via webhooks on create, update, and delete using Drupal entity hooks, delivered through a dedicated queue worker for reliability and retry.
Chat Widget
The widget is attached automatically via an asset library. Language and currency are detected from the Drupal request context.
Multilingual
Products and pages sync with translated names, descriptions, categories, and attributes from all configured Drupal languages, consolidated into one payload per entity.
Variation Sync
Full parent/child sync for Commerce variations. Variation changes trigger a parent product re-sync. Deleting a variation sends a delete event and re-syncs the parent.
Cart Operations
Customers can add, update, remove, and checkout from the chat. Routes: /emporiqa/api/cart/*, working directly with commerce_cart.
Field Auto-detection
On install, the module discovers your category, brand, image, stock, and attribute fields on product and variation entities. Zero-config for standard Commerce setups.
Admin Sync UI
Trigger a full sync from the Sync tab with Drupal's batch API. Test Connection sends a dry-run payload for validation without storing data.
Conversion Tracking
An event subscriber on Commerce order state transitions sends an order.completed event, linking chat sessions to revenue on your dashboard.
Webhook Payload
Each product or page is sent as a single webhook event containing all languages and channels. Translatable fields are nested by channel and language code.
Product Event
{
"type": "product.updated",
"data": {
"identification_number": "product-42",
"sku": "product-42",
"channels": [""],
"names": {"": {"en": "Hiking Boots", "de": "Wanderschuhe"}},
"descriptions": {"": {"en": "Waterproof leather boots...", "de": "Wasserdichte Lederstiefel..."}},
"links": {"": {"en": "https://store.com/hiking-boots", "de": "https://store.com/de/wanderschuhe"}},
"categories": {"": {"en": ["Footwear > Hiking"], "de": ["Schuhe > Wandern"]}},
"attributes": {"": {"en": {"Material": "Leather"}, "de": {"Material": "Leder"}}},
"brands": {"": "TrailPeak"},
"prices": {"": [{"currency": "EUR", "current_price": 129.99, "regular_price": 149.99}]},
"images": {"": ["https://store.com/files/boots-front.jpg"]},
"availability_statuses": {"": "available"},
"stock_quantities": {"": 42},
"is_parent": false,
"parent_sku": null,
"variation_attributes": {}
}
}
Page Event
{
"type": "page.created",
"data": {
"identification_number": "page-45",
"channels": [""],
"titles": {"": {"en": "Shipping Policy", "de": "Versandrichtlinien"}},
"contents": {"": {"en": "<p>Rendered Emporiqa display...</p>", "de": "<p>Gerenderte Emporiqa-Anzeige...</p>"}},
"links": {"": {"en": "https://store.com/shipping-policy", "de": "https://store.com/de/versandrichtlinien"}}
}
}
Field Structure
| Type | Pattern | Fields |
|---|---|---|
| Translatable | {channel: {lang: value}} |
names, descriptions, links, categories, attributes, variation_attributes, titles, contents |
| Shared | {channel: value} |
brands, prices, images, availability_statuses, stock_quantities |
| Flat | Direct value | identification_number, sku, channels, is_parent, parent_sku |
Customization Hooks
The module provides Drupal alter hooks you can implement in a custom module (mymodule.module) to control sync behavior, modify payloads, and extend order tracking and cart operations. Full documentation lives in emporiqa.api.php.
| Hook | Description |
|---|---|
hook_emporiqa_entity_sync_alter |
Set $sync = FALSE to skip a specific entity (product, variation, or page). |
hook_emporiqa_data_alter |
Modify the formatted payload before it is queued for delivery. |
hook_emporiqa_channels_alter |
Assign products to sales channels (e.g. b2b, retail, amazon). |
hook_emporiqa_price_entry_alter |
Modify an individual price entry (tax-inclusive/exclusive, extras). |
hook_emporiqa_tier_prices_alter |
Provide tier pricing (volume discounts) from custom fields or external pricing engines. |
hook_emporiqa_checkout_route_alter |
Override the route used for the chat cart's checkout URL. |
hook_emporiqa_cart_alter |
Cancel or modify cart operations (add, remove, update, clear, checkout). |
hook_emporiqa_order_tracking_alter |
Provide order tracking data from a custom ERP or order system. |
Example: skip draft pages
/**
* Implements hook_emporiqa_entity_sync_alter().
*/
function mymodule_emporiqa_entity_sync_alter(
bool &$sync,
\Drupal\Core\Entity\EntityInterface $entity,
string $entity_type,
string $operation,
): void {
if (
$entity_type === 'page'
&& $entity instanceof \Drupal\node\NodeInterface
&& str_contains($entity->getTitle(), '[DRAFT]')
) {
$sync = FALSE;
}
}
Example: add tax-inclusive prices
/**
* Implements hook_emporiqa_price_entry_alter().
*/
function mymodule_emporiqa_price_entry_alter(
array &$entry,
array $context,
): void {
$entry['price_incl_tax'] = round($entry['current_price'] * 1.20, 2);
$entry['price_excl_tax'] = $entry['current_price'];
}
Example: provide tier prices
/**
* Implements hook_emporiqa_tier_prices_alter().
*/
function mymodule_emporiqa_tier_prices_alter(
array &$tier_prices,
array $context,
): void {
$variation = $context['variation'];
if ($variation->hasField('field_tier_prices')) {
foreach ($variation->get('field_tier_prices') as $item) {
$tier_prices[] = [
'min_quantity' => (int) $item->min_qty,
'price' => (float) $item->price,
'currency' => $context['currency'],
];
}
}
}
Example: cancel a cart operation
/**
* Implements hook_emporiqa_cart_alter().
*/
function mymodule_emporiqa_cart_alter(array &$context): void {
if ($context['operation'] === 'add') {
$total_qty = 0;
foreach ($context['items'] as $item) {
$total_qty += $item['quantity'] ?? 1;
}
if ($total_qty > 10) {
$context['cancel'] = TRUE;
$context['cancel_message'] = 'Maximum 10 items per operation.';
}
}
}
Clear the cache with drush cr after adding a new hook implementation so Drupal picks it up.
Drush Commands
The module provides Drush commands for deployment pipelines, cron jobs, and debugging.
# Full sync (products + pages)
drush emporiqa:sync-all # alias: em:sa
# Sync products only
drush emporiqa:sync-products # alias: em:sp
# Sync pages only
drush emporiqa:sync-pages # alias: em:spg
# Test the webhook connection (dry run with a real product)
drush emporiqa:test-connection # alias: em:tc
# Adjust batch size for large catalogs
drush emporiqa:sync-products --batch-size=25
Configure Drush URI for correct payload URLs
Drush runs on the command line and doesn't know your site's public URL. For correct product and page URLs in webhook payloads, create drush/drush.yml in your Drupal root:
options:
uri: 'https://your-store-domain.com'
Order Tracking
Emporiqa can look up order status on behalf of customers during chat conversations. The module registers a signed endpoint that Emporiqa calls when a customer asks about their order.
Flow
- Customer asks "Where is my order #12345?" in the chat.
- Emporiqa sends an HMAC-SHA256 signed POST to your Drupal site.
- The module looks up the Commerce order, verifies the customer's email, and returns the status.
- The salesperson presents the order information to the customer.
Endpoint
POST /emporiqa/api/order/tracking
The endpoint is rate-limited to 50 requests per hour per IP using Drupal's Flood API.
Default behavior
If Commerce Order is installed, the module looks up orders by order number and returns status, items, and totals. No code needed. Email verification is always required — the customer must provide the email on the order before any data is returned.
Setup
The endpoint is always active once the module is installed. To enable order lookup from chat, set the Order Tracking API URL in your Emporiqa dashboard (Store Settings → Integration) to:
https://your-store.com/emporiqa/api/order/tracking
Custom order systems
For non-Commerce order systems, implement hook_emporiqa_order_tracking_alter() in a custom module:
/**
* Implements hook_emporiqa_order_tracking_alter().
*/
function mymodule_emporiqa_order_tracking_alter(
?array &$response,
string $order_identifier,
array $body,
): void {
$order = my_erp_get_order($order_identifier);
if ($order) {
$response = [
'order_id' => $order->id,
'status' => $order->status,
'placed_at' => $order->created_at,
'items' => $order->items,
];
}
}
Requests are authenticated using the same HMAC-SHA256 connection secret. Requests older than 5 minutes are rejected. See the Webhook Setup Guide for the full request/response schema.
Order tracking is optional. Without the dashboard URL configured, order questions route to the Customer Support agent instead.
Troubleshooting
Products not appearing in chat
- Run
drush emporiqa:sync-productsto force a full sync. - Verify products are published and have at least one variation with a price.
- Confirm your Store ID and Connection Secret match the dashboard.
- Check the watchdog log:
drush ws --filter=emporiqa.
Chat widget not showing
- Clear Drupal's cache:
drush cr. - Confirm the module is enabled and Store ID is configured.
- Check the browser console for JavaScript errors.
- Disable aggressive page caching on the page while testing.
Webhook errors or sync stuck
- Confirm your server can make outbound HTTPS requests.
- Run
drush emporiqa:test-connectionto validate the connection with a dry-run payload. - Check the queue depth:
drush queue:list. Process stuck items withdrush queue:run emporiqa_webhook. - Check the watchdog log:
drush ws --filter=emporiqa.
Variations not syncing
- Verify variations have prices and the parent product is published.
- Save the parent product to trigger a re-sync.
- Run a full product sync:
drush emporiqa:sync-products.
Related Articles
Chat for Drupal Commerce
Webhook architecture, queue workers, variations, and customization with alter hooks.
Multilingual Chat Support
Cross-language search, 65+ languages, how translations sync.
5 Questions Before You Pay
Evaluation checklist: data sync, handoff, pricing, languages, attribution.
Conversion Tracking
Prove chat ROI: session to cart to purchase attribution.