This is how you add a checkbox to checkout in Woocommerce. The Checkbox will appear in the checkout is not required (optional).

Add this code to your theme’s functions.php file:

// Add Checkbox
add_action('woocommerce_after_checkout_billing_form', 'newsletter_accept_field');
function newsletter_accept_field()
	woocommerce_form_field('newsletter_accept', array(
		'type' => 'checkbox',
		'class' => array('input-checkbox'),
		'label' => __('Yes, send me your newsletter.'),
		'required' => true,
	), WC()->checkout->get_value('newsletter_accept'));

//Update the order meta with field value
add_action('woocommerce_checkout_update_order_meta', 'newsletter_accept_update_order_meta');
function newsletter_accept_update_order_meta($order_id)
	if ($_POST['newsletter_accept']) {
		update_post_meta($order_id, 'Newsletter Accept', esc_attr($_POST['newsletter_accept']));

See also: Add Checkbox To Woocommerce (Required Checkbox)

See also: Add Multiple Required Checkbox Fields On WooCommerce Checkout Page

How useful was this post?

Click on a star to rate it!

Average rating / 5. Vote count:

No votes so far! Be the first to rate this post.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?