Please make sure to update to WPML 4.3.5 and check our list of Known Issues before reporting

Hi, Amit here, I am the WPML Support Manager, our current ticket queue is high, update your WPML plugins and make sure you meet the minimal requirements for running WPML before reporting an issue please - many tickets are resolved doing that

Please look at our updated list of Known Issues and you can also use our support search to find helpful information and of course review our documentation before opening a ticket.

If you do need to open a ticket please make sure to provide us with all the needed information as described in this page

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

This thread is resolved. Here is a description of the problem and solution.

Problem:

How to limit the WooCommerce checkout form to specific countries for each language?

Solution:

This is part of the solution for the issues that were presented in this thread.

You can try and use this custom code in the functions.php file of your theme.

function woo_override_checkout_fields_billing( $fields ) { 
    if(ICL_LANGUAGE_CODE=='tr'){
    $fields['billing']['billing_country'] = array(
        'type'      => 'select',
        'label'     => __('My New Country List', 'woocommerce'),
        'options'   => array('TR' => 'Turkey')
    );
    }
    elseif (ICL_LANGUAGE_CODE=='en'){
        $fields['billing']['billing_country'] = array(
            'type'      => 'select',
            'label'     => __('My New Country List', 'woocommerce'),
            'options'   => array('AU' => 'Australia')
        ); 
    }
    return $fields;
} 
add_filter( 'woocommerce_checkout_fields' , 'woo_override_checkout_fields_billing' );

Of cours, that this is an example and you will need to do some adjatments for this code to your case/countries.

Relevant Documentation:

This code is based on the information from the following links.

https://stackoverflow.com/questions/45385808/strict-to-1-country-only-in-checkout-page-with-wordpress-and-woocommerce

https://wpml.org/documentation/support/wpml-coding-api/

It is important to mention that since it is custom code and it involves a third party function (WooCommerce), we will not be able to support it or guarantee that it will work.

100% of people find this useful.

This topic contains 15 replies, has 2 voices.

Last updated by Itamar 2 years ago.

Assigned support staff: Itamar.

Author Posts
November 19, 2017 at 10:27 pm #1435210

Itamar
Supporter

Languages: English (English ) Hebrew (עברית )

Timezone: Asia/Jerusalem (GMT+02:00)

Hi, Baljot.

You are right unfortunately the code does not work.
The thing is that the original code, the one from this link (hidden link), does not work either.
Even without our suggested modification and if this code is added to the functions.php file of the theme, the countries list does not change.
I'm sorry but as I already mentioned these custom modifications relate to WooCommerce and not to WPML and out of the scope of this support forum.
If you are stuck then, please consider again getting professional help as I've already suggested here https://wpml.org/forums/topic/checkout-currency-and-countries-not-converting/#post-1416727.

Best regards,
Itamar.