1
woocommerce_initで使用されているクーポンを取得しようとしています。 $ GLBALS配列を表示しようとしましたが、関連性はありますが、アクセス方法はわかりません。woocommerce_initフックでカートにクーポンを適用する
function remove_email_for_testcop_coupon($order_id) {
global $woocommerce;
$coupons = $woocommerce->cart->applied_coupons;
var_dump($GLOBALS['GLOBALS']['wp_filter']['init']); //=> here there are found but don't know how to access it normaly => need to reach applied_coupons, just that is generating a dinamic nonce.
remove_action('init', array('WC_Emails', 'init_transactional_emails'));
if (in_array('testcop', $coupons)) {
remove_action('init', array('WC_Emails', 'init_transactional_emails'));
}
}
//add_action('wp', 'remove_email_for_testcop_coupon');
add_action('woocommerce_init', 'remove_email_for_testcop_coupon');