Skip to content

Commit a98c352

Browse files
fix: only allow postal delivery if enabled in branch settings
1 parent 528d040 commit a98c352

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

backend/app/services/vipps/vipps_checkout_service.ts

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ async function createLogistics(order: Order) {
5757
Math.ceil((totalWeightInGrams / 1000) * 20) + (needPickupPoint ? 150 : 75);
5858

5959
const branch = await StorageService.Branches.get(order.branch);
60+
console.log(branch);
61+
console.log(branch.deliveryMethods);
6062
return {
6163
fixedOptions: [
6264
...(order.amount > 0 && branch.deliveryMethods?.branch
@@ -75,19 +77,25 @@ async function createLogistics(order: Order) {
7577
} as const,
7678
]
7779
: []),
78-
{
79-
id: needPickupPoint ? "mail_pickup_point" : "mailbox",
80-
amount: {
81-
value: deliveryPrice * 100,
82-
currency: "NOK",
83-
},
84-
brand: "POSTEN",
85-
title: needPickupPoint ? "Pakke til hentested" : "Pakke i postkasse",
86-
description: `Forventet levering om ${APP_CONFIG.delivery.deliveryDays + 2} dager`,
87-
type: needPickupPoint ? "PICKUP_POINT" : "MAILBOX",
88-
priority: 1,
89-
isDefault: order.amount === 0,
90-
} as const,
80+
...(branch.deliveryMethods?.byMail
81+
? [
82+
{
83+
id: needPickupPoint ? "mail_pickup_point" : "mailbox",
84+
amount: {
85+
value: deliveryPrice * 100,
86+
currency: "NOK",
87+
},
88+
brand: "POSTEN",
89+
title: needPickupPoint
90+
? "Pakke til hentested"
91+
: "Pakke i postkasse",
92+
description: `Forventet levering om ${APP_CONFIG.delivery.deliveryDays + 2} dager`,
93+
type: needPickupPoint ? "PICKUP_POINT" : "MAILBOX",
94+
priority: 1,
95+
isDefault: order.amount === 0,
96+
} as const,
97+
]
98+
: []),
9199
],
92100
};
93101
}

0 commit comments

Comments
 (0)