Shop_events_listener.js — add-to-cart analytics broken when same variant appears twice with different properties

Short description of issue

parseFormData in shop_events_listener.js deduplicates items by variant ID, causing a mismatch when the same variant appears twice with different properties (e.g. BXGY deals). Results in “Payload body and response have different number of items” console error and dropped analytics events.

Reproduction steps

  1. Send a fetch /cart/add request with two items that share the same variant ID but have different properties values
  2. Observe console warning: [shop_events_listener] Error in handleFetchRequest: Payload body and response have different number of items

This happens because parseFormData merges items with the same id into one, so the payload item count (1) doesn’t match the cart API response item count (2). The cart API correctly keeps them separate because their properties differ.

Additional info

No customer-facing impact — the add-to-cart succeeds and the error is caught/swallowed. Only analytics tracking is silently dropped for the request.

Affects any app that sends two lines of the same variant with different properties (e.g. BXGY free item + paid item).

What type of topic is this

Bug report

Upload screenshot(s) of issue

2 Likes

Hey @dostu, thanks for reporting this as well.

This is an issue our team is aware of and we are looking in to ways to resolve it. I don’t have a timeline on a solution, however we will keep an eye on it and update here if anything changes.

1 Like