WooCommerce makes the validation field mandatory if

I have created several new validation fields for my design page. One of the fields is the first switch with "type klant", which allows the user to choose between the type of client (business or private). When ever selected, some fields are hidden / shown by me using Javascript.

The bedrijfsnaam field (company name) is displayed; when bedrijf (business) is selected, it is not required. If this is required, and the user selects "particulier" (private), the field is not hidden with js, but html-wise is present, so when checking is completed, an error is given to enter the company name.

How to change validation only to check the business name field when a business is selected in the client type?

I probably need to do something with do_action( 'woocommerce_before_checkout_process' );to do the required check based on the switch, but am I stuck there, any hints?

Thank!

+4
source share
1 answer

Offering you the best plugin for this:

https://wordpress.org/plugins/woo-checkout-field-editor-pro/

You can add several validation fields and make them mandatory. You can also modify tables of existing fields.

enter image description here

0
source

All Articles