• Resolved poojajosh

    (@poojajosh)


    I am trying to limit the user to either use the coupon code or the “Pay by Wallet” one at a time but not in conjunction.

    Somehow it’s not working.

    // Disable Coupon when cashback is used.
    add_filter('woocommerce_available_payment_gateways', 'applied_coupons_hide_payment_gateways', 20, 1 );
    function applied_coupons_hide_payment_gateways( $available_gateways){
        // Not in backend (admin)
        if( is_admin() ) 
            return $available_gateways;
    
        // If at least a coupon is applied
        if( sizeof( WC()->cart->get_applied_coupons() ) > 0 ){
            // Loop through payment gateways
            foreach ( $available_gateways as $gateway_id => $gateway ) {
                // Remove all payment gateways except BACS (Bank Wire)
                if( $gateway_id != 'wallet' )
                    unset($available_gateways[$gateway_id]);
            }
        }
    
        return $available_gateways;
    }

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘How do we remove “Pay by wallet” option if the user uses any coupon code.’ is closed to new replies.