fix(medusa): Validate customer_id when completing a cart (#3967)

This commit is contained in:
Frane Polić
2023-05-07 13:12:06 +02:00
committed by GitHub
parent eff9f4c6f9
commit 0c58ead6d8
4 changed files with 43 additions and 4 deletions
+9 -2
View File
@@ -637,6 +637,13 @@ class OrderService extends TransactionBaseService {
)
}
if (!cart.customer_id) {
throw new MedusaError(
MedusaError.Types.INVALID_DATA,
"Cannot create an order from the cart without a customer"
)
}
const { payment, region, total } = cart
// Would be the case if a discount code is applied that covers the item
@@ -667,7 +674,7 @@ class OrderService extends TransactionBaseService {
// Is the cascade insert really used? Also, is it really necessary to pass the entire entities when creating or updating?
// We normally should only pass what is needed?
const shippingMethods = cart.shipping_methods.map((method) => {
(method.tax_lines as any) = undefined
;(method.tax_lines as any) = undefined
return method
})
@@ -775,7 +782,7 @@ class OrderService extends TransactionBaseService {
// TODO: Due to cascade insert we have to remove the tax_lines that have been added by the cart decorate totals.
// Is the cascade insert really used? Also, is it really necessary to pass the entire entities when creating or updating?
// We normally should only pass what is needed?
(method.tax_lines as any) = undefined
;(method.tax_lines as any) = undefined
return shippingOptionServiceTx.updateShippingMethod(method.id, {
order_id: order.id,
})