Enhance delivery cost calculation and shipping information display: Implement free shipping threshold for cart value in DeliveryMethodSelector and OrderProcessingService. Update CartDropdown and OrderSummary to reflect shipping costs and free shipping messages based on cart value, improving user clarity on shipping fees.

This commit is contained in:
sebseb7
2025-07-16 01:59:43 +02:00
parent 925667fc2c
commit b78de53786
5 changed files with 98 additions and 28 deletions

View File

@@ -347,7 +347,7 @@ class OrderProcessingService {
// Calculate delivery cost
getDeliveryCost() {
const { deliveryMethod, paymentMethod } = this.getState();
const { deliveryMethod, paymentMethod, cartItems } = this.getState();
let cost = 0;
switch (deliveryMethod) {
@@ -367,7 +367,16 @@ class OrderProcessingService {
cost = 6.99;
}
// Add onDelivery surcharge if selected
// Check for free shipping threshold (>= 100€ cart value)
// Free shipping applies to DHL, DPD, and Sperrgut deliveries when cart value >= 100€
if (cartItems && Array.isArray(cartItems) && deliveryMethod !== "Abholung") {
const cartValue = cartItems.reduce((total, item) => total + item.price * item.quantity, 0);
if (cartValue >= 100) {
cost = 0; // Free shipping for orders >= 100€
}
}
// Add onDelivery surcharge if selected (still applies even with free shipping)
if (paymentMethod === "onDelivery") {
cost += 8.99;
}