I have added a custom field on the checkout page using this:
add_action( 'woocommerce_checkout_fields',
'woo_add_conditional_checkout_fields' );
function woo_add_conditional_checkout_fields( $fields ) {
foreach( WC()->cart->get_cart() as $cart_item ){
$product_id = $cart_item['product_id'];
$fields['billing']['billing_field_newfield'] = array(
'label' => __('New Field', 'woocommerce'),
'placeholder' => _x('', 'placeholder', 'woocommerce'),
'required' => true,
'class' => array('form-row-wide'),
'clear' => false
);
}
return $fields;
}
Now, I would like to include whatever the user enters in this field in the 'New Order' woocommerce email, however when I go to Woocommerce > Settings > Emails > New Order and put {billing_field_newfield} in the subject, I just get {billing_field_newfield} in the email and not its actual value.
Does anyone know how to do this?
Thanks