Last active
December 20, 2023 09:48
-
-
Save cryptexvinci/acfffd317ea6593d85f87191f92528c6 to your computer and use it in GitHub Desktop.
Rename WooCommerce checkout field label & placeholder
This file contains 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 | |
// WooCommerce Rename Checkout Fields | |
add_filter( 'woocommerce_checkout_fields' , 'custom_rename_wc_checkout_fields' ); | |
// Change placeholder and label text | |
function custom_rename_wc_checkout_fields( $fields ) { | |
$fields['billing']['billing_first_name']['placeholder'] = 'Wonka'; | |
$fields['billing']['billing_first_name']['label'] = 'Your Awesome First Name'; | |
return $fields; | |
} |
AmeenJalali
commented
Jan 30, 2020
For those that are having issues in translate/change WooCommerce fields, just use gettext filter. Tested with the latest WooCommerce version.
function imde_text_strings( $translated_text, $text, $domain ) {
switch ( $translated_text ) {
case 'Postcode' :
$translated_text = __( 'Postcode (Required)', 'woocommerce' );
break;
}
return $translated_text;
}
add_filter( 'gettext', 'imde_text_strings', 20, 3 );
Works with WooCommerce 8.4.0
add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
// Our hooked in function - $fields is passed via the filter!
function custom_override_checkout_fields( $fields ) {
$fields['billing']['billing_postcode']['label'] = 'Postal Code ';
return $fields;
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment