Skip to content

[Bug]: bug/upgrade, getLineItemActionsStep - matching by metada and variant_id #14731

@jbrigbyjs

Description

@jbrigbyjs

Package.json file

{}

Node.js version

v21.0.0

Database and its version

PostgresSQL 16

Operating system name and version

ubuntu

Browser name

No response

What happended?

The line-item action resolution was updated to match existing cart line items by both variant_id and metadata (not just variant_id). Existing items are now grouped per variant_id, and updates are accumulated per line-item id.

Expected behavior

When adding an item, the system should increase quantity only for the existing line item with the same variant_id and matching metadata. If the metadata differs, it should create a new line item instead of merging.

Actual behavior

The logic assumed variant_id is unique and used a Map<variant_id, item>, so if multiple line items shared the same variant_id, one would overwrite another in the map. This could lead to updating the wrong line item, merging quantities incorrectly, or creating duplicates when an update was intended.

Link to reproduction repo

#14730

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions