How to Remove Checkout Fields from Woo-commerce Checkout page - xenelsoft
January 14, 2025

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

Featured Posts

How to Remove Checkout Fields from Woo-commerce Checkout page

How to Remove Checkout Fields from Woo-commerce Checkout page With the growing demands of eCommerce,…

January 14, 2025

Mastering Google SEO: The Crucial Role of Indexing and Crawling in Search Rankings

Many SEO’s are now moving back to learn about indexing and crawling of the websites…

June 28, 2024

8 Proven Ways to use Generative AI for Effective Marketing Campaign

Generative AI is the proven and valuable tool for marketers to market engaging and valuable…

June 7, 2024