WooCommerce: How to Hide “Shipping Calculator” Fields @ Cart

The “Shipping Calculator” can be enabled via the WooCommerce settings in order to give the user a way to calculate their shipping fees before getting to the Checkout Page. Usually they fill out the country, state, city and postcode form fields and click on “Update Totals” in order to calculate the shipping.

However, what if you only calculate shipping based on country? Or what if you only charge by zip code / postcode? In this case, you will need to hide the input fields you don’t need, and make UX better.

Well, here are some WooCommerce filters you can use from WooCommerce version 3.4 onwards to hide the fields you like (apart from country, which is mandatory).

WooCommerce: how to hide shipping calculator input fields

PHP Snippet: Hide “Shipping Calculator” Fields @ WooCommerce Cart

/**
 * @snippet       Remove Shipping Calculator Fields - WooCommerce Cart
 * @how-to        Get CustomizeWoo.com FREE
 * @author        Rodolfo Melogli
 * @compatible    WooCommerce 5
 * @community     https://businessbloomer.com/club/
 */
 
// 1 Disable State
add_filter( 'woocommerce_shipping_calculator_enable_state', '__return_false' );

// 2 Disable City
add_filter( 'woocommerce_shipping_calculator_enable_city', '__return_false' );

// 3 Disable Postcode
add_filter( 'woocommerce_shipping_calculator_enable_postcode', '__return_false' );

Where to add custom code?

You should place custom PHP in functions.php and custom CSS in style.css of your child theme: where to place WooCommerce customization?

This code still works, unless you report otherwise. To exclude conflicts, temporarily switch to the Storefront theme, disable all plugins except WooCommerce, and test the snippet again: WooCommerce troubleshooting 101

Related content

  • WooCommerce: How to Fix the “Cart is Empty” Issue
    For some reason, sometimes you add products to cart but the cart page stays empty (even if you can clearly see the cart widget has products in it for example). But don’t worry – it may just be a simple cache issue (and if you don’t know what cache is that’s no problem either) or […]
  • WooCommerce: “You Only Need $$$ to Get Free Shipping!” @ Cart
    This is a very cool snippet that many of you should use to increase your average order value. Ecommerce customers who are near the “free shipping” threshold will try to add more products to the cart in order to qualify for free shipping. It’s pure psychology. Here’s how we show a simple message on the […]
  • WooCommerce: Cart and Checkout on the Same Page
    This is your ultimate guide – complete with shortcodes, snippets and workarounds – to completely skip the Cart page and have both cart table and checkout form on the same (Checkout) page. But first… why’d you want to do this? Well, if you sell high ticket products (i.e. on average, you sell no more than […]
  • WooCommerce: Weight-Based Shipping Methods
    With WooCommerce you get 3 default shipping methods: Flat Rate, Free Shipping, Local Pickup. For each one you can define a cost, however there is no way to set up some “weight” restrictions. So, what if you want to display a rate for orders below 10 kg, and another shipping rate for orders above that […]
  • WooCommerce: Hide Shipping Method If Shipping Class Is In The Cart
    Our goal is to check if a Product with a specific Shipping Class is in the Cart, and consequently disabling a shipping rate such as Free Shipping if this is true. This is super useful when there are multiple items in the cart and you don’t want to give free shipping for certain orders for […]

Rodolfo Melogli

Business Bloomer Founder

Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as an independent WooCommerce freelancer since 2011. His goal is to help entrepreneurs and developers overcome their WooCommerce nightmares. Rodolfo loves travelling, chasing tennis & soccer balls and, of course, wood fired oven pizza. Follow @rmelogli

34 thoughts on “WooCommerce: How to Hide “Shipping Calculator” Fields @ Cart

  1. Hmm. It doesn’t display the options, but it then doesn’t seem to calculate the shipping options when you submit it, just returning the calculate shipping string.

    We have a bunch of shipping zones which determine shipping methods based on the postcode, so you’d expect it to only need the postcode field, but if you hide any of them via this method, the calculator stops working.

    1. I find that weird. Anyhow, you can always hide those fields with CSS instead?

  2. Thanks a lot! How to always show fields no clicking ‘Calculate shipping’?

    1. You’re welcome! Not sure I follow

  3. Shipping fees not calculated when the zip code is disabled on WooCommerce 5.1

    1. Ouch! Do you get any specific PHP error?

  4. Is it possible to add additional dropdowns in the shipping calculator? I would like the option for customers to select between a residential and business address.

    1. Hi Larissa, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

  5. Thanks a lot! Works even in woo 4.0

    1. Great!

  6. If you want keep the state dropdown but remove the City dropdown & Zip code input, you can do this via CSS:

    .input-text[name="calc_shipping_city"], [name="calc_shipping_postcode"] {
       display: none;
    }
    1. Nice!

      1. Chuckers – Thanks works a treat. Needed to remove state & city fields so adjusted the code a little. Topman

        Rodolfo – is there any .css that you can use to change the ‘calculate shipping’ to say ‘Please enter postcode to calculate shipping’?
        I have inspected the element and tried copying the code but an error on .css
        Any advice would be appreciated.
        Thanks
        Fastamir

  7. Perfect!!! Thank you

    1. Great!

  8. Le code est parfait ! merci

    1. Cool!

  9. Hi, this still works. I was wondering if it was possible to set a default country in the shipping calculator.

    1. Hi Jorp, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

  10. Still works, thank you.

    1. Great!

  11. It still works! thank you…

    1. Awesome!

  12. hi !is there any way to add shipping calculator to woocommerce checkout page?

    1. Owais, thanks so much for your comment! Yes, this is possible – unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. Thanks a lot for your understanding! ~R

  13. Hi. I only ship in the US. I have a flat rate and free shipping if order is over a $ value. I have this working great. How can I show shipping cost on the Cart page without needing the address input (as it isn’t needed for my shipping methods)? Woo seems to calculate this shipping without an address because the Checkout page has the shipping calculated properly without an address. I tried setting Default Customer Location to Store Location but that added sales tax for my store location as well. Thank you!

    1. Hey Tania, thanks so much for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. Thanks a lot for your understanding! ~R

  14. Worked perfectly thanks. However, I am also one who only ships to the to US locations and so it seems odd to customers to have to click US, especially when it is easy to not have to have that as a required field on the checkout page using a plugin.

    Someone need to develop a plugin to set the country field on the cart page to a particular country and have that automatically hide the country field.

    1. Good thinking John – thanks so much for your comment! Maybe you want to suggest that to Woo developers here: https://github.com/woocommerce/woocommerce/issues > new issue

  15. Hi,
    My shipping is local and charges are based on the zip-code, so I wanted to hide the country and state fields, as these will always be the same. The problem is, when I do it, the shipping calculation doesn’t work for new clients, probably because woocommerce needs to know the country and maybe state too to do it correctly. Is it possible to set the relevant variables and then hide the fields?

    1. Hello Dimitris, thanks so much for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. Thanks a lot for your understanding! ~R

  16. Thanks!
    Is it possible to hide the block Shipping itself (IE shipping, IE fast shipping, etc. in your example) on the cart page?
    Shipping will be calculated, depending on postcode filled in on the checkout page. I’d like to have shipping details on checkout page only.

    1. Hey Mieke, thanks so much for your comment! You should be able to hide shipping costs from the WooCommerce settings ๐Ÿ™‚

Questions? Feedback? Customization? Leave your comment now!
_____

If you are writing code, please wrap it like so: [php]code_here[/php]. Failure to complying with this, as well as going off topic or not using the English language will result in comment disapproval. You should expect a reply in about 2 weeks - this is a popular blog but I need to get paid work done first. Please consider joining the Business Bloomer Club to get quick WooCommerce support. Thank you!

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