How to make the WooCommerce Eircode checkout field required for Ireland

You can use the following code snippet to make the default Eircode checkout field required.

add_filter( 'woocommerce_checkout_fields', 'custom_override_default_address_fields' );
function custom_override_default_address_fields($fields){
    global $woocommerce;
    $country = $woocommerce->customer->get_billing_country();
    if($country == 'IE'){
        $fields['billing']['billing_postcode']['required'] = true;
        $fields['shipping']['shipping_postcode']['required'] = true;
    return $fields;

This code can be added following the instructions here:

How to add custom code to your WooCommerce/WordPress site the right way

Have any feedback? Be sure to let me know here: Contact me

Share your thoughts

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