Menu Close

WooCommerce: Disable Postcode/ZIP Validation @ Checkout

default

An annoying thing for sellers based in Ireland (for example), is that we still don’t use post codes (they recently introduced them, but nobody’s using them). So, in today’s task, I want to show you how to disable the “REQUIRED” feature of the postcode on the checkout page.

We already saw how to completely remove the PostCode/ZIP field… but this time we wish to leave it on the checkout, and just avoid a validation error if we don’t enter anything.

Disable Postcode/ZIP Validation @ WooCommerce Checkout
Disable Postcode/ZIP Validation @ WooCommerce Checkout

PHP Snippet (Alternative #1): Disable Postcode/ZIP Validation @ WooCommerce Checkout


/**
* @snippet       Disable Postcode/ZIP Validation @ WooCommerce Checkout
* @how-to        Get CustomizeWoo.com FREE
* @sourcecode    https://businessbloomer.com/?p=20203
* @author        Rodolfo Melogli
* @testedwith    WooCommerce 3.5.3
* @donate $9     https://businessbloomer.com/bloomer-armada/
*/

add_filter( 'woocommerce_default_address_fields' , 'bbloomer_override_postcode_validation' );

function bbloomer_override_postcode_validation( $address_fields ) {
  $address_fields['postcode']['required'] = false;
  return $address_fields;
}

PHP Snippet (Alternative #2): Disable Postcode/ZIP Validation @ WooCommerce Checkout


/**
* @snippet       Disable Postcode/ZIP Validation @ WooCommerce Checkout
* @how-to        Get CustomizeWoo.com FREE
* @sourcecode    https://businessbloomer.com/?p=20203
* @author        Rodolfo Melogli
* @testedwith    WooCommerce 3.5.3
* @donate $9     https://businessbloomer.com/bloomer-armada/
*/

add_filter( 'woocommerce_checkout_fields' , 'bbloomer_alternative_override_postcode_validation' );

function bbloomer_alternative_override_postcode_validation( $fields ) {
$fields['billing']['billing_postcode']['required'] = false;
$fields['shipping']['shipping_postcode']['required'] = false;
return $fields;
}

Official Documentation

https://docs.woothemes.com/document/tutorial-customising-checkout-fields-using-actions-and-filters/

View Source
Posted in WooCommerce Tips