Skip Navigation

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

Problem:
The client needed to export feeds with different currencies using WP All Export. They could export in EUR using a custom function, but the same approach did not work for NOK, even though the default currency was SEK.
Solution:
Here is the function that solved the issue (provided by the user):

function allafroer_convert_currency($price, $to_currency = 'EUR') {
    if(is_array($price)) $price = $price[0];
    return apply_filters('wcml_raw_price_amount', $price, $to_currency);
}

The following shortcode should be used in the WP All Export field:

[allafroer_convert_currency({Price}, 'NOK')]

If you're experiencing similar issues with currency conversion in WP All Export, we recommend trying the provided custom function and adjusting the shortcode accordingly. However, please note that this solution might be outdated or not applicable to your case. If it doesn't resolve your issue, 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 you still need assistance, 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.

This topic contains 9 replies, has 3 voices.

Last updated by Nigel 1 year, 2 months ago.

Assisted by: Itamar.

Author Posts
April 5, 2024 at 3:36 pm #15488896

martinW-75

I try to export feeds with wp all export with different currenies.
When i add this function i can export with EUR. But when i add NOK i cant export with NOK . My default currency is SEK. How should i do for exporting feeds with different currencies. This is the code i insert in the field in wp all export [all_export_price_euro({Price})]

Function1

function all_export_price_euro($value){
apply_filters('wcml_raw_price_amount', $value, 'SEK');
return apply_filters('wcml_raw_price_amount', $value, 'EUR');
}

Function 2 (doesnt works with NOK but still with EUR)

function all_export_price_euro($value){
apply_filters('wcml_raw_price_amount', $value, 'SEK');
return apply_filters('wcml_raw_price_amount', $value, 'EUR');

}

function all_export_price_nok($value){
apply_filters('wcml_raw_price_amount', $value, 'SEK');
return apply_filters('wcml_raw_price_amount', $value, 'NOK');
}

April 7, 2024 at 3:29 pm #15491818

Itamar
WPML Supporter since 02/2016

Languages: English (English )

Timezone: Asia/Jerusalem (GMT+03:00)

Hi,

I'm consulting our second-tier supporters regarding your case.

I'll update you here once I have their reply.

I appreciate your patience.

Regards,
Itamar.

April 8, 2024 at 7:58 am #15492840

Itamar
WPML Supporter since 02/2016

Languages: English (English )

Timezone: Asia/Jerusalem (GMT+03:00)

Hi,

I have the explanation from our second-tier supporter about your case.

First, in each example, the following line is redundant.

lapply_filters('wcml_raw_price_amount', $value, 'SEK');

When you apply_filters to a value, you (potentially) modify the value and return it, but in these examples, you don't do anything with the returned value, and it is discarded, so it is meaningless.

As for the problem, in WP All Export, when exporting a field, in this case, price, you can pass it through a function.

According to what you wrote, you use the all_export_price_euro function.

Do you have a separate export where they use the all_export_price_nok function instead of the euro function?

Simply declaring a all_export_price_nok function isn't enough, you have to use it. That seems obvious, but you don't state that you do, and it is the simplest explanation for why this wouldn't work.

I hope that this explanation helps you to solve the problem.

Regards,
Itamar.

April 9, 2024 at 7:28 am #15497109

martinW-75

Okay. So I can remove this from the function?
apply_filters('wcml_raw_price_amount', $value, 'SEK');

I have two separate exports. One in English and one in Norwegian.
I have attached a picture of how it looks in the function editor and then how it looks in the price field for each export.

The English export exports EUR but the Norwegian still exports SEK.

feed-norway.png
feed-english.png
function.png
April 9, 2024 at 9:52 am #15498096

Itamar
WPML Supporter since 02/2016

Languages: English (English )

Timezone: Asia/Jerusalem (GMT+03:00)

Hi,

Please add your code here and not as a screenshot. You can use the 'Code' tags for this. Please see the attached screenshot.

Thanks,
Itamar.

2024-04-09_12-52-09.png
April 9, 2024 at 12:46 pm #15499295

martinW-75

Sorry for another screenshot but i cant find a 'Code' tag.

Skärmbild 2024-04-09 144434.png
April 9, 2024 at 1:54 pm #15499550

Itamar
WPML Supporter since 02/2016

Languages: English (English )

Timezone: Asia/Jerusalem (GMT+03:00)

Thanks.

I'll check this issue with our system team.

Meanwhile just please send the code in the next reply without using the code tag.

Thanks,
Itamar.

April 9, 2024 at 2:33 pm #15499924

martinW-75

function all_export_price_euro($value){
apply_filters('wcml_raw_price_amount', $value, 'SEK');
return apply_filters('wcml_raw_price_amount', $value, 'EUR');

}

function all_export_price_nok($value){
apply_filters('wcml_raw_price_amount', $value, 'SEK');
return apply_filters('wcml_raw_price_amount', $value, 'NOK');
}

In the price field for nok

[all_export_price_nok({Price})]

In the price field for eur

[all_export_price_euro({Price})]

Eur works but nok doesnt

April 9, 2024 at 5:11 pm #15500629

Itamar
WPML Supporter since 02/2016

Languages: English (English )

Timezone: Asia/Jerusalem (GMT+03:00)

Thanks!

I'm consulting our second-tier supporter about it and will let you know once I have his reply.

Regards,
Itamar.

April 12, 2024 at 8:38 am #15511970

Nigel
WPML Supporter since 02/2016

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

Hi there

Sorry for the slow response, we've had a busy spell with some absences.

Itamar isn't working today, so let me reply to you directly.

Although the code you shared in your last reply still includes the redundant lines

apply_filters('wcml_raw_price_amount', $value, 'SEK');

that shouldn't affect the outcome.

It's not clear why the EUR conversion would work but not the NOK conversion, and I'd really need to see your site and look at the data being exported to better understand why this may be happening.

Could I get access to your site. Do you have a staging server I could check rather than a production site? (I may want to run the export a few times as part of the debugging process, and it may require adding one or two utility plugins to help.) If you only have the production server and I can't spot anything just reviewing the settings, I could take a copy of the site to install locally to work on.

Let me mark your next reply as private so that we can get log-in credentials from you—you may want to create a temporary admin user for us to use that you can later delete. And be sure to have a current backup of your site.

Can you also confirm which export job you are running?

(Note, I'm not actually working today either, but I was conscious that this has been waiting for a response, and if I can get the credentials from you I'll be able to address this Monday morning.)

April 12, 2024 at 11:11 am #15512622

martinW-75

I solved it with this function.

function allafroer_convert_currency($price, $to_currency = 'EUR')
{
if(is_array($price)) $price = $price[0];
return apply_filters('wcml_raw_price_amount', $price, $to_currency);
}

and this in the field: [allafroer_convert_currency({Price}, "NOK")]