A non-numeric value encountered in advanced-flat-rate-shipping-for-woocommerce plugins

This morning, I woke up my client keep annoy me with the warning message appear after updated all her plugins and keep asking to check what happen to their website.

Checking the error log found out a lot of error sounds like;

FastCGI sent in stderr: “PHP message: PHP Warning: A non-numeric value encountered in /www/xxxx.com/wp-content/plugins/advanced-flat-rate-shipping-for-woocommerce/admin/partials/afrsm-init-shipping-methods.php on line 168

Apparently, there problem with the “advanced-flat-rate-shipping-for-woocommerce” plugins that she used. Then I open the files located at,

/wp-content/plugins/advanced-flat-rate-shipping-for-woocommerce/admin/partials/afrsm-init-shipping-methods.php

and try to figure out what happen there. Looking at the code from line 165 to 170 it seems something not right there. Here is the code snippets.

$cart_based_qty = '';
if (!empty($cart_array)) {
foreach ($cart_array as $woo_cart_item_key => $value) {
$cart_based_qty += $value['quantity'];
}
}

The variable declared there $cart_based_qty = ‘’; looks not right to me. I think it better to put 0 instead declared with empty string. So I suggest if you're having the same problem, to update the variable there by given value int 0 instead let it become empty string. So the snippets code should be like this;

$cart_based_qty = '0';
if (!empty($cart_array)) {
foreach ($cart_array as $woo_cart_item_key => $value) {
$cart_based_qty += $value['quantity'];
}
}

I’m not sure this is the right fix to this, but I hope the plugins' developer see this and update the code accordingly. And this post intended just to share my opinions and help others who facing the same error.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store