This can be done using a custom function hooked in woocommerce_email_order_details action hook (for example) that will display in admin emails notifications the used coupons in the order:
// The email function hooked that display the text
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();
}
// For one coupon
if( count($coupon_codes) == 1 ){
$coupon_code = reset($coupon_codes);
echo '<p>'.__( 'Coupon Used: ').$coupon_code.'<p>';
}
// For multiple coupons
else {
$coupon_codes = implode( ', ', $coupon_codes);
echo '<p>'.__( 'Coupons Used: ').$coupon_codes.'<p>';
}
}
Code goes in function.php file of your active child theme (or theme) or also in any plugin file.
Tested and works...
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…