Configuring a role based checkout field in WooCommerce
This documentation is for the Advanced Checkout Fields for WooCommerce plugin.
Using the WooCommerce Advanced Checkout Fields plugin you can setup checkout fields for many different scenario's. For example, you can setup a role based checkout field such as a VAT number field only for wholesale users.
Role based checkout fields in WooCommerce
To setup a role based checkout field you first want to create a new Checkout Field group in the plugin. In the first section on the page you can set the conditions for when you'd like the checkout group to be applied. In here you can set / add a 'User role' condition and set this to the 'Wholesale' (or something else) user role. If you don't have the wanted user role yet, at the end of this doc you'll find more information on how you can create new user roles.
Then you can add a new checkout field in any of the 'Billing', 'Shipping' or 'Other' sections on the screen for the VAT Number field. For this I believe it fits best under the Billing section;
As you can see I've positioned the VAT Number field just below the Company name field, which just feels right.
Role based checkout field on the front-end
On the front-end it fits perfectly with the other fields, and it only affects logged-in users with the 'Wholesale' user role assigned to their account.
Creating new user roles
The 'Customer' user role that WooCommerce comes with by default is automatically assign to each new user that is ordering something at your store (and creating a account in the process). In this doc I've described how to setup a field based on a 'Wholesale' user role, which doesn't exist by default. To create this I recommend to use a user management plugin such as User Role Editor.