WPSlash Licences

Add WooFood postal code validation on Multistep Checkout Pro

Add WooFood postal code validation on Multistep Checkout Pro – code snippet guide from WPSlash
Published
Updated
Reading time
1 minutes
Written by
WPSlash team

Here is a small snippet to make WooFood compatible with Multistep Checkout Pro.

Just copy and and paste the following code to your functions.php on your child theme.

Code
if ( ! function_exists( 'wpslash_multistep_checkout_postal_code_validation' ) ) {
    function wpslash_multistep_checkout_postal_code_validation( $errors, $fields ) {
		 $options_woofood = get_option('woofood_options');
        $woofood_postalcodes = isset($options_woofood['woofood_postalcodes']) ? $options_woofood['woofood_postalcodes'] : null;
        $woofood_postalcodes = str_replace(" ", "", $woofood_postalcodes);
        $woofood_postalcodes = strtoupper($woofood_postalcodes);
       
        $woofood_current_postcode = $fields['billing_postcode'];
        $woofood_current_postcode = str_replace(" ", "",  $woofood_current_postcode);
        $woofood_current_postcode = strtoupper($woofood_current_postcode);

        $postal_codes_array = explode(",",  trim($woofood_postalcodes));
        
		 if(!in_array(trim($woofood_current_postcode), $postal_codes_array))
        {

          

                       $errors['billing_postcode'] = __( 'Your postcode is outside our delivery area' );


        }
		
		
	
        return $errors;
    }
}
add_action( 'wmsc_custom_validation', 'wpslash_multistep_checkout_postal_code_validation', 10, 2 );
All guides

FoodMaster (formerly WooFood)12 min read

Best Store Address Setup for Pickup

Compare single-address, multi-location, and directions-first pickup setups to reduce wrong-door visits and simplify checkout.

The plugins these guides are about

FoodMaster for restaurants, courier vouchers for the Greek market, marketplace sync and store tools, all for WooCommerce.

Browse plugins30-day money-back on every plugin