Skip Navigation

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 – 15:00 9:00 – 15:00 9:00 – 15:00 9:00 – 15:00 9:00 – 15:00 - -
- - - - - - -

Supporter timezone: Asia/Yerevan (GMT+04:00)

This topic contains 13 replies, has 2 voices.

Last updated by johannesB-16 1 day, 10 hours ago.

Assisted by: Christopher Amirian.

Author Posts
October 22, 2024 at 9:27 am #16316009

johannesB-16

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.

Questions:
How to fix?

October 22, 2024 at 9:42 am #16316156

Christopher Amirian
Supporter

Languages: English (English )

Timezone: Asia/Yerevan (GMT+04:00)

Hi,

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.

Thank you.

October 23, 2024 at 6:52 am #16320056

johannesB-16

Hi,

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?

Many thanks in advance!

October 23, 2024 at 3:17 pm #16322573

Christopher Amirian
Supporter

Languages: English (English )

Timezone: Asia/Yerevan (GMT+04:00)

Hi,

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.

October 24, 2024 at 1:03 pm #16326426

johannesB-16

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.

hidden link

wpml.png
October 24, 2024 at 1:48 pm #16326739

Christopher Amirian
Supporter

Languages: English (English )

Timezone: Asia/Yerevan (GMT+04:00)

Hi,

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:

hidden link

Thanks.

October 24, 2024 at 2:22 pm #16326923

johannesB-16

Hi and thanks for the quick reply.

If I go to the product page and select customer group 'B2B', the issue still occurs?

October 27, 2024 at 2:36 pm #16334836

Christopher Amirian
Supporter

Languages: English (English )

Timezone: Asia/Yerevan (GMT+04:00)

Hi,

You are correct, I created a report to the compatibility team.

I'd appreciate it that you also share the form below with the plugin developer:

https://wpml.org/documentation/support/go-global-program/

By registering there we will help the plugin developer to make their product compatible with Woocommerce Multilingual.

If I have an update from the compatibility team I will share here.

Thanks

October 30, 2024 at 8:31 am #16345256

johannesB-16

Ok, thanks for the reply.

Should I leave the B2B-Market plugin connected to the sandbox installation?
I had to enter a license key, that's why I'm asking.

Thanks in advance and I will forwad the link to the plugin author.

October 30, 2024 at 3:42 pm #16348208

Christopher Amirian
Supporter

Languages: English (English )

Timezone: Asia/Yerevan (GMT+04:00)

Hi,

I have an answer from the compatibility team.

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:

public function init_bm_update_price() {

	$update_price = BM_Update_Price::get_instance();

	add_action( 'wp_enqueue_scripts', array( $update_price, 'load_assets' ) );
	add_action( 'woocommerce_before_add_to_cart_form', array( $update_price, 'add_hidden_id_field' ), 5 );
	add_action( 'wp_ajax_update_price', array( $update_price, 'update_price' ) );
	add_action( 'wp_ajax_nopriv_update_price', array( $update_price, 'update_price' ) );
}

In order to fix this, we need to add it to our AJAX filters using the wcml_multi_currency_ajax_actions filter:

https://wpml.org/wcml-hook/wcml_multi_currency_ajax_actions/

Workaround:

Add the code below to the functions.php of your theme:

// WPML Workaround for compsupp-7663
add_filter( 'wcml_multi_currency_ajax_actions', 'wpml_compsupp7663_add_actions_to_multi_currency_ajax', 10, 1 );
 
function wpml_compsupp7663_add_actions_to_multi_currency_ajax( $ajax_actions ) {
 
    $ajax_actions[] = 'update_price'; // Add a AJAX action to the array
    return $ajax_actions;
 
}

Would you please test and get back to us with the result?

And if it works, I'd appreciate it if you share it with the plugin developers?

Thanks.

October 31, 2024 at 6:58 am #16349752

johannesB-16

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.

Sorry.

October 31, 2024 at 1:41 pm #16351601

Christopher Amirian
Supporter

Languages: English (English )

Timezone: Asia/Yerevan (GMT+04:00)

Hi,

Thank you. it seems that you added the code before the Endif; in theme functions.php

I made sure that the code is at the very end of the file and it works ok for me now:

hidden link

Thanks.

November 4, 2024 at 7:46 am #16358962

johannesB-16

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.

Thanks in advance!

November 4, 2024 at 10:13 am #16360048

Christopher Amirian
Supporter

Languages: English (English )

Timezone: Asia/Yerevan (GMT+04:00)

Hi,

I am not sure about Astra, but maybe the same error in adding the code that you had for the default theme happens on Asra theme.

I can take a look at the code you added in functions.php and see if it is added correctly.

To do that I will need you to set the next reply as private and provide the login information as the previous login info is deleted by the system.

Thanks.