이 순서대로 사용 된 쿠폰을 통지를 관리자 이메일에 표시됩니다 (예를 들어) woocommerce_email_order_details 액션 후크에서 꺾어 사용자 정의 함수를 사용하여 수행 할 수 있습니다 :
// 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>';
}
}
코드는 function.php 파일의 이동을 활성 어린이 테마 (또는 테마) 또는 모든 플러그인 파일에서도 사용할 수 있습니다.
테스트 완료 후 작동 ...