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.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
- | 9:00 – 12:00 | 9:00 – 12:00 | 9:00 – 12:00 | 9:00 – 12:00 | 9:00 – 12:00 | - |
- | 13:00 – 18:00 | 13:00 – 18:00 | 13:00 – 18:00 | 13:00 – 18:00 | 13:00 – 18:00 | - |
Supporter timezone: Asia/Singapore (GMT+08:00)
Tagged: Custom Work
This topic contains 20 replies, has 2 voices.
Last updated by Kor 1 year, 8 months ago.
Assisted by: Kor.
Author | Posts |
---|---|
December 28, 2022 at 3:27 pm #12723565 | |
louisN-4 |
I Am using this on kideno.com/ WooCommerce Multilingual & Multicurrency with WPML i want to know what can i put in url link, in order to to show by certain currency when hidden link for example ?currency=USD then the page will open with USD currency of hidden link then it will show GBP price when someone opens the page - please convert it to support forum ticket and answer there |
December 28, 2022 at 3:39 pm #12723699 | |
louisN-4 |
? |
December 28, 2022 at 4:01 pm #12723885 | |
Kor Supporter
Languages: English (English ) Timezone: Asia/Singapore (GMT+08:00) |
Hi there, Thanks for your reply. I would need to take a closer look at your site. So I would need to request temporary access (WP-Admin and FTP) preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed IMPORTANT: Please, note, a backup is required for security reasons, and to avoid any data loss, you can use the https://wordpress.org/plugins/updraftplus/plugin for these backup needs. Your following answer will be private, which means only you and I have access to it. ✙ I would need your permission to de-activate and re-activate Plugins and the Theme and to change configurations on the site if required. This is also a reason the backup is critical. Thanks! Kor |
December 28, 2022 at 4:20 pm #12723911 | |
Kor Supporter
Languages: English (English ) Timezone: Asia/Singapore (GMT+08:00) |
Hi there, Thanks for your reply. Sorry, I wanted to check and see if you've inserted the code below into your theme's functions.php file. As explained here https://wpml.org/forums/topic/change-the-currency-with-the-url-parameters/#post-8451565 , it should achieve what you needed there. add_filter( 'wcml_client_currency', 'modify_client_currency', 10, 1 ); function modify_client_currency( $current_currency ) { if( !is_admin() ){ global $woocommerce; $currency = isset( $_GET['currency'] ) ? esc_attr( $_GET['currency'] ) : $current_currency; $currency = strtoupper( $currency ); $woocommerce->session->set('client_currency', $currency); return $currency; } } Could you perform a backup and try inserting the code above into your themes functions.php file? You can use the code snippet plugin if you want. Let me know how it goes. Thanks! Kor |
December 28, 2022 at 10:16 pm #12725165 | |
louisN-4 |
i think you have difficulties understanding me, so maybe if you have problem with english or my english you should pass the ticket to someone else - the reason i am sure you have a problem on your end since its the 2nd time - you don't ANSWER MY QUESTION if you want to give another try, please erase everything you think you read above and try to read my question again........................ What do i need to put in the URL line, - Same as i am able to choose variable from the URL line (?attribute_pa_color=) EXAMPLE: hidden link |
December 29, 2022 at 5:13 am #12726079 | |
Kor Supporter
Languages: English (English ) Timezone: Asia/Singapore (GMT+08:00) |
Hi there, Thanks for your reply. I apologize for not being able to clearly explain my answer in a way you can understand. To be able to select a currency using a URL parameter on your product (eg. ?currency=USD or ?currency=GBP), you need to insert the custom PHP code below into your theme's functions.php file. IMPORTANT: Please, note, a backup is required for security reasons, and to avoid any data loss, you can use the https://wordpress.org/plugins/updraftplus/plugin for these backup needs. add_filter( 'wcml_client_currency', 'modify_client_currency', 10, 1 ); function modify_client_currency( $current_currency ) { if( !is_admin() ){ global $woocommerce; $currency = isset( $_GET['currency'] ) ? esc_attr( $_GET['currency'] ) : $current_currency; $currency = strtoupper( $currency ); $woocommerce->session->set('client_currency', $currency); return $currency; } } Once you've done that, try changing the currency using the links below and see if it works. hidden link If you want me to insert this custom PHP code, let me know, and please backup first. Let me know how it goes. Thanks! Kor |
December 29, 2022 at 11:54 am #12728323 | |
louisN-4 |
shall i run the above snippet only on admin or also on frontend? |
December 29, 2022 at 3:22 pm #12729605 | |
Kor Supporter
Languages: English (English ) Timezone: Asia/Singapore (GMT+08:00) |
Hi there, Thanks for your reply. I believe you're referring to the options in the Code Snippet plugin. You can select "Run snippet everywhere, " which should work without issues. I apologize again for any inconvenience that this may have caused. Thanks! Kor |
December 29, 2022 at 3:52 pm #12729765 | |
louisN-4 |
1. good - i implemented your snippet, and when i go to i get this page with GBP pricing can you please try from your end that all is ok? |
December 29, 2022 at 3:54 pm #12729767 | |
Kor Supporter
Languages: English (English ) Timezone: Asia/Singapore (GMT+08:00) |
Hi there, It works fine here, as shown in the attached screenshot. Glad that helped. Thanks! Kor |
January 3, 2023 at 9:43 am #12743711 | |
louisN-4 |
the snippet is working, but we started getting this log error every several minutes 2023-01-02T23:41:07+00:00 CRITICAL Uncaught Error: Call to a member function set() on null in /home/kidenoad/domains/kideno.com/public_html/wp-content/plugins/code-snippets/php/snippet-ops.php(469) : eval()'d code:10 |
January 3, 2023 at 10:22 am #12744097 | |
louisN-4 |
also another thing going into: i see GBP, BUT if i continue to browse the site, it will show USD pricing, can you amend your snippet? |
January 4, 2023 at 10:45 am #12750477 | |
Kor Supporter
Languages: English (English ) Timezone: Asia/Singapore (GMT+08:00) |
Hi there, Thanks for your reply. The error message you're getting refers to the "Code Snippet" plugin, which has to be addressed by that plugin author. As for "BUT if i continue to browse the site, it will show USD pricing,", I couldn't replicate this as shown in this screen recording. hidden link Thanks! Kor |
January 4, 2023 at 11:31 am #12750699 | |
louisN-4 |
you video is great, BUT 1. go to the cart page OR 2. homepage AND you will see it changes to USD |
January 5, 2023 at 11:32 am #12757813 | |
louisN-4 |
are you checking why in cart page it goes back to USD? |
The topic ‘[Closed] WooCommerce Multilingual & Multicurrency with WPML’ is closed to new replies.