Reputation: 59
I have a code below, it adds the field with label but does not add required field not sure why.
add_filter('woocommerce_checkout_fields',
'override_default_address_fields');
function override_default_address_fields($address_fields)
{
$address_fields['billing']['billing_address_2'] = array(
'label' => __('Mobile', 'woocommerce'),
'required' => true,
);
return $address_fields;
}
Any help is appreciated! thanks in advance
Upvotes: 0
Views: 109
Reputation: 65274
I think you're doing it wrong...
instead of ['billing_address_2']
, use your own like ['billing_mobile']
.
add_filter('woocommerce_checkout_fields', 'override_default_address_fields');
function override_default_address_fields( $address_fields ) {
$address_fields['billing']['billing_mobile'] = array(
'label' => __('Mobile', 'woocommerce'),
'required' => true,
);
return $address_fields;
}
with what you are doing you're overriding ['billing_address_2']
. Which I think you are seeing it as a problem because you are only seeing the Mobile
label.
Upvotes: 1