diff --git a/Model/Checkout/WidgetConfigProvider.php b/Model/Checkout/WidgetConfigProvider.php
index 76e3ce7..79bfa63 100644
--- a/Model/Checkout/WidgetConfigProvider.php
+++ b/Model/Checkout/WidgetConfigProvider.php
@@ -188,6 +188,9 @@ 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();
+ }
$config = array_merge($config, $this->languageProvider->getConfig());
diff --git a/Model/Config.php b/Model/Config.php
index 04ea2bc..1fce00a 100644
--- a/Model/Config.php
+++ b/Model/Config.php
@@ -313,6 +313,14 @@ public function isFreeShippingEnabled($store = null)
return $this->getValue(self::API_CONFIG_PATH . '/freeshipping_enabled', $store);
}
+ /**
+ * @return mixed
+ */
+ public function isPriceIncludesTax($store = null)
+ {
+ return $this->getValue(self::API_CONFIG_PATH . '/price_incl_tax', $store);
+ }
+
/**
* @param null|Store|int|string $store
*
@@ -454,6 +462,16 @@ public function getGoogleMapKey($store = null)
return null;
}
+ /**
+ * @param null|Store|int|string $store
+ *
+ * @return mixed
+ */
+ public function getTotalPrice($store = null)
+ {
+ return $this->getValue(self::API_CONFIG_PATH . '/total_price', $store);
+ }
+
/**
* @param null|Store|int|string $store
*
diff --git a/Model/System/Config/Source/TotalPrice.php b/Model/System/Config/Source/TotalPrice.php
new file mode 100644
index 0000000..3708a3b
--- /dev/null
+++ b/Model/System/Config/Source/TotalPrice.php
@@ -0,0 +1,36 @@
+options) {
+ $this->options = [
+ ['value' => 'subtotal_incl_discount', 'label' => __('Subtotal including DISCOUNT')],
+ ['value' => 'grand_total', 'label' => __('Grand total')]
+ ];
+ }
+
+ return $this->options;
+ }
+}
diff --git a/Model/System/Config/Source/WidgetTheme.php b/Model/System/Config/Source/WidgetTheme.php
index 732389a..51c556b 100755
--- a/Model/System/Config/Source/WidgetTheme.php
+++ b/Model/System/Config/Source/WidgetTheme.php
@@ -31,7 +31,7 @@ public function toOptionArray()
['value' => 'DEFAULT', 'label' => __('Default')],
['value' => 'MINIMAL', 'label' => __('Minimal')],
['value' => 'GREEN', 'label' => __('Green')],
- ['value' => 'LIGHT-GREEN', 'label' => __('Light Green')],
+ ['value' => 'LIGHT_GREEN', 'label' => __('Light Green')],
['value' => 'BROWN', 'label' => __('Brown')],
['value' => 'BLUE', 'label' => __('Blue')],
['value' => 'RED', 'label' => __('Red')],
diff --git a/Plugin/Tax/Config.php b/Plugin/Tax/Config.php
new file mode 100644
index 0000000..2a8eec0
--- /dev/null
+++ b/Plugin/Tax/Config.php
@@ -0,0 +1,92 @@
+orderHelper = $orderHelper;
+ $this->paazlConfig = $paazlConfig;
+ $this->shippingMethod = $shippingMethod;
+ $this->session = $session;
+ $this->cartRepository = $cartRepository;
+ }
+
+ /**
+ * @param TaxConfigModel $subject
+ * @param bool $result
+ * @param null $store
+ *
+ * @return bool
+ */
+ public function afterShippingPriceIncludesTax(
+ TaxConfigModel $subject,
+ bool $result,
+ $store = null
+ ) {
+ try {
+ $cartId = $this->session->getQuoteId();
+ //we can't use Magento\Checkout\Model\Session::getQuote() because of infinity loop on place order
+ $quote = $this->cartRepository->getActive($cartId);
+ $shippingMethod = $quote->getShippingAddress()->getShippingMethod();
+ if ($shippingMethod
+ && $this->orderHelper->isPaazlShippingMethod($shippingMethod)
+ && $this->paazlConfig->isPriceIncludesTax($store)
+ ) {
+ return true;
+ }
+ } catch (NoSuchEntityException $e) {
+ return $result;
+ }
+
+ return $result;
+ }
+}
diff --git a/composer.json b/composer.json
index a89a25c..25aa800 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.7.0",
+ "version": "1.8.0",
"keywords": [
"Paazl",
"Magento 2",
diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml
index 399a20d..ed61dae 100755
--- a/etc/adminhtml/system.xml
+++ b/etc/adminhtml/system.xml
@@ -251,6 +251,11 @@
Google Account]]>
+
+
+ Paazl\CheckoutWidget\Model\System\Config\Source\TotalPrice
+ Select the price which will be used for totalPrice.
+
Magento\Config\Model\Config\Source\Yesno
@@ -262,6 +267,11 @@
+
+
+ Magento\Config\Model\Config\Source\Yesno
+ If yes - shipping price will always includes tax regardless Magento settings
+
Magento\Config\Model\Config\Source\Yesno
diff --git a/etc/config.xml b/etc/config.xml
index fb6a023..f557752 100644
--- a/etc/config.xml
+++ b/etc/config.xml
@@ -8,7 +8,7 @@
- v1.7.0
+ v1.8.0
0
0
0
@@ -33,6 +33,7 @@
5
0
1
+ subtotal_incl_discount
diff --git a/etc/di.xml b/etc/di.xml
index 71784a3..ae4c2ea 100644
--- a/etc/di.xml
+++ b/etc/di.xml
@@ -30,6 +30,10 @@
type="Paazl\CheckoutWidget\Plugin\Quote\AfterAddProduct" sortOrder="1" disabled="false" />
+
+
+
+