WC_Countries::get_address_fields()
Apply locale and get address fields.
Метод класса: WC_Countries{}
Хуки из метода
Возвращает
Массив
.
Использование
$WC_Countries = new WC_Countries(); $WC_Countries->get_address_fields( $country, $type );
- $country(разное)
- Country.
По умолчанию: '' - $type(строка)
- Address type.
По умолчанию: 'billing_'
Код WC_Countries::get_address_fields() WC Countries::get address fields WC 9.8.1
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 ) { if ( 'state' === $key ) { $value['country_field'] = $type . 'country'; $value['country'] = $country; } $address_fields[ $type . $key ] = $value; } // Add email and phone fields. if ( 'billing_' === $type ) { if ( 'hidden' !== CartCheckoutUtils::get_phone_field_visibility() ) { $address_fields['billing_phone'] = array( 'label' => __( 'Phone', 'woocommerce' ), 'required' => 'required' === CartCheckoutUtils::get_phone_field_visibility(), 'type' => 'tel', 'class' => array( 'form-row-wide' ), 'validate' => array( 'phone' ), 'autocomplete' => 'tel', 'priority' => 100, ); } $address_fields['billing_email'] = array( 'label' => __( 'Email address', 'woocommerce' ), 'required' => true, 'type' => 'email', 'class' => array( 'form-row-wide' ), 'validate' => array( 'email' ), 'autocomplete' => 'email', 'priority' => 110, ); } /** * 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 ); // Sort each of the fields based on priority. uasort( $address_fields, 'wc_checkout_fields_uasort_comparison' ); return $address_fields; }