{{ Cart::total() -Cart::tax() }}
when i tried to write this line to a blade it shows the error named A non well formed numeric value encountered. But if I use {{ Cart::total() }} or {{ Cart::tax() }} separately then it works. Can anyone help me?
I've noticed the exact same error if the item price or total cart price exceeds 999
I suspect it maybe because LaravelShoppingcart is using floats to store values, rather than the generally accepted integer for storing monetary values.
@fearless-hasan did you find the solution of that problem? coz i am also facing the same prob.
Hello guys! i fixed the problem by putting a condition, for me it was if there's a coupon then do a mathematics operation else just ignore the code and it worked
@fearless-hasan can you share the code with us.
@zahidshuvo12 i noticed this problem only when i try to do a mathematical operation on Cart::subtotal() or Cart::total(). here how i solved it.
First clear your cart so the program won't stuck on the previous problem, then put your Cart::subtotal or Cart::total() inside number_format() like this $subtotal = number_format((float)Cart::subtotal(), 2) because if you notice, if you try to dump and die Cart::total() it will return a string.
Hope it helps!!!
if that didnt work out for you try this
$var =str_replace( ',', '', Cart::total() );
$operation = $var - 1 ;
Most helpful comment
if that didnt work out for you try this