-
-
Save cryptexvinci/acfffd317ea6593d85f87191f92528c6 to your computer and use it in GitHub Desktop.
<?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; | |
} |
any update for woo 3.9 as the code to change the label does not work.
// Tested with woocommerce 3.9.1:
add_filter( 'woocommerce_default_address_fields' , 'override_default_address_fields' );
function override_default_address_fields( $address_fields ) {
$address_fields['address_1']['label'] = 'Shipping Address';
$address_fields['address_1']['placeholder'] = 'Your Complete Shipping Address';
return $address_fields;
}
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;
}
any update for woo 3.9 as the code to change the label does not work.