Automattic\WooCommerce\Blocks\Domain\Services
CheckoutFields::update_default_locale_with_fields
Update the default locale with additional fields without country limitations.
Method of the class: CheckoutFields{}
No Hooks.
Returns
Mixed.
Usage
$CheckoutFields = new CheckoutFields(); $CheckoutFields->update_default_locale_with_fields( $locale );
- $locale(array) (required)
- The locale to update.
CheckoutFields::update_default_locale_with_fields() CheckoutFields::update default locale with fields code WC 10.8.1
public function update_default_locale_with_fields( $locale ) {
foreach ( $this->get_fields_for_location( 'address' ) as $field_key => $field ) {
if ( empty( $locale[ $field_key ] ) ) {
// If the field has conditional rules, we need to set the required property to false so it can be evaluated.
if ( $this->is_conditional_field( $field_key ) ) {
$field['required'] = false;
}
$locale[ $field_key ] = $field;
}
}
return $locale;
}