diff --git a/Model/Checkout/WidgetConfigProvider.php b/Model/Checkout/WidgetConfigProvider.php
index 79bfa63..dffeb7b 100644
--- a/Model/Checkout/WidgetConfigProvider.php
+++ b/Model/Checkout/WidgetConfigProvider.php
@@ -128,12 +128,22 @@ public function getConfig()
$numberOfProcessingDays = self::DEFAULT_NUMBER_OF_PROCESSING_DAYS;
$goods = [];
+ $widthAttribute = $this->scopeConfig->getProductAttributeWidth();
+ $heightAttribute = $this->scopeConfig->getProductAttributeHeight();
+ $lengthAttribute = $this->scopeConfig->getProductAttributeLength();
+ $useDimensions = $widthAttribute && $lengthAttribute && $heightAttribute;
foreach ($this->getQuote()->getAllVisibleItems() as $item) {
$goodsItem = [
"quantity" => (int)$item->getQty(),
"weight" => doubleval($item->getWeight()),
"price" => $this->itemHandler->getPriceValue($item)
];
+ if ($useDimensions) {
+ $product = $this->productRepository->getById($item->getProduct()->getId());
+ $goodsItem["length"] = $product->getData($lengthAttribute);
+ $goodsItem["width"] = $product->getData($widthAttribute);
+ $goodsItem["height"] = $product->getData($heightAttribute);
+ }
if (($itemNumberOfProcessingDays = $this->getProductNumberOfProcessingDays($item))
&& $itemNumberOfProcessingDays > $numberOfProcessingDays) {
@@ -190,6 +200,8 @@ public function getConfig()
}
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();
}
$config = array_merge($config, $this->languageProvider->getConfig());
diff --git a/Model/System/Config/Source/TotalPrice.php b/Model/System/Config/Source/TotalPrice.php
index 3708a3b..dd792bf 100644
--- a/Model/System/Config/Source/TotalPrice.php
+++ b/Model/System/Config/Source/TotalPrice.php
@@ -27,6 +27,7 @@ public function toOptionArray()
if (!$this->options) {
$this->options = [
['value' => 'subtotal_incl_discount', 'label' => __('Subtotal including DISCOUNT')],
+ ['value' => 'subtotal_excl_discount', 'label' => __('Subtotal excluding DISCOUNT')],
['value' => 'grand_total', 'label' => __('Grand total')]
];
}
diff --git a/Plugin/Carrier/Infotext.php b/Plugin/Carrier/Infotext.php
index 7709509..c33c700 100755
--- a/Plugin/Carrier/Infotext.php
+++ b/Plugin/Carrier/Infotext.php
@@ -33,7 +33,7 @@ class Infotext
* Infotext constructor.
*
* @param ShippingMethodExtensionFactory $extensionFactory
- * @param Config $scopeConfig
+ * @param Config $scopeConfig
*/
public function __construct(
ShippingMethodExtensionFactory $extensionFactory,
@@ -54,15 +54,18 @@ public function __construct(
public function afterModelToDataObject(ShippingMethodConverter $subject, ShippingMethodInterface $result)
{
$carrierCode = $result->getCarrierCode();
- $infotext = $this->scopeConfig->getValue(
- 'carriers/' . $carrierCode . '/infotext'
- );
- $extensibleAttribute = ($result->getExtensionAttributes())
- ? $result->getExtensionAttributes()
- : $this->extensionFactory->create();
+ if ($carrierCode == 'paazlshipping') {
+ $infotext = $this->scopeConfig->getValue(
+ 'carriers/' . $carrierCode . '/infotext'
+ );
+ $extensibleAttribute = ($result->getExtensionAttributes())
+ ? $result->getExtensionAttributes()
+ : $this->extensionFactory->create();
+
+ $extensibleAttribute->setInfotext($infotext);
+ $result->setExtensionAttributes($extensibleAttribute);
+ }
- $extensibleAttribute->setInfotext($infotext);
- $result->setExtensionAttributes($extensibleAttribute);
return $result;
}
}
diff --git a/Plugin/Quote/AfterAddProduct.php b/Plugin/Quote/AfterAddProduct.php
deleted file mode 100644
index c417fbe..0000000
--- a/Plugin/Quote/AfterAddProduct.php
+++ /dev/null
@@ -1,84 +0,0 @@
-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/Plugin/Quote/BeforeQuoteSave.php b/Plugin/Quote/BeforeQuoteSave.php
new file mode 100644
index 0000000..85c44e9
--- /dev/null
+++ b/Plugin/Quote/BeforeQuoteSave.php
@@ -0,0 +1,67 @@
+scopeConfig = $scopeConfig;
+ $this->config = $config;
+ }
+
+ /**
+ * @param QuoteRepository $subject
+ * @param CartInterface $quote
+ *
+ * @return CartInterface[]
+ */
+ public function beforeSave(
+ QuoteRepository $subject,
+ CartInterface $quote
+ ) {
+ $shippingAddress = $quote->getShippingAddress();
+ if (!$shippingAddress->getCountryId() && $this->config->isEnabled()) {
+ $origin = $this->scopeConfig->getValue(self::ORIGIN);
+ $shippingAddress = $quote->getShippingAddress();
+ $billingAddress = $quote->getBillingAddress();
+ $billingAddress->setCountryId($origin);
+ $shippingAddress->setCountryId($origin);
+ $quote->setShippingAddress($shippingAddress);
+ $quote->setBillingAddress($billingAddress);
+ }
+ return [$quote];
+ }
+}
diff --git a/composer.json b/composer.json
index 25aa800..58c9c29 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.8.0",
+ "version": "1.9.0",
"keywords": [
"Paazl",
"Magento 2",
diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml
index ed61dae..23ffb6f 100755
--- a/etc/adminhtml/system.xml
+++ b/etc/adminhtml/system.xml
@@ -141,6 +141,14 @@
Magento\Config\Model\Config\Source\Yesno
+
+
+
+ 1
+
+ Use this to show some info on checkout shipping method.
+
diff --git a/etc/config.xml b/etc/config.xml
index f557752..fa4ffd2 100644
--- a/etc/config.xml
+++ b/etc/config.xml
@@ -8,7 +8,7 @@
- v1.8.0
+ v1.9.0
0
0
0
diff --git a/etc/di.xml b/etc/di.xml
index ae4c2ea..5505aea 100644
--- a/etc/di.xml
+++ b/etc/di.xml
@@ -25,9 +25,9 @@
sortOrder="70"/>
-
-
+
+
diff --git a/view/frontend/web/js/checkout/action/set-shipping-information-mixin.js b/view/frontend/web/js/checkout/action/set-shipping-information-mixin.js
index c775f41..7651c03 100755
--- a/view/frontend/web/js/checkout/action/set-shipping-information-mixin.js
+++ b/view/frontend/web/js/checkout/action/set-shipping-information-mixin.js
@@ -28,7 +28,9 @@ define(
return;
}
- var methods = res.extension_attributes && res.extension_attributes.shipping_methods || [];
+ var methods = res.totals.extension_attributes
+ && res.totals.extension_attributes.shipping_methods
+ || [];
var found = _.find(methods, function (m) {
return m.carrier_code === shippingMethod.carrier_code
&& m.method_code === shippingMethod.method_code;
diff --git a/view/frontend/web/template/checkout/shipping-method-item.html b/view/frontend/web/template/checkout/shipping-method-item.html
index f8686dd..125f48f 100755
--- a/view/frontend/web/template/checkout/shipping-method-item.html
+++ b/view/frontend/web/template/checkout/shipping-method-item.html
@@ -35,7 +35,9 @@
attr="'aria-labelledby': 'label_method_' + method.method_code + '_' + method.carrier_code + ' ' + 'label_carrier_' + method.method_code + '_' + method.carrier_code" />
- |
+
+
+ |
|