fix: make it possible to update order shipping address (#668)

This commit is contained in:
Sebastian Rindom authored and GitHub committed 2021-11-05 16:48:29 +01:00
1 parent 45b344fbe1
commit e0fa06fe96
3 files changed
+93 -7

No files matched your search

+14 -7
View File
@@ -784,7 +784,7 @@ class OrderService extends BaseService {
await addrRepo.save({ ...addr, ...address })
} else {
const created = await addrRepo.create({ ...address })
const created = addrRepo.create({ ...address })
await addrRepo.save(created)
}
}
@@ -877,26 +877,33 @@ class OrderService extends BaseService {
)
}
const { ...rest } = update
const {
metadata,
shipping_address,
billing_address,
no_notification,
items,
...rest
} = update
if ("metadata" in update) {
order.metadata = this.setMetadata_(order, update.metadata)
order.metadata = this.setMetadata_(order, metadata)
}
if ("shipping_address" in update) {
await this.updateShippingAddress_(order, update.shipping_address)
await this.updateShippingAddress_(order, shipping_address)
}
if ("billing_address" in update) {
await this.updateBillingAddress_(order, update.billing_address)
await this.updateBillingAddress_(order, billing_address)
}
if ("no_notification" in update) {
order.no_notification = update.no_notification
order.no_notification = no_notification
}
if ("items" in update) {
for (const item of update.items) {
for (const item of items) {
await this.lineItemService_.withTransaction(manager).create({
...item,
order_id: orderId,