Skip to main content
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Source Link
Stanley Tan
  • 195
  • 1
  • 1
  • 10

How to add a user custom field into Woocommerce emails?

How do you add a user custom field into Woocommerce emails?

This is my code so far in functions.php

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' => __( 'Store number' ),
        'value' => get_user_meta( $user_id, 'wpcf-store-number', true ),
    );
    return $fields;
}

The user custom field is wpcf-store-number which is already in the database. All I need to do now is to show it in the order confirmation email / New order email.