PluginUs.Net - Business Tools for WooCommerce and WordPress

[realize your idea - make your dreams come true]

Support Forum

You need to log-in to create request (topic) to the support

Fatal PHP Error in woocommerce_package_rates – Unsupported operand types (string * float)

The support doesn work on Saturdays and Sundays, so some Friday requests can be answered on Monday. If you have problems with registration ask help on contact us page please
If you not got email within 24~36 business hours, firstly check your spam box, and if no any email from the support there - back to the forum and read answer here. DO NOT ANSWER ON EMAILS [noreply@pluginus.net] FROM THE FORUM!! Emails are just for your info, all answers should be published only here.
The support doesn work on Saturdays and Sundays, so some Friday requests can be answered on Monday.

Hi support.

I’m encountering a fatal PHP error on my WooCommerce store that originates from your plugin WOOCS – WooCommerce Currency Switcher. The server log reports the following error:

PHP Fatal error: Uncaught TypeError: Unsupported operand types: string * float in /wp-content/plugins/woocommerce-currency-switcher/classes/woocs.php:4132

The issue occurs in the woocommerce_package_rates() function, specifically in this line:
$value = $rate->cost * $currencies[$this->current_currency]['rate'];

It seems that in some cases, $rate->cost or the currency rate is stored as a string (e.g. "125,00"), which causes a fatal error when attempting multiplication.

To prevent this, a type cast could be added:
$value = floatval($rate->cost) * floatval($currencies[$this->current_currency]['rate']);

Is this a known issue, and will it be addressed in a future update?

Thanks in advance for your support.

Hello

What plugin version number are you using?

Hi

First of all, I realized I was running version 2.4.1.9, which I know is quite outdated. In that version, I managed to resolve the issue by modifying the code as previously mentioned (specifically at line 4092).

Afterwards, I upgraded to the latest version 2.4.2.3. However, the issue still persists — even after clearing all caches, both server-side and browser-side. I’m still unable to add products to the cart when browsing the site in a non-default language, which seems to be the core of the problem.

Please let me know if there’s anything else I should try.

Thanks!

Hello

Thank you for your cooperation.

Yes, we will fix this in the next version.