Skip to content

Instantly share code, notes, and snippets.

@ncyhere
Created October 3, 2019 08:23
Show Gist options
  • Save ncyhere/e1fa1496272a9a11d35ac3ec034a375d to your computer and use it in GitHub Desktop.
Save ncyhere/e1fa1496272a9a11d35ac3ec034a375d to your computer and use it in GitHub Desktop.
/**
* @snippet Shipping Phone in WooCommerce Checkout
* @author Ncy Design https://wordpress.ncy.design
* @compatible WooCommerce 3.7.0
*/
add_filter( 'woocommerce_checkout_fields', 'ncydesign_shipping_phone_checkout' );
function ncydesign_shipping_phone_checkout( $fields ) {
$fields['shipping']['shipping_phone'] = array(
'label' => 'Phone',
'required' => false,
'class' => array( 'form-row-wide' ),
'priority' => 25,
);
return $fields;
}
add_action( 'woocommerce_admin_order_data_after_shipping_address', 'ncydesign_shipping_phone_checkout_display' );
function ncydesign_shipping_phone_checkout_display( $order ){
echo '<p><b>Shipping Phone:</b> ' . get_post_meta( $order->get_id(), '_shipping_phone', true ) . '</p>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment