Warning: A non-numeric value encountered in class-wc-cart-totals.php on line 234
-
Today I found an annoying bug.
The warning Warning: A non-numeric value encountered in wp-content/plugins/woocommerce/includes/class-wc-cart-totals.php on line 234 was shown after I logged out from wordpress.
I’ve look into the class-wc-cart-totals.php on line 234 and decide to look what the value of $cart_item. So I write the content of $cart_item into a log file.
Then I saw what was causing it.
A product has a price of “-“!
This is of course not a number:I wonder why such input isn’t prevent.
Then I think what about negative numbers like -1.
So I enter it.
Oh my god, I could store it.
On frontend the price is shown as 0 and there a no warnings if I logged out.
But this values are unlogical and entering / storing it should be prevented.Therefore, I would recommend updating the admin js to check the price fields for illogical values so that this annoying error could no longer occur.
- The topic ‘Warning: A non-numeric value encountered in class-wc-cart-totals.php on line 234’ is closed to new replies.