Short description of issue
A /cart/add request whose line items get merged by a Cart Transform function makes shop_events_listener.js throw Payload body and response have different number of items, so no product_added_to_cart event fires. Items still add to the cart, but Shopify Analytics and downstream pixels (Meta, GA4) miss the add-to-cart.
Reproduction steps
- Set up a Cart Transform function that merges line items (e.g. a bundles app that merges selected component variants into a single bundle line).
- POST multiple items to
/cart/addin one request (e.g. 3 component variants). - The Cart Transform merges them server-side, so the cart response contains fewer lines (e.g. 1 line).
- Observe the console warning:
[shop_events_listener] ... Payload body and response have different number of items. - No
product_added_to_cartevent fires, so the add-to-cart is missing from Shopify Analytics and all downstream pixels.
Additional info
Same root assumption as this existing report: Shop_events_listener.js — add-to-cart analytics broken when same variant appears twice with different properties
The cause is in handleBulkItemCartAddResponse, which assumes a 1:1 mapping between request payload items and response items:
if (parsedResponseItemsList.length != parsedPayloadBodyItemsList.length) {
throw Error("Payload body and response have different number of items")
}
Request has 3 items, response has 1, so it throws before any handleItemAdded call and no event is emitted. The listener assumes response line count equals payload count, which breaks whenever a Cart Transform reshapes the cart (by design). Merchants running one lose add-to-cart analytics with no app-side workaround.
Could the listener tolerate a mismatch instead of throwing, e.g. emitting events from the response lines rather than zipping by index?
What type of topic is this
Bug report
