In the complete-cart workflow, the cart transforms the line items using prepareLineItemData but this requires a variant to be set.
Other times that prepareLineItemData are used, there seems to be a variant check first, then it uses a prepareCustomLineItemData instead.
There are a few places that only use prepareLineItemData without checking if a variant exists, so not sure if adding the prepareCustomLineItemData will solve a few other bugs?
Expected behavior
Add a custom line item using cartModuleService.addLineItems
Initiate payment session using store.payment.initiatePaymentSession
Call store.cart.complete to complete the order in the admin panel
Actual behavior
Add a custom line item using cartModuleService.addLineItems
Initiate payment session using store.payment.initiatePaymentSession
Call store.cart.complete to complete the order (FAILS: "Cannot read properties of undefined (reading 'product')")
Package.json file
Node.js version
v20.11.1
Database and its version
PostgresSQL 16
Operating system name and version
Docker
Browser name
No response
What happended?
In the complete-cart workflow, the cart transforms the line items using prepareLineItemData but this requires a variant to be set.
Other times that prepareLineItemData are used, there seems to be a variant check first, then it uses a prepareCustomLineItemData instead.
There are a few places that only use prepareLineItemData without checking if a variant exists, so not sure if adding the prepareCustomLineItemData will solve a few other bugs?
Expected behavior
Actual behavior
Link to reproduction repo
TODO