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