at present global coupons are being abused so we have in place below code which i wanted to run past you to check if this is the correct way of doing it.
at present if a customer purchases a sample pack or they are just a new customer they will get 20% off with a coupon. Upon checkout and order received page we do this.
$coupon_id = wc_get_coupon_id_by_code('example');
$addcoupon_id = explode(',',get_post_meta($coupon_id , '_wjecf_customer_ids', true));
update_post_meta($coupon_id, '_wjecf_customer_ids', array_merge(array($user_id), $addcoupon_id));
is there a better way of doing ? im unsure until i watch someone checkout if the “_wjecf_customer_ids” will grow with customer or just replace i think it will grow. unsure if i do need to explode or not.