Hi, please see the screenshot.
I want to remove the Company field in the cart page, and also want to change the text in the other fields.
Let me know how can I do that?
Thanks.
This topic has 8 replies, 2 voices, and was last updated 2 months, 3 weeks ago ago by Will
Hi, please see the screenshot.
I want to remove the Company field in the cart page, and also want to change the text in the other fields.
Let me know how can I do that?
Thanks.
Hi @Will,
Please add the following code under functions.php file locates in your child theme:
function customize_woocommerce_checkout_fields( $fields ) {
// Remove company field from billing only
unset( $fields['billing']['billing_company'] );
// Change street address placeholder text for billing
if ( isset( $fields['billing']['billing_address_1'] ) ) {
$fields['billing']['billing_address_1']['placeholder'] = 'Enter your street address';
}
// Change address line 2 placeholder text for billing
if ( isset( $fields['billing']['billing_address_2'] ) ) {
$fields['billing']['billing_address_2']['placeholder'] = 'Apartment, suite, unit, etc. (optional)';
}
return $fields;
}
add_filter( 'woocommerce_checkout_fields', 'customize_woocommerce_checkout_fields' );
Hope it helps!
Hi Luca, please see the screenshot of my functions.php file.
Could you point where exactly should I add the code?
Thanks.
Hi @Will,
You put the custom codes after the line:
add_filter(...
Let us know how it goes!
Hello Luca,
The Company field has been removed but the new place holder text in the Street Address fields do not show up.
I have made the following changes in the place holder text..
———
function customize_woocommerce_checkout_fields( $fields ) {
// Remove company field from billing only
unset( $fields[‘billing’][‘billing_company’] );
// Change street address placeholder text for billing
if ( isset( $fields[‘billing’][‘billing_address_1’] ) ) {
$fields[‘billing’][‘billing_address_1’][‘placeholder’] = ‘House Number, Street Name, Colony Name’;
}
// Change address line 2 placeholder text for billing
if ( isset( $fields[‘billing’][‘billing_address_2’] ) ) {
$fields[‘billing’][‘billing_address_2’][‘placeholder’] = ‘Post Office, District etc.’;
}
return $fields;
}
add_filter( ‘woocommerce_checkout_fields’, ‘customize_woocommerce_checkout_fields’ );
————-
But still the old place holder text is showing up instead of the new text.
See the screenshot. What can I do to fix this?
Dear Will,
We would like to inform you that we have made some updates to the custom code. At your earliest convenience, could you please clear your cache and check the changes?
You may refer to the following screenshot for reference:
https://prnt.sc/t6Vk4DB7UGwa
Thank you for your cooperation.
Best regards,
The 8Theme Team
Hi Luca,
Thank you so so much.
It is working now. Really appreciate your help!
Thanks for the support! My topic “Want To Customize Fields in The Cart Page” has been successfully resolved.
The issue related to '‘Want To Customize Fields in The Cart Page’' has been successfully resolved, and the topic is now closed for further responses