Skip to content

Commit

Permalink
20.1.5 SHQ18-1978 Trim postcode and ensure condition value is not null
Browse files Browse the repository at this point in the history
  • Loading branch information
wsajason committed May 9, 2019
1 parent c7d9e9d commit c579d19
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 35 deletions.
8 changes: 6 additions & 2 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ M2-23 remove crontab file, not required, M2-20 account for upload when no upload
## 20.1.0
M2-23 remove crontab file

## 20.2.2
SHQ16-2486 Fix rate matching when using country,region,post,w/o city
## 20.2.3 (2019-05-09)
SHQ18-1978 Trim postcode and ensure condition value is not null


## 20.1.5 (2019-05-09)
SHQ18-1978 Trim postcode and ensure condition value is not null


12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,19 @@ The MatrixRate shipping extension is the original Magento solution that enables

Compatibility
-------------
- Magento >= 2.0 (Includes 2.2)
- Magento >= 2.0 (Includes 2.3)

This library aims to support and is [tested against][travis] the following PHP
This library aims to support and is tested against the following PHP
implementations:

* PHP 5.5
* PHP 5.6
* PHP 5.7
enforced in the composer.json
* PHP 7.0
* PHP 7.1
* PHP 7.2

per the [official Magento 2 requirements](https://devdocs.magento.com/guides/v2.0/install-gde/system-requirements-tech.html)

Installation Instructions
-------------------------
Expand All @@ -42,7 +46,7 @@ WebShopApps MatrixRates is provided AS IS and we are not accepting feature reque

Magento Issues Impacting MatrixRates
-------
1. Magento v2.1.3 - Website specific shipping rates or configuration are not working
1. Magento v2.1.3 - Website specific shipping rates or configuration are not working - you may not see any rates when placing an order via the admin panel
- Github Issue: https://github.com/magento/magento2/issues/7840
- Related Issue: https://github.com/magento/magento2/issues/7943
- Code change required to fix: https://github.com/magento/magento2/issues/7943#issuecomment-269508822
Expand Down
72 changes: 43 additions & 29 deletions src/Model/ResourceModel/Carrier/Matrixrate.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,21 +191,24 @@ protected function _construct()
$this->_init('webshopapps_matrixrate', 'pk');
}

/**
* Return table rate array or false by rate request
*
* @param \Magento\Quote\Model\Quote\Address\RateRequest $request
* @param bool $zipRangeSet
* @return array|bool
*/
/**
* Return table rate array or false by rate request
*
* @param \Magento\Quote\Model\Quote\Address\RateRequest $request
* @param bool $zipRangeSet
*
* @return array|bool
* @throws \Magento\Framework\Exception\LocalizedException
* @throws \Zend_Db_Select_Exception
*/
public function getRate(\Magento\Quote\Model\Quote\Address\RateRequest $request, $zipRangeSet = false)
{
$adapter = $this->getConnection();
$shippingData=[];
$postcode = trim($request->getDestPostcode());
$postcode = trim($request->getDestPostcode()); //SHQ18-1978
if ($zipRangeSet && is_numeric($postcode)) {
# Want to search for postcodes within a range
$zipSearchString = ' AND :postcode BETWEEN dest_zip AND dest_zip_to ';
# Want to search for postcodes within a range. SHQ18-98 Can't use bind. Will convert int to string
$zipSearchString = ' AND ' .(int)$postcode. ' BETWEEN dest_zip AND dest_zip_to ';
} else {
$zipSearchString = " AND :postcode LIKE dest_zip ";
}
Expand All @@ -228,7 +231,7 @@ public function getRate(\Magento\Quote\Model\Quote\Address\RateRequest $request,
':country_id' => $request->getDestCountryId(),
':region_id' => (int)$request->getDestRegionId(),
':city' => $request->getDestCity(),
':postcode' => trim($request->getDestPostcode()),
':postcode' => $postcode,
];
break;
case 1: // country, region, no city, postcode
Expand All @@ -237,7 +240,7 @@ public function getRate(\Magento\Quote\Model\Quote\Address\RateRequest $request,
$bind = [
':country_id' => $request->getDestCountryId(),
':region_id' => (int)$request->getDestRegionId(),
':postcode' => trim($request->getDestPostcode()),
':postcode' => $postcode,
];
break;
case 2: // country, state, city, no postcode
Expand All @@ -260,7 +263,7 @@ public function getRate(\Magento\Quote\Model\Quote\Address\RateRequest $request,
.$zipSearchString;
$bind = [
':country_id' => $request->getDestCountryId(),
':postcode' => trim($request->getDestPostcode()),
':postcode' => $postcode,
];
break;
case 5: // country, region
Expand All @@ -285,7 +288,15 @@ public function getRate(\Magento\Quote\Model\Quote\Address\RateRequest $request,

$bind[':website_id'] = (int)$request->getWebsiteId();
$bind[':condition_name'] = $request->getConditionMRName();
$bind[':condition_value'] = floatval($request->getData($request->getConditionMRName()));

//SHQ18-1978
$condition = $request->getData($request->getConditionMRName());

if ($condition == null || $condition == "") {
$condition = 0;
}

$bind[':condition_value'] = $condition;

$select->where('condition_name = :condition_name');
$select->where('condition_from_value < :condition_value');
Expand All @@ -308,15 +319,16 @@ public function getRate(\Magento\Quote\Model\Quote\Address\RateRequest $request,
return $shippingData;
}

/**
* Upload table rate file and import data from it
*
* @param \Magento\Framework\Object $object
* @throws \Magento\Framework\Exception\LocalizedException
* @return \WebShopApps\MatrixRate\Model\ResourceModel\Carrier\Matrixrate
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
/**
* Upload table rate file and import data from it
*
* @param \Magento\Framework\DataObject $object
*
* @return \WebShopApps\MatrixRate\Model\ResourceModel\Carrier\Matrixrate
* @throws \Magento\Framework\Exception\LocalizedException
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
public function uploadAndImport(\Magento\Framework\DataObject $object)
{
//M2-24
Expand Down Expand Up @@ -625,12 +637,14 @@ protected function _getImportRow($row, $rowNumber = 0)
];
}

/**
* Save import data batch
*
* @param array $data
* @return \WebShopApps\MatrixRate\Model\ResourceModel\Carrier\Matrixrate
*/
/**
* Save import data batch
*
* @param array $data
*
* @return \WebShopApps\MatrixRate\Model\ResourceModel\Carrier\Matrixrate
* @throws \Magento\Framework\Exception\LocalizedException
*/
protected function _saveImportData(array $data)
{
if (!empty($data)) {
Expand Down

0 comments on commit c579d19

Please sign in to comment.