0

Updated EE 3 to EE 5 and Cartthrob to 4.2.

Now we get this error message

    Warning
A non-numeric value encountered
user/addons/cartthrob/cartthrob/core/Cartthrob_product.php, line 151

Severity: E_WARNING`

Any ideas where to fix this?

EDIT:

After the fix from Harsh Barach we have this error message left

Warning
A non-numeric value encountered
user/addons/cartthrob/libraries/Cartthrob_variables.php, line 625

Severity: E_WARNING

Appreciate some help here.

  • I have modified my answer according to your new error. Please review it. – Harsh Barach Mar 6 '19 at 14:12
  • I'm also experiencing the Cartthrob_variables.php error, but in CartThrob 5.1.1. Warning A non-numeric value encountered user/addons/cartthrob/libraries/Cartthrob_variables.php, line 484 Severity: E_WARNING – SyA Jul 20 at 16:47
0

You can try by adding type-casting to it. Try like below manner in the file from this path system/user/addons/cartthrob/cartthrob/core/Cartthrob_product.php, line 151.

Change $price += $row['price']; to $price += (int)$row['price']; in line 151. I hope this will works for you.

Cartthrob Issue

You need to add type-casting here like this way $taxed_price = (int)$price * (1 + ee()->api_cartthrob_tax_plugins->tax_rate()); in line 625. I hope this will also works for you

Cartthrob Issue 2

| improve this answer | |
  • Very helpful, thanks. This removed this error message. Now we have another one. Updated my entry. – Werner Gusset Mar 6 '19 at 7:23
  • @WernerGusset I have modified my answer according to your requirement. Please check it. – Harsh Barach Mar 6 '19 at 14:12
  • Yes, that error is gone too. Thanks for the help. – Werner Gusset Mar 7 '19 at 7:09
  • I might add this note from Cartthrob support:for others: "As a side note, you do not want Line 151 to be $price += (int)$row['price']; because that will round your option price. Instead, you want to use $price += (float)$row['price']; which will allow it to be a floating point number with decimals." Version 4.3 should have this in place. – Werner Gusset Mar 9 '19 at 9:48
  • @WernerGusset That's great idea. Cartthrob should take care of these small issues. This is very nice idea to contribute to community. – Harsh Barach Mar 10 '19 at 7:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.