Files
medusa-store/packages/core
Abdulrahman eb376eb4cf fix(core-flows): handle missing variants and preserve zero unit_price in prepareLineItems (#13179)
* fix: handle missing variants and preserve zero unit_price in prepareLineItems

Fixed two issues in prepareLineItems:
1. unit_price value of 0 was previously treated as falsy and overwritten with the variant's price. Updated the check to only fallback when unitPrice is null or undefined.
2. When no variants array was provided, the code could throw due to non-null assertions. Now safely handles missing or empty variants.

Additional adjustments:
- Replaced `||` with `??` for array defaults to preserve valid empty arrays.
- Kept changes minimal to avoid altering function signature.

* Create sweet-wasps-build.md

* Update add-line-items.ts

* Update packages/core/core-flows/src/order/workflows/add-line-items.ts

Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>

* Update packages/core/core-flows/src/order/workflows/create-order.ts

Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>

---------

Co-authored-by: Carlos R. L. Rodrigues <37986729+carlos-r-l-rodrigues@users.noreply.github.com>
Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
2025-08-18 14:50:25 +02:00
..