Please make sure to update to WPML 4.3.6 and check our list of Known Issues before reporting

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 6 replies, has 2 voices.

Last updated by Shekhar Bhandari 1 year, 7 months ago.

Assigned support staff: Shekhar Bhandari.

Author Posts
June 26, 2018 at 1:29 pm #2435376

Bruno Antunes Luis

Hello,
I'm trying to get the product price for each currencies in function.php.

Also tried without success to implement: https://wpml.org/forums/topic/wcml_product_price_by_currency-returns-id-insted-of-price/

If there another option/solution I can use?

Many thanks in advance for your help.

Hope you're doing well.

Have a nice day.

June 28, 2018 at 9:54 am #2440565

Shekhar Bhandari
Supporter

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

Hello there,

Thank you for contacting WPML support. I'd be happy to assist you further on this issue.

I am discussing this questions with our 2nd tier supporters and will respond to you soon.

Thanks

July 2, 2018 at 7:50 am #2450071

Bruno Antunes Luis

Hello, did you managed to have a look at my problem by any chance? Many thanks in advance. Hope you're doing well. Have a nice day. Best, Bruno

July 2, 2018 at 10:05 am #2452919

Shekhar Bhandari
Supporter

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

Hello there,

I can confirm that the code provided is not working, so in order to better help, I have escalated this issue to our 2nd tier supporter and one of the 2nd tier supporters will respond to you soon.

Thanks

July 3, 2018 at 7:29 am #2455826

Shekhar Bhandari
Supporter

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

Hello there,

Our 2nd tier provided a feedback on this issue and they mentioned that you should use the following code to retrieve the results

add_action( 'admin_init', 'test' );
function test() {
global $woocommerce_wpml;
$price = $woocommerce_wpml->multi_currency->prices->get_product_price_in_currency( 29, 'USD' ); //Assuming if secondary currency is USD and product ID is 28
};

You should use the function in the admin_init action to make it work.

Let me know if this helps.

Thanks

July 3, 2018 at 7:38 am #2455853

Bruno Antunes Luis

Hello Shehar,
So it's not possible to get this information inside "woocommerce_rest_prepare_product_object" for instance?
Thanks for your support. Much appreciated.
Hope you're doing well. Have a nice day.

July 3, 2018 at 8:31 am #2456115

Shekhar Bhandari
Supporter

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

Hello there,

I am not totally sure if you can use this inside the hook you mentioned, you can give it a try further I also received an information from the 2nd tier that you can also get the currencies with the following code, which doesn't require any admin_init action.

global $woocommerce_wpml;
$multi_currency = $woocommerce_wpml->get_multi_currency();
$multi_currency->prices->prices_init();
$price = $multi_currency->prices->get_product_price_in_currency( 29, 'AED' )

Let me know if this helps.

Thanks