How to Remove Checkout Fields from Woo-commerce Checkout page
With the growing demands of eCommerce, businesses increasingly require customized checkout pages designed to their specific needs. One such challenge was recently addressed by the team at XenelSoft Technologies when we were tasked with simplifying the WooCommerce checkout page to align with a client’s unique requirements.
A client approached us with a specific requirement: to simplify the WooCommerce checkout form by displaying only the Name, Email, and Phone Number fields, along with a “Get Pricing” button. The task was to remove mandatory fields such as Shipping Address, Billing Address, Country, State, Postcode, and Last Name, while making the Phone Number field mandatory, which is optional by default in WooCommerce. This setup would allow the client to send price details at a later stage.
Initially, the team tried modifying the WooCommerce plugin’s checkout form file and experimented with several solutions from forums and online communities.Various methods, including setting the fields as “not required” in the functions.php file and using plugins like WooCommerce Direct Checkout and Checkout Field Editor, were tried. However, these approaches did not achieve the desired results.
Here is the code that internet was flooded with:
function custom_disable_postcode_checkout($fields) {
unset($fields[‘billing’][‘billing_postcode’]);
unset($fields[‘shipping’][‘shipping_postcode’]);
return $fields;
}
add_filter(‘woocommerce_checkout_fields’, ‘custom_disable_postcode_checkout’);
Unfortunately, this method no longer works with the latest updates.
After further investigation, it became clear that the latest version of WordPress utilizes a block-based structure for WooCommerce pages, replacing the previous file-based approach. With this insight, we were able to implement the solution by adding a specific code to the functions.php file, “This modification successfully adjusted the checkout form fields to meet the client’s requirements. The code was customized for the Canadian market, as the client operates in Canada, but it can be adapted for any country based on specific needs.
Many users face similar challenges and often resort to purchasing premium plugins for solutions. However, with the right approach, such issues can be resolved without additional costs.
Here’s how the solution was implemented:
add_filter(‘woocommerce_get_country_locale’, function( $locale ) {
$locale[‘CA’][‘first_name’][‘label’]=’Name’;
$locale[‘CA’][‘last_name’][‘required’] = false;
$locale[‘CA’][‘last_name’][‘hidden’] = true;
$locale[‘CA’][‘state’][‘required’] = false;
$locale[‘CA’][‘state’][‘hidden’] = true;
$locale[‘CA’][‘address_1’][‘required’] = false;
$locale[‘CA’][‘address_1’][‘hidden’] = true;
$locale[‘CA’][‘postcode’][‘required’] = false;
$locale[‘CA’][‘postcode’][‘hidden’] = true;
$locale[‘CA’][‘city’][‘required’] = false;
$locale[‘CA’][‘city’][‘hidden’] = true;
// Making the phone number field required
$locale[‘CA’][‘phone’][‘required’] = true;
// Removing the “optional” text from the placeholder
$locale[‘CA’][‘phone’][‘placeholder’] = ”;
return $locale;
});
This code can be added to the functions.php file to simplify the checkout process for WooCommerce users.
Stay tuned for more insights on WordPress and WooCommerce development!
Need help with your WordPress or WooCommerce projects?
At XenelSoft Technologies, we specialize in providing customized eCommerce solutions. Connect with us today to discuss how we can help optimize your online business.
Nalini Tomar
Founder and Managing Director
-
Mastering Google SEO: The Crucial Role of Indexing and Crawl...
February 17, 2025 -
8 Proven Ways to use Generative AI for Effective Marketing C...
February 17, 2025 -
How Marketers uses Generative AI for Search
February 17, 2025 -
Google SGE: Google Search Generative Experience Explained in...
February 17, 2025 -
Boost Your Business Growth with Advanced Online Marketing Se...
February 17, 2025 -
How to Audit Your Website for SEO?
February 17, 2025 -
Google Announces Bard AI, A New Challenger to ChatGPT
February 17, 2025 -
How Google’s Local Search Algorithm Vicinity can be Your Nex...
February 17, 2025 -
5 Practices Undertaken By Healthcare Digital Marketing Servi...
February 17, 2025 -
5 Reasons Your Business Needs a New Website
February 17, 2025
We’re Just One Click Away
Send us your details, and we’ll offer the support you need.
XenelSoft Worldwide Presence
As a leading digital solutions company, XenelSoft operates globally, delivering services from multiple locations around the world.


B-79, First floor, Sector-63, Noida-201301, India.



11 Woodlands Close, #03-35 Woodlands 11,Singapore (737853)


70 Manning Road, BS4 1FL, Bristol, United Kingdom

.png)

4380 south service road unit 14 Burlington ON

General Enquiry


Be the First to Know –
Join Us
