WooCommerce: Add Shipping Phone @ Checkout

I’m surprised WooCommerce doesn’t offer this field out of the box. Most ecommerce websites actually require a shipping phone to organize delivery and communicate with the end customer in case there are problems.

Thankfully, there is a hook (filter) for that. It’s called “woocommerce_checkout_fields” and can be used to remove, move or add checkout fields quickly. And here’s how to add, for example, a new shipping field called “shipping_phone”. Enjoy!

How to create a new checkout field: shipping phone

PHP Snippet: Display Shipping Phone @ Checkout Fields

/**
 * @snippet       Shipping Phone & Email - WooCommerce
 * @how-to        Get CustomizeWoo.com FREE
 * @author        Rodolfo Melogli
 * @compatible    WooCommerce 6
 * @community     https://businessbloomer.com/club/
 */

add_filter( 'woocommerce_checkout_fields', 'bbloomer_shipping_phone_checkout' );

function bbloomer_shipping_phone_checkout( $fields ) {
	$fields['shipping']['shipping_phone'] = array(
		'label' => 'Phone',
      'type' => 'tel',
		'required' => false,
		'class' => array( 'form-row-wide' ),
      'validate' => array( 'phone' ),
		'autocomplete' => 'tel',
		'priority' => 25,
	);
	return $fields;
}
 
add_action( 'woocommerce_admin_order_data_after_shipping_address', 'bbloomer_shipping_phone_checkout_display' );

function bbloomer_shipping_phone_checkout_display( $order ){
    echo '<p><b>Shipping Phone:</b> ' . get_post_meta( $order->get_id(), '_shipping_phone', true ) . '</p>';
}

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: “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: Disable Payment Method If Product Category @ Cart
    Today we take a look at the WooCommerce Checkout and specifically at how to disable a payment gateway (e.g. PayPal) if a specific product category is in the Cart. There are two tasks to code in this case: (1) based on all the products in the Cart, calculate the list of product categories in the […]
  • WooCommerce: Add Privacy Policy Checkbox @ Checkout
    Here’s a snippet regarding the checkout page. If you’ve been affected by GDPR, you will know you now need users to give you Privacy Policy consent. Or, you might need customer to acknowledge special shipping requirements for example. So, how do we display an additional tick box on the Checkout page (together with the existing […]
  • WooCommerce: Redirect to Custom Thank you Page
    How can you redirect customers to a beautifully looking, custom, thank you page? Thankfully you can add some PHP code to your functions.php or install a simple plugin and define a redirect to a custom WordPress page (as opposed to the default order-received endpoint). This is a great way for you to add specific up-sells, […]

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

28 thoughts on “WooCommerce: Add Shipping Phone @ Checkout

  1. Hello,
    Thanks for the code. However I believe it would be better to use “woocommerce_shipping_fields” filter to add new field. With this filter new phone filed will be added to the forms under customers’ “/my-account/edit-address” page

    1. Thanks for your feedback!

  2. Thanks! I just added the snippet to my website and it works great.
    Quick question – is there a way to make it mandatory (rather than optional)?
    Thanks!

    1. Great! Try with ‘required’ => true

  3. Just added this and works great. Thank you

  4. This is great. Can you tweak it a bit to behave more like the billing phone field where only numbers, brackets and dashes are allowed? I tried setting the type as ‘tel’ with no luck. I also tried ‘number’ but I’m not getting it to quite matchup to the billing phone field.

    1. Thanks for your feedback, Anan. Changed the snippet a little, check it out

  5. Hi,
    Thanks a lot for the snippet! It works great.

  6. Hi there,

    Thanks a lot for the snippet! It works like a charm.

    Is there a way to get the phone number in emails as well? is there a short code for it? Am trying to add it to my email customizer builder.

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

      1. adding phone in the email should be part of this. Come on Rodolfo, you’ll be charging 100 USD just to show us how to do this?

        1. I have this already in other snippets on this same site: https://www.businessbloomer.com/woocommerce-add-custom-checkout-field-php/ (part 3).

          As you can see, I share all my knowledge for free, so I charge only when the customer has no time or knowledge. You simply had to do a search on Business Bloomer, but it seems you didn’t have the time lol

  7. I just added this and it still works ๐Ÿ™‚

    1. Great!

  8. Thanks! I love your website – I learned a lot from your code snippets and started always looking for code-snippet solutions instead of adding plugins for everything!

    I added this code and it shows up correctly in the checkout page. How to add a second field (shipping email for example) in addition to the first field?

    1. Hello Judith, 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. congratulations for the code and thanks. Is it possible to make the field editable from backend? because when I have to add orders manually I can’t enter the number

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

    I’m Nani.
    I’ve added this kind of thing, but somehow now showing the phone number in email.
    How to solve that?
    Thanks.

    1. Hi Nani, I don’t fully understand. Can you provide a screenshot please?

      1. I guess the question was how to have the recipient’s phone visible in the new order email (shipping address details) – there should be a line of code that adds shipping phone number in the new order email template.

        1. Ah, gotcha. Yes, that’s a complex yet doable customization

  11. Thank you! This still works, however the shipping fields end up misaligned with the billing fields since the Shipping Phone is inserted after the Name instead of after the Zip. The example given at https://docs.woocommerce.com/document/tutorial-customising-checkout-fields-using-actions-and-filters/ has a cleaner implementation.

    1. Thank you!

  12. Thank you Rodolfo,
    code is working, text field is added in checkout page, is present in the order in the back office, but is not returned in the “Thank you for your order” email
    Grazie
    Mauro

    1. Correct, Mauro. Try studying this: https://businessbloomer.com/woocommerce-add-custom-checkout-field-php/ (part #5 snippet #2)

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 *