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.
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
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).
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.
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
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?
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.
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.
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).
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,
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?
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
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.
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.