-
Notifications
You must be signed in to change notification settings - Fork 1
Synchronization
The plugin provides bidirectional data synchronization between WooCommerce and Mirakl. All syncs are cron-driven with configurable intervals and manual triggers from the admin.
Direction: Mirakl → WooCommerce
Orders placed on the marketplace are fetched via the Mirakl OR01/OR11 APIs and created as WooCommerce orders.
- New orders are created as
on-holdin WooCommerce - WooCommerce customer emails are suppressed for Mirakl-imported orders (the marketplace handles customer communication)
- Orders are tracked in the
mirakl_orderstable for status mapping - Shipping updates (carrier code, tracking number) can be sent back to Mirakl when the order status changes to
completed
| WooCommerce Status | Mirakl Action |
|---|---|
completed |
Triggers shipping notification to Mirakl |
cancelled |
Can trigger order refusal via admin action |
| Manual ship action | Update tracking info via OR24/OR25 |
Direction: WooCommerce → Mirakl
Product stock quantities are pushed to Mirakl via the ST01 API.
- Only products marked as active for Mirakl sync (meta:
_mirakl_active = 'yes') are included - Stock quantities are resolved using the OF21-backed offer SKU cache
- Aside-inventory reservation rules are applied via
effective_stock_quantity() - The sync runs per-store and processes all active products
The effective_stock_quantity() method applies:
- Subtract aside-inventory reservations
- Respect minimum stock thresholds
- Apply per-product adjustments from the
_mirakl_stock_adjustmentmeta
Direction: WooCommerce → Mirakl
Prices are pushed to Mirakl via the PRI01 Pricing Import API. This is a bulk import workflow:
-
Submit — WooCommerce prices are formatted into rows and submitted via
POST /api/pricing/imports -
Track — An import record is created in the
mirakl_pricing_importstable with statuspending -
Poll — The import status is polled periodically (
poll_pending_imports()); on completion, the record is updated with success/failure counts - Error Report — Failed rows include error details from the Mirakl error report
| Source | Trigger |
|---|---|
cron |
Automatic cron job |
manual |
Manual price sync from admin |
| Status | Description |
|---|---|
pending |
Submitted, awaiting processing |
running |
Being processed by Mirakl |
completed |
Successfully processed (may have errors) |
failed |
Import rejected |
cancelled |
Import cancelled |
Direction: Bidirectional
Products are exported via the OF24 API:
- Filters products with
_mirakl_active = 'yes' - Resolves WC SKU → Mirakl shop SKU via the offer SKU cache
- Includes: price, stock, images, categories, brand (
_mirakl_brand), and GTIN (_mirakl_gtin) - The
format_product_for_mirakl()method structures data for the API
Note: Product import from Mirakl is available but less commonly used. Configured via Sync Schedule.
Direction: WooCommerce → Mirakl
When a Mirakl order is shipped in WooCommerce (status changes to completed or manual ship action):
- Carrier code and tracking number are captured from the order meta (
_carrier_code,_tracking_number) - Data is sent to Mirakl via the OR24/OR25 API
- Update time is recorded in
mirakl_tracking_update_timesfor incremental sync
Registered on plugin activation:
| Interval | Schedule Name |
|---|---|
| 5 minutes | mirakl_5min |
| 10 minutes | mirakl_10min |
| 15 minutes | mirakl_15min |
| 30 minutes | mirakl_30min |
| 1 hour |
hourly (WordPress default) |
| Hook | Method | Controlled By |
|---|---|---|
mirakl_connector_orders_import_cron |
cron_orders_import() |
mirakl_orders_sync_enabled |
mirakl_connector_tracking_update_cron |
cron_tracking_update() |
Same as orders |
mirakl_connector_auto_stock_sync_cron |
cron_auto_stock_sync() |
mirakl_stock_sync_enabled |
mirakl_connector_prices_sync_cron |
cron_prices_sync() |
mirakl_price_sync_enabled |
mirakl_connector_products_sync_cron |
cron_products_sync() |
mirakl_products_sync_enabled |
To prevent concurrent runs, each store+type combination has a TTL-based lock (Mirakl_Sync_Lock). If a sync is still running when the next cron tick fires, the second run is skipped. The lock automatically expires after 360 seconds (configurable).
Every sync operation is recorded in the mirakl_sync_history table. View logs at Mirakl → Sync Logs. Entries are filterable by:
- Store name
- Sync type (
order,product,stock,price,offer,return) - Status (
success,failed,pending) - Date range
Each log entry stores the Mirakl ID, WooCommerce ID, and error message (if applicable).