Wanted to add a custom checkbox field to the billing section on the WooCommerce checkout page. This can be useful for collecting additional information or obtaining user consent. Below is the snippet for this use case.
add_filter( 'woocommerce_checkout_fields', 'ts_billing_checkbox_checkout' ); function ts_billing_checkbox_checkout( $fields ) { $fields['billing']['billing_year'] = array( 'label' => 'Aggregation Policy', 'type' => 'checkbox', 'required' => true, 'class' => array( 'form-row-wide' ), 'priority' => 26, ); // Move the 'billing_year' field after the 'billing_email' field $fields['billing']['billing_year']['priority'] = $fields['billing']['billing_email']['priority'] + 1; return $fields; }
Output
The below output shows that the custom checkbox fields have been added to the billing area section of the WooCommerce checkout page.
![How to Create Checkbox Field In WooCommerce Checkout Page? 1 How to Create Checkbox Field In WooCommerce Checkout Page? - Tyche Softwares](https://media.tychesoftwares.com/wp-content/uploads/WooCommerce-Custom-Checkbox-in-billing-Section-1024x709.png)
Additionally, you can also create a textfield in WooCommerce checkout page on the billing section for collecting any extra information about the user experience in the store.