1

I want to modify the WooCommerce checkout page. I want to change the default state label for the UK.

The UK default state label is "county". I want to modify this to "State Code".

I tried the following code but nothing changes.

add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );

function custom_override_checkout_fields( $fields ) {

  unset($fields['billing']['billing_postcode']);
  unset($fields['billing']['billing_state']);
  $fields['billing']['billing_state'] = array(

  'label'=> __('State Code', 'woocommerce'),
  'required'  => true,
  'class'     => array('form-row-wide'),

  );

 return $fields;
}
1

1 Answer 1

0

My reply might be late but,

Ive had a similar issue earlier so i used the woocommerce_default_address_fields instead.

add_filter( 'woocommerce_default_address_fields' ,'customize_checkout_fields' );
function customize_checkout_fields( $address_fields ) {

// Customizing city and state labels
$address_fields['city']['label'] = __('Just a City');
$address_fields['state']['label'] = __('Just a State');

return $address_fields;

}

Hope this works.

1
  • does not work for US. JS updates these labels. Trying to find where is it.
    – mysterious
    Commented Oct 12, 2017 at 19:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.