Editing Email Template with Custom Checkout Fields Plugin
-
I’m getting “reguired” errors when submitting order because my email template seems to cause some errors. I don’t know how the two are tied together, but they are.
Anyways, I’m adding custom checkout fields to the email template using the instructions from here:
https://docs.woocommerce.com/document/add-a-custom-field-in-an-order-to-the-emails/
When I add only one field, everything works just fine with order submissions and email template. But when I add second and third checkout fields to email template, errors arise. I want to make sure I’m adding multiple fields properly.
Right now this is how I add them:
/**
* 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[‘about_event’] = array(
‘label’ => __( ‘About the Event’ ),
‘value’ => get_post_meta( $order->id, ‘about_event’, true ),
);
return $fields;
}`function custom_woocommerce_email_order_meta_fields( $fields, $sent_to_admin, $order ) {
$fields[‘event_number’] = array(
‘label’ => __( ‘How many people at the event’ ),
‘value’ => get_post_meta( $order->id, ‘event_number’, true ),
);
return $fields;
}`function custom_woocommerce_email_order_meta_fields( $fields, $sent_to_admin, $order ) {
$fields[‘date’] = array(
‘label’ => __( ‘Date of the Event’ ),
‘value’ => get_post_meta( $order->id, ‘date’, true ),
);
return $fields;
}
- The topic ‘Editing Email Template with Custom Checkout Fields Plugin’ is closed to new replies.