Question: How can we add custom field to “customer details” block in order email?
Answer: Using below code/filter, we can add custom field to “customer details” block in order email
/**
* Add custom fields to emails
*/
add_filter('woocommerce_email_customer_details_fields', 'my_checkout_field_order_meta_fields', 40, 3 );
function my_checkout_field_order_meta_fields( $fields, $sent_to_admin, $order ) {
$fields['custom_field_1'] = array(
'label' => __( 'Vælg og bekræft din biltype' ),
'value' => get_post_meta( $order->id, 'Vælg og bekræft din biltype', true ),
);
$fields['custom_field_2'] = array(
'label' => __( 'Afgivet bestilling' ),
'value' => get_post_meta( $order->id, 'Afgivet bestilling', true ),
);
return $fields;
}
No comments:
Post a Comment