diff --git a/Model/Admin/Order/Create/WidgetConfigProvider.php b/Model/Admin/Order/Create/WidgetConfigProvider.php
index 07ddd85..586a159 100755
--- a/Model/Admin/Order/Create/WidgetConfigProvider.php
+++ b/Model/Admin/Order/Create/WidgetConfigProvider.php
@@ -169,6 +169,10 @@ public function getConfig()
"initialPickupLocations" => $this->getInitialPickupLocations()
];
+ if ($this->isFreeShippingEnabled() && $shippingAddress->getFreeShipping()) {
+ $config['shipmentParameters']['startMatrix'] = $this->getFreeShippingMatrixLetter();
+ }
+
$config = array_merge($config, $this->languageProvider->getConfig());
$this->generalHelper->addTolog('config', $config);
@@ -403,4 +407,14 @@ protected function validateDeliveryMatrixCode(string $value)
return count($matches) === 1;
}
+
+ /**
+ * Check if free shipping enabled in store config
+ *
+ * @return bool
+ */
+ protected function isFreeShippingEnabled()
+ {
+ return $this->scopeConfig->isFreeShippingEnabled($this->getQuote()->getStoreId());
+ }
}
diff --git a/Model/Checkout/WidgetConfigProvider.php b/Model/Checkout/WidgetConfigProvider.php
index 9ef5bf7..76e3ce7 100644
--- a/Model/Checkout/WidgetConfigProvider.php
+++ b/Model/Checkout/WidgetConfigProvider.php
@@ -185,6 +185,10 @@ public function getConfig()
"initialPickupLocations" => $this->getInitialPickupLocations()
];
+ if ($this->isFreeShippingEnabled() && $shippingAddress->getFreeShipping()) {
+ $config['shipmentParameters']['startMatrix'] = $this->getFreeShippingMatrixLetter();
+ }
+
$config = array_merge($config, $this->languageProvider->getConfig());
$this->generalHelper->addTolog('request', $config);
@@ -397,6 +401,14 @@ public function isEnabled()
return $this->scopeConfig->isEnabled();
}
+ /**
+ * @return mixed
+ */
+ public function getFreeShippingMatrixLetter()
+ {
+ return $this->scopeConfig->getFreeShippingMatrixLetter($this->getQuote()->getStoreId());
+ }
+
/**
* Gets delivery matrix from product
*
@@ -433,4 +445,14 @@ protected function validateDeliveryMatrixCode(string $value)
return count($matches) === 1;
}
+
+ /**
+ * Check if free shipping enabled in store config
+ *
+ * @return bool
+ */
+ protected function isFreeShippingEnabled()
+ {
+ return $this->scopeConfig->isFreeShippingEnabled($this->getQuote()->getStoreId());
+ }
}
diff --git a/Model/Config.php b/Model/Config.php
index faadf6b..04ea2bc 100644
--- a/Model/Config.php
+++ b/Model/Config.php
@@ -293,6 +293,26 @@ public function isCarrierActive($store = null)
in_array($this->getValue('carriers/' . Paazlshipping::CODE . '/active', $store), [1, 'true']);
}
+ /**
+ * @param null|Store|int|string $store
+ *
+ * @return string
+ */
+ public function getFreeShippingMatrixLetter($store = null)
+ {
+ return (string)$this->getValue(self::API_CONFIG_PATH . '/freeshipping_matrix_letter', $store);
+ }
+
+ /**
+ * @param null|Store|int|string $store
+ *
+ * @return mixed
+ */
+ public function isFreeShippingEnabled($store = null)
+ {
+ return $this->getValue(self::API_CONFIG_PATH . '/freeshipping_enabled', $store);
+ }
+
/**
* @param null|Store|int|string $store
*
diff --git a/Model/System/Config/Source/WidgetTheme.php b/Model/System/Config/Source/WidgetTheme.php
index 864f5d6..732389a 100755
--- a/Model/System/Config/Source/WidgetTheme.php
+++ b/Model/System/Config/Source/WidgetTheme.php
@@ -29,6 +29,7 @@ public function toOptionArray()
if (!$this->options) {
$this->options = [
['value' => 'DEFAULT', 'label' => __('Default')],
+ ['value' => 'MINIMAL', 'label' => __('Minimal')],
['value' => 'GREEN', 'label' => __('Green')],
['value' => 'LIGHT-GREEN', 'label' => __('Light Green')],
['value' => 'BROWN', 'label' => __('Brown')],
@@ -37,7 +38,6 @@ public function toOptionArray()
['value' => 'CUSTOM', 'label' => __('Custom')],
];
}
-
return $this->options;
}
}
diff --git a/Plugin/Quote/AfterAddProduct.php b/Plugin/Quote/AfterAddProduct.php
new file mode 100644
index 0000000..c417fbe
--- /dev/null
+++ b/Plugin/Quote/AfterAddProduct.php
@@ -0,0 +1,84 @@
+scopeConfig = $scopeConfig;
+ $this->quoteRepository = $quoteRepository;
+ $this->config = $config;
+ }
+
+ /**
+ * Fire event after item was added to the cart (only after post request)
+ *
+ * @param QuoteModel $subject
+ * @param Item $result
+ * @param Product $product
+ *
+ * @return Item
+ * @throws Exception
+ */
+ public function afterAddProduct(
+ QuoteModel $subject,
+ $result,
+ Product $product
+ ) {
+ $shippingAddress = $subject->getShippingAddress();
+ if (!$shippingAddress->getCountryId() && $this->config->isEnabled()) {
+ $origin = $this->scopeConfig->getValue(self::ORIGIN);
+ $shippingAddress = $subject->getShippingAddress();
+ $billingAddress = $subject->getBillingAddress();
+ $billingAddress->setCountryId($origin);
+ $shippingAddress->setCountryId($origin);
+ $subject->setShippingAddress($shippingAddress);
+ $subject->setBillingAddress($billingAddress);
+ $this->quoteRepository->save($subject);
+ }
+ return $result;
+ }
+}
diff --git a/composer.json b/composer.json
index 6f5f7af..a89a25c 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.6.1",
+ "version": "1.7.0",
"keywords": [
"Paazl",
"Magento 2",
diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml
index 86ea690..399a20d 100755
--- a/etc/adminhtml/system.xml
+++ b/etc/adminhtml/system.xml
@@ -251,7 +251,18 @@
Google Account]]>
-
+
+
+ Magento\Config\Model\Config\Source\Yesno
+
+
+
+
+ 1
+
+
+
+
Magento\Config\Model\Config\Source\Yesno
Write API calls to var/log/paazl.log. Not recommended in Paazl's production environment for performance reasons.
@@ -268,4 +279,4 @@
-
\ No newline at end of file
+
diff --git a/etc/config.xml b/etc/config.xml
index 03568e1..fb6a023 100644
--- a/etc/config.xml
+++ b/etc/config.xml
@@ -8,7 +8,7 @@
- v1.6.1
+ v1.7.0
0
0
0
diff --git a/etc/di.xml b/etc/di.xml
index 81cef32..71784a3 100644
--- a/etc/di.xml
+++ b/etc/di.xml
@@ -25,6 +25,11 @@
sortOrder="70"/>
+
+
+
+