How to Add a Privacy Policy Checkbox in WooCoommerce Checkout

>How to Add a Privacy Policy Checkbox in WooCoommerce Checkout
  • checkout cart checkobox

You’ve probably already read that one of the GDPR requirements is to add a consent/privacy policy checkbox to all your forms that gather personal data, including your WooCommerce checkout page.

At this point, by default, WooCommerce only allows you to add a Terms & Conditions checkbox on the checkout page.

And yes, I’m aware that they’ll implement some GDPR features in the 3.4 version, but it will still be a little different from what I’m about to show you.

In WooCommerce 3.4, a privacy policy snippet will be added in the checkout page, not a checkbox, as you can see below.

woocommerce policy snippet

While this might be enough to comply with the GDPR requirements, some of you might want to go further, to be extra safe, and add another checkbox for the users to check if they agree with your privacy policy.

How to add a privacy policy checkbox in the WooCoommerce checkout page

To add a privacy policy checkbox in the WooCommerce checkout page, you’ll need to add some code in your theme’s functions.php file.

To do that, first, you’ll need to know how to access and edit your WordPress files.

The functions.php file is usually found in /public_html/wp-content/themes/YOURTHEMENAME-child/functions.php. This is for your primary domain.

If you want to edit the file of an add-on domain that’s found on the same hosting account, you’ll most likely have to go here: /public_html/YOURDOMAIN.COM/wp-content/themes/YOURTHEMENAME-child/functions.php.

This might differ from web host to web host.

I recommend backing up the functions.php file or the whole website before making any changes, and I also recommend having a child theme in place.

Once you’ve opened the functions.php file for editing, add the below code at the very bottom, or right before ?> (if there’s any).

add_action( 'woocommerce_review_order_before_submit', 'add_privacy_checkbox', 9 );
function add_privacy_checkbox() {
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 Policy</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 agree to our privacy policy in order to proceed' ), 'error' );

Don’t forget to add your actual domain name for the privacy policy page.

Save the file and that’s it!

A privacy policy checkbox should appear in your WooCommerce checkout page.

woocommerce privacy policy checkbox

You can change the label text and error message with whatever you see fit.

That’s a wrap

Hope you found the post useful and comprehensive!

If you have any questions or thoughts, drop a comment, contact us or message us on Facebook.

You can also follow us on Twitter and subscribe to our YouTube channel.

If you want to start your own WordPress blog, or need a website for your business, our WordPress services are at your disposal! We also provide WordPress support and maintenance!

You can also purchase a ready-made WordPress website with hosting and support included!

WP Rocket - WordPress Caching Plugin
By |2018-10-10T14:52:45+00:00May 19th, 2018|Customization, Plugins|10 Comments


  1. Ben May 25, 2018 at 10:03 AM - Reply

    How can you save the consent, will it appear in the user profile of WP?

    • ThemeSkills May 25, 2018 at 6:50 PM - Reply

      Hello! I don’t know, to be honest, especially if it’s custom. You could drop a question here –

    • John June 15, 2018 at 5:37 PM - Reply

      I reckon that, because it’s a required field, getting past this page implies consent. So the fact that order details are saved to your database mean the user has accepted your privacy policy. Unless you intend to use this data for anything other than processing this order I believe this should be enough.

      If you are worried about offering the option to let users withdraw their consent, I don’t think it is even possible when the order is already processed. You cannot undo the processing and you may by law be required to keep this data (for instance Dutch administration requires me to keep the invoice I sent for 7 years).

      The only case where I think it might be an issue is if the order is not completely processed and remains on pending. But in that case you can just remove this order (or change the personal data to some fake info in order to keep your stats). I’m not a lawyer though 🙂

      • Eemeli July 23, 2018 at 5:50 PM - Reply

        John, maybe he wants to get a consent to do marketing. According to the GDPR you need that on the checkout page if you want to send your newsletter to the customer. That needs be optional, so the customer will not refuse to order just because you force him to register on the mailing list. Also you need to prove this consent later, so it has to be stored like he wrote.

  2. John June 15, 2018 at 5:15 PM - Reply

    Thanks for this! I’m using this instead of the built in functionality because this code allows me to link to my existing privacy policy and terms of service (which are outside my wordpress root).

  3. n4gash October 3, 2018 at 3:00 PM - Reply

    Hey! thanks for your guide, is superb!!

    I have added this code in functions.php

    add_action( 'woocommerce_review_order_before_submit', 'add_privacy_checkbox', 9 );
    function add_privacy_checkbox() {
    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' => 'He leĂ­do y aceptado la <a href="" rel="nofollow">pol&iacute;tica de privacidad</a>',
    add_action('woocommerce_checkout_process', 'privacy_checkbox_error_message');
    function privacy_checkbox_error_message() {
    if ( ! (int) isset( $_POST['privacy_policy'] ) )
    wc_add_notice( __( 'Debes aceptar nuestra política de privacidad.' ), 'error' );

    As far I know, we can modify the order of validation using hooks. I think that “woocommerce_checkout_process” should be executed before Stripe is fired, but not…. when I click on CHECKOUT, the system validates all woocommerce fields (including accept terms and conditions), but not my new custom field, before it, the system validates the Stripe’s fields.

    Do you know how can we change the order / priority of validation of fields? we want to leave the Stripe’s validation at the end.

    Thanks in advance for your time

    • ThemeSkills October 3, 2018 at 9:10 PM - Reply

      Hello! Unfortunately, no, I don’t know. It requires some additional custom coding and, unfortunately, I’m not a web developer. I just use whatever codes I found myself, then share it with you guys.

      • n4gash October 4, 2018 at 1:15 PM - Reply

        Thanks for your time!!!

  4. Marcos October 7, 2018 at 12:27 PM - Reply

    Hey! Awesome post!

    I would like to know if I can translate it using some php inside the “label”.
    Otherwise I would like to display this checkbox under the registration form (not checkout page). Could you help me?

    Thank you very much!

    • ThemeSkills October 7, 2018 at 1:45 PM - Reply

      Hello! Thanks!

      If you want the label to be in another language, then simply add it another language from the start, after 'label' =>.

      As for displaying the checkbox under the registration form, you could try this plugin or search for a custom code on Google. I haven’t written a tutorial for that yet, but it’s on my to-do list :D.

Leave A Comment


- Get guides and offers right into your inbox -

The type of emails that you would like to receive (multiple selection allowed):

You can unsubscribe at any time by clicking the link in the footer of the emails. For more information, please check the privacy policy.

I use MailChimp as my emailing service. By subscribing, you understand that your email and preferences will be transferred to MailChimp. Learn more about MailChimp's privacy practices here.