This thread is resolved. Here is a description of the problem and solution.
Problem: You have set up the multi-currency function in WPML with German as the default language and linked the currency CHF to the German language. However, when visiting a product page, the currency switches back to EUR after 2 seconds. Solution: This issue is related to the
BM_Update_Price::update_price()
method, which is hooked to AJAX. To fix this, you need to add it to our AJAX filters using the wcml_multi_currency_ajax_actions filter. Add the following code to the functions.php of your theme:
// WPML Workaround for compsupp-7663<br />add_filter( 'wcml_multi_currency_ajax_actions', 'wpml_compsupp7663_add_actions_to_multi_currency_ajax', 10, 1 );<br /><br />function wpml_compsupp7663_add_actions_to_multi_currency_ajax( $ajax_actions ) {<br /><br /> $ajax_actions[] = 'update_price'; // Add a AJAX action to the array<br /> return $ajax_actions;<br /><br />}
Please test this solution and provide feedback. If it resolves the issue, we recommend sharing this workaround with the plugin developers.
If this solution does not apply to your case, or if it seems outdated, we highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If issues persist, please open a new support ticket.
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.
Background of the issue:
I have set up the multi-currency function in WPML. My default language is German, and I have linked the currency CHF to the German language. This means that if German is the standard language, the prices should be displayed in CHF.
Symptoms:
When I visit a product page, the currency switches back to EUR after 2 seconds.
There was no answer in the chat. I turned the chat into a ticket to be able to answer the question.
That 2 second point you have mentioned suggests that it might be a javascript code of some sort causing the change.
To make sure if it is or not please do as follows:
- IMPORTANT STEP! Create a backup of your website. Or better approach will be to test this on a copy/staging version of the website to avoid any disruption of a live website.
- Switch to the default theme such as "TwentyTwenty" by going to "WordPress Dashboard > Appearance > themes".
- Go to "WordPress Dashboard > Plugins" and deactivate all plugins except Woocommerce, WPML Multilingual CMS, WPML String Translation, and Woocommerce Multilingual.
- Check if you can still recreate the issue.
- If not, re-activate your plugins one by one and check the issue each time to find out the plugin that causes the problem.
FYI: The response time in tickets is longer than in chat.
I was able to track down the issue to the plugin 'B2B Market'.
The developers of the plugin have told me the following:
The problem at this point is that the filter “wcml_price_currency” only works in the frontend.
However, our price updater uses an Ajax call that leads to the backend.
Can you do anything with this or give me further assistance?
This seems to be a compatibility issue with the B2b Market plugin. We can report this to the compatibility team. There is no guarantee for a fix but if the developers of the plugin cooperate we might find a solution.
To be able to report the compatibility issues we need to replicate the issue on a clean installation.
I created a clean installation of WordPress, Woocommerce, WPML, and all necessary WPML add-ons.
You can access the WordPress dashboard using the link below: hidden link
Kindly follow the steps below:
- Install the plugin in question
- Set it up and setup multicurrency
- Try to replicate the issue and get back to us with the steps to see the issue
This will help us to report the probable issue to the compatibility team and solve the possible problem faster.
Hi,
I've setup the B2B Market plugin, multicurrency and WC geolocation.
For customer group 'B2B' exists a 10% discount.
The issue occurs when I am using customer group 'customer' or 'B2B'
If I switch to 'no group', it seems to be working.
Also I mapped USD to English and EUR to German. So if you switch language, the currency is also changed.
Thank you very much. I did some testing and I see if I go to WordPress Dashboard > WPML > Settings > Store a language cookie to support language filtering for AJAX
And uncheck that option, the changing of the currency does not happen:
This issue is related to the BM_Update_Price::update_price() method (app/public/wp-content/plugins/b2b-market/src/class-bm-update-price.php) which is hooked to AJAX in app/public/wp-content/plugins/b2b-market/src/class-bm-hooks.php:
Hi and thanks for the quick response from your compatibility team.
Unfortunately this workaround doesn't work. I tried it on the sandbox installation and also on my staging site.
As soon as I switch to a B2B Market customer group, the issue of changing prices after 2 seconds still occurs.
Hello Christopher and thank you for taking another look at the code.
It seems to work in the sandbox for me.
Unfortunately not on the staging site. However, there seems to be a problem with the Astra theme there. When I switch to Twente Twenty-Four, it seems to work.
So I will also contact the Astra theme support. Do you have any idea what it might be related to? Is it maybe a Javascript problem?
If you have any information that I can pass on to the Astra developers, I would be very grateful.
I unpublished the code from the snippet plugin you used and went to Appearance > Theme file editor and went to functions.php and added the code there.
After that I saw that you did not select which currency to show in each language in multi-currency settings and you set all to KEEP.
I went there and set USD for English and EURO for German. Now if you check you will see that the currencies work ok in English and German.
Select the ones you like for the other languages in Woocomemrce > Woocommerce multilingual & Multi-currency . Multi-currency (tab) (check the screenshot)