WooCommerce Shipping – Hide checkout fields based on shipping method

[vc_cta h2=”The Below Code Works for the Following Plugins:”]

[/vc_cta]

In many cases, you to show the Billing Address field.

Using the below code snippet, one can easily hide any checkout field when a particular shipping method is selected.

Just copy and paste the snippet in Appearance –>Edidone!

As we can see, in the above snippet, on selecting “Free Shipping” as a shipping method in the cart page, Billing address 1 and 2 are hidden from the checkout page. This can be validated from the screenshot shown below:


10 thoughts on “WooCommerce Shipping – Hide checkout fields based on shipping method”

  1. $shipping_method =’free_shipping:1′; // Set the desired shipping method to hide the checkout field(s).

    How to add more than one shipping method?

  2. Good evening, I am trying to use your method but it does not work for me at any time, this version designed in the concrete version of woocommerce? I want to do it with a local environment, without free shipping, but I do not understand why you put free_shipping:1, the number 1 where it comes from?

    Greetings and thanks

    1. Hi,

      This snippet is designed to hide checkout fields based on the ‘Shipping method’ value(free_sipping:1 is the value of that method). You can get the shipping method value by inspecting a shipping method.
      – Select a shipping method –> Right Click–> Inspect–> You can see the ‘Value’ of that method.

    1. Hi Justin,

      Once the hipping method is selected the values will be shown based on this Method. However, when you switch to any other method, WooCommerce will show the previously cached values. Hence, in order to avoid displaying cached values, you would need to refresh the page.

  3. I am trying to get this to work when using the table rate plug-in. I want to hide the shipping address if the following is true:

    I have been trying it by setting my shipping_method=’table_rate:10:1′, but that is clearly not right. Ideas?

    1. Hi @carin,

      This snippet will hide only specific fields of Billing address.
      However, you do have an option to change the default shipping destination fields in WooCommerce shipping options.
      WooCommerce–> Shipping Options–> Shipping Destination –> (select) Default to customer billing address.

      Once done, “Ship to a different address” will not checked by default.
      Hope that helps!

  4. Thank you Anindo for the reply.

    Hiding in checkout a custom_field based on ‘Payment method’ is tricky? 🙁

    Ho good!

    Regards,

  5. Great tutorial!

    thanks.

    But how can i hide field based on gateway choice?

    $payment_method instead of #shipping_method ???

    1. Hi,

      This snippet is designed to hide checkout fields based on ‘Shipping method’ only.
      Also it would not be practically possible to hide any checkout fields based on ‘Payment method’. This is because, you will be directed to ‘Payment method’ only after you complete the initial process of filing in checkout fields.
      Hence, hiding checkout fields based on ‘Payment method’ is quite tricky to acheive.

      Regards,

Comments are closed.

Scroll to Top