From d01bf141f8c32d9e0e20ebc78e7f5b7565384df0 Mon Sep 17 00:00:00 2001 From: Richard Perdaan Date: Mon, 26 Oct 2020 11:44:36 +0100 Subject: [PATCH 1/3] change int to float --- Model/Sales/Package.php | 27 +++++++++------------------ Model/Sales/PackageInterface.php | 8 ++++---- 2 files changed, 13 insertions(+), 22 deletions(-) diff --git a/Model/Sales/Package.php b/Model/Sales/Package.php index ebc7ae79..93a7d1c8 100755 --- a/Model/Sales/Package.php +++ b/Model/Sales/Package.php @@ -18,14 +18,7 @@ namespace MyParcelNL\Magento\Model\Sales; - -use Magento\Framework\App\ObjectManager; -use Magento\Framework\Module\ModuleListInterface; -use Magento\Framework\App\Helper\Context; -use Magento\Quote\Api\Data\EstimateAddressInterfaceFactory; use MyParcelNL\Magento\Helper\Data; -use MyParcelNL\Sdk\src\Services\CheckApiKeyService; -use Psr\Log\LoggerInterface; class Package extends Data implements PackageInterface { @@ -85,7 +78,7 @@ class Package extends Data implements PackageInterface private $package_type = null; /** - * @return int + * @return float */ public function getWeight() { @@ -93,19 +86,19 @@ public function getWeight() } /** - * @param $weight + * @param float $weight */ - public function setWeight(int $weight) + public function setWeight(float $weight) { - $this->weight = (int) $weight; + $this->weight = $weight; } /** - * @param int $weight + * @param float $weight */ - public function addWeight(int $weight) + public function addWeight(float $weight) { - $this->weight += (int) $weight; + $this->weight += $weight; } /** @@ -117,14 +110,13 @@ public function getMaxWeight(): int } /** - * @param int $max_weight + * @param float $max_weight */ - public function setMaxWeight(int $max_weight) + public function setMaxWeight(float $max_weight) { $this->max_weight = $max_weight; } - /** * @return bool */ @@ -222,7 +214,6 @@ public function setAllProductsFit(bool $all_products_fit) } } - /** * package = 1 * diff --git a/Model/Sales/PackageInterface.php b/Model/Sales/PackageInterface.php index 0cbce394..55ae06c2 100755 --- a/Model/Sales/PackageInterface.php +++ b/Model/Sales/PackageInterface.php @@ -22,17 +22,17 @@ interface PackageInterface { /** - * @return int + * @return float */ public function getWeight(); /** * @param $weight */ - public function setWeight(int $weight); + public function setWeight(float $weight); /** - * @param int $weight + * @param float $weight */ - public function addWeight(int $weight); + public function addWeight(float $weight); /** * @return bool */ From 5e3dec61b0b2f2720e40c015894b35165963a4c7 Mon Sep 17 00:00:00 2001 From: Richard Perdaan Date: Mon, 26 Oct 2020 11:44:54 +0100 Subject: [PATCH 2/3] add getQty for product weight --- Model/Sales/TrackTraceHolder.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Model/Sales/TrackTraceHolder.php b/Model/Sales/TrackTraceHolder.php index c1efc7e5..20d3fe66 100755 --- a/Model/Sales/TrackTraceHolder.php +++ b/Model/Sales/TrackTraceHolder.php @@ -331,7 +331,7 @@ private function convertDataForCdCountry($magentoTrack) $myParcelProduct = (new MyParcelCustomsItem()) ->setDescription($product->getName()) ->setAmount($product->getQty()) - ->setWeight($product->getWeight() ?: 1) + ->setWeight($this->getWeightTypeOfOption($product->getWeight()) ?: 1) ->setItemValue($this->getCentsByPrice($product->getPrice())) ->setClassification( (int) $this->getAttributeValue('catalog_product_entity_int', $product['product_id'], 'classification') @@ -347,7 +347,7 @@ private function convertDataForCdCountry($magentoTrack) $myParcelProduct = (new MyParcelCustomsItem()) ->setDescription($item->getName()) ->setAmount($item->getQty()) - ->setWeight($this->getWeightTypeOfOption($item->getWeight())) + ->setWeight($this->getWeightTypeOfOption($item->getWeight() * $item->getQty())) ->setItemValue($item->getPrice() * 100) ->setClassification((int) $this->getAttributeValue('catalog_product_entity_int', $item->getProductId(), 'classification')) ->setCountry($this->getCountryOfOrigin($item->getProductId())); From eb1cc0605203998b779cd534e3664efb432007c3 Mon Sep 17 00:00:00 2001 From: Richard Perdaan Date: Tue, 27 Oct 2020 08:53:36 +0100 Subject: [PATCH 3/3] Update Package.php --- Model/Sales/Package.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Model/Sales/Package.php b/Model/Sales/Package.php index 93a7d1c8..6b066296 100755 --- a/Model/Sales/Package.php +++ b/Model/Sales/Package.php @@ -98,7 +98,7 @@ public function setWeight(float $weight) */ public function addWeight(float $weight) { - $this->weight += $weight; + $this->weight += $weight; } /**