B
B
BIGO232019-06-21 02:08:37
WordPress
BIGO23, 2019-06-21 02:08:37

How to set the country at the top of the list?

Hello. Tell me how to put the country Russia at the top of the list when choosing a country in the delivery just in the store about 70 countries

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mikhail Kobzarev, 2019-06-21
@mihdan

You can sort the finished list through a hook

add_filter( 'woocommerce_checkout_fields', 'add_custom_select_country' );
function add_custom_select_country( $fields ) {
    $fields['billing']['billing_select_country'] = array(
        'type'      => 'select',
        'required'  => true,
        'clear'     => false,
        'options'   => array(
        'country'   => __('Country', 'woocommerce' ),
        'fr'        => __('France', 'woocommerce' ),
        'gb'        => __('United Kingdom', 'woocommerce' ),
        'ru'        => __('Russian', 'woocommerce' )
    )
);
return $fields;
}

In the example, it's just a task of a static list, but in your case you need to take the entire list, unset for Russia and add it to the beginning.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question