This article is applicable for our dropshipping plugins for WooCommerce, such as vidaXL and BigBuy.
Introduction #
Unfortunately there is no phone number field in the shipping address of WooCommerce. Weird, because in many countries a phone number is required by shipping countries. Besides the dropshipping suppliers vidaXL and BigBuy, also require a phone number in the shipping address. In this article we’re going to explain how to add the phone number to the checkout of the shipping address. If you’re not a developer yourself, please forward this article to your developer instead.
Add snippet to functions.php #
To add the field to the checkout of the shipping address you will need to add the code below to your functions.php file.
/** Add Shipping Phone to WooCommerce Checkout **/
add_filter( 'woocommerce_checkout_fields', 'woosa_shipping_phone_checkout' );
function woosa_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', 'woosa_shipping_phone_checkout_display' );
function woosa_shipping_phone_checkout_display( $order ){
echo '<p><b>Shipping Phone:</b> ' . get_post_meta( $order->get_id(), '_shipping_phone', true ) . '</p>';
}