1

I want to get all the available shipping methods along with their prices by postCode and countryId in a page which is not Checkout page.

Example: I have CountryId as 'IN' and postCode as '560029' in a phtml file of backend orders page. Now i want to get all the available shipping methods with their prices which will be displayed for the customer in frontend in checkout page as follows.

enter image description here

Please let me know how can i get all the shipping methods with their prices using countryId and postCode.

2

Thank you Magento Stack Exchange Viewers,

I found the answer in one of the Question - Magento : Get all Shipping Rates

and the answer is:

// Change to your postcode / country.
$zipcode = '560029';
$country = 'IN';

// Update the cart's quote.
$cart = Mage::getSingleton('checkout/cart');
$address = $cart->getQuote()->getShippingAddress();
$address->setCountryId($country)
        ->setPostcode($zipcode)
        ->setCollectShippingrates(true);
$cart->save();

// Find if our shipping has been included.
$rates = $address->collectShippingRates()
                 ->getGroupedAllShippingRates();

foreach ($rates as $carrier) {
    foreach ($carrier as $rate) {
        print_r($rate->getData());
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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