Hi,
You can achieve your requirement by adding the below code snippet in your child theme’s functions.php file.
add_filter( 'woocommerce_get_order_item_totals', 'add_coupons_codes_to_emails', 10, 3 );
function add_coupons_codes_to_emails( $total_rows, $order, $tax_display ) {
if( sizeof( $order->get_coupon_codes() ) == 0 )
return $total_rows;
$new_total_rows = [];
foreach($total_rows as $key => $total ){
$new_total_rows[$key] = $total;
if( ! isset($total_rows['discount']) && $key === 'shipping' ) {
$new_total_rows['discount'] = array(
'label' => __( 'Discount:', 'woocommerce' ),
'value' => wc_price(0),
);
}
if( $key === 'discount' || isset($new_total_rows['discount']) ){
$applied_coupons = $order->get_coupon_codes();
$new_total_rows['coupon_codes'] = array(
'label' => __('Applied coupons:', 'woocommerce'),
'value' => implode( ', ', $applied_coupons ),
);
}
}
return $new_total_rows;
}
Thank you!