Skip to content Skip to sidebar

This thread is resolved. Here is a description of the problem and solution.

Problem:
The client reported an issue with WPML multicurrency where, after a sale ends, the product price does not revert to the original price correctly. This problem occurs when the sale end date is reached, and the sale price fields become empty as expected, but the original price displayed is incorrect, seemingly due to a currency calculation error.
The issue is related to the price filter on scheduled event when the default currency is not set for the default language.

Solution:
We provided a workaround to address the issue until a permanent fix is released in a new version of WooCommerce Multilingual (WCML). We recommended adding the following code to the functions.php file of the client's current theme:

/**
 * @link wpmlsupp-11119
 */
function wpmlsupp_11119_remove_price_filter() {
	global $woocommerce_wpml;
	$actions_to_remove_back = [
		'wc_before_products_starting_sales' => 'wc_after_products_starting_sales',
		'wc_before_products_ending_sales' => 'wc_after_products_ending_sales',
	];

	if ($woocommerce_wpml instanceof woocommerce_wpml && isset($actions_to_remove_back[current_action()])) {
		remove_filter('get_post_metadata', [$woocommerce_wpml->multi_currency->prices, 'product_price_filter'], 10);
		add_action($actions_to_remove_back[current_action()], function () use ($woocommerce_wpml) {
			add_filter('get_post_metadata', [$woocommerce_wpml->multi_currency->prices, 'product_price_filter'], 10, 4);
		});
	}
}
add_action('wc_before_products_starting_sales', 'wpmlsupp_11119_remove_price_filter');
add_action('wc_before_products_ending_sales', 'wpmlsupp_11119_remove_price_filter');

We asked the client to let us know if this solution resolved the issue.

Please note that this solution might be outdated or not applicable to your case. If you're experiencing a similar issue and the provided solution does not help, we highly recommend checking related known issues, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If the issue persists, please open a new support ticket with us.

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 topic contains 24 replies, has 4 voices.

Last updated by Nicolas V. 1 year, 3 months ago.

Assisted by: Nicolas V..

Author Posts
April 3, 2024 at 11:46 am #15477801

jesperA

I found a bug (and a solution) which seems to be related to wpml multicurrency.
After a sale of a product ends (end date is expired) there’s an error recalculating the price of a product to its original price.

Scenario (can be repeated on my site):

1. I put a product on sale by putting a new price in “Sale price" (original currency).
2. I set the start and end date of the sale.
3. I wait until the end date is reached/expired. The sale price and the start and end date are shown as empty (as it should) in the backend. I expect the original price to be returned however this price is very wrong. Seems to be wrong in the currency calculation although you can’t see this when editing the product - only in the list view of the products etc.
4. To “fix” this I need to set an end date manually (start date isn’t necessary) to a future date, and publish. The price is now correct (returned to original price)!

Btw. this option is chosen: Calculate prices in other currencies automatically

Skärmavbild 2024-04-03 kl. 13.45.15.png
April 3, 2024 at 1:32 pm #15478706

Alejandro
WPML Supporter since 02/2018

Languages: English (English ) Spanish (Español ) Italian (Italiano )

Timezone: Europe/Rome (GMT+02:00)

Hi there!

I'll help you out while a supporter takes your ticket.

1) Could you test the latest versions we released for WooCommerce Multilingual, String Translation and WPML, and check if the problem is still there?

2) Can you check if this issue happens also if you do not have the multicurrency feature enabled? because I'm not entirely sure the multicurrency is part of the issue (but it can help us recreate the issue on our end easily).

April 3, 2024 at 1:45 pm #15478766

jesperA

Hi,
1) All the WPML plugins should be the latest ones.

2) The error can't really happen without the multi currency plugin since the problem is the currency "translation" or recalculation. So without it it works as normal for one currency.

I've noticed you had another ticket where this was a problem (and also the currency was actually Swedish krona) but it seemed to be unresolved. I saw this bug/behaviour already back since last summer but did manage to get around it with the workaround I described. However this workaround is time consuming and shouldn't be necessary.

April 4, 2024 at 1:19 am #15480732

Ilyes
Supporter

Languages: English (English ) French (Français ) Arabic (العربية )

Timezone: Pacific/Easter (GMT-06:00)

Hello,

In order to see if this issue is happening because of the configuration of your site, or just the combination of Woocommerce & WCML we need to isolate the issue.

I’ve created a sandbox here: hidden link

I’ve already configured WPML in 2 languages.

Please do the following:

- Open the Sandbox link mentioned above
- Activate Multicurrency to be similar to what you have on your site
- Create a basic product with similar scenario

Does the issue replicate?

Please note that we only need the theme/plugin and the related functionality, you don’t need to set up an entire website or clone your existing site.
https://wpml.org/faq/how-to-reproduce-issues-and-share-them-with-wpml-support/

Also, please share the ticket you mentioned, it might help me get a better idea on it.

Please let me know when it is done.
Best regards,

April 4, 2024 at 10:03 am #15482103

jesperA

Thanks for setting up a sandbox test environment.
I've tried to configure it as close to the original site as possible.
There's only one product and you reach it from the "Shop" in the menu (to see the price the customer sees).

On the original site I set prices in the swedish currency kr (SEK), even when editing the product in english. It's then automatically calculated to EUR and USD (since the "Calculate prices in other currencies automatically" option is chosen.

However, I can't get this to work on the sandbox site. It shows the same amount (1799) in both EUR and USD, which is of course wrong.

I have a feeling this is part of the problem since it's the automatic calculation that seems to have a bug. However, this part seems to work on the original site. Can you check why it's not automatically calculated on the Sandbox?

Skärmavbild 2024-04-04 kl. 12.03.34.png
April 4, 2024 at 8:13 pm #15485753

Ilyes
Supporter

Languages: English (English ) French (Français ) Arabic (العربية )

Timezone: Pacific/Easter (GMT-06:00)

Hello,

Thank you for taking the time to set this up,

I think the conversion is not working properly because you didn't set the conversion rate in the multicurrency settings : hidden link

Your product is now showing the all 3 currencies and the right conversion, could you complete the rest of the settings in order to replicate this issue.

Best,

April 5, 2024 at 7:02 am #15486455

jesperA

Yes, it seems these values weren't set at first. Not sure if the automatic currency converter fetch the current value once per day, or something?

Anyway, they are there now. I added a currency switcher in the footer. It's supposed to automatically choose Swedish krona when I switch to the Swedish language (works). And it let me change between USD and EUR when the English language is selected. Good.

So now to the real problem! I've created a sale of the single product. It will start tomorrow, Saturday, and expire on Sunday. The price is reduced to 1000 from 1799 in this time.

Will check the price on Monday when everything is supposed to be back to original price.

April 5, 2024 at 7:01 pm #15489542

Ilyes
Supporter

Languages: English (English ) French (Français ) Arabic (العربية )

Timezone: Pacific/Easter (GMT-06:00)

Thank you for the follow-up,

I will then keep an eye on the sandbox by Monday.

Best,

April 8, 2024 at 7:19 am #15492693

jesperA

Hi, it's now Monday and the sale price has returned to normal - as it should.
However, when I checked prices on Saturday (and Sunday) I didn't get the expected sale price.
Please see included screendumps. This is not the same problem as I reported but it seems to be related. Since the price didn't really change, I can't know for sure if the problem I experienced (on the other site) is replicated.
So let's first solve why the sale didn't change the price on Saturday (both original price and calculated price, as can be seen in the screendumps).

Skärmavbild 2024-04-06 kl. 09.51.49.png
Skärmavbild 2024-04-06 kl. 09.52.09.png
Skärmavbild 2024-04-06 kl. 09.51.33.png
April 8, 2024 at 5:55 pm #15495743

Ilyes
Supporter

Languages: English (English ) French (Français ) Arabic (العربية )

Timezone: Pacific/Easter (GMT-06:00)

Hello,

So if I understood correctly, the initial issue was that the prices did not go back to normal after the sale period ended on your live website.

However, when trying to replicate it on the Sandbox, the prices went back to normal as expected, however, the sale price wasn't applied on Saturdays even thought it was on the configured sale schedule.

So you configured it April 5th for the sales to be on both April 6th and April 7th, however, it didn't apply the sales on April 6th, was it different for the 7th? I can't help but think maybe the WordPress configured Timezone was different from yours which created a delay on when to apply the sale, is that a possibility?

Thank you again for taking the time to test this out, it really helped us,

Best,

April 10, 2024 at 8:12 am #15502629

jesperA

That's correct understood.
The sale price was still the same on the 7th (same as 6th). So it didn't change during the whole time.
As far as I know, the timezone wasn't responsible for the unchanged price since I checked several times, but I can be wrong.
There is something spooky going on, for sure, (and it might have to do with timezones). But how do we continue to find the problem? Should I create a new sale?

April 10, 2024 at 5:05 pm #15505957

Nicolas V.
Supporter

Languages: English (English ) French (Français )

Timezone: America/Lima (GMT-05:00)

Hello,

Ilyes is off for a few days so I will continue here.

I have created 2 scenarios:

1. For the existing product I was able to set a new sale price which is actually running (until midnight).
- Sale price is immediately visible on the frontend and applied to all currencies
- Tomorrow I will be able to see if the price go back to regular price in all currencies

2. I duplicated that product and set a new sale price that will start tomorrow and end tomorrow at midnight
- Right now the regular price is applied in all languages
- Tomorrow I'll be able to see if the scheduled sale price is applied correctly on all currencies
- And the following day I will be able to see if the price go back to regular price in all currencies

Let me know if I missed something but I think I have all the possibilities covered here. I'll get back to you tomorrow with the results

April 11, 2024 at 6:14 am #15507097

jesperA

OK, please let me know the results.

April 11, 2024 at 11:13 am #15508707

jesperA

This screen dump shows the second product does not have the correct price while the first product shows the sale price even though the sale was ended on the 10th.
So there are clearly problems here.

Skärmavbild 2024-04-11 kl. 13.11.24.png
April 11, 2024 at 3:34 pm #15510169

Nicolas V.
Supporter

Languages: English (English ) French (Français )

Timezone: America/Lima (GMT-05:00)

Hi Jesper,

You're right. I can see those issues. It seems to be related to the schedule feature from WooCommerce. Moreover the issue is visible in all languages and all currencies. So I'm not sure that the currency calculation is the issue here.

I created another sandbox site without the Multicurrency option to see if it works correctly (to identify if the issue is related to our Multicurrency feature or the schedule feature from Woocommerce)

I also created another sandbox because WordPress 6.5 brings a lot of changes. So I wanted to test with WP 6.5 and all our plugins up-to-date (our latest versions are compatible with WP6.5)

Unfortunately, because the issue relies on the scheduling feature, we will have to wait until tomorrow to see the results but I already escalated your ticket to the second tier support.