WPSlash

Add WooFood postal code validation on Multistep Checkout Pro

Thursday July 9, 2020

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.

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 );

Leave a Comment

Your email address will not be published. Required fields are marked *

Related Articles

Tutorials

How to Set Up Delivery Zones and Distance-Based Fees on Your WooCommerce Restaurant Website (2025)

Why Delivery Zones Matter for Restaurant Profitability Every mile your delivery driver travels costs money — fuel, time, vehicle wear, and the opportunity cost of not fulfilling another order closer to home. Without clearly defined delivery boundaries, restaurants often find themselves sending drivers on 20-minute round trips for a $15 order, effectively losing money on […]
April 30, 2026
Tutorials

How to Build a Customer Loyalty Program for Your WordPress Restaurant Website (2025)

Why Loyalty Programs Matter for Restaurants With Online Ordering Here’s a number that should stop every restaurant owner in their tracks: acquiring a new customer costs five to seven times more than retaining an existing one. According to research from Bain & Company, increasing customer retention by just 5% can boost profits by 25% to […]
April 29, 2026
Tutorials

How to Speed Up Your WooCommerce Restaurant Website: Performance Optimization Tips (2025)

Why Website Speed Matters for Restaurant Ordering (And How It Affects Your Revenue) A hungry customer pulls up your <a href="https://www.wpslash.com/how-to-rank-your-restaurant-website-on-google-local-seo-for-wordpress-2025/" title="How to Rank Your Restaurant Website on Google: Local SEO for WordPress (2025)”>restaurant website on their phone, ready to place a delivery order. The page takes five seconds to load. They leave and order […]
April 29, 2026