Skip Navigation

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

Problem:
The client needs to retrieve a value from the converted price of WCML to use it with another plugin, specifically for setting up product feeds in USD for Google Merchant and Snapchat catalogs. Additionally, the client is unable to locate the 'wcml_load_multi_currency' function.
Solution:
We recommended using the wcml_product_price_by_currency hook to fetch product prices in a specific currency. Here is an example on how to use this hook:

// Get the EUR price of the product ID = 80
$product_id = 80;
$currency = 'EUR';
echo apply_filters('wcml_product_price_by_currency', $product_id, $currency);

This code allows selecting a product and specifying the desired currency to get its price. The client should integrate this hook within the Product Feed PRO Plugin to achieve the desired functionality. Additionally, we suggested that the client check if the Elite version of the Product Feed PRO plugin, which supports WPML, also supports the WCML Currency Switcher or if there are plans for its integration.

If this solution does not resolve your issue or 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 further assistance is needed, please open a new support ticket at WPML support forum.

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.

Tagged: 

This topic contains 17 replies, has 2 voices.

Last updated by Andreas W. 10 months, 2 weeks ago.

Assisted by: Andreas W..

Author Posts
July 5, 2024 at 11:03 pm #15900487

Eslam Badr

Background of the issue:
I need help with getting a value from the converted price of WPML to a field so that I can use it with another plugin. Also, I can't find 'this wcml_load_multi_currency'.

Symptoms:
I can't find 'this wcml_load_multi_currency'.

Questions:
How can I get a value from the converted price of WCML to use it with another plugin?
Where can I find 'this wcml_load_multi_currency'?

July 5, 2024 at 11:23 pm #15900541

Andreas W.
WPML Supporter since 12/2018

Languages: English (English ) Spanish (Español ) German (Deutsch )

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

Hello,

It sounds like this hook is what you are looking for:
https://wpml.org/wcml-hook/wcml_product_price_by_currency/

Example:

// Get the EUR price of the product ID = 80 
$product_id = 80; 
$currency = 'EUR'; 
echo apply_filters( 'wcml_product_price_by_currency', $product_id, $currency );

Best regards
Andreas

July 5, 2024 at 11:36 pm #15900554

Eslam Badr

I already know this hook but, How can I use it to have the required field of the converted price?

Can you guide me?

Thanks

July 6, 2024 at 4:29 pm #15903783

Andreas W.
WPML Supporter since 12/2018

Languages: English (English ) Spanish (Español ) German (Deutsch )

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

The hook lets you select a product and the expected currency. You simply pass the product ID, which also should work inside a loop, and you set the expected currency.

This should give you a price in a specific currency.

I can offer to provide a test site with WPML and WooCommerce on which you can recreate the issue and I can assist you further on this matter.

Should I send you a link?

July 6, 2024 at 4:54 pm #15903836

Eslam Badr

Thanks for responding.

Yeah, please send it.

July 6, 2024 at 5:07 pm #15903853

Andreas W.
WPML Supporter since 12/2018

Languages: English (English ) Spanish (Español ) German (Deutsch )

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

Here is the link for the test site. We do not have server access here, but you can use the File Manager Plugin.

One-Click-Login:
hidden link

Please leave me a comment on this ticket once you are done replicating the issue.

Do not migrate your whole website to this test site. Simply create an example of what you are trying to achieve.

July 6, 2024 at 7:12 pm #15904165

Eslam Badr

As I can see, This will take some time.

I will tell you exactly what am trying to achieve, I'm using a feed plugin called "Product Feed Pro" to set up a feed for all needed channels including both Google Merchant and Snapchat catalogs. Unlike other channels, Google Merchant and Snapchat Require "USD currency" while my store is built with "QAR" and here is the role of WMPL while I use the currency exchange from QAR to USD.

with Prdodcut feed bro I can choose the field for the price and that is the issue " I need the field with the USD price " where I can't find it and have tested a lot of codes...etc.

So as a brief, I need to have a field that contains the price value in USD price so I can select it with the product feed pro plugin " check the attachment".

Please, Let me know if this is not clear enough. Also, If the hook can help me to achieve that can you send a video or something like that with the instructions?

Thanks for your help

price.PNG
July 6, 2024 at 11:23 pm #15904694

Andreas W.
WPML Supporter since 12/2018

Languages: English (English ) Spanish (Español ) German (Deutsch )

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

This is something that can only be achieved programmatically, and in this case, it is something that would need to be achieved inside the Product Feed PRO Plugin.

This means they would need to implement our hook into their plugin and make sure that product prices are always obtained in English.

Do you mean this plugin?
https://wordpress.org/plugins/woo-product-feed-pro/

July 7, 2024 at 12:40 am #15904801

Eslam Badr

Yeah, it is.

By default, does WPML have a field containing the converted price?

I have already tried some codes to achieve that but still, that doesn't work.

I think the reason maybe that this hook doesn't exist in my website!

July 7, 2024 at 1:54 am #15905083

Andreas W.
WPML Supporter since 12/2018

Languages: English (English ) Spanish (Español ) German (Deutsch )

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

The hook will work as long as our addon WCML is used on your website. It allows you to hook into the product(s) and receive a price in a determined currency.

Those prices in different currencies are created on the fly, on Frontend, and are not saved on the database.

Exception:
You can use the product option "Set prices in other currencies manually" which lets you enter a custom price on each product for each currency.

For example, if I set on a product a custom price for EURO, then it will save a new entry on the wp_postmeta table of WordPress, which in this case has the option_name "_price_EUR".

You could call this field directly from the database, but you would need to consider also that you are calling the correct field for the correct product ID as each product will use its proper meta field.

---

The approach that usually needs to be taken in this case is to make use of hooks.

The feed plugin must provide specific hooks that allow you to take action before the data is sent to an external service. WCML then would need to hook into such a specific hook and set a default currency for specific platforms.

---

Is this the plugin that you are using?
https://wordpress.org/plugins/woo-product-feed-pro/

I need to ask you again to please recreate the issue on the test site so that we will be able to assist you on this matter.

July 7, 2024 at 12:53 pm #15907313

Eslam Badr

Hi once again,

Thanks for your time, Really Appreciate it.

In your test site, I already tried to do a simulation except for one thing only, The main currency in my website is " QAR" unlike your web is based on USD and I don't know how to change but it's ok. Let's say in the test website I want to use the converted price from USD to QAR to be used in the product feed pro plugin. I already did the setup of the feed of Google Merchant and a test product. You can check and let me know if you still have any questions.

Thanks

July 8, 2024 at 7:03 am #15910391

Andreas W.
WPML Supporter since 12/2018

Languages: English (English ) Spanish (Español ) German (Deutsch )

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

Hello,

Please take kindly note that my working days are from Tuesday to Saturday.

Details:
https://wpml.org/forums/users/andreas-w/

I will be glad to assist you as soon.

Best regards
Andreas

July 9, 2024 at 4:29 pm #15922139

Andreas W.
WPML Supporter since 12/2018

Languages: English (English ) Spanish (Español ) German (Deutsch )

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

I have set the currency in WooCommerce to QAR and revised the Google Merchant Feed.

According to this date the currency is set correctly:
hidden link

Please have another look at the test site and let me know if you can recreate the issue.

Captura de pantalla 2024-07-09 113332.jpg
July 9, 2024 at 5:21 pm #15922396

Eslam Badr

Hi, I hope you had a good rest.

I created a secondary currency " USD " and edit the settings like the current store.

if you check the feed right now the price is based on "QAR" and I mean the value itself cause I can set the name of currency while the value is this issue " I need the price value in USD " and I can't find the right field.

Thanks

July 9, 2024 at 5:33 pm #15922425

Andreas W.
WPML Supporter since 12/2018

Languages: English (English ) Spanish (Español ) German (Deutsch )

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

Thank you, I will take a closer look into this and update you as soon as possible.