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: Custom Work
This topic contains 5 replies, has 2 voices.
Last updated by Dražen 10 months, 2 weeks ago.
Assisted by: Dražen.
Author | Posts |
---|---|
April 3, 2024 at 9:01 am #15476911 | |
jozefC-3 Site owner |
Hello, on the entire eshop, I have set the prices to be rounded without decimal values (every currency has it set that way), but for the statistics with one own price, we need to achieve that it can also recalculate with decimal values: here is the code for a sample: $unit_price = $meta_variant["metadata_unit-price"][0]; the problem is that sometimes the $final_unit_price prices are so low in some currencies that they are rounded to 0 |
April 3, 2024 at 9:47 am #15477206 | |
Dražen Supporter
Languages: English (English ) Timezone: Europe/Zagreb (GMT+01:00) |
Hello, I created a minimal installation of WordPress, WPML, and all necessary WPML add-ons. You can access the WordPress dashboard using the link below: Kindly follow the steps below: Regards, |
April 3, 2024 at 11:32 am #15477738 | |
jozefC-3 Site owner |
It can be replicated easily, for some reasons I need to display some products (especially their prices) with decimal numbers even though all others should behave as set. So we have two products here hidden link one is nice but the other has such a low price that I need to display it with decimal places and thus bypass the settings at hidden link .sandbox.otgs.work/wp-admin/admin.php?page=wpml-wcml&tab=multi-currency ... could you advise me how to get around this? |
April 3, 2024 at 11:39 am #15477776 | |
Dražen Supporter
Languages: English (English ) Timezone: Europe/Zagreb (GMT+01:00) |
Hello, thanks for getting back and replicating the issue, I understand the problem now. Can you please show us how this works correctly without WPML or what code you use? For example, if I disable WPML plugins, I can still see 0 showing there. I am asking this since I am not sure if this is a direct issue from WPML and it is plugin, if you can make it work without WPML then we can advise how to make it work with WPML, but we can not suggest and help with general coding issues from WP. Let me know. Thanks, |
April 10, 2024 at 12:57 pm #15504877 | |
jozefC-3 Site owner |
Let's try another way, let's say my custom price is 10, I need wcml_formatted_price to support decimal numbers, because in some cases my custom price is 0.001 and then wcml_formatted_price shows zero (because it is set in the settings that we don't use decimal numbers). Through wc_price, it prints it nicely even with decimal numbers, but after switching to another currency, the conversion does not work. I know that it would work if I set decimal places for each currency in the settings for multicurrency, but I don't want this, because I need to display the custom price only in some special cases. Is it possible to somehow extend wcml_formatted_price with decimal numbers like wc_price? $currency = get_woocommerce_currency(); apply_filters('wcml_formatted_price', 10, $currency); wc_price(10, array('currency'=>get_woocommerce_currency(), 'decimals'=>5)) |
April 10, 2024 at 1:43 pm #15505257 | |
Dražen Supporter
Languages: English (English ) Timezone: Europe/Zagreb (GMT+01:00) |
Hello, thanks for getting back. I understand, and I am afraid that is not possible with WPML out of the box, you will need some further custom coding and adjustment to achieve what you wish for. As per our support policy, we can not provide custom coding services for specific cases, for such we recommend using the service of WPML contractors: - https://wpml.org/contractors/ Hope this helps. Regards, |