Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Asikur22/3fafe6842d02a5892c92cd76a78ec1ba to your computer and use it in GitHub Desktop.
Save Asikur22/3fafe6842d02a5892c92cd76a78ec1ba to your computer and use it in GitHub Desktop.
Add CheckoutWC shipping phone number to WooCommerce order email.
<?php
// Do NOT include the opening php tag.
// Place in your theme's functions.php file
/**
* Add a custom field (in an order) to the emails
*/
add_filter( 'woocommerce_email_order_meta_fields', 'custom_woocommerce_email_order_meta_fields', 10, 3 );
function custom_woocommerce_email_order_meta_fields( $fields, $sent_to_admin, $order ) {
$fields['meta_key'] = array(
'label' => __( 'Shipping Phone' ),
'value' => get_post_meta( $order->id, '_shipping_phone', true ),
);
return $fields;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment