0

I can't use of coupon in cart section because of this error (a numeric value encountered) When I add a product to the card section and when I want to add the discount coupon , the coupon is not added and it gives the above error***

        Session::put('coupon',[
            'coupon_name' => $coupon->coupon_name,
            'coupon_discount' => $coupon->coupon_discount,
            'discount_amount' => round(Cart::total() * $coupon->coupon_discount/100),
            'total_amount' =>  round(Cart::total() - cart::total() * $coupon->coupon_discount/100),
        ]);
Tim Lewis
  • 27,813
  • 13
  • 73
  • 102
ehsan
  • 1
  • [Error_log: PHP Warning: A non-numeric value encountered](https://stackoverflow.com/questions/57733789/error-log-php-warning-a-non-numeric-value-encountered) – steven7mwesigwa Feb 02 '23 at 17:49
  • What kind of debugging have you done? Are `Cart::total()` and `$coupon->coupon_discount` numbers? Your error should indicate which line is triggering that error, so check that and debug. – Tim Lewis Feb 02 '23 at 17:49
  • [How do I fix my "PHP Warning: A non-numeric value encountered" error?](https://stackoverflow.com/questions/52733078/how-do-i-fix-my-php-warning-a-non-numeric-value-encountered-error) – steven7mwesigwa Feb 02 '23 at 17:50
  • 1
    @TimLewis My bad. Thanks for the suggestion. I will keep that in mind next time. – steven7mwesigwa Feb 02 '23 at 17:53
  • 1
    No problem You can edit comments for up to 5 minutes, so get all the links, then post em as a single comment, and delete the extra ones (or leave as is, doesn't really matter, just housekeeping) – Tim Lewis Feb 02 '23 at 17:55

0 Answers0