Support » Plugin: WooCommerce » Fatal error: WC_Validation::format_phone() in…

  • chesneyryan


    Please help,

    I’m getting this error “Fatal error: Call to undefined method WC_Validation::format_phone() in /home/…/…”

    It tells me to go to line 222 of “class-wc-checkout.php” which reads this:

    $this->posted[ $key ] = $validation->format_phone( $this->posted[ $key ] );

    Here is the entire section of code:

    						case "billing_phone" :
    							$this->posted[ $key ] = $validation->format_phone( $this->posted[ $key ] );
    							if ( ! $validation->is_phone( $this->posted[ $key ] ) )
    								$woocommerce->add_error( '<strong>' . $field['label'] . '</strong> ' . __('is not a valid number.', 'woocommerce') );

    Perhaps the validation is messed up? This is what is in “class-wc-validation.php”

    	 * Validates a phone number using a regular expression
    	 * @param   string	phone number
    	 * @return  boolean
    	function is_phone( $phone ) {
    		if (strlen(trim(preg_replace('/[\s\#0-9_\-\+\(\)]/', '', $phone)))>0) return false;
    		return true;

    Does that look correct? Please someone help me make sense of this! Should that be normal after a new install of the plugin??

  • The topic ‘Fatal error: WC_Validation::format_phone() in…’ is closed to new replies.