public function get_address_fields($country = '', $type = 'billing_')
{
if (!$country) {
$country = $this->get_base_country();
}
$fields = $this->get_default_address_fields();
$locale = $this->get_country_locale();
if (isset($locale[$country])) {
$fields = wc_array_overlay($fields, $locale[$country]);
}
// Prepend field keys
$address_fields = array();
foreach ($fields as $key => $value) {
$keys = array_keys($fields);
$address_fields[$type . $key] = $value;
}
// Add email and phone fields.
if ('billing_' === $type) {
$address_fields['billing_phone'] = array('label' => __('Phone', 'woocommerce'), 'required' => true, 'type' => 'tel', 'class' => array('form-row-first'), 'validate' => array('phone'), 'autocomplete' => 'tel');
$address_fields['billing_email'] = array('label' => __('Email address', 'woocommerce'), 'required' => true, 'clear' => true, 'type' => 'email', 'class' => array('form-row-last'), 'validate' => array('email'), 'autocomplete' => 'no' === get_option('woocommerce_registration_generate_username') ? 'email' : 'email username');
}
/**
* Important note on this filter: Changes to address fields can and will be overridden by
* the woocommerce_default_address_fields. The locales/default locales apply on top based
* on country selection. If you want to change things like the required status of an
* address field, filter woocommerce_default_address_fields instead.
*/
$address_fields = apply_filters('woocommerce_' . $type . 'fields', $address_fields, $country);
return $address_fields;
}