Skip to content

Commit

Permalink
add soft delivery calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
Xziy committed Aug 24, 2024
1 parent 2e98edc commit 3eeb18f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 24 deletions.
28 changes: 15 additions & 13 deletions models/Order.js
Original file line number Diff line number Diff line change
Expand Up @@ -689,19 +689,21 @@ let Model = {
emitter.emit("core:order-is-self-service", order, customer, isSelfService, address);
}
else {
order.selfService = false;
if (address) {
if (!address.city)
address.city = await Settings.get("CITY");
checkAddress(address);
order.address = { ...address };
}
else {
if (!isSelfService && order.address === null) {
throw {
code: 5,
error: "address is required",
};
if (!await Settings.get("SOFT_DELIVERY_CALCULATION")) {
order.selfService = false;
if (address) {
if (!address.city)
address.city = await Settings.get("CITY");
checkAddress(address);
order.address = { ...address };
}
else {
if (!isSelfService && order.address === null) {
throw {
code: 5,
error: "address is required",
};
}
}
}
}
Expand Down
24 changes: 13 additions & 11 deletions models/Order.ts
Original file line number Diff line number Diff line change
Expand Up @@ -861,17 +861,19 @@ let Model = {
order.selfService = true;
emitter.emit("core:order-is-self-service", order, customer, isSelfService, address);
} else {
order.selfService = false;
if (address) {
if (!address.city) address.city = await Settings.get("CITY")
checkAddress(address);
order.address = { ...address };
} else {
if (!isSelfService && order.address === null) {
throw {
code: 5,
error: "address is required",
};
if(!await Settings.get("SOFT_DELIVERY_CALCULATION")) {
order.selfService = false;
if (address) {
if (!address.city) address.city = await Settings.get("CITY")
checkAddress(address);
order.address = { ...address };
} else {
if (!isSelfService && order.address === null) {
throw {
code: 5,
error: "address is required",
};
}
}
}
}
Expand Down

0 comments on commit 3eeb18f

Please sign in to comment.