Created
November 4, 2015 19:07
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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