-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Description
Steps to reproduce
- Magento 2.0.5 or current version on branch develop
- In table rates csv file add one row with any country with condition_value/order total starting from 0, shipping price is A.
- In same csv file add on second row same country, bigger condition_value/order total = X, shipping price is B.
Expected result
- On checkout page, when order total is greater than X than it should display/calculate that shipping price is B
Actual result
- In checkout it displays shipping price A
It happens because it fetches the first row from table shipping_tablerate
by getRate method from tablerate resource class/classes.
It's missing condition_value column in $select->order() as parameter (as in ORDER BY for SQL).
In Code
Magento 2.0.5:
Magento\OfflineShipping\Model\ResourceModel\Carrier\Tablerate::getRate()
->order(
['dest_country_id DESC', 'dest_region_id DESC', 'dest_zip DESC']
)
It's missing 'condition_value DESC'.
In Magento 1 this column exists:
https://github.com/OpenMage/magento-mirror/blob/magento-1.9/app/code/core/Mage/Shipping/Model/Resource/Carrier/Tablerate.php
in method getRate():
->order(array('dest_country_id DESC', 'dest_region_id DESC', 'dest_zip DESC', 'condition_value DESC'))
In Magento 2 on develop branch there is:
https://github.com/magento/magento2/blob/develop/app/code/Magento/OfflineShipping/Model/ResourceModel/Carrier/Tablerate/RateQuery.php
in method getRate():
$select->where(
'website_id = :website_id'
)->order(
['dest_country_id DESC', 'dest_region_id DESC', 'dest_zip DESC']
)->limit(
1
);
I haven't tested Magento 2 on develop branch. It looks like the issue persists looking at the code.
Workaround to current release
In the import table rates csv file, sort the rows by order total descending per same destination (country, zipcode, region - all that will create the shipping price condition).
Thank you