diff --git a/CHANGELOG-PUBLIC.md b/CHANGELOG-PUBLIC.md index 09ac952..ba2f7b3 100644 --- a/CHANGELOG-PUBLIC.md +++ b/CHANGELOG-PUBLIC.md @@ -584,3 +584,7 @@ MNB-1385 Add check for zip required for destination MNB-1429 Ensure correct method code is passed to shipping insights +## 20.45.0 (2021-07-30) +MNB-1471 Add cache timeout. MNB-1465 Ensure order comment containing packing info is accurate. MNB-1464 Dont send details to Shipping Insights for non SHQ methods + + diff --git a/CHANGELOG.MD b/CHANGELOG.MD index 09ac952..ba2f7b3 100755 --- a/CHANGELOG.MD +++ b/CHANGELOG.MD @@ -584,3 +584,7 @@ MNB-1385 Add check for zip required for destination MNB-1429 Ensure correct method code is passed to shipping insights +## 20.45.0 (2021-07-30) +MNB-1471 Add cache timeout. MNB-1465 Ensure order comment containing packing info is accurate. MNB-1464 Dont send details to Shipping Insights for non SHQ methods + + diff --git a/composer.json b/composer.json index 0593cfe..6efab89 100755 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "shipperhq/module-shipper", "description": "Magento Shipping integration with ShipperHQ", "type": "magento2-module", - "version": "20.44.3", + "version": "20.45.0", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/src/Helper/CarrierCache.php b/src/Helper/CarrierCache.php index bc9cae0..c20deab 100755 --- a/src/Helper/CarrierCache.php +++ b/src/Helper/CarrierCache.php @@ -57,6 +57,8 @@ class CarrierCache */ private $serializer; + private $cacheTimeout; + /** * @param CacheInterface $cache * @param ScopeConfigInterface $config @@ -69,6 +71,10 @@ public function __construct(CacheInterface $cache, ScopeConfigInterface $config, ScopeInterface::SCOPE_STORE ); $this->serializer = $serializer; + $this->cacheTimeout = $config->getValue( + 'carriers/shipper/cache_timeout', + ScopeInterface::SCOPE_STORE + ); } /** @@ -125,7 +131,7 @@ public function setCachedQuotes($requestParams, $response, $carrierCode) { if ($this->useCache && $this->responseCanBeCached($response)) { $key = $this->getQuotesCacheKey($requestParams, $carrierCode); - $this->cache->save($this->serialize($response), $key, [self::CACHE_TAG]); + $this->cache->save($this->serialize($response), $key, [self::CACHE_TAG], $this->cacheTimeout); } return $this; } diff --git a/src/Helper/Package.php b/src/Helper/Package.php index 124f3c7..f5bea5f 100644 --- a/src/Helper/Package.php +++ b/src/Helper/Package.php @@ -241,6 +241,8 @@ public function saveOrderPackages($order, $shippingAddress) /** * Finds the packages/boxes saved in the session * + * MNB-1465 Switched order of if/else. Now will favour carrier_method code over just carrier + * * @param $sessionData * @param $shippingAddressId * @param $methodCode @@ -255,10 +257,10 @@ private function getPackagesFromSession($sessionData, $shippingAddressId, $metho if (!empty($sessionData) && array_key_exists($shippingAddressId, $sessionData)) { if (array_key_exists($carrierGroupId, $sessionData[$shippingAddressId])) { - if (array_key_exists($carrierCode, $sessionData[$shippingAddressId][$carrierGroupId])) { - $packages = $sessionData[$shippingAddressId][$carrierGroupId][$carrierCode]; - } elseif (array_key_exists($carrierCode . '_' . $methodCode, $sessionData[$shippingAddressId][$carrierGroupId])) { + if (array_key_exists($carrierCode . '_' . $methodCode, $sessionData[$shippingAddressId][$carrierGroupId])) { $packages = $sessionData[$shippingAddressId][$carrierGroupId][$carrierCode . '_' . $methodCode]; + } elseif (array_key_exists($carrierCode, $sessionData[$shippingAddressId][$carrierGroupId])) { + $packages = $sessionData[$shippingAddressId][$carrierGroupId][$carrierCode]; } } } diff --git a/src/Observer/AbstractRecordOrder.php b/src/Observer/AbstractRecordOrder.php index 72a0881..822176f 100644 --- a/src/Observer/AbstractRecordOrder.php +++ b/src/Observer/AbstractRecordOrder.php @@ -157,13 +157,14 @@ public function recordOrder($order) $this->carrierGroupHelper->recordOrderItems($order); $this->packageHelper->saveOrderPackages($order, $shippingAddress); - // RIV-443 Save order details to OMS - if ($this->shipperDataHelper->getStoreQuoteOrder()) { + $shippingMethod = $order->getShippingMethod(); + $shippingRate = $shippingAddress->getShippingRateByCode($shippingMethod); + + // RIV-443 Save order details to OMS / MNB-1464 Ensure only saving for SHQ methods + if (strstr($shippingRate->getCarrier(), 'shq') && $this->shipperDataHelper->getStoreQuoteOrder()) { $this->postOrderHelper->handleOrder($order, $shippingAddress, $quoteId); } - $shippingMethod = $order->getShippingMethod(); - $shippingRate = $shippingAddress->getShippingRateByCode($shippingMethod); if ($shippingRate) { list($carrierCode, $method) = explode('_', $shippingMethod, 2); $carrierType = $shippingRate->getCarrierType(); diff --git a/src/composer.json b/src/composer.json index 561e8a7..8b2d079 100644 --- a/src/composer.json +++ b/src/composer.json @@ -2,7 +2,7 @@ "name": "shipperhq/module-shipper", "description": "Magento Shipping integration with ShipperHQ", "type": "magento2-module", - "version": "20.44.3", + "version": "20.45.0", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/src/etc/adminhtml/system.xml b/src/etc/adminhtml/system.xml index 9d95a96..3f039d2 100755 --- a/src/etc/adminhtml/system.xml +++ b/src/etc/adminhtml/system.xml @@ -129,7 +129,12 @@ Set timeout period in seconds to wait for ShipperHQ to return rates before calling backup carrier - + + + Set cache time to live in seconds. Default is 300 seconds (5 minutes) + + Refresh Authorization Token ShipperHQ\Shipper\Block\Adminhtml\System\Config\RefreshAuthToken diff --git a/src/etc/config.xml b/src/etc/config.xml index c71c102..bcccb40 100755 --- a/src/etc/config.xml +++ b/src/etc/config.xml @@ -62,9 +62,10 @@ 30 0 1 - 20.44.3 + 20.45.0 + 300 1