Checkout Page terms and privacy check

You can add this to your checkout page with an action:

add_action('woocommerce_after_checkout_registration_form', 'add_terms_accept_box', 1)

This is better than modifying the template from woocomerce in your own theme.

Add this in the functions.php of your theme

 * Terms and privacy checkbox on the billing page
add_action('woocommerce_after_checkout_registration_form', 'add_terms_accept_box', 1);
function add_terms_accept_box() {
    wc_get_template( 'checkout/terms.php' );

    woocommerce_form_field('privacy_policy', array(
        'type' => 'checkbox',
        'class' => array('form-row privacy'),
        'label_class' => array('woocommerce-form__label woocommerce-form__label-for-checkbox checkbox'),
        'input_class' => array('woocommerce-form__input woocommerce-form__input-checkbox input-checkbox'),
        'required' => true,
        'label' => __('I\'ve read and accept the <a href="/privacy">', 'yourlanguagedomain') . __("Privacy Policy", 'yourlanguagedomain') . '</a>',

add_action('woocommerce_checkout_process', 'privacy_checkbox_error_message');
function privacy_checkbox_error_message()
    if (!(int)isset($_POST['privacy_policy'])) {
        wc_add_notice(__('You have to have read and accept our privacy policy in order to proceed', 'yourlanguagedomain'), 'error');

Make sure that in _label' => _('I\'ve read and accept the <a href="/privacy"\>', 'yourlanguagedomain') you replace the url to your own.

Last update: Tue, 13 Sep 2022 14:32:15