From 9d7871b8f3930e6550466418eab671575a5474e3 Mon Sep 17 00:00:00 2001 From: Bohdan Medvediev Date: Mon, 19 Jul 2021 12:59:05 +0200 Subject: [PATCH 1/3] #17590 weight calculation fix --- src/modules/mo/mo_dhl/Adapter/BaseShipmentBuilder.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/modules/mo/mo_dhl/Adapter/BaseShipmentBuilder.php b/src/modules/mo/mo_dhl/Adapter/BaseShipmentBuilder.php index 31173148..8258bdf3 100644 --- a/src/modules/mo/mo_dhl/Adapter/BaseShipmentBuilder.php +++ b/src/modules/mo/mo_dhl/Adapter/BaseShipmentBuilder.php @@ -80,8 +80,10 @@ protected function calculateWeight(Order $order): float $articleWeight = $this->getArticleWeight($orderArticle, $config, $this->isInternational($order)); $weight += $articleWeight * $orderArticle->getFieldData('oxamount'); } - $weight *= 1 + (float)$config->getShopConfVar('mo_dhl__packing_weight_in_percent') / 100.0; - $weight += (float)$config->getShopConfVar('mo_dhl__packing_weight_absolute'); + if ($config->getShopConfVar('mo_dhl__calculate_weight')) { + $weight *= 1 + (float)$config->getShopConfVar('mo_dhl__packing_weight_in_percent') / 100.0; + $weight += (float)$config->getShopConfVar('mo_dhl__packing_weight_absolute'); + } return max(self::MO_DHL__MIN_WEIGHT_FOR_ORDER, $weight); } From 10cbab34ee31ee926eb0a048b459c77583cf459f Mon Sep 17 00:00:00 2001 From: Bohdan Medvediev Date: Tue, 20 Jul 2021 15:28:05 +0200 Subject: [PATCH 2/3] #17590 same calculation for local delivery --- src/modules/mo/mo_dhl/Adapter/BaseShipmentBuilder.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/modules/mo/mo_dhl/Adapter/BaseShipmentBuilder.php b/src/modules/mo/mo_dhl/Adapter/BaseShipmentBuilder.php index 8258bdf3..f7cc24c8 100644 --- a/src/modules/mo/mo_dhl/Adapter/BaseShipmentBuilder.php +++ b/src/modules/mo/mo_dhl/Adapter/BaseShipmentBuilder.php @@ -77,7 +77,7 @@ protected function calculateWeight(Order $order): float $config = Registry::getConfig(); $weight = 0.0; foreach ($order->getOrderArticles() as $orderArticle) { - $articleWeight = $this->getArticleWeight($orderArticle, $config, $this->isInternational($order)); + $articleWeight = $this->getArticleWeight($orderArticle, $config); $weight += $articleWeight * $orderArticle->getFieldData('oxamount'); } if ($config->getShopConfVar('mo_dhl__calculate_weight')) { @@ -145,16 +145,15 @@ protected function getParticipation(Order $order) /** * @param OrderArticle $orderArticle * @param \OxidEsales\Eshop\Core\Config $config - * @param bool $isInternationalShipment * @return float|mixed */ - protected function getArticleWeight(OrderArticle $orderArticle, \OxidEsales\Eshop\Core\Config $config, bool $isInternationalShipment) + protected function getArticleWeight(OrderArticle $orderArticle, \OxidEsales\Eshop\Core\Config $config) { /** @var OrderArticle $orderArticle */ $articleWeight = $config->getShopConfVar('mo_dhl__calculate_weight') ? (float)$orderArticle->getFieldData('oxweight') : (float)$config->getShopConfVar('mo_dhl__default_weight'); - if ($isInternationalShipment && $articleWeight < self::MO_DHL__MIN_WEIGHT_FOR_ORDERITEMS) { + if ($articleWeight < self::MO_DHL__MIN_WEIGHT_FOR_ORDERITEMS) { $articleWeight = max(self::MO_DHL__MIN_WEIGHT_FOR_ORDERITEMS, (float)$config->getShopConfVar('mo_dhl__default_weight')); } return $articleWeight; From 63fb2cdc1c28a7ce39ab53ab959c994ce16eaba3 Mon Sep 17 00:00:00 2001 From: mbe Date: Mon, 20 Sep 2021 13:37:12 +0200 Subject: [PATCH 3/3] new version release --- Changelog.md | 4 ++++ project.json | 2 +- src/modules/mo/mo_dhl/metadata.php | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Changelog.md b/Changelog.md index 4e3190a4..65841387 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,4 +1,8 @@ # Changelog +## 1.5.1 +* same weight calculation for local and international delivery +* weight calculation fix: use package weight only if calculate weight is active + ## 1.5.0 * New product: Warenpost International * specify endorsement for parcel send via Paket International diff --git a/project.json b/project.json index 545b77c4..7f2685d4 100644 --- a/project.json +++ b/project.json @@ -4,7 +4,7 @@ "pathToModule": "copy_this/modules/mo/mo_dhl", "prefix": "mo_", "suffix": "", - "version": "1.5.0", + "version": "1.5.1", "compatibility": { "minimumVersion": "6.0", "maximumVersion": null, diff --git a/src/modules/mo/mo_dhl/metadata.php b/src/modules/mo/mo_dhl/metadata.php index b05c2e0d..fc5dc733 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.

' . '

Handbook

', ], 'thumbnail' => 'logo.png', - 'version' => '1.5.0', + 'version' => '1.5.1', 'author' => 'mediaopt.', 'url' => 'http://www.mediaopt.de', 'email' => 'shopsoftware@deutschepost.de',