Forum Replies Created

Viewing 1 replies (of 1 total)
  • I am trying to do the same thing for a custom user group. Used this code and made some tweaks, but from what I could see you aren’t returning the origin available_gateways array after you unset specific payments.

    Let me know how you go, I was able to get it working with a wholesale user group.

    function dfg_hide_payment_form($available_gateways) {
        if ($_customer['dfg-pay-later-enabled'] == 1) {
            if( is_checkout() ) {  
                global $woocommerce, $_customer;
                $packages = $_customer['dfg-package-ids'];
    
                foreach ($packages as $package) {
                    if (dfg_woo_in_cart($package)) {
                        unset($available_gateways['inspire']);
                    }
                }
            }
        } else {
            unset($available_gateways['cod']);
        }
        
        return $available_gateways;
    }
    
    add_filter('woocommerce_available_payment_gateways', 'dfg_hide_payment_form', 1);
Viewing 1 replies (of 1 total)