Skip to content

Commit

Permalink
20.45.0 MNB-1471 Add cache timeout. MNB-1465 Ensure order comment con…
Browse files Browse the repository at this point in the history
…taining packing info is accurate. MNB-1464 Dont send details to Shipping Insights for non SHQ methods
  • Loading branch information
wsajosh committed Jul 30, 2021
1 parent 110976f commit 1923cd1
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 12 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG-PUBLIC.md
Original file line number Diff line number Diff line change
Expand Up @@ -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


4 changes: 4 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -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


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": "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"
Expand Down
8 changes: 7 additions & 1 deletion src/Helper/CarrierCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ class CarrierCache
*/
private $serializer;

private $cacheTimeout;

/**
* @param CacheInterface $cache
* @param ScopeConfigInterface $config
Expand All @@ -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
);
}

/**
Expand Down Expand Up @@ -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;
}
Expand Down
8 changes: 5 additions & 3 deletions src/Helper/Package.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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];
}
}
}
Expand Down
9 changes: 5 additions & 4 deletions src/Observer/AbstractRecordOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
7 changes: 6 additions & 1 deletion src/etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,12 @@
<label>Timeout (seconds)</label>
<tooltip>Set timeout period in seconds to wait for ShipperHQ to return rates before calling backup carrier</tooltip>
</field>
<field id="refresh_auth_key" translate="button_label" sortOrder="336" showInDefault="1" showInWebsite="0" showInStore="0">
<field id="cache_timeout" translate="label" type="text" sortOrder="340" showInDefault="1" showInWebsite="1"
showInStore="1">
<label>Cache Lifetime (seconds)</label>
<tooltip>Set cache time to live in seconds. Default is 300 seconds (5 minutes)</tooltip>
</field>
<field id="refresh_auth_key" translate="button_label" sortOrder="350" showInDefault="1" showInWebsite="0" showInStore="0">
<button_label>Refresh Authorization Token</button_label>
<frontend_model>ShipperHQ\Shipper\Block\Adminhtml\System\Config\RefreshAuthToken</frontend_model>
</field>
Expand Down
3 changes: 2 additions & 1 deletion src/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,10 @@
<ws_timeout>30</ws_timeout>
<use_cache>0</use_cache>
<always_use_cache>1</always_use_cache>
<extension_version>20.44.3</extension_version>
<extension_version>20.45.0</extension_version>
<allowed_methods></allowed_methods>
<magento_version></magento_version>
<cache_timeout>300</cache_timeout>
</shipper>
<shipperadmin>
<active>1</active>
Expand Down

0 comments on commit 1923cd1

Please sign in to comment.