true ) ); $result = $client->checkVat( array( 'countryCode' => $country_code, 'vatNumber' => $vat_number, ) ); return ( isset( $result->valid ) ) ? $result->valid : null; } else { return null; } } catch( Exception $exception ) { return null; } } } if ( ! function_exists( 'wcj_validate_vat_with_method' ) ) { /** * wcj_validate_vat_with_method. * * @version 2.9.0 * @since 2.9.0 * @return mixed: bool on successful checking (can be true or false), null otherwise */ function wcj_validate_vat_with_method( $country_code, $vat_number, $method ) { switch ( $method ) { case 'soap': return wcj_validate_vat_soap( $country_code, $vat_number ); default: // 'curl', 'file_get_contents' return wcj_validate_vat_no_soap( $country_code, $vat_number, $method ); } } } if ( ! function_exists( 'wcj_validate_vat' ) ) { /** * wcj_validate_vat. * * @version 3.2.2 * @since 2.9.0 * @return mixed: bool on successful checking (can be true or false), null otherwise */ function wcj_validate_vat( $country_code, $vat_number ) { if ( '' != ( $skip_countries = get_option( 'wcj_eu_vat_number_advanced_skip_countries', array() ) ) ) { $skip_countries = array_map( 'trim', explode( ',', $skip_countries ) ); $skip_countries = array_map( 'strtoupper', $skip_countries ); if ( in_array( strtoupper( $country_code ), $skip_countries ) ) { return true; } } $methods = array(); switch ( get_option( 'wcj_eu_vat_number_first_method', 'soap' ) ) { case 'curl': $methods = array( 'curl', 'file_get_contents', 'soap' ); break; case 'file_get_contents': $methods = array( 'file_get_contents', 'curl', 'soap' ); break; default: // 'soap' $methods = array( 'soap', 'curl', 'file_get_contents' ); break; } foreach ( $methods as $method ) { if ( null !== ( $result = wcj_validate_vat_with_method( $country_code, $vat_number, $method ) ) ) { return $result; } } return null; } }