feat: normalize delivery methods in CartTab and DeliveryMethodSelector components

This commit is contained in:
sebseb7
2026-03-18 06:59:20 +01:00
parent 1e1a0c7320
commit f0e4a94dfc
4 changed files with 47 additions and 14 deletions

View File

@@ -8,6 +8,8 @@ import CheckoutValidation from "./CheckoutValidation.js";
import { withI18n } from "../../i18n/index.js";
class CartTab extends Component {
normalizeDeliveryMethod = (deliveryMethod) => (deliveryMethod === "DPD" ? "DHL" : deliveryMethod);
constructor(props) {
super(props);
@@ -107,10 +109,12 @@ class CartTab extends Component {
// Map delivery method values if needed
const deliveryMethodMap = {
"standard": "DHL",
"express": "DPD",
"express": "DHL",
"pickup": "Abholung"
};
prefillDeliveryMethod = deliveryMethodMap[prefillDeliveryMethod] || prefillDeliveryMethod;
prefillDeliveryMethod = this.normalizeDeliveryMethod(
deliveryMethodMap[prefillDeliveryMethod] || prefillDeliveryMethod
);
// Determine payment method - respect constraints
let prefillPaymentMethod = template.payment_method || "wire";
@@ -168,7 +172,9 @@ class CartTab extends Component {
const cartItems = Array.isArray(window.cart) ? window.cart : [];
const shouldForcePickup = CheckoutValidation.shouldForcePickupDelivery(cartItems);
const newDeliveryMethod = shouldForcePickup ? "Abholung" : this.state.deliveryMethod;
const newDeliveryMethod = shouldForcePickup
? "Abholung"
: this.normalizeDeliveryMethod(this.state.deliveryMethod);
const deliveryCost = this.orderService.getDeliveryCost();
// Get optimal payment method for the current state
@@ -215,7 +221,7 @@ class CartTab extends Component {
};
handleDeliveryMethodChange = (event) => {
const newDeliveryMethod = event.target.value;
const newDeliveryMethod = this.normalizeDeliveryMethod(event.target.value);
const deliveryCost = this.orderService.getDeliveryCost();
// Get optimal payment method for the new delivery method

View File

@@ -96,7 +96,7 @@ class CheckoutForm extends Component {
cartItems={cartItems}
/>
{(deliveryMethod === "DHL" || deliveryMethod === "DPD") && (
{deliveryMethod === "DHL" && (
<>
<FormControlLabel
control={

View File

@@ -20,14 +20,6 @@ const DeliveryMethodSelector = ({ deliveryMethod, onChange, isPickupOnly, cartIt
price: isFreeShipping ? (t ? t('delivery.prices.free') : 'kostenlos') : (t ? t('delivery.prices.dhl') : '5,90 €'),
disabled: isPickupOnly
},
{
id: 'DPD',
name: 'DPD',
description: isPickupOnly ? (t ? t('delivery.descriptions.notAvailable') : "nicht auswählbar weil ein oder mehrere Artikel nur abgeholt werden können") :
isFreeShipping ? (t ? t('delivery.descriptions.standardFree') : 'Standardversand - KOSTENLOS ab 100€ Warenwert!') : (t ? t('delivery.descriptions.standard') : 'Standardversand'),
price: isFreeShipping ? (t ? t('delivery.prices.free') : 'kostenlos') : (t ? t('delivery.prices.dpd') : '4,90 €'),
disabled: isPickupOnly
},
{
id: 'Sperrgut',
name: t ? t('delivery.methods.sperrgutName') : 'Sperrgut',