Skip to content

Developer notes

Overview · Installation · Configuration · Usage · FAQ

Table Content
?:kv_emc_queue Jobs: ref (unique), kind (profile, subscribe, unsubscribe, event, products, store), name, email, order_id, payload (JSON), status (pending, sending, sent, skipped, failed), attempts, next_at, error
?:kv_emc_consents Consent log (append only): email, user_id, consent Y/N, source, text, ip, created_at
?:kv_emc_remote (1.1) Mailchimp / Omnisend objects already sent: provider, account (Mailchimp store id / Omnisend key hash), kind (store, customer, product, order, cart), local id, state (pending, created), md5 of the last payload

place_order (checkout opt-in), change_order_status_post (order events), update_profile (profile and registration opt-in), newsletters_update_subscriptions_post (Newsletters bridge), post_add_to_cart (1.1: cart of a signed-in customer), update_product_post (1.1: product catalog). Controllers: checkout.pre, profiles.post, products.post, newsletters.pre (storefront) and kv_email_connect (dashboard, consent log, cron; storefront: catalog feed and the signed cart restore link kv_email_connect.restore).

  • Every change becomes a job; nothing is sent during checkout. Jobs go out right after the page (optional), by cron or with Send now. Retry delays: 5 min, 30 min, 2 h, 6 h, 24 h, then failed (HTTP 0, 408, 429, 5xx are temporary).
  • A job is claimed with UPDATE ... WHERE status = 'pending' before it is sent, so cron and page runs never send it twice.
  • HTTP 401 pauses the whole queue (nothing is lost, the job stays waiting) until “Test connection” passes or the key changes.
  • Mailchimp allows 10 simultaneous connections per user; the add-on sends one request at a time. Omnisend allows 400 requests per minute per brand; the client keeps at least 160 ms between requests.
  • Mailchimp and Omnisend order jobs read the order when the job is sent: a retried older job never sends an older status.

Authentication: HTTP Basic with any user name and the API key as password (Authentication). Host: the key’s data-center suffix (...-us21 -> https://us21.api.mailchimp.com/3.0, the “server prefix” of the official SDKs, Client libraries); a key without suffix uses https://api.mailchimp.com/3.0 (API structure).

Purpose Endpoint Fields sent Source
Test GET /ping, GET /?fields=account_name - Ping, API root
Audiences GET /lists?count=1000&offset=&fields=lists.id,lists.name,total_items - Get lists info
Store GET /ecommerce/stores/{id}, POST /ecommerce/stores, PATCH /ecommerce/stores/{id} id, list_id, name, platform, domain, currency_code, primary_locale, email_address, money_format, timezone, phone; is_syncing during the history import Add store, Get store, Update store
Customer PUT /ecommerce/stores/{id}/customers/{customer_id} id (kv + md5 of the email, 34 characters; limit 50), email_address, opt_in_status, first_name, last_name, company, address (address1, address2, city, province, province_code, postal_code, country, country_code) Add or update customer
Product PUT /ecommerce/stores/{id}/products/{product_id} id, title, url, description, image_url, vendor, type (first category), published_at_foreign, one variant (id and title of the product, url, price, sku, image_url, inventory_quantity) Add or update product
Order POST /ecommerce/stores/{id}/orders, GET/PATCH .../orders/{order_id} id, customer {id}, currency_code, order_total, discount_total, tax_total, shipping_total, processed_at_foreign, updated_at_foreign, financial_status, fulfillment_status (shipped), cancelled_at_foreign, order_url, promos (code, amount_discounted, type fixed), billing_address, shipping_address (name, company, phone, address fields), lines (id, product_id, product_variant_id, quantity, price, discount) Add order, Get order, Update order
Cart POST /ecommerce/stores/{id}/carts, GET/PATCH/DELETE .../carts/{cart_id} id, customer {id}, currency_code, order_total, tax_total, checkout_url, lines (id, product_id, product_variant_id, quantity, price) Add cart, Update cart, Delete cart
Consent PUT /lists/{list_id}/members/{md5(lowercase email)} email_address, status_if_new subscribed, status subscribed (not for imports), ip_signup, timestamp_signup, merge_fields FNAME / LNAME Add or update list member
Withdrawal PATCH /lists/{list_id}/members/{hash} status unsubscribed (404 = nothing to do) Update list member

Mapping rules, all from E-commerce concepts:

  • opt_in_status is true only when the customer’s latest consent-log decision is “subscribed”. Mailchimp adds other customers as transactional members and never lowers an existing member’s status through this field.
  • financial_status: paid (status with the core “payment received” flag), pending, refunded (your refunded statuses), cancelled (your cancelled statuses, Failed, Declined). fulfillment_status: shipped for your fulfilled statuses. These values trigger Mailchimp order notifications if you enable them in Mailchimp.
  • Products are sent before the cart or order lines that reference them (“Products come first”). A product that is no longer active is created once from the line data.
  • Product recommendations need inventory_quantity > 0: products without stock tracking, or sold on backorder with 0 stock, are sent with 1.
  • After an order is sent, the customer’s cart is deleted, so no abandoned cart email follows the purchase.
  • campaign_id / outreach are not sent: Mailchimp now sets them itself (Release note 2024-12-06).
  • Idempotency: an order is stored as “pending” before the POST. When the answer is lost or the POST is refused, the order is looked up with GET and updated with PATCH instead of created again. Unchanged objects (same md5) are not sent again.

Headers: Authorization: Omnisend-API-Key <key>, Omnisend-Version: 2026-03-15, base https://api.omnisend.com/api (Authentication, Migrate from v5). Errors use RFC 9457 problem details (Responses); 429 on more than 400 requests per minute (Rate limit).

Purpose Endpoint Fields sent Source
Test GET /brands/current - (name / website shown) Get brand
Contact POST /contacts (creates or updates by email) identifiers [{type email, id, channels.email {status, statusChangedAt = time of the decision in the consent log (1.1.1)}, consent {createdAt, source, ip}, sendWelcomeMessage}], firstName, lastName (50), countryCode, city, address, postalCode, state (only short subdivision codes), customProperties cscart_* Create or update contact, Contacts > Custom properties, How to sync contacts
Events POST /events eventName, eventID (UUID), eventTime, eventVersion, origin api, contact {email, firstName, lastName}, properties Send customer event, Events overview
Products PUT /products/{productID}; on 404 POST /products; on 409 PUT again id, title, url, currency, status (inStock / outOfStock), description, defaultImageUrl, vendor, tags (category names), createdAt, updatedAt, variants [{id, title, url, price, sku, status, defaultImageUrl, strikeThroughPrice}] Replace product, Create product
Store event Omnisend event (version) Properties Source
Order placed placed order (v2), eventTime = order date orderID, orderNumber, createdAt, currency, totalPrice, subTotalPrice, subTotalTaxIncluded, totalTax, shippingPrice, totalDiscount, paymentStatus, fulfillmentStatus, paymentMethod, shippingMethod, orderStatusURL, note, discounts [{code, amount, type fixed_amount}], billingAddress / shippingAddress (firstName, lastName, company, address1, address2, city, state, stateCode, zip, country, phone), lineItems [{productID, productVariantID, productTitle, productQuantity, productPrice, productSKU, productDiscount, productURL, productImageURL, productCategories [{id, title}], productVendor}] placed order, How to sync historic orders
Payment received paid for order (v2) as placed order paid for order
Fulfilled statuses order fulfilled (v2) as placed order order fulfilled
Cancelled statuses order canceled (v2) as placed order order canceled
Refunded statuses order refunded (v2) + totalRefundedAmount, totalRefundedTaxAmount, refundedLineItems (whole order) order refunded
Checkout with a known email started checkout (“”) cartID, currency, value, lineItems, abandonedCheckoutURL started checkout
Add to cart (signed in) added product to cart (“”) + addedItem added product to cart, How to enable cart abandonment

paymentStatus: paid -> paid, pending -> awaitingPayment, refunded -> refunded, cancelled -> voided. fulfillmentStatus: fulfilled or unfulfilled.

Not sent: viewed product (the docs list only the JavaScript API for it), ordered product (the lines are in placed order), contact tags (since 2026-03-15 they replace all tags of the contact), the JavaScript snippet (no script on your storefront).

Idempotency: Omnisend deduplicates by eventID + eventTime only for historical events, not for real-time events (Events overview > Event deduplication). The add-on queues each event once per order and name, claims it before sending, and sends a deterministic eventID (UUID, version 5 layout) with the original order time for imports.

  • Only customers whose latest consent-log decision is “subscribed” become subscribers (Mailchimp subscribed, Omnisend email channel subscribed with the consent record). Others: Mailchimp transactional, Omnisend contact without channel change.
  • History imports never re-subscribe a contact who unsubscribed in the service (Mailchimp status_if_new only; Omnisend sends no welcome message).
  • Cart, checkout and browsing events of every service (Klaviyo / Brevo Started Checkout and Viewed Product, Mailchimp carts, Omnisend cart and checkout events) go out only for subscribed customers while “Cart, checkout and browsing events only of subscribed customers” is on (default). A cart job that waits while the customer places an order is dropped (no reminder after a purchase).
  • Mailchimp store id: created once per audience from the default storefront and kept (storage kv_emc_mc_store_*); store data comes from the default storefront’s settings, never from the request. When the store was deleted in Mailchimp the local sync state is reset and the store is created again.
  • Products that are disabled, hidden, deleted or of an inactive vendor are sent as unavailable (Mailchimp stock 0, Omnisend notAvailable): on save / delete and with the daily catalog run.
  • Links (products, images, orders, cart restore) use https when the storefront they point to is secure (its own Settings > Security value; the current storefront on the storefront, the default one in the admin panel and the cron job).
  • No list / audience selected: consent jobs (Mailchimp: every job) wait in the queue and the dashboard shows a notice.

index.php?dispatch=kv_email_connect.restore&c=<data>&s=<signature>: base64url JSON of up to 50 lines (product id, quantity, options) and a time, HMAC-SHA256 signed with the add-on’s own random key (1.1.1; storage kv_emc_restore_secret, never shown or sent; before 1.1.1 the catalog feed token, which is part of the feed URL; such older links keep working until they expire), valid 30 days. It adds the lines to the visitor’s own cart (lines already in the cart are skipped) and opens the cart page; a wrong or expired signature opens the cart unchanged. The page sends Cache-Control: no-store and is not a full page cache dispatch.

Contract tests (tests/unit.php, tests/e2e/e2e.mjs) use response bodies copied from the documentation pages above (tests/fixtures/SOURCES.md). Flagged, not verified with a live account:

  • Mailchimp does not document the error of a duplicate order id; the add-on therefore looks the order up after any refused create.
  • Omnisend’s GET /brands/current page has a schema but no example response; the fixture is built from the schema.
  • Omnisend state is documented as an ISO 3166-2 subdivision code since 2026-03-15; only short codes are sent, and a 400 on state retries the contact without it.
  • Omnisend started checkout and added product to cart are captured for identified contacts; server-side events carry the email, which the docs list as an identifier.

php admin.php --dispatch=kv_email_connect.cron sends up to 1000 jobs in about 4 minutes, continues the history import, queues the daily product sync (Brevo, Mailchimp, Omnisend) and removes old jobs.

Nothing is printed on cacheable guest pages. The queue, consent and remote-state tables are in ignore_cache_tags. Cart data comes only from signed-in customers (add to cart) and the checkout (never cached).