I want to display a custom notice on cart page "if customer's order total above $299, then he is qualified for free shipping". For that I have imported following table rates:

Country | Region/State | Zip/Postal Code | Order Subtotal (and above) | Shipping Price

US | * | * | 0 | 15

US | * | * | 299 | 0

I can get single table rate using collectRatesByAddress() function of \Magento\Shipping\Model\Shipping class, but I can't get multiple table rates. Please see sample code as follows:

$quote = $this->_checkoutSession->getQuote();
$shippingAddress = $quote->getShippingAddress();
            ->setCity("New York") 

$shippingCarrier = 'tablerate';
$carriers[$shippingCarrier] = '';

$result = $this->_shippingModel->collectRatesByAddress($shippingAddress, array_keys($carriers))->getResult();

foreach ($result->getAllRates() as $rate) {
    echo $rate->getPrice();

Please give me any solution/suggestion/hint to resolve this problem.

Thanks in appreciation.

1 Answer 1


Have you tried using the method \Magento\Shipping\Model\Shipping::collectRates ?

Or, Alternatively you may query the database table shipping_tablerate which has the table rates stored in it.

  • After investigation, I found that collectRatesByAddress() returns applicable table rate data based on subtotal. So finally I used suggested alternate solution. @nikin Thank you for the guide lines. Dec 7, 2018 at 6:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.