fix: customer not found (#152)
This commit is contained in:
1 parent
ff49d23322
commit
282eaae675
2 files changed
+12
-14
No files matched your search
@@ -33,23 +33,20 @@ export default async (req, res) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const manager = req.scope.resolve("manager")
|
|
||||||
const cartService = req.scope.resolve("cartService")
|
const cartService = req.scope.resolve("cartService")
|
||||||
|
|
||||||
await manager.transaction(async m => {
|
// Update the cart
|
||||||
// Update the cart
|
await cartService.update(id, value)
|
||||||
await cartService.withTransaction(m).update(id, value)
|
|
||||||
|
|
||||||
// If the cart has payment sessions update these
|
// If the cart has payment sessions update these
|
||||||
const updated = await cartService.withTransaction(m).retrieve(id, {
|
const updated = await cartService.retrieve(id, {
|
||||||
relations: ["payment_sessions"],
|
relations: ["payment_sessions"],
|
||||||
})
|
|
||||||
|
|
||||||
if (updated.payment_sessions?.length && !value.region_id) {
|
|
||||||
await cartService.withTransaction(m).setPaymentSessions(id)
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if (updated.payment_sessions?.length && !value.region_id) {
|
||||||
|
await cartService.setPaymentSessions(id)
|
||||||
|
}
|
||||||
|
|
||||||
const cart = await cartService.retrieve(id, {
|
const cart = await cartService.retrieve(id, {
|
||||||
select: defaultFields,
|
select: defaultFields,
|
||||||
relations: defaultRelations,
|
relations: defaultRelations,
|
||||||
|
|||||||
@@ -689,12 +689,13 @@ class CartService extends BaseService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let customer = await this.customerService_
|
let customer = await this.customerService_
|
||||||
|
.withTransaction(this.transactionManager_)
|
||||||
.retrieveByEmail(value)
|
.retrieveByEmail(value)
|
||||||
.catch(() => undefined)
|
.catch(() => undefined)
|
||||||
|
|
||||||
if (!customer) {
|
if (!customer) {
|
||||||
customer = await this.customerService_
|
customer = await this.customerService_
|
||||||
.withTransaction(this.manager_)
|
.withTransaction(this.transactionManager_)
|
||||||
.create({ email })
|
.create({ email })
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1112,7 +1113,7 @@ class CartService extends BaseService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, "SERIALIZABLE")
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in new issue
Block a user