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