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://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.
Related documentation:
This topic contains 15 replies, has 2 voices.
Last updated by Itamar 2 years ago.
Assigned support staff: Itamar.
Author | Posts |
---|---|
October 24, 2017 at 6:44 pm #1410504 | |
kamalpreetS |
Hi there, How can I limit countries during checkout as some people are automatically using US prices to turn Canadian and pay without conversion. How do I fix this? For example, someone visits: hidden link They fill out the form and go all the way to check out. Once they go to checkout and change their country to Canada, they still pay the same price without conversion. How is this even possible? That's the reason why I have WPML and WooCommerce. |
October 25, 2017 at 8:50 am #1410997 | |
Itamar Supporter
Languages: English (English ) Hebrew (עברית ) Timezone: Asia/Jerusalem (GMT+02:00) |
Hello. I've visited the link that you shared with me and filled the form, and I could see that the price does not change. Regards, |
October 25, 2017 at 12:24 pm #1411276 | |
kamalpreetS |
Hi @itamar, Sorry I think you didn't understand. The entire form is here: hidden link Once you fill out the entire form (if you can do so with any test fields, etc.), you'll see it redirect to WooCommerce Cart/Checkout. When checking out, the listed countries available include Canada although being on the USA website: hidden link When you select Canada, the currency doesn't convert. I want people to have a converted currency even if they choose Canada because I don't want my Canadian clients ordering from the US website. Right now it's not even converting and that's all through WPML. Please advise. |
October 25, 2017 at 5:41 pm #1411863 | |
Itamar Supporter
Languages: English (English ) Hebrew (עברית ) Timezone: Asia/Jerusalem (GMT+02:00) |
Hi. Because it wasn't clear to me from which form I should start, I have gone through the checkout process twice. First starting from here hidden link and the second time starting from here hidden link |
October 26, 2017 at 3:15 pm #1413129 | |
kamalpreetS |
Hi @itamar, For the USA, it just states CAD but it's not really CAD for the US website. If you go to PayPal it'll show you in USD. The issue is if you choose "Canada" in the country under the USA checkout, the currency doesn't convert. People are able to pay in CAD which shouldn't be allowed! |
October 29, 2017 at 3:51 pm #1415042 | |
Itamar Supporter
Languages: English (English ) Hebrew (עברית ) Timezone: Asia/Jerusalem (GMT+02:00) |
Hi and sorry for the late response here. OK, now I can see the problem on your site. Could you, please tell me what are the multi-currency settings (WooCommerce -> WooCommerce Multilingual -> Multi-currency tab) that you have set? Thanks, |
October 30, 2017 at 2:53 pm #1415815 | |
kamalpreetS |
Hi Itamar, Here are the issues clearly, similar to how you defined the issue: 1. You are correct, on the US website when checking out and selecting Canada, it doesn't convert the USD to CAD. Also, tax doesn't show up. This happens vice versa. 2. What people are doing to take advantage of the flaw, is for the Canadian website, people are putting USA in the billing country which ends up avoiding tax for people when checking out. This shouldn't be allowed. Next step is: 1. Currency should convert automatically so people can't avoid paying the difference. 2. How can we limit the countries on checkout for each version of the site? We should remove Canada from the USA and remove USA from Canada. Attached are the settings on the WooCommerce Multilingual page. |
October 31, 2017 at 12:09 pm #1416727 | |
Itamar Supporter
Languages: English (English ) Hebrew (עברית ) Timezone: Asia/Jerusalem (GMT+02:00) |
Hi. You write: "1. Currency should convert automatically so people can't avoid paying the difference." You ask: "How can we limit the countries on checkout for each version of the site? We should remove Canada from the USA and remove USA from Canada." Please let me know if my answers address your issue. Regards, |
November 8, 2017 at 9:59 pm #1425196 | |
kamalpreetS |
Hi there, See attached my screenshot. What happens is that someone selects USA from the Canadian website to get no tax in checkout and they'll still pay Canadian given the site is the Canadian version thus CAD. How can we stop that? |
November 9, 2017 at 8:13 pm #1426528 | |
Itamar Supporter
Languages: English (English ) Hebrew (עברית ) Timezone: Asia/Jerusalem (GMT+02:00) |
Hi. I may be failing to understand what you want to achieve, so I'm consulting our second tier supporter about this issue. |
November 13, 2017 at 3:27 pm #1429100 | |
kamalpreetS |
Hi Itamar, Any word on this? Thanks, Baljot |
November 13, 2017 at 4:00 pm #1429130 | |
Itamar Supporter
Languages: English (English ) Hebrew (עברית ) Timezone: Asia/Jerusalem (GMT+02:00) |
Hi, Baljot. Our second tier confirms what I have said here and says that WPML does not control the WooCommerce country based on the language of the site. Languages can be limited, but countries can be all. Or restrict shipping countries list on Woocommerce checkout page by adjusting the code example that is attached to the article in the following link. function woo_override_checkout_fields( $fields ) { if (apply_filters( 'wpml_current_language', 'us')) { $fields['shipping']['shipping_country'] = array( 'type' => 'select', 'label' => __('My New Country List', 'woocommerce'), 'options' => array('US' => 'United States') ); } elseif (apply_filters( 'wpml_current_language', 'ca' )) { $fields['shipping']['shipping_country'] = array( 'type' => 'select', 'label' => __('My New Country List', 'woocommerce'), 'options' => array('CA' => 'Canada') ); } return $fields; } add_filter( 'woocommerce_checkout_fields' , 'woo_override_checkout_fields' ); Please note that the above code was not tested and is just a suggestion. Regards, |
November 13, 2017 at 4:04 pm #1429134 | |
kamalpreetS |
Hi Itamar, Thank you for the response. I think the code you provided is the right direction. One adjustment I have and with your guidance it would be perfect. Can you provide a code that would restrict Canada from the USA website and restrict USA from the Canada website? Because people on the USA website should be allowed to order from any country excluding Canada. For Canada, it's only Canada and no other country in the world.. Thank you!! |
November 13, 2017 at 4:15 pm #1429168 | |
Itamar Supporter
Languages: English (English ) Hebrew (עברית ) Timezone: Asia/Jerusalem (GMT+02:00) |
I see, Baljot. So for Canada, I believe that the second part of the suggested code will get you what you need. Thank you for your understanding. Best regards, |
November 17, 2017 at 3:22 pm #1434089 | |
kamalpreetS |
Hi Itamar, Unfortunately the code you provided didn't work. Can you try testing on my website here: hidden link All countries are still available when checking out for some reason. Baljot |