To the good folk of Stack Overflow,
I'm trying to create an "Upgrade Safe" way (as a function in my Theme's functions.php file) of customising the footer of the standard WooCommerce email notification email that customers receive when placing orders.
What I'm trying to achieve is to add custom text to said email footer when products from specific categories are ordered, but in all honesty, I'm struggling a bit with the in_array test for the categories, and I'm pretty sure I haven't got it quite right!
If any of you had any pointers on where I've gone wrong with it, I'd be eternally grateful!
function farm_shop_woocommerce_email_footer( $order, $sent_to_admin, $plain_text, $email ) {
$items = $order->get_items();
foreach ( $items as $item ) {
$terms = wp_get_post_terms( $item['product_id'], 'product_cat' );
foreach($terms as $term){
$term_names[] = $term->name; // Product cat Name
//$term->term_id; Product cat Id
//$term->slug; Product cat slug
}
}
if ( in_array('Farm Shop', 'Cowdray Kitchen', 'Cowdray Living', 'The Meditator', 'Cowdray Hampers', 'Cowdray Supper Kits', 'Grocery', 'Butchery', 'Deli', 'Pantry', 'Houseplants and Flowers', 'Picnic Hampers', 'Afternoon Tea', 'Drinks', 'Wreaths', $term_names) ) {
echo 'Cowdray Farm Shop Ltd<br>VAT Number: 970407718';
}
};
add_action( 'woocommerce_email_footer', 'farm_shop_woocommerce_email_footer', 10, 4 );