Untitled
unknown
plain_text
2 years ago
537 B
33
Indexable
add_filter( 'woocommerce_coupon_is_valid', function($is_valid, $coupon, $discount){
$coupon_id = wc_get_coupon_id_by_code($coupon->get_code());
$agent_id = get_post_meta($coupon_id, 'salesking_agent', true);
if (!empty($agent_id)){
if (intval($agent_id) !== 1){
// if agent, only allow b2b custoemrs
if (get_user_meta(get_current_user_id(),'b2bking_b2buser', true) !== 'yes'){
if (intval(get_post_meta($coupon_id, 'coupon_amount', true)) == 100){
$is_valid = false;
}
}
}
}
return $is_valid;
}, 10, 3);Editor is loading...
Leave a Comment