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(); $shippingAddress->setCountryId("US") ->setCity("New York") ->setPostcode("11209") ->setRegionId("") ->setRegion("") ->setCollectShippingRates(true)->collectShippingRates(); $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.