In this post I’ll show you how to handle WooCommerce checkout page fields. The Checkout page is an eCommerce term that refers to pages shown to a customer during the step-by-step checkout process.
Add Custom Shipping Field
The ecommerce shipping is a service through which seller ships their products to buyers. A shipping form collects the shipping details of a customer. It must contain all required shipping fields.
WooCommerce is a very flexible ecommerce system. We can easily customize the checkout page, it provides all the necessary hooks. Below are the three steps to add a custom field to WooCommerce checkout shipping form.
- Add the required field array() data and hook it to woocommerce_checkout_fields
- Field validation to check it must contain value
- Store the Field value in database
- Display field value on the admin order edit page
Add the following code to functions.php file
Remove WooCommerce Checkout Page Fields
Removing any checkout field is too easy. You just need to pass that field within unset() function. The unset() function is a PHP function that is used to delete a specified variable. In WooCommerce it is used to remove array elements e.g unset( $fields[“billing_country”] );
Add the following code to functions.php file to remove billing for fields.
Add the following code to functions.php file to remove Order Notes from checkout field in Woocommerce.
Add the following code to functions.php file to remove biiling, shipping, accounts and Order Notes from checkout page in Woocommerce.
Re-Order Checkout Fields
Sometime you want to reorder any woocommerce checkout page fields. In order to do this you have to use the priorty array value with relevant form array value e.g $fields[‘billing’][‘billing_first_name’][‘priority’] = 10;
To reorder of fields, the priority value must be changed. Higher priority fields are shown in the end. e.g priority value of 30 will be displayed after 20.
Add the following code to functions.php file.