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.
Tagged: WooCommerce Multilingual
Related documentation:
This topic contains 11 replies, has 2 voices.
Last updated by John 1 year, 10 months ago.
Assigned support staff: Raja Mohammed.
Author | Posts |
---|---|
February 26, 2019 at 1:07 pm #3244983 | |
John |
Hello there, Waiting for your answer. Hope this is possible. {code} Ps. I don.t know what happened to actual ticket |
February 27, 2019 at 9:46 am #3249309 | |
Raja Mohammed Supporter
Languages: English (English ) Timezone: Asia/Kolkata (GMT+05:30) |
Hi There, To switch the language based on user shipping country you might have to add the bit of code hooked up to the function which changes the shipping county based on user country. global $sitepress; /* $lang language code based on the country, it's up to you to decide how to get language code based on country */ $lang = 'nb'; $sitepress->switch_lang($lang, true); I'm really not sure what happened to your previous ticket, we don't close any unanswered tickets up to 10days. However, I will try to resolve your issue in this ticket. Kind regards |
February 27, 2019 at 9:52 am #3249403 | |
John |
Hey Raja, thanks for your reply. |
February 27, 2019 at 9:55 am #3249425 | |
Raja Mohammed Supporter
Languages: English (English ) Timezone: Asia/Kolkata (GMT+05:30) |
Hi John, Please send me a screenshot of the code or paste the entire code here where it is placed. it can give me a better idea. Kind regards, |
February 27, 2019 at 9:57 am #3249430 | |
John |
Hope it is ok thanks. |
February 27, 2019 at 11:56 am #3249970 | |
Raja Mohammed Supporter
Languages: English (English ) Timezone: Asia/Kolkata (GMT+05:30) |
HI John Your code is checking whether the language code is "RO" and sets the language to "RO" which doesn't make any change. The switch language code should be placed in country switch hook please check with the PCB plugin author for the correct hook to add the language switch.You can ask them about the action hook that triggers after county change. Kind regards |
March 4, 2019 at 3:22 pm #3269548 | |
John |
Hello there. I have contacted the plugin author but he doesn't respond yet...any chance to find those hooks by myself? |
March 5, 2019 at 5:25 am #3271725 | |
Raja Mohammed Supporter
Languages: English (English ) Timezone: Asia/Kolkata (GMT+05:30) |
HI John, Please check if you can find any documentation related to the plugin. We can help you with the appropriate code and its placement. Unfortunately, we cannot find any place to look out for available hooks for you. only your plugin author can advise on this. Kind regards |
March 8, 2019 at 3:13 pm #3293514 | |
John |
Hello Raja, -------- |
March 11, 2019 at 5:20 am #3307781 | |
Raja Mohammed Supporter
Languages: English (English ) Timezone: Asia/Kolkata (GMT+05:30) |
Hi there, Try the below code, add in the theme functions.php file. add_action('wp_loaded','customer_country_base'); function customer_country_base() { $user_country = wcpbc_get_woocommerce_country(); $lang = ICL_LANGUAGE_CODE; /* * map languages for country */ switch ( $user_country ) { case "US" : // if country is US $lang = 'en'; // language is set to english break; /* * Add more checks */ } global $sitepress; $sitepress->switch_lang($lang, true); } I hope this helps you better Kind regards |
March 11, 2019 at 4:09 pm #3314639 | |
John |
Raja you are the man. Thanks for your support really appreciate. The code works flawless and i'm using different domains per language. |
March 11, 2019 at 4:09 pm #3314641 | |
John |
My issue is resolved now. Thank you! |