Skip to content

Instantly share code, notes, and snippets.

@jessepearson
Created November 4, 2015 19:07
Show Gist options
  • Select an option

  • Save jessepearson/6ea374a21026e15f6610 to your computer and use it in GitHub Desktop.

Select an option

Save jessepearson/6ea374a21026e15f6610 to your computer and use it in GitHub Desktop.
Function to modify/change the label and placeholder for address fields in WooCommerce
<?php
/**
* Removes "Town" from label/placeholder in checkout forms
*/
function jp_address_field_filter( $fields ) {
// fields we want to look for
$search = array(
'billing_city',
'shipping_city',
'city',
);
// go through each field
foreach ( $fields as $k => $field ) {
// if it's one of our fields
if ( in_array( $k, $search ) ) {
// make it just City
$fields[ $k ][ 'label' ] = 'City';
$fields[ $k ][ 'placeholder' ] = 'City';
}
}
// return the fields
return $fields;
}
// add_filter( 'woocommerce_billing_fields', 'jp_address_field_filter', 99 );
// add_filter( 'woocommerce_shipping_fields', 'jp_address_field_filter', 99 );
add_filter( 'woocommerce_get_country_locale_base', 'jp_address_field_filter', 99 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment