From f95e6d88912d56c3249897152cb419aa52d206c7 Mon Sep 17 00:00:00 2001 From: Lex Date: Tue, 12 Jul 2022 16:06:52 +0200 Subject: [PATCH 1/6] [FIX-TOTALPRICE-SHIPMENTPARAMETER] Remove redundant OrderFactory variable --- Model/Checkout/WidgetConfigProvider.php | 9 --------- composer.json | 2 +- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/Model/Checkout/WidgetConfigProvider.php b/Model/Checkout/WidgetConfigProvider.php index f014354..fc90a48 100644 --- a/Model/Checkout/WidgetConfigProvider.php +++ b/Model/Checkout/WidgetConfigProvider.php @@ -13,7 +13,6 @@ use Magento\Framework\Exception\NoSuchEntityException; use Magento\Quote\Model\Quote; use Magento\Quote\Model\Quote\Item\AbstractItem; -use Magento\Sales\Model\OrderFactory; use Paazl\CheckoutWidget\Helper\General as GeneralHelper; use Paazl\CheckoutWidget\Model\Config; use Paazl\CheckoutWidget\Model\Handler\Item as ItemHandler; @@ -42,11 +41,6 @@ class WidgetConfigProvider implements ConfigProviderInterface */ private $checkoutHelper; - /** - * @var OrderFactory - */ - private $order; - /** * @var GeneralHelper */ @@ -82,7 +76,6 @@ class WidgetConfigProvider implements ConfigProviderInterface * * @param Config $scopeConfig * @param Data $checkoutHelper - * @param OrderFactory $order * @param GeneralHelper $generalHelper * @param ItemHandler $itemHandler * @param TokenRetriever $tokenRetriever @@ -92,7 +85,6 @@ class WidgetConfigProvider implements ConfigProviderInterface public function __construct( Config $scopeConfig, Data $checkoutHelper, - OrderFactory $order, GeneralHelper $generalHelper, ItemHandler $itemHandler, TokenRetriever $tokenRetriever, @@ -101,7 +93,6 @@ public function __construct( ) { $this->scopeConfig = $scopeConfig; $this->checkoutHelper = $checkoutHelper; - $this->order = $order; $this->generalHelper = $generalHelper; $this->itemHandler = $itemHandler; $this->tokenRetriever = $tokenRetriever; diff --git a/composer.json b/composer.json index 8dd20e7..320ceb8 100755 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "paazl/magento2-checkout-widget", "description": "Paazl checkoutWidget for Magento 2", "type": "magento2-module", - "version": "1.12.0", + "version": "1.12.1", "keywords": [ "Paazl", "Magento 2", From 4521263af33d0fd769dc0f4f44baf7fb06ecd1b5 Mon Sep 17 00:00:00 2001 From: Lex Date: Tue, 12 Jul 2022 16:07:16 +0200 Subject: [PATCH 2/6] [FIX-TOTALPRICE-SHIPMENTPARAMETER] Declare $this->quote if it is not declared yet --- Model/Checkout/WidgetConfigProvider.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Model/Checkout/WidgetConfigProvider.php b/Model/Checkout/WidgetConfigProvider.php index fc90a48..9a7a501 100644 --- a/Model/Checkout/WidgetConfigProvider.php +++ b/Model/Checkout/WidgetConfigProvider.php @@ -219,7 +219,7 @@ public function getConfig() public function getQuote() { if (!$this->quote) { - return $this->checkoutHelper->getQuote(); + $this->quote = $this->checkoutHelper->getQuote(); } return $this->quote; From 6686456dfe5b30359f33246897473d045ad8f812 Mon Sep 17 00:00:00 2001 From: Lex Date: Tue, 12 Jul 2022 16:08:11 +0200 Subject: [PATCH 3/6] [FIX-TOTALPRICE-SHIPMENTPARAMETER] Add missing default option + use amounts including vat --- Model/Checkout/WidgetConfigProvider.php | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/Model/Checkout/WidgetConfigProvider.php b/Model/Checkout/WidgetConfigProvider.php index 9a7a501..3304a9f 100644 --- a/Model/Checkout/WidgetConfigProvider.php +++ b/Model/Checkout/WidgetConfigProvider.php @@ -200,12 +200,24 @@ public function getConfig() if ($this->isFreeShippingEnabled() && $shippingAddress->getFreeShipping()) { $config['shipmentParameters']['startMatrix'] = $this->getFreeShippingMatrixLetter(); } - if ($this->scopeConfig->getTotalPrice() == 'grand_total') { - $config['shipmentParameters']['totalPrice'] = (float)$this->getQuote()->getGrandTotal(); - } elseif ($this->scopeConfig->getTotalPrice() == 'subtotal_excl_discount') { - $config['shipmentParameters']['totalPrice'] = (float)$this->getQuote()->getSubtotal(); + + switch ($this->scopeConfig->getTotalPrice()) { + case "grand_total": + $totalPriceValue = (float) $this->getQuote()->getShippingAddress()->getGrandTotal(); + break; + case "subtotal_excl_discount": + $totalPriceValue = (float) $this->getQuote()->getShippingAddress()->getSubtotalInclTax(); + break; + case "subtotal_incl_discount": + default: // default from config.xml = "subtotal_incl_discount" + $totalPriceValue = ( + (float) $this->getQuote()->getShippingAddress()->getSubtotalInclTax() + + (float) $this->getQuote()->getShippingAddress()->getDiscountAmount() + ); + break; } + $config['shipmentParameters']['totalPrice'] = $totalPriceValue; $config = array_merge($config, $this->languageProvider->getConfig()); $this->generalHelper->addTolog('request', $config); From ca3419c4dd6502842842fa271cbbb8596397b77d Mon Sep 17 00:00:00 2001 From: Lex Date: Tue, 12 Jul 2022 16:43:56 +0200 Subject: [PATCH 4/6] [FIX-TOTALPRICE-SHIPMENTPARAMETER] Set default value to 0.0000 --- Model/Checkout/WidgetConfigProvider.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Model/Checkout/WidgetConfigProvider.php b/Model/Checkout/WidgetConfigProvider.php index 3304a9f..bcb9034 100644 --- a/Model/Checkout/WidgetConfigProvider.php +++ b/Model/Checkout/WidgetConfigProvider.php @@ -187,7 +187,7 @@ public function getConfig() ], "shipmentParameters" => [ "totalWeight" => (float)$this->getTotalWeight($goods), - "totalPrice" => (float)$this->getQuote()->getSubtotalWithDiscount(), + "totalPrice" => 0.0000, "numberOfGoods" => (int)$this->getProductsCount(), "goods" => $goods ], From 26136fe2c6363ab5f07f2a2767e720532793b518 Mon Sep 17 00:00:00 2001 From: Lex Date: Thu, 14 Jul 2022 10:08:16 +0200 Subject: [PATCH 5/6] [FIX-TOTALPRICE-SHIPMENTPARAMETER] Make use of $shippingAddress variable --- Model/Checkout/WidgetConfigProvider.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Model/Checkout/WidgetConfigProvider.php b/Model/Checkout/WidgetConfigProvider.php index bcb9034..060f890 100644 --- a/Model/Checkout/WidgetConfigProvider.php +++ b/Model/Checkout/WidgetConfigProvider.php @@ -203,16 +203,16 @@ public function getConfig() switch ($this->scopeConfig->getTotalPrice()) { case "grand_total": - $totalPriceValue = (float) $this->getQuote()->getShippingAddress()->getGrandTotal(); + $totalPriceValue = (float) $shippingAddress->getGrandTotal(); break; case "subtotal_excl_discount": - $totalPriceValue = (float) $this->getQuote()->getShippingAddress()->getSubtotalInclTax(); + $totalPriceValue = (float) $shippingAddress->getSubtotalInclTax(); break; case "subtotal_incl_discount": default: // default from config.xml = "subtotal_incl_discount" $totalPriceValue = ( - (float) $this->getQuote()->getShippingAddress()->getSubtotalInclTax() + - (float) $this->getQuote()->getShippingAddress()->getDiscountAmount() + (float) $shippingAddress->getSubtotalInclTax() + + (float) $shippingAddress->getDiscountAmount() ); break; } From 4736e6758d7f59923f357be50e1aa9e67fbc6f10 Mon Sep 17 00:00:00 2001 From: Marvin Besselsen Date: Mon, 18 Jul 2022 18:35:10 +0200 Subject: [PATCH 6/6] Version bump --- etc/config.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/config.xml b/etc/config.xml index f01a932..bff486c 100644 --- a/etc/config.xml +++ b/etc/config.xml @@ -8,7 +8,7 @@ - v1.12.0 + v1.12.1 0 0 0