The code in this download folder enables you to add conditional fields to the contact information block when using the block checkout in WooCommerce.
Note : The code will not work with the old woocommerce checkout shortcode.
The code adds 3 fields in the contact location :
- A checkbox which once checked shows the a conditional field.
- A conditional select field. When the option named other is selected, the next field displays.
- A text field which displays conditionally when the select field equals a value of other.
Here’s the checkbox which displays by default on page load :

Followed by the conditional select field :

Which then displays a text field when a specific option is selected :

Demo Video
Shows the 3 fields added to the contact information block and shown conditionally based on field values.
Installation
- Copy and paste the PHP code to the end of your child themes functions file or custom code snippets plugin.
- Modify the values for the labels and values for the options.
Related Coded Solutions
Leave a Reply