5

we are plan to ship only to one default country - so the question is, how to change Magento CE 1.8 cart Estimate Shipping and Tax block - to automatically show (calculate) all shipping methods. By default Magento requires to fill post code - but we will ship only with one country - so the price for any post code is the same.

Any hints how to force Magento to show automatically estimation without filling post code ?

Thank You

2
  • I'v got the same problem as Alex, did you found a solution?
    – Samuel
    Jun 7, 2019 at 13:27
  • This does not really answer the question. If you have a different question, you can ask it by clicking Ask Question. You can also add a bounty to draw more attention to this question once you have enough reputation. - From Review
    – fmsthird
    Jun 7, 2019 at 13:59

1 Answer 1

4

You can:

1) copy file app\code\core\Mage\Checkout\Block\Cart\Shipping.php in the app\code\local\Mage\Checkout\Block\Cart\Shipping.php

2) define method

protected function _getQuote()
{
    return Mage::getSingleton('checkout/cart')->getQuote();
}

3) in the function getEstimateRates add

$this->_getQuote()->getShippingAddress()
        ->setCountryId($country)
        ->setCity($city)
        ->setPostcode($postcode)
        ->setRegionId($regionId)
        ->setRegion($region)
        ->setCollectShippingRates(true);
$this->_getQuote()->save();

where $country and other variables are you pre-defined values.

4) copy the template app\design\frontend\base\default\template\checkout\cart\shipping.phtml into your custom theme and adjust if if needed.

3
  • Hi, for some reason on first load of the cart getGroupedAllShippingRates() is empty, then subsequent visits it isn't. so your code works for all bar the first visit to the cart. Any thoughts? Jun 11, 2015 at 16:29
  • Alex, may be it depends on the Magento version and other extensions. You may check debug back trace and share your findings here. Also, be careful with virtual products bought together with normal products, as they are assigned to different addresses.
    – Amasty
    Jun 19, 2015 at 15:21
  • @AlexHadley, any updates on your question?
    – Roy
    Sep 3, 2015 at 12:27

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.