Black Friday & Cyber Monday SUPER SALE ALL WEEK:
Grab 40% OFF on plugins
Days
Hours
Minutes
Seconds

How to Create Checkbox Field In WooCommerce Checkout Page?

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? - Tyche Softwares

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.

Browse more in: Code Snippets, WooCommerce How Tos, WooCommerce Tutorials

Share It:

Subscribe
Notify of
0 Comments
Newest
Oldest
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x