Trying to put the description of applied coupon into the "New Order" admin email with not success
So far trying to use this code I put into functions.php
add_action( 'woocommerce_email_order_details', 'display_applied_coupons', 10, 4 );
function display_applied_coupons( $order, $sent_to_admin, $plain_text, $email ) {
// Only for admins and when there at least 1 coupon in the order
if ( ! $sent_to_admin && count($order->get_items('coupon') ) == 0 ) return;
foreach( $order->get_items('coupon') as $coupon ){
$coupon_codes[] = $coupon->get_code();
$coupon_desc[] = $coupon->get_description();
}
// For one coupon
if( count($coupon_codes) == 1 ){
$coupon_code = reset($coupon_codes);
echo '<p>'.__( 'Coupon Used: ').$coupon_code.'<p>';
$coupon_des = reset($coupon_desc);
echo '<p>'.__( 'Coupon Description: ').$coupon_des.'<p>';
}
// For multiple coupons
}
Unless it doesn't produce any error, I can't see the coupon description into the "New Order" admin email
Somebody can help me? Thank you in advance