WooCommerce: “Ship to a Different Address” Opened by Default

When you have special shipping requirements, maybe you want checkout users to see the shipping form section visible on load.

Here’s how you do it. You’ll also find the opposite task in case you happen to have the shipping form opened by default and you want to hide it. Enjoy!

WooCommerce Ship to Different Address Checkbox
WooCommerce Ship to Different Address Checkbox

PHP Snippet: Open “Ship to A Different Address” by Default @ WooCommerce Checkout

/**
 * @snippet       Open Ship to Different Address @ Checkout Page
 * @how-to        Get CustomizeWoo.com FREE
 * @author        Rodolfo Melogli
 * @testedwith    WooCommerce 3.9
 * @donate $9     https://businessbloomer.com/bloomer-armada/
 */


add_filter( 'woocommerce_ship_to_different_address_checked', '__return_true' );

PHP Snippet: Close “Ship to A Different Address” by Default @ WooCommerce Checkout

/**
 * @snippet       Close Ship to Different Address @ Checkout Page
 * @how-to        Get CustomizeWoo.com FREE
 * @author        Rodolfo Melogli
 * @testedwith    WooCommerce 3.9
 * @donate $9     https://businessbloomer.com/bloomer-armada/
 */

add_filter( 'woocommerce_ship_to_different_address_checked', '__return_false' );

Where to add this snippet?

You can place PHP snippets at the bottom of your child theme functions.php file (delete "?>" if you have it there). CSS, on the other hand, goes in your child theme style.css file. Make sure you know what you are doing when editing such files - if you need more guidance, please take a look at my free video tutorial "Where to Place WooCommerce Customization?"

Does this snippet (still) work?

Please let me know in the comments if everything worked as expected. I would be happy to revise the snippet if you report otherwise (please provide screenshots). I have tested this code with Storefront theme, the WooCommerce version listed above and a WordPress-friendly hosting on PHP 7.3.

If you think this code saved you time & money, feel free to join 14,000+ WooCommerce Weekly subscribers for blog post updates or 250+ Business Bloomer supporters for 365 days of WooCommerce benefits. Thank you in advance :)

Need Help with WooCommerce?

Check out these free video tutorials. You can learn how to customize WooCommerce without unnecessary plugins, how to properly configure the WooCommerce plugin settings and even how to master WooCommerce troubleshooting in case of a bug!

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.

68 thoughts on “WooCommerce: “Ship to a Different Address” Opened by Default

  1. Is there a way to use this to open ship to different address for specific user roles? For example I have wholesale users that would normally send to someone else and bill to themselves so for that role having this open for that role would be useful but not for other roles.

    1. Hi Chris, 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!

  2. Hi Everyone,

    I am like 12 and trying to sort out a little project in wordpress – built a website and working stuff out and found this website really hope someone can help me figure how to change the size of text for DELIVER TO A DIFFERENT ADDRESS ? on my checkout page.

    I got a lot of help making it work but the text is to small on checkout.

    looked everywhere for the PHP code that is for this and also looked around the Theme Editor bit but just cant find where this title is in wordpress or woo.

    really appreciate any help please

    trying to figure out how to increase font size for that Title Label DELIVER TO DIFFERENT ADDRESS really and think Im just lost now

    Thanks very much
    Zane

    1. Hi Zane, you’ll need CSS for that, and not PHP. Hope this helps!

  3. Hello Sir !!! I was usig the snippit in reverse (was forcing it to be checked always) through my custom plugin. Worked for first three days but no longer work. I have no Idea Why, can you help please ?

    1. Sounds like a plugin conflict to me

  4. Stopped working for me as well for a few months now. Both in Salient and Avada theme.

    1. Weird, works perfectly for others too

  5. I noticed the delivery address was ticked by default and I can see others reporting the code does not work. After some messing around I found that this code prevented your code from working. in case others were using something similar. I haven’t found a way to get both working together as yet. But im not very good at coding so . . . . :/

    add_filter( 'woocommerce_checkout_fields', 'custom_override_checkout_fields' );
    function custom_override_checkout_fields( $fields ) {
    unset($fields['billing']['billing_company']);
    return $fields;
    }
    1. Thank you!

  6. For those, for whom these snippets didn’t work:
    checkout.js compares billing and shipping fields and if they are different, it triggers click on the “Ship to a Different Address” checkbox on the page load. In my case they were different: I removed some fields in the billing part and forgot to remove them in the shipping part.

    1. Thank you. It works.

      1. Brilliant!

  7. WooCommerce at last has recognized that there is an issue with checkbox activated by default on last WooCommerce 3.9 …. so this it seems that this is not working properly .. in fact in my sites ( storefront and woo 3.9) it’s not working anymore since 3.9

    1. Works for me on 3.9.1

    2. Do maybe have the following plug-in installed? “Checkout Field Editor for WooCommerce”

      I have the same problem. When I deactivate this plug-in the problem no longer occurs.

      1. OOOh. I have the same issue. Lucky. NOT lucky..

  8. Hi Rodolfo,
    This is a neat topic, but doesn’t seem to work with this other nice one :
    DISPLAY CART & CHECKOUT ON SAME PAGE @ https://businessbloomer.com/?p=80321

    Did you use them together in a way it worked ?

    1. Hey Thibault, 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!

  9. Since the woocommerce update 3.9 this snippet no longer works. Do you know why? Or do you have another snippet to use?

    1. Hi there, thanks for your comment! I just tested this again with Storefront theme and it works perfectly. Maybe your theme (or another plugin) is messing/conflicting with my snippet?

      To troubleshoot, disable all plugins but WooCommerce and also switch temporarily to “Twentyseventeen” theme (load the snippet there in functions.php) – does it work? If yes, you have a problem with your current theme or one of the plugins.

      Hope this helps!

      R

      1. Hi
        I have the same issue. Just upgraded to 3.9 and it stopped working.
        always showing “ship to a different address” checked.
        I switched to Twenty Twenty + Storefront
        Not working on both. can you advice?

        1. Works for me on 3.9.1

  10. Hi Rodolfo,

    I want to confine shipping country in the “ship to a different address?” section based on billing country.

    As an example, if a customers billing country is United States, I only want orders to be able to shipped to within the United States. The can use a different shipping address but it must be within the United States.

    I want to do the same with some other countries, like Romania, Hungary etc as I need to cut down on credit card fraud.

    But I want to leave other countries open, Such as Australia and New Zealand.

    Is there a plug-in or a way you can code this?

    Thanks

    1. Hello Charlie, 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!

  11. Thanks! This was exactly what I needed 🙂

    1. Cool!

    1. Awesome

  12. Still works! 😉

    1. Great!

  13. Whenever when I have a problem to solve, after search in google, I find you with the exactly solution! Thank you my friend!

    1. Fantastic!

  14. Still works 😉

    1. Awesome!

  15. It works fine, thanks

  16. Thanks for this – and all your tips! They have saved me much research time.

    Question: Can I hide the “Ship to a Different Address” title altogether based on chosen_shipping_method? (Not just uncheck it)

    I tried this code, but it throws an error: (the ‘hideshipto’ script adds CSS to hide the title)

    add_action( 'init', 'fb_ship_to_open' );
    function fb_ship_to_open() {
        global $woocommerce;
    	if ( !is_admin() && WC()->session->get( 'chosen_shipping_methods' ) ) {
    			$chosen_methods = WC()->session->get( 'chosen_shipping_methods' );
    			$chosen_shipping = $chosen_methods[0];
    				if ('flat_rate:9' == $chosen_shipping ) {
    					add_filter( 'woocommerce_ship_to_different_address_checked', '__return_true' );
    				} else {
    					add_action( 'wp_enqueue_scripts', 'fb_load_ship_script' );
    					function fb_load_ship_script() {
    						wp_enqueue_script( 'hideshipto');
    					}
    				}
    		  }
    	}
    

    Is there an easier way to do this? Or am I just adding to the wrong hook?

    1. Diana, 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

  17. Hi, i try using both code but nothing works out for my site. I’m using bazar theme and my checkout page still only show billing address

    1. Hello Lea, thanks so much for your comment! I just retested this on the latest version of WooCommerce and it still works. Unfortunately this looks like custom troubleshooting work and I cannot help here via the blog comments. Thanks a lot for your understanding! ~R

  18. Hi. Could you tell me how to swap the positions of the billing and shipping address fields around – so that shipping address is on the left and opened by default, and billing address is on the right, closed by default. Please let me know! Thank you in advance. 🙂

    1. Hey Peter, 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

  19. hello for some reason this option “ship to a different address” disappears for logged in customers/users. Do you know how to force it to always be there?

    1. Hey there, thanks so much for your comment! Have you tried using snippet #2?

  20. Worked great! I added it to a custom plugin, which is my preferred method for adding quick functionality (I’m using the default Storefront theme with no child theme).

    1. Cool, thanks Stephanie 🙂

    2. Hi Stephanie and Rodolfo,

      I cannot seem to make this code snippet work on my site by adding it to my child theme’s “functions.php” file.
      Do you mind letting me know where did you add the code exactly? which plugin?

      Thank you very much.

      1. Try with the “Code Snippets” plugin, and see if that works for you 🙂

  21. Hi Rodolfo,

    Is it also possible to entirely remove the option of shipping to a different address?

    Thanks so much.

    1. Hey Geert, thanks for your comment! You can force “shipping to billing address” in the WooCommerce settings, and then completely remove the shipping form via simple PHP if that’s what you’re asking for. Let me know!

    2. Great, the forcing did the job. Thank you!

      Last question: in Europe it’s necessary to have the VAT number for invoicing. Is it possible to add an optional field so customers can input their VAT number?

      1. Awesome – great to hear that! Yes, of course, VAT can be added. There is an official WooCommerce premium plugin, or otherwise this can be coded pretty easily via custom PHP 🙂 Let me know!

        1. I figured out a way Rodolfo. Thanks a lot for the support!

  22. This was perfect. Thanks for a nice easy fix to seeing a bunch of ugly fields by default (used the closed by default version). Thank you!

    1. Awesome, thanks for your feedback Aaron!

  23. I was trying to add this using both my Snippets plugin and on the functions.php file of the theme (Flatsome)

    It seems like nothing works and the SHIP TO A DIFFERENT ADDRESS? checkbox is still on by default.

    What can be the cause of that?

    I am pasting the code exactly like that, should I change something maybe?

    Will appreciate your help on this!

    Best regards,
    Daniel

    1. Hey Daniel, thanks for your message! I believe your theme is already overriding something with the same hook, however I can’t prove that unless I take a look at your theme files. If this is the case, then you’re trying to execute some code too early, and then your theme changes that around again. You will ned to search for the filter “woocommerce_ship_to_different_address_checked” through the Flatsome files to see if I’m right. Best of luck 🙂

  24. Hi man, I would like to have the Shipping fields open be default but the checkbox uncheck.

    Text above next to the checkbox should say: “Deliver to billing address?”
    Then once the user checks this box (yes I would like to have it delivered to my billing address)
    Then the shipping form disappears.

    I have been trying to edit the form_shipping.php file but can change the text but can not get the checkbox to swop its value.

    Please help

    1. Hello Christo, thanks a million for your comment!

      As all PHP customization, yes, this seems possible – unfortunately this is custom development work and I cannot provide this solution on the blog right now. I will add it to my to-write list but I cannot guarantee I will be publishing this within 2-3 months.

      If you would like to get a quote for the fix, feel free to go here to get in touch.

      Thanks for your understanding!

      ~R

  25. Where i to edit / add this code for our site ?

    1. Hey Grosir, thanks for your comment! You should add this in the functions.php file of your child theme. See this tutorial if you don’t know what that means 🙂

      1. Hi Rodolfo, thanks for your reply & response..
        God bless you!

        1. about that link, i was subscribe on your site.. but are the script just add in functions.php only ?

          1. Yes, all these scripts (snippets) go into the functions.php only. Sometimes, some of them have CSS and that would go into style.css. Hope this helps!

  26. Awesome tip, thanks, exactly what I was looking for. I sell a lot of gift cards so I wanted the ‘Order Notes’ text box prominently shown and this fix fit the bill perfectly.

    1. Thanks for your feedback!

Questions? Feedback? Support? Leave your Comment Now!
_____

If you are writing code, please wrap it between shortcodes: [php]code_here[/php]. Failure to complying with this (as well as going off topic, not writing in English, etc.) will result in comment deletion. 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 BloomerArmada to get blog comment reply priority, ask me 1-to-1 WooCommerce questions and enjoy many more perks. Thank you :)

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