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        businessbloomer.com/woocommerce-customization
 * @author        Rodolfo Melogli, Business Bloomer
 * @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

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

30 thoughts on “WooCommerce: Add Shipping Phone @ Checkout

  1. I added the snippet and it works fine.
    Woocommerce have a native function to fetch the billing phone number:

    $billing_phone = $order->get_billing_phone();

    How do I fetch the shipping number in a similar manner?
    Kinldy assist.
    Thank you!

    1. get_post_meta( $order_id, '_shipping_phone', true )
      
  2. 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!

  3. 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

  4. Just added this and works great. Thank you

  5. 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

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

  7. 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

  8. I just added this and it still works 🙂

    1. Great!

  9. 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!

  10. 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!

  11. 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

  12. 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!

  13. 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 *