php – Uncaught Error: Call to a member function get_billing_state()

Question

I have a issues with the function get_billing_state();
Theses is the error: “[05-Jun-2021 18:32:48 UTC] PHP Fatal error: Uncaught Error: Call to a member function get_billing_state() on null in /home/perfume1/public_html/perfumeslujosos.com/wp-content/themes/generatepress_child/functions.php:593”

//Deshabilitar pago en efectivo por ciudades
add_filter( 'woocommerce_available_payment_gateways', 'Deshabilitar_por_ciudad');
function Deshabilitar_por_ciudad ($available_gateways){
     
  if ( is_admin() ) return $available_gateways;
    if ( isset( $available_gateways['authorize'] ) && WC()->customer->get_billing_state() <> 'Asunción' ) {
        unset( $available_gateways['authorize'] );
    } else {
        
        if ( isset( $available_gateways['cod'] ))
        {
            // $aux = preventa_crema_blanqueadora();
          /*if($aux > 0)
          {
               unset( $available_gateways['cod'] );
          }
          */
             
           
       if(!empty(WC()->customer->get_billing_state()))
       {
                $ciudad = WC()->customer->get_billing_state();
                if($ciudad != 'Asunción' && $ciudad != 'Lambare' && $ciudad != 'Fernando de la Mora' && $ciudad != 'Loma Pyta'  && $ciudad != 'Villa Elisa' && $ciudad != 'Zeballos' && $ciudad != 'San Antonio' && $ciudad != 'San Lorenzo' &&$ciudad != 'Luque'  && $ciudad != 'Mariano Roque Alonso' && $ciudad != 'Ñemby' && $ciudad != 'Limpio'  && $ciudad != 'Capiata' && $ciudad != 'Ypané' && $ciudad != 'Areguá' )
                {
          
                    unset( $available_gateways['cod'] );
            
                }
        
          
          
            
       }    
    }
    return $available_gateways; 
}//
}//fin

0
Aveiro Sol 6 months 2021-06-11T08:44:22-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse