Skip to content

Commit

Permalink
Update actions.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
gijsmin committed Nov 11, 2024
1 parent fbbf54d commit 0844dae
Showing 1 changed file with 7 additions and 19 deletions.
26 changes: 7 additions & 19 deletions src/repositories/order/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,14 +198,9 @@ export class OrderUpdateHandler
throw new Error("Resource has no shipping info");
}

if (Array.isArray(resource.shippingInfo.deliveries)) {
for (const delivery of resource.shippingInfo.deliveries) {
if (delivery.id !== deliveryId) continue;
if (delivery.custom) {
const update = delivery.custom.fields;
update[name] = value;
Object.assign(delivery.custom.fields, update);
}
for (const delivery of resource.shippingInfo.deliveries || []) {
if (delivery.id === deliveryId && delivery.custom?.fields) {
delivery.custom.fields[name] = value;
}
}
}
Expand Down Expand Up @@ -235,17 +230,10 @@ export class OrderUpdateHandler
throw new Error("Resource has no shipping info");
}

if (Array.isArray(resource.shippingInfo.deliveries)) {
for (const delivery of resource.shippingInfo.deliveries) {
if (Array.isArray(delivery.parcels)) {
for (const parcel of delivery.parcels) {
if (parcel.id !== parcelId) continue;
if (parcel.custom) {
const update = parcel.custom.fields;
update[name] = value;
Object.assign(parcel.custom.fields, update);
}
}
for (const delivery of resource.shippingInfo.deliveries || []) {
for (const parcel of delivery.parcels || []) {
if (parcel.id === parcelId && parcel.custom?.fields) {
parcel.custom.fields[name] = value;
}
}
}
Expand Down

0 comments on commit 0844dae

Please sign in to comment.