Skip to content

Instantly share code, notes, and snippets.

@wbcomdev
Created May 17, 2021 04:57
Show Gist options
  • Select an option

  • Save wbcomdev/ff6e42cc1d09e66158f0fabfe8d4388b to your computer and use it in GitHub Desktop.

Select an option

Save wbcomdev/ff6e42cc1d09e66158f0fabfe8d4388b to your computer and use it in GitHub Desktop.
/**
* Add a custom field (in an order) to the emails.
*/
function wb_woocommerce_email_order_meta_fields( $fields, $sent_to_admin, $order ) {
$fields['meta_key'] = array(
'label' => __( 'Label' ),
'value' => get_post_meta( $order->id, 'meta_key', true ),
);
return $fields;
}
add_filter( 'woocommerce_email_order_meta_fields', 'wb_woocommerce_email_order_meta_fields', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment