I have been trying to make the billing phone number a required component, but have been unable to affect it in any way. Here’s what I have tried so far
using hooks in functions.php
add_filter('woocommerce_billing_fields', 'no_billing_phone_validation' );
function no_billing_phone_validation( $fields ) {
$fields['billing_phone']['required'] = true;
return $fields;
}
Setting the phone to required in my theme
and using the plugin "Checkout Field Editor for WooCommerce" to set the phone to required
but despite all of this, the billing phone is still optional, and I am able to check out without adding a phone number. Is there anything that I’m missing?
2
Answers
In the end i was able to find a solution. The following file defines the object for the billing field woocommerce/src/blocks/domains/services/checkoutfields.php. That file had the following object
Confusingly, if I set required to true, this did NOT actually make the field required. There must be some function overriding that elsewhere. So what I did was delete the phone object and make an identical phone2 object. This was able to be set to required
How can I add a new field to the new guttenberg Checkout bock? Thanks to the method you put I managed to add the field, but I can’t get it to be reflected in the invoice.
enter image description here