diff --git a/Changelog.md b/Changelog.md index ab3b27d5..67fb1577 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,4 +1,7 @@ # Changelog +## 1.5.9 +* bugfix for empty additional sender lines + ## 1.5.8 * sender data build logic updated for warenpost international * retoure and individual label buttons removed for warenpost international diff --git a/project.json b/project.json index 0b1bdb28..8d448f4f 100644 --- a/project.json +++ b/project.json @@ -4,7 +4,7 @@ "pathToModule": "copy_this/modules/mo/mo_dhl", "prefix": "mo_", "suffix": "", - "version": "1.5.7", + "version": "1.5.9", "compatibility": { "minimumVersion": "6.0", "maximumVersion": null, diff --git a/src/modules/mo/mo_dhl/Adapter/WarenpostShipmentOrderRequestBuilder.php b/src/modules/mo/mo_dhl/Adapter/WarenpostShipmentOrderRequestBuilder.php index 8ef96e90..c18026d8 100755 --- a/src/modules/mo/mo_dhl/Adapter/WarenpostShipmentOrderRequestBuilder.php +++ b/src/modules/mo/mo_dhl/Adapter/WarenpostShipmentOrderRequestBuilder.php @@ -62,17 +62,17 @@ protected function buildSender(Config $config): string * @param Config $config * @return string */ - protected function buildAddressLine1(Config $config): string + protected function buildSenderAdditionalLines(Config $config): string { - return $config->getShopConfVar('mo_dhl__sender_line2') - . ' ' . $config->getShopConfVar('mo_dhl__sender_line3'); + return trim($config->getShopConfVar('mo_dhl__sender_line2') + . ' ' . $config->getShopConfVar('mo_dhl__sender_line3')); } /** * @param Config $config * @return string */ - protected function buildAddressLine2(Config $config): string + protected function buildSenderAddressLine(Config $config): string { return $config->getShopConfVar('mo_dhl__sender_street') . ' ' . $config->getShopConfVar('mo_dhl__sender_street_number'); @@ -109,6 +109,12 @@ protected function buildItems(Order $order, Config $config, string $senderName): $config->getShopConfVar('mo_dhl__sender_country') ); + $senderAddressLine = $this->buildSenderAddressLine($config); + + // We have three sender lines, street and street number. + // DHL have only one sender line and two address lines. + $senderAdditionalLines = $this->buildSenderAdditionalLines($config); + $itemData = new ItemData( $this->getProductId($order), $recipient, @@ -117,7 +123,7 @@ protected function buildItems(Order $order, Config $config, string $senderName): $customerData['city'], $country->getCountryISOCode(), $senderName, - $this->buildAddressLine1($config), + $senderAdditionalLines ? : $senderAddressLine, $config->getShopConfVar('mo_dhl__sender_zip'), $config->getShopConfVar('mo_dhl__sender_city'), $senderCountry, @@ -125,7 +131,12 @@ protected function buildItems(Order $order, Config $config, string $senderName): $this->calculateWeight($order) * 1000 ); - $itemData->setSenderAddressLine2($this->buildAddressLine2($config)); + // If sender line 2 and 3 not empty - they go to senderAddressLine1 + // street and street number go to senderAddressLine2 + if (!empty($senderAdditionalLines)) { + $itemData->setSenderAddressLine2($senderAddressLine); + } + $itemData->setShipmentCurrency($order->getFieldData('oxcurrency')); $itemData->setContents($this->buildContetns($order)); diff --git a/src/modules/mo/mo_dhl/metadata.php b/src/modules/mo/mo_dhl/metadata.php index 2d277010..82bd91bb 100644 --- a/src/modules/mo/mo_dhl/metadata.php +++ b/src/modules/mo/mo_dhl/metadata.php @@ -17,7 +17,7 @@ 'en' => '
Enable features providing Post & Paket Delivery to your OXID shop.
' . '', ], 'thumbnail' => 'logo.png', - 'version' => '1.5.8', + 'version' => '1.5.9', 'author' => 'mediaopt.', 'url' => 'http://www.mediaopt.de', 'email' => 'shopsoftware@deutschepost.de',