-
Posted in : Interioz
-
Hi,
need add checkbox at the end of woocommerce checkout page.
Need checkbox to be confirmed before finalizing the order (accepting the terms and conditions). But it has to be X by customer in checkbox (not only text).
Is there an easy way to do this?
Hi,
Thanks for your message.
To easily add a required checkbox to the WooCommerce checkout page, without writing custom code, you can use this free plugin:
Checkout Field Editor (Checkout Manager) for WooCommerce:
https://wordpress.org/plugins/woo-checkout-field-editor-pro/With this plugin, you can:
– Add a checkbox field at the bottom of the checkout page.
– Make it required, so customers must check it before placing the order.
– Customize the label text as needed (e.g. “I confirm that I accept the additional terms and conditions”).After installing and activating the plugin:
1. Go to WooCommerce > Checkout Form.
2. Add a new Checkbox field.
3. Set its position (e.g. “After order notes”).
4. Enable the “Required” option.
5. Save changes.Let us know if you need further help.
Best regards,
MehmetHi,
thank you for information. I don’t want install any plugin. I’d like do by adding new function in functions.php in theme child or by by coping specific file to child theme and make changes it.
Can you help with this ?
Hi,
Sure! You don’t need to use any plugin. You can simply copy and paste the code below into your child theme’s
functions.phpfile:// 1. Add required checkbox to the checkout page add_action( 'woocommerce_review_order_before_submit', 'custom_checkout_checkbox_field', 10 ); function custom_checkout_checkbox_field() { echo '<div class="form-row custom-terms-checkbox">'; woocommerce_form_field( 'custom_terms', array( 'type' => 'checkbox', 'class' => ['form-row'], 'label' => 'I confirm that I accept the additional terms and conditions.', 'required'=> true, ), WC()->checkout->get_value( 'custom_terms' ) ); echo '</div>'; } // 2. Prevent order placement if the checkbox is not checked add_action( 'woocommerce_checkout_process', 'custom_checkout_checkbox_validation' ); function custom_checkout_checkbox_validation() { if ( empty( $_POST['custom_terms'] ) ) { wc_add_notice( __( 'You must accept the additional terms and conditions to place your order.' ), 'error' ); } } // 3. Save checkbox response to order meta add_action( 'woocommerce_checkout_update_order_meta', 'custom_checkout_checkbox_update_order_meta' ); function custom_checkout_checkbox_update_order_meta( $order_id ) { if ( ! empty( $_POST['custom_terms'] ) ) { update_post_meta( $order_id, '_custom_terms', 'Accepted' ); } }This will:
– Add a required checkbox just above the “Place Order” button.
– Prevent order submission if the checkbox is not checked.
– Save the checkbox response in the order meta (you’ll see “Accepted” in order custom fields).Let me know if you want to change the position or text of the checkbox.
Best regards,
MehmetHi Mehmet,
it’ s not working. div with class “custom-terms-checkbox” doesn’t appear.
Maybe the problem is because of button, which sometimes is working and sometimes it doesn’t work. When it’s working correctly it has classes “wc-block-components-button wp-element-button wc-block-components-checkout-place-order-button contained is-ready button is-primary”, but sometimes it has only “wc-block-components-button wp-element-button wc-block-components-checkout-place-order-button contained”
But still, even when button is being displayed – checkbox is not appearing. Functions.php is working correctly in my child theme.
Best regards,
PtakHi Ptak,
Thank you for the update and for sharing the link.
The reason the checkbox is not appearing is because your site is using the new WooCommerce Checkout Block (part of the WooCommerce Blocks system), which is different from the classic (shortcode-based) checkout. The woocommerce_review_order_before_submit hook does not run in the block-based checkout, so our custom PHP code doesn’t work there.
Solution Options:
Option 1: Revert to Classic Checkout (Shortcode-based)
If you’re not using specific block-only features, you can switch back to the classic checkout, and our previous code will work perfectly.
You can disable the Checkout Block from:WooCommerce > Settings > Advanced > Features (or similar section depending on WooCommerce version), and switch to legacy checkout.
Option 2: Customize Block Checkout (More Advanced)
WooCommerce Blocks does not support traditional PHP hooks. You’d need to extend the block editor using React (JavaScript) to add custom fields. This approach requires JS/React development.Official guide from WooCommerce (for developers):
https://developer.woocommerce.com/docs/block-development/extensible-blocks/cart-and-checkout-blocks/additional-checkout-fields/If you’re open to switching back to the classic checkout, I’d be happy to guide you through it step-by-step.
Let me know how you’d like to proceed.
Best regards,
Serkan
You must be logged in and have valid license to reply to this topic.