January 11, 2021

How To Change The Postcode To Eircode and Make it Required in WooCommerce

A very useful snippet that changes the Postcode label to Eircode and makes it a required field.

I had a request from a client today to change the Postcode field in the WooCommerce checkout page to a required field and to rename it to ‘Eircode’. After some trial and error, the following two snippets worked a treat.

1. Make the Postcode field required

We do this by adding the following code snippet to the site:

// Make Postcode Required for all Countries
add_filter('woocommerce_get_country_locale', function($locales){
    foreach ($locales as $key => $value) {
        $locales[$key]['postcode']['required'] = true;
    return $locales;

2. Rename the Postal Code field to ‘Eircode’

Add the following snippet to the site:

add_filter( 'woocommerce_checkout_fields', 'ifd_rename_woo_checkout_fields' );
function ifd_rename_woo_checkout_fields( $fields ) {
    $fields['billing']['billing_postcode']['placeholder'] = '';
    $fields['billing']['billing_postcode']['label'] = 'Eircode';
    return $fields;

I hope you find this useful but let me know if you have any trouble implementing it.

Amanda Lucas

Amanda Lucas runs a web design agency in Ireland called Itchy Fingers Design. She enjoys creating websites that help support business goals and growth and sharing her knowledge.