Repository Forums Support WooCommerce Extended Coupon Features PRO Remove Customer Programically From Allowed List Reply To: Remove Customer Programically From Allowed List

#13017
Heidi Maskelyne
Participant

Hi i have figured out myself which works great added to thank you page

for other users you can use below:

$coupons = $order->get_used_coupons();
if(preg_match("/woolcoolreturn/", json_encode($coupons))) { 
    $coupon_id = wc_get_coupon_id_by_code('woolcoolreturn');        
    $allowed_customer_ids = explode(',', str_replace(get_current_user_id(),'',get_post_meta($coupon_id, '_wjecf_customer_ids', true)));         
    update_post_meta($coupon_id, '_wjecf_customer_ids', implode(',', $allowed_customer_ids));
}

if admin can check that this is correct way of doing then great.