Skip to content

Commit e7f9be2

Browse files
author
Xziy
committed
Fix for assigning promotion-delivery to the order.
1 parent 5e1d282 commit e7f9be2

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

models/Order.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -1308,13 +1308,15 @@ let Model = {
13081308
order.promotionCode = order.promotionCode.id;
13091309
}
13101310
// Calculate delivery costs
1311-
let delivery = {}; // for self service
1311+
let delivery = {};
13121312
let softDeliveryCalculation = null;
13131313
if (order.selfService === false) {
1314+
// The SOFT_DELIVERY_CALCULATION setting disables strict checking of the delivery address.
13141315
softDeliveryCalculation = await Settings.get("SOFT_DELIVERY_CALCULATION");
13151316
emitter.emit("core:count-before-delivery-cost", order);
1317+
// order.promotionDelivery is preferred over the delivery setting
13161318
if (order.promotionDelivery && isValidDelivery(order.promotionDelivery)) {
1317-
order.delivery = order.promotionDelivery;
1319+
delivery = order.promotionDelivery;
13181320
}
13191321
else {
13201322
let deliveryAdapter = await Adapter.getDeliveryAdapter();
@@ -1337,6 +1339,7 @@ let Model = {
13371339
}
13381340
}
13391341
}
1342+
// Case when the shipping cost cannot be calculated
13401343
if (softDeliveryCalculation &&
13411344
(!order.delivery ||
13421345
Object.keys(order.delivery).length === 0 ||

models/Order.ts

+8-3
Original file line numberDiff line numberDiff line change
@@ -1577,14 +1577,17 @@ let Model = {
15771577
}
15781578

15791579
// Calculate delivery costs
1580-
let delivery = {} as Delivery // for self service
1580+
let delivery = {} as Delivery
15811581
let softDeliveryCalculation = null;
15821582
if(order.selfService === false) {
1583-
1583+
1584+
// The SOFT_DELIVERY_CALCULATION setting disables strict checking of the delivery address.
15841585
softDeliveryCalculation = await Settings.get("SOFT_DELIVERY_CALCULATION")
15851586
emitter.emit("core:count-before-delivery-cost", order);
1587+
1588+
// order.promotionDelivery is preferred over the delivery setting
15861589
if (order.promotionDelivery && isValidDelivery(order.promotionDelivery)) {
1587-
order.delivery = order.promotionDelivery;
1590+
delivery = order.promotionDelivery;
15881591
} else {
15891592
let deliveryAdapter = await Adapter.getDeliveryAdapter();
15901593
await deliveryAdapter.reset(order);
@@ -1606,6 +1609,8 @@ let Model = {
16061609
}
16071610
}
16081611

1612+
1613+
// Case when the shipping cost cannot be calculated
16091614
if (
16101615
softDeliveryCalculation &&
16111616
(!order.delivery ||

0 commit comments

Comments
 (0)