27-05-2026 Update DHL Modul v2.0
This commit is contained in:
parent
53bdba33cd
commit
036595be94
41 changed files with 3346 additions and 310 deletions
|
|
@ -35,15 +35,27 @@ class DhlDataHelper
|
|||
$settingController = new SettingController;
|
||||
$dhlConfig = $settingController->getDhlConfig();
|
||||
}
|
||||
$dimensions = isset($dhlConfig['dimensions'][$options['product_code']]) ? $dhlConfig['dimensions'][$options['product_code']] : $dhlConfig['dimensions']['default'];
|
||||
$resolver = new DhlProductResolver;
|
||||
$destinationCountryCode = $shippingAddress['country']?->code;
|
||||
if (! $destinationCountryCode) {
|
||||
throw new \Exception('shipping_address.country is required');
|
||||
}
|
||||
|
||||
$resolvedDhlProduct = $resolver->resolveForShipment(
|
||||
$destinationCountryCode,
|
||||
$options['product_code'] ?? null,
|
||||
$dhlConfig['default_product'] ?? 'V01PAK'
|
||||
);
|
||||
$dimensions = $dhlConfig['dimensions'][$resolvedDhlProduct['product_code']] ?? $dhlConfig['dimensions']['default'];
|
||||
|
||||
return [
|
||||
'order_id' => $order->id,
|
||||
'weight_kg' => $weight,
|
||||
'product_code' => $options['product_code'] ?? 'V01PAK',
|
||||
'product_code' => $resolvedDhlProduct['product_code'],
|
||||
'label_format' => $options['label_format'] ?? $dhlConfig['label_format'] ?? 'PDF',
|
||||
'print_format' => $options['print_format'] ?? $dhlConfig['print_format'] ?? null,
|
||||
'retoure_print_format' => $options['retoure_print_format'] ?? $dhlConfig['retoure_print_format'] ?? null,
|
||||
'print_only_if_codeable' => (bool) ($options['print_only_if_codeable'] ?? $dhlConfig['print_only_if_codeable'] ?? config('dhl.print_only_if_codeable', true)),
|
||||
|
||||
// Shipper data (sender) - from admin settings
|
||||
'shipper' => [
|
||||
|
|
@ -66,7 +78,7 @@ class DhlDataHelper
|
|||
'houseNumber' => $shippingAddress['houseNumber'] ?? '',
|
||||
'postalCode' => $shippingAddress['zipcode'] ?? '',
|
||||
'city' => $shippingAddress['city'] ?? '',
|
||||
'country' => $shippingAddress['country']?->code ?? 'DE',
|
||||
'country' => $resolvedDhlProduct['country_code'],
|
||||
'email' => $shippingAddress['email'] ?? '',
|
||||
'phone' => $shippingAddress['phone'] ?? '',
|
||||
// DHL Postnummer für Packstation/Paketbox
|
||||
|
|
@ -82,7 +94,18 @@ class DhlDataHelper
|
|||
'services' => $options['services'] ?? [],
|
||||
|
||||
// Custom reference for tracking
|
||||
'reference' => 'Order-'.$order->id,
|
||||
'reference' => self::normalizeReference($options['reference'] ?? $options['shipment_reference'] ?? null, $order),
|
||||
];
|
||||
}
|
||||
|
||||
private static function normalizeReference(?string $reference, ShoppingOrder $order): string
|
||||
{
|
||||
$reference = trim((string) $reference);
|
||||
|
||||
if ($reference === '') {
|
||||
return 'Order-'.$order->id;
|
||||
}
|
||||
|
||||
return mb_substr(preg_replace('/\s+/', ' ', $reference), 0, 35);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue