Skip to content

Commit

Permalink
Merged in develop (pull request #103)
Browse files Browse the repository at this point in the history
Develop

Approved-by: Martin Beckmann
  • Loading branch information
Bohdan-Medv committed Nov 30, 2021
2 parents e47433a + d7ed186 commit 8b26917
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 8 deletions.
3 changes: 3 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion project.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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,
Expand All @@ -117,15 +123,20 @@ 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,
ShipmentNatureType::SALE_GOODS,
$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));

Expand Down
2 changes: 1 addition & 1 deletion src/modules/mo/mo_dhl/metadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
'en' => '<p>Enable features providing Post & Paket Delivery to your OXID shop.</p>' . '<p><a href="https://projects.mediaopt.de/projects/mopt-postp-ua/wiki" target="_blank">Handbook</a></p>',
],
'thumbnail' => 'logo.png',
'version' => '1.5.8',
'version' => '1.5.9',
'author' => '<a href="http://www.mediaopt.de" target="_blank">mediaopt.</a>',
'url' => 'http://www.mediaopt.de',
'email' => '[email protected]',
Expand Down

0 comments on commit 8b26917

Please sign in to comment.