WP SITES

3082 Coded Tutorials & 284 Plugins

Conditional Fields For Contact Block Using Block Checkout

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 :

  1. A checkbox which once checked shows the a conditional field.
  2. A conditional select field. When the option named other is selected, the next field displays.
  3. 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

  1. Copy and paste the PHP code to the end of your child themes functions file or custom code snippets plugin.
  2. Modify the values for the labels and values for the options.

Related Coded Solutions

Leave a Reply

New Plugins