Cartlines inside Cart Transformation function is different then the actual cart

Topic summary

A developer encounters a discrepancy between cart line items displayed in the UI versus those processed in Shopify’s Cart Transformation function during a buy-one-get-one (BOGO) promotion.

The Issue:

  • In the UI (via cart.js): Discounted items appear as separate line items, displaying correctly
  • In Cart Transformation function: These separate discounted line items are combined into a single line item

Impact:
This consolidation causes the Cart Transformation function to behave incorrectly, preventing accurate calculation of the cart’s total price.

Status:
The issue remains unresolved with no responses or solutions provided yet. The developer has included screenshots demonstrating the difference between the UI representation and the Cart Transformation function’s handling of the line items.

Summarized with AI on November 1. AI used: claude-sonnet-4-5-20250929.

first image is the cart lines on the UI I can see using cart.js. This is where I can see discounted item is created as another line item and same this is represented on the UI as well which is absolutly fine. But on the cart transformation functions both the line discounted items are combined into one and coming as one line item.

This is a buy one get one situation. Issue with combining this is cart transformation function is behaving buggy because I am not getting the cart total price properly.