Always show shipping costs in Magento

Sometimes you just need one shipping method, or perhaps 99% of your customers use a specific method. This is often the case for European shops serving just one country. By default, Magento allows customers to get a quote estimate for shipping costs in the cart page.

The customer has to set it’s country and select the appropriate method in order to get a correct quote, including the shipping costs. In the scenario I mentioned earylier, it could be best to just set the country and shipping method by default. This way the customer will always get a price including shipping costs. Never again will they be surprised by a higher then expected price at the end of the checkout process!

A solution
So how to achieve this? Well… One can write a small extension that catches Magento’s sales_quote_collect_totals_before and set a shipping method if none is set. This shipping method then should be configurable from Magento’s backend. Not into writing code? Check the attachment. Download the extension here. I tested it in Magento CE 1.4, 1.5, 1.6. Should work in 1.7 as well.

Magento always show shopping costs

Magento always show shopping costs

Instructions for installing this extension:
1. Download the zip (DUH!)
2. Extract it’s contents to the root of your Magento installation. You can use FTP to do that. It’s the directory containing index.php [App] [Skin] [Media] among others
3. Log in to your Magento backend
4. Go to System -> Cache Management, select all options, and in the action dropdown select “Refresh”. Then click Submit.
5. Log out/in to your backend
6. Go to System -> Configuration -> Shipping Settings and drop down the “Origin” selection
7. This extension adds two new options here; “Apply defaults to empty quote” and “Default shipping method”
8. Set “Apply defaults to empty quote” to “Yes” , set “Default shipping method” to your preferred shipping method. And make sure “Country” is set.
9. Click save config.
10. All done!

When a customer visits your site and starts adding stuff to his shopping cart, all prices will be shown including shipping costs! (If this does not happen the first time you visit your site yourself, clear all your cookies, as you might still have an active quote present, in which case the extension will leave it alone).

How does this work… I mean in code…?
Well… The extension uses a simple observer to check if the shipping address has a country set. If it does not (which is the case for an empty quote) it will set one including the default method. Pretty simple stuff!!

Update 7/9/12: Idev OneStepChecout bug
Stevan from Enigma Webdesign reported an issue with Idev OneStepChecout. As it turns out the Idev OSC extension “assumes” a billing address is present in the quote when a shipping address is found. This causes the OSC to load with no valid billing address, and as a result, it will show the default country with just the default payment method.

One can work around this by using this version of the extension when using Idev OneStepChecout. This update will set a billing address as well as the shipping address, to enable Idev OCS to work. Set the “Apply defaults to billing address” option in “System -> Configuration -> Shipping Settings” to Yes. Download the update here.

Like this free extension?
Let us know, and like our Facebook page!

60 thoughts on “Always show shipping costs in Magento

  1. Hi Pieter,

    I’ve installed and configured the extension and it does set the country code on an empty quote. I did see my shipping costs the first time I viewed my cart. But after adding another product to my cart, the shipping costs didn’t show up.
    Because the country code was already set, your extension did not do anything anymore. But the shipping costs are gone.

    I tested with several shipping options, like flatrate, and tablerate.

    Any idea?

    • Hi Maikel,

      Hmm. It should not remove the costs when adding another product (and it doesn’t). Check out a demo here; (It will set the destination to Malta, don’t ask me why I picked Malta).

      After adding a second product to my cart it will just update the costs like it should. The demo shop is setup with flatrate.

      So I guess the issue is lies elsewhere. Here is how I would go about debugging;

      1. Disable the module under System -> Configuration -> Advanced -> Disable RapidCommerce_DefaultDestination. Then flush your cache.
      2. Clear your browsers cookies so you loose your quote if you have one.
      3. Make sure the “Estimate Shipping and Tax” block in the shopping cart is enabled.
      4. Put one product in your cart.
      5. Estimate costs.
      6. Put the second product in your cart.
      7. Check if the costs are still ok
      8. Estimate costs.
      9. Check if the costs are still ok.

      Could you do that and come back to me? That way I know how you shop behaves by default.


  2. Ok, I’m working on a shop for a client, de shop was not build by me. It’s an older Magento version with the ‘Estimate Shipping and Tax’ disabled. I think that will be the problem.

    I’m going to enable it and see what happens. Thanks so far.

  3. If I understand correctly; this extension will only work with Estimate Shipping Costs enabled?
    Any solution with this disabled?

    • Hello Annemieke,

      No… It will work without the “Estimate Shopping Costs” block on the cart page.

      It will actually have the same effect as a visitor using the block to set their country to your default shipping country (without requiring this block). So it makes this “Estimate Shopping Costs” block obsolete.

      Groetjes, Pieter

  4. Hi there,

    I really would like to use your extension in Magento 1.7.0. but I can’t seem to download it.
    My customer has 2 products in the enrtire shop and one uses shipping in the cart. Sometimes Magento shows shipping costs but not always so I really need this extension. Could you please e-mail it to me or give a link?



  5. Thank you very much for this, it was exactly what I was looking for. Customers had been abandoning their carts as they didn’t know what shipping would cost, and couldn’t be bothered to fill out all their details just to find out. Once again, thanks a lot, I never usually leave comments either!

  6. Hi

    Thanks for this. Although I have a problem. My store is setup to give free shipping on cart value above £30 and a fixed £2.70 below £30. This works fine, however when applying your extension it now shows a delivery charge, even if the cart value goes above £30.

    • Hi Tom,

      Did you try the version with the OSC fix (see the update part of this article)? Which extension are you using for the fee? Fooman Surcharge?

      • Hi Pieter

        Thanks for this extension. It’s very useful, however I have the same issue as Tom S.

        We offer a flat delivery charge of £7.95 but have set free delivery for orders over £75.

        The problem is that the free delivery charge is being ignored. Whatever amount the shopper adds to their cart, the flat rate delivery charge is always being displayed even when the shopper is ordering over £75.

        I have installed the version with the OSC fix but this does not make a difference.

        Can your extension be made to apply free delivery when the shopper’s cart value is over the relevant threshold?



        P.S. – This is important to us, so happy to pay for a solution. Just let me know.

  7. Hello,
    Your extension is working just fine.
    I am having some products with free shipping and other with flat rate.
    So i need to call your function if any item in my cart is having paid shipping. In this case i dont need customer to select shipping method in checkout step.
    I hope you can guide me, what to do

    • Yes sure I can, the file app/code/local/RapidCommerce/DefaultDestination/Model/Observer.php sets the ‘auto’ shipping method in ‘->setShippingMethod($method)’.

      You could loop your shopping cart products and set another method (the method uses a code, you can find in the shipping module code).

      If you need more specific help or some example code, let me know.

  8. i did some changes and managed to set two different shipping methods according to the products.
    But in checkout step it is saving state and postcode retrieved by following statements
    $state = Mage::getStoreConfig(‘shipping/origin/region_id’);
    $postcode = Mage::getStoreConfig(‘shipping/origin/postcode’);

    it should save the address which customer is providing.

    • I don’t exactly get your question.

      Where did your customer already provide the postcode and region in the checkout process? And If the country is not overridden, what does it matter?

      Hope I can help.

      • Thanks for replying Pieter,
        In observer.php we used the origin address(provided in backend) to save the shipping method. And customer provides his/her billing+shipping(i am using same for both) details in checkout page(2nd step). So in order details i am not getting the address provided by customer but gettting the address used in observer.php.

        • Hmm. Did you remove the if statement that checks if an address already exists in observer.php? It should not touch the address again after it has been “touched” by the customer…

  9. Does anyone have any experience with this extension and matrix rate shipping extension in Mage CE 1.5?
    When I go to the shipping settings in the backend I get the error a:5:{i:0;s:48:”Invalid model for shipping method: productmatrix”;i:1;s:1902:”#0 /app/code/core/Mage/Shipping/Model/Config.php(104): Mage::exception(‘Mage_Shipping’, ‘Invalid model f…’)

    • Hallo Sander,

      Yes er zijn issues tussen beiden. Een exception heb ik echter nog niet eerder gezien. Er zijn wat aanpassingen nodig in de Matrix extensie om beiden naast elkaar te laten werken.

    • Hi Arnold.

      The right way
      – In you your design package, create a local.xml (/app/design/frontend/MYPACKAGENAME/default/layout/local.xml) which contains;

      < ?xml version="1.0"?>

      A worse but easier way;
      Edit /app/design/frontend/MYPACKGE/default/template/checkout.xml. If it does not exist copy that from /app/design/frontend/base/default/template/checkout.xml
      And remove;


      The n00b way;
      Edit /app/design/frontend/frontend/MYPACKAGE/default/template/checkout/cart.phtml.

      < ?php if (!$this->getIsVirtual()): echo $this->getChildHtml('shipping'); endif; ?>

      The I really want to, but can’t, please shoot me, way;
      Edit /skin/frontend/MYPACKAGE/default/css/styles.css

      .cart-collaterals .col2-set .shipping { display: none; }
  10. Hi there,

    The extension is absolutely fine. But I want to restrict the customer from going to checkout process/paypal if customer does not choose any shipping option. We need to make shipping options as required in shopping cart page. Please help me out on this.

    • Hi Rajesh, you mean the customer has to choose a method in the estimate shipping/tax block in the cart index page?
      If not the proceed to checkout button should be disabled?

      • Yeah that is correct. If not check out button as well as paypal express check out button should be disabled or we can make shipping options as ‘required’ as ask customer to update the total before they checkout or proceed to paypal.

  11. Hi Pieter,

    This extension works great on CE 1.7.0.

    We have a free shipping option in orders above $80. I wonder if it could be possible for this extension to display “Free shipping” in the cart for orders above that amount? (instead of displaying the default shipping method)


    • Hello Luis,

      The free option, is that an option of the shipping method you set as the default using the extension? Or is it that a separate shipping method?

      • Hello,

        Using the extension I set as default flate rate shipping. However we enabled in magento back-end the free shipping option on orders above $80.

        When items in the cart are $80 or more, free shipping option does not appear. It still appears the flat rate option, and I would like the cart displays “free shipping”


  12. I just installed the module on Magento CE However, it does not seem to work.

    When I put a log into the observer function, it does not seem to load.

    I am using OSC and the fix of this plugin for OSC. Anyone else having problems on

  13. I have a problem whith coupon cart price rules, when the module is enabled if you write a coupon it never applies.

    Disabling the module the same rule is applied without problem.

    Is this a known issue? Looking the observer code there is a code to get the quote and later save it again. It is possible that this process lose teh coupon.

    Regards, Alberto.

  14. Hi there,
    i have a problem with free cart rules. I have the rule to set the shipping fee to “0” if the weight > 23.

    The first time, the customer adds a product with a weight “1” in qty of “24” or above in the cart, the shipping costs are the flat fee.. a refresh of the cart shows then the correct 0,- shipping cost. Is it a problem with any observer not set ? or is it a custom magento bug?

    thank you for your help :)

    • We have a new version available which should solve your problem, but we need to make a post. Contact us on facebook and we’ll send you the new version.

  15. If anyone else got an issue with login in checkout like i did (Magento 1.8.0 CE)
    edit the Observer.php File like this:

    public function handleCollect($observer) {
    $pageIdentifier = Mage::app()->getFrontController()->getAction()->getFullActionName();

    if($pageIdentifier == ‘customer_account_loginPost’){
    return $this;

    if ( !Mage::getStoreConfig(‘shipping/origin/applydefaultstoemptyquote’) )
    return $this;

    $quote = $observer->getEvent()->getQuote();
    $shippingAddress = $quote->getShippingAddress();
    $billingAddress = $quote->getBillingAddress();
    $saveQuote = false;
    if (!$shippingAddress->getCountryId()) {
    $country = Mage::getStoreConfig(‘shipping/origin/country_id’);
    $state = Mage::getStoreConfig(‘shipping/origin/region_id’);
    $postcode = Mage::getStoreConfig(‘shipping/origin/postcode’);
    $method = Mage::getStoreConfig(‘shipping/origin/shippingmethod’);


    $saveQuote = true;
    if (Mage::getStoreConfig(‘shipping/origin/applydefaultstobillingaddress’) && !$billingAddress->getCountryId()) {
    $country = Mage::getStoreConfig(‘shipping/origin/country_id’);
    $state = Mage::getStoreConfig(‘shipping/origin/region_id’);
    $postcode = Mage::getStoreConfig(‘shipping/origin/postcode’);


    $saveQuote = true;

    if ($saveQuote)
    return $this;

  16. Hi,

    Ik gebruik jullie extensie Default Destination en heb de default shipping method set op flat rate.
    Nu wil ik graag gaan werken met gratis verzending vanaf 40 euro en wil dit uiteraard ook direct zichtbaar maken in het winkelmand-overzicht. Nu ziet de klant echter gewoon mijn standaard verzendtarief en komt er bij afrekenen pas achter dat er ook een optie gratis verzenden is.
    Hoe kan ik op winkelmand niveau al de Gratis Verzending laten zien?


  17. above solution for login problem also seems to work for magento

    one remark, i had to replace all the quotes

    for example:




    for it to work

    Michel Vinke

  18. Hello,

    Installed this on Magento 1.9 CE and it broke the onepage checkout login. When a customer tries to login, he is redirected back to the login page. Nothing happens.

    Any ideas?

    If the observer file needs edit, what would be the filepath?

    Bryan Veloso tried editing observer.php but that didn’t work on Magento 1.9

    Any possible solutions?

    Thank you.

  19. Hi Pieter,

    You had raised a hot issue that is facing by my most of the customers at checkout Page about shiping cost. So if you want to avoid these problems in front of your customers then you need to install some pLUG-in for it as you mentioned earlier. As an experienced Web developer I also recommend a Module will be beneficial for Merchants and their customers.

  20. Magento 1.9 with IWD OPC worked for me. The first time it didn’t, but i reinstalled it. Enabled all cache, refreshed all cache, disabled all cache. Edited settings and it was there. The only issue i had is that I didn’t want the default state and postal code entered because of Tax. After fixing that in the code, it’s brilliant. Thanks for such a quick and simple fix. I spent the last 2 full days on it and kept getting close, but never was quite right.

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>