Skip to content

Instantly share code, notes, and snippets.

@rynaldos-zz
Created July 21, 2017 08:51
Show Gist options
  • Save rynaldos-zz/f938020839573c8cf12e8cef26b96ff9 to your computer and use it in GitHub Desktop.
Save rynaldos-zz/f938020839573c8cf12e8cef26b96ff9 to your computer and use it in GitHub Desktop.
[WooCommerce 3.0] add phone extension field to checkout page
add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
function custom_override_checkout_fields( $fields ) {
$fields['billing']['billing_phone_ext'] = array(
'label' => __('Phone ext', 'woocommerce'),
'placeholder' => _x('Phone ext', 'placeholder', 'woocommerce'),
'required' => false,
'priority' => 105,
'class' => array('form-row-last'),
'clear' => true
);
return $fields;
}
add_action( 'woocommerce_admin_order_data_after_billing_address', 'my_custom_checkout_field_display_admin_order_meta', 10, 1 );
function my_custom_checkout_field_display_admin_order_meta($order){
echo '<p><strong>'.__('Phone ext.').':</strong> ' . get_post_meta( $order->get_id(), '_billing_phone_ext', true ) . '</p>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment