fix(medusa): Missing withTransaction on update in get-cart.ts (#3246)
This commit is contained in:
committed by
GitHub
parent
a2cc084db8
commit
bbbb3d8882
5
.changeset/new-spoons-flash.md
Normal file
5
.changeset/new-spoons-flash.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@medusajs/medusa": patch
|
||||
---
|
||||
|
||||
fix(medusa): Get cart missing transaction on update
|
||||
@@ -1,4 +1,5 @@
|
||||
import { CartService } from "../../../../services"
|
||||
import { EntityManager } from "typeorm"
|
||||
|
||||
/**
|
||||
* @oas [get] /carts/{id}
|
||||
@@ -47,6 +48,7 @@ export default async (req, res) => {
|
||||
const { id } = req.params
|
||||
|
||||
const cartService: CartService = req.scope.resolve("cartService")
|
||||
const manager: EntityManager = req.scope.resolve("manager")
|
||||
|
||||
const cart = await cartService.retrieve(id, {
|
||||
select: ["id", "customer_id"],
|
||||
@@ -59,8 +61,10 @@ export default async (req, res) => {
|
||||
!cart.email ||
|
||||
cart.customer_id !== req.user.customer_id
|
||||
) {
|
||||
await cartService.update(id, {
|
||||
customer_id: req.user.customer_id,
|
||||
await manager.transaction(async (transctionManager) => {
|
||||
await cartService.withTransaction(transctionManager).update(id, {
|
||||
customer_id: req.user.customer_id,
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user