Skip to content

Commit

Permalink
Merge pull request #96 from Paazl/release/1.12.1
Browse files Browse the repository at this point in the history
Release/1.12.1
  • Loading branch information
Marvin-Magmodules authored Jul 18, 2022
2 parents a75277c + 4736e67 commit d96969a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 17 deletions.
33 changes: 18 additions & 15 deletions Model/Checkout/WidgetConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -42,11 +41,6 @@ class WidgetConfigProvider implements ConfigProviderInterface
*/
private $checkoutHelper;

/**
* @var OrderFactory
*/
private $order;

/**
* @var GeneralHelper
*/
Expand Down Expand Up @@ -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
Expand All @@ -92,7 +85,6 @@ class WidgetConfigProvider implements ConfigProviderInterface
public function __construct(
Config $scopeConfig,
Data $checkoutHelper,
OrderFactory $order,
GeneralHelper $generalHelper,
ItemHandler $itemHandler,
TokenRetriever $tokenRetriever,
Expand All @@ -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;
Expand Down Expand Up @@ -196,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
],
Expand All @@ -209,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) $shippingAddress->getGrandTotal();
break;
case "subtotal_excl_discount":
$totalPriceValue = (float) $shippingAddress->getSubtotalInclTax();
break;
case "subtotal_incl_discount":
default: // default from config.xml = "subtotal_incl_discount"
$totalPriceValue = (
(float) $shippingAddress->getSubtotalInclTax() +
(float) $shippingAddress->getDiscountAmount()
);
break;
}

$config['shipmentParameters']['totalPrice'] = $totalPriceValue;
$config = array_merge($config, $this->languageProvider->getConfig());

$this->generalHelper->addTolog('request', $config);
Expand All @@ -228,7 +231,7 @@ public function getConfig()
public function getQuote()
{
if (!$this->quote) {
return $this->checkoutHelper->getQuote();
$this->quote = $this->checkoutHelper->getQuote();
}

return $this->quote;
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<default>
<carriers>
<paazlshipping>
<version>v1.12.0</version>
<version>v1.12.1</version>
<active>0</active>
<sallowspecific>0</sallowspecific>
<price>0</price>
Expand Down

0 comments on commit d96969a

Please sign in to comment.