gdpr

How to create a B2B Ecommerce

 

To create a B2B Ecommerce with WordPress, we recommend using the Woo Commerce B2B plugin. The plugin is done very well. His programmer, is really very prepared, perhaps one of the best wordpress plugin developers that we have ever had the opportunity to know at a working level.

A B2B Ecommerce, as the name implies, is an Ecommerce reserved only for customers with VAT. Often you would like to limit the visibility of the catalog to registered customers only, or display products with hidden prices to users who are not logged in. This plugin includes all the features needed to set up our store exactly how we want it.

The very intuitive Setup screen, located in the settings under the Woocommerce menu -> Setup -> B2B, and is divided into four sections. A settings section and a products section in which we have the possibility to:

  • Limit the visibility of the catalog – For example, if we want to make access exclusive
  • Hide prices from non-logged in customers – For example, if you want to show the catalog to all users of the website
  • Decide whether you want to display one or more product categories to certain groups – useful, for example, when you want to reserve the sale of some products, perhaps exclusive and reserved for a certain type of customer

WooCommerce_B2B - Impostazione prodotti

Then we have various options regarding the checkout and cart. In this area there are the two items that allow us to transform our Ecommerce into a B2B shop. To achieve this, we must activate the VAT request option (in order to exclude any private individuals from registration) and make it mandatory.

If you want, however, you can even set the plugin to sell to B2Cs. Such as? Let’s move to the users menu and create a “PRIVATE” group. In this case, we must NOT make the VAT a mandatory field and we must remember to check the box to display one or more product categories to certain groups. We then create special categories and combine them with the “PRIVATE” group. We can give this group the possibility, for example, to purchase via credit cards, while the other groups can make requests for quotations. And yes, this plugin also has this ability to manage offers !!!

 

WooCommerce_B2B - Impostazioni Carrello e caasa

I also remind you to enable the option in the last section to allow customers to login only after approval by the admin “, so that you can match the correct group based on the type of user you are registered.

Woo Commerce B2B - Impostazione Clienti

Yoast plugin & Woo Commerce B2B

If you also use the Yoast SEO plugin, there is a conflict when you enable “display one or more product categories to certain groups” option. Yoast writes the “NOIndex” attribute on the category pages. This appears to be caused by the tax_query when updated using pre_get_posts (read here for more information). Here is the exact workaround to use to get around the problem:

 

add_filter(‘wpseo_robots’, ‘yoast_cat_noindex’, 999);
function yoast_cat_noindex($string= “”) {
if (is_product_category()) {
$string= “index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1”;
}
return $string;
}

 

for more information on the various features, please refer to the plugin website. Instead, below we are going to see how to make this plugin compliant with Iubenda’s GDPR solutions.

 

How to make “Woo Commerce B2B” GDPR compliance using Iubenda solutions

 

The default woocommerce registration form does not have the flags for acceptance of the Privacy Policy and terms and conditions and not even a possible flag for the request to send the Newsletter.

Using the add_action function, we are going to implement the registration form. If you use for example WPML, and set a well-defined label such as ‘privacy_management’, by usign a plugin, you can then translate them into various languages.

add_action( ‘woocommerce_register_form’, ‘mywoocommerce_register_form’, 11 );

function mywoocommerce_register_form() {
woocommerce_form_field( ‘receive_newsletter’, array(
‘type’ => ‘checkbox’,
‘class’ => array(‘form-row-wide’),
‘label’ => __( ‘Do you want to subscribe to our newsletter?’, ‘privacy_management’ ),
‘clear’ => true,
), get_user_meta(get_current_user_id(), ‘receive_newsletter’, true));
woocommerce_form_field( ‘privacy_policy_reg’, 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”>Privacy Policy</a>’, ‘privacy_management’ )
));
woocommerce_form_field( ‘terms_reg’, 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=”/terms-conditions”>Terms and conditions</a>’, ‘privacy_management’ )
));
}

As usual, we must take care to collect the user’s consent. As this form is not based on Contact Form 7, we will not be able to leverage Iubenda’s wordpress plugin to map the fields and register them in the Iubenda Consent Solution.

What can we do in this case? By leveraging the woocommerce_created_customer hook we can intercept when the user has been created and execute the save trigger via the iubenda API

add_action( ‘woocommerce_created_customer’, ‘mywoocommerce_created_customer’, 10, 3 );

{

‘ preparo $consent_data secondo le mie esigenze. Vedi a questo proposito la guida di Iubenda per le API

$req = curl_init(); $req = curl_init();

curl_setopt($req, CURLOPT_URL, ‘https://consent.iubenda.com/consent’);

curl_setopt($req, CURLOPT_RETURNTRANSFER, true);

curl_setopt($req, CURLOPT_HTTPHEADER, array( ‘ApiKey: myapikey’, ‘Content-Type: application/json’ ));

curl_setopt($req, CURLOPT_POST, true);

curl_setopt($req, CURLOPT_POSTFIELDS,

json_encode($consent_data)); $response = curl_exec($req);

}

 

We will also have to worry about capturing a possible change of consent from the details screen by leveraging the woocommerce_save_account_details hook, for example if the user changes the flag for newsletters.

 

Now we are able to register the consent as required by the GDPR, in the consent Solution of Iubenda!

Newsletter subscription form