I need to modify the checkout process for an woocommere website. The process is determinated by the status of the person that could be one of this:
- 'legal entity'
- 'individual'
I need to have a selector 'User status'
(or radio buttons), just after the 'billing_first_name' and 'billing_last_name'.
The selector should work this way:
- If
'legal entity'
is selected, it should display 3 fields:
- 'phone_number'
- 'email'
- 'serial_id'
- If
'individual'
is selected, it should display 3 other fields:
- 'custom_field1'
- 'custom_field2'
- 'custom_field3'
I tried WooCommerce Checkout Manager and another plugin but the problem is that I can't make matching conditions.
How can I achieve this?
Thanks.
For WooCommerce 3+ (update):
Below I am just updating the part related to ordering fields:
Reference: Reordering checkout fields in WooCommerce 3
Original answer:
You need to use
woocommerce_checkout_fields
hook. Then first create the new fields. After Customize some field classes. To finish reorder the field to match your desire.Here is the code:
Naturally this goes on function.php file of your active child theme or theme
This code is tested and fully functional.
Official reference: WooThemes - Customizing checkout fields using actions and filters