Hello,
I have just added this simple code on a PHP page on the root of WordPress with WPML install and instead of returning the value from the database is getting me a converted one (other currency).
With WCML disabled the regular_price is returning the right amount.
The id is one of the default products in the main language.
Well, the problem is that I use a more complex function to retrieve the post meta value, and sometimes (random) it returns the default currency which is not okay.
I have tried to find a hook to return the current price of that product but without luck.
Some hooks are working only on the front end.
So can you please give me a solution to retrieve the default saved data in the post meta table?
Many thanks
In order to help you can you please tell me exactly what you are trying to achieve?
For example, you can use REST API in order to get the price from a product, without involving actions and filters that may run in the middle of your request.
Sure,
Many thanks for your suggestion.
Yes, simply I'm trying to get the default currency for the products based on the ID.
There is a hook for that but like I said only works on the front end. I was looking for something to suppress this price modification by WCML.
Regarding rest API seems to be the only way to achieve this, even if all the data are on the same installation...it's kind of strange to use rest API when you have all the data in the same place.
Are you 100% there is no hook to bypass this? And get the correct value by post meta? Thanks
We are having many ajax requests in the frontend and adjusting them in order to get the price from the database it is not the optimum way. This is why I suggest rest api which in general, not this implementation, can save you time and speed.
If you insist to use hooks, the only way I can think is to use this hook :
You know the product ID, you know the default currency, so you can get for the product the price in default currency.
Again maybe this is not fit in your implementation, you can check all the hooks you are having and maybe you can find other combinations that might work for you.