Checkout V2 - Ability to specify optional and required for checkout fields (like the default WooCommerce)

Hello bricks team,

One crucial feature regarding checkout field management which was overlooked in version 2.4 is the ability to configure fields as either optional or required. It would be fantastic if the addition of this feature brought the Bricks checkout system to full maturity, eliminating the need for custom code or third-party plugins to manage field requirements.

WooCommerce has this feature in the Billing fields block.

You should be able to configure this in Apperance > Customize > WooCommerce > Checkout

Hi,

I agree that this feature is missing. But what if I said that customizing the Field “mandatory” or not should also be allowed for other fields such as:

  • Last Name / First Name → In some cases, we only need one “Name” field and can set its Label as Full Name, what then?

  • Country → What if we have defined the country as unique and default from the configuration? It doesn’t need to be entered, it can be changed,

  • Phone Number / Email → What if we make the core of the registration and create a “Customer” as Phone Number instead of email, and email is secondary?

  • Address 1 / Address 2 / City / State / Postcode / Company → All of these need the ability to customize.

add_filter('woocommerce_billing_fields', function (array $fields): array {
    $fields['billing_first_name']['required'] = true;
    $fields['billing_last_name']['required']  = true;
    $fields['billing_company']['required']    = false;
    $fields['billing_country']['required']    = true;
    $fields['billing_address_1']['required']  = true;
    $fields['billing_address_2']['required']  = false;
    $fields['billing_city']['required']       = true;
    $fields['billing_state']['required']      = true;
    $fields['billing_postcode']['required']   = false;
    $fields['billing_phone']['required']      = true;
    $fields['billing_email']['required']      = true;

    return $fields;
}, 20);

If it is not available, we can and must use the code above.

This will also be necessary to enforce requirements for fields other than billing fields—such as shipping fields, notes, and so on.

It enables optimized customization for our checkout page.

@Matej Please take a look and keep this in mind for us :heart_eyes:.

Thanks

:bear: