简体   繁体   中英

Add company name to WooCommerce "New Order" email

How do I add the company name as the subject / title for the WooCommerce order e-mail? So when a customer places an order, we'd like to receive an email saying "New B2B order from (COMPANY NAME). We get the company name in the WooCommerce checkout and I tried adding it using {company_name} but without luck.

If you used the woocommerce_form_field() function to create the field in the checkout, you can access it via key and use the filter woocommerce_email_order_meta_keys to place it inside of the emails. The value of your field has to be part of the order meta data.

Create a custom plugin or place the code inside of the function.php of your theme:

function yourfield_display_in_email( $keys ) {
     $keys['your-label'] = '_your_key';
     return $keys;
}
add_filter( 'woocommerce_email_order_meta_keys', 'yourfield_display_in_email' );

Don't fortget to put the _ before the key name, like in _your_key .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM