How to add GDPR support on your custom WooCommerce plugin

- PHP, Wordpress

I am not an expert of GDPR but probably like you I was looking for a way to add GDPR support on my freemium plugin, WooCommerce Fiscalità Italiana.

The problem actually that aren’t available on the net articles or tutorial about how to do it…

There is the official announcement of WooCommerce about 3.4 that add this support but now how to use for developers.

So the step for me was to search about other plugin that support WooCommerce 3.4 and by Automattic to be fast and find a plugin where find hooks and also code examples that works.

After a while I saw that there are 2 sets of filters useful for a plugin developer that add on users and order specific data that are sensible.

The first one are the family of hooks *_props that is a filter that require the IDs of the methods of WC_Customer/WC_Order classes (automatically will do a loop and with a little bit of magic the support is already done).

In my case this wasn’t good because I not extended this classes and added custom functions (to use it also frontend site) so there are another family of hooks that is an action executed at the end, perfect for me.

You can see my code that:

  • Add support on erase this data inside orders, for my WooCommerce plugin means that VAT and other info are replaced with [erased]
  • Add support on erase this data for customer removing them
  • Add support on export order and customer data included by custom stuff

With the support of WooCommerce with stuff this confirm that this procedure will work for everyone.

The code: https://plugins.trac.wordpress.org/browser/woo-fiscalita-italiana/tags/1.2.21/includes/WFI_GDPR.php

Actually I don’t know about implement other kind of GDPR stuff, I hope that WooCommerce will do a documentation for it soon.

My suggestion is you don’t know look on other plugins that do what you need and look their code.

This is open source, baby!

Liked it? Take a second to support Mte90 on Patreon!

Become a Patreon
All the stuff released in this website, where the author is Daniele Scasciafratte, is under the GPL 2.0 license except when the resources have their licenses.

Leave a Reply