Kryptronic Software Support Forum

You are viewing this forum as a guest. Login to an existing account, or create a new account, to reply to topics and to create new topics.

#1 04-30-2024 10:30:57

Registered: 04-29-2024
Posts: 77

Shopping Cart Code Error

NOTE: This post was created on 2023-09-23 on the Kryptronic eCommerce Community facebook page, which has been replaced with this forum.  All facebook support content was migrated into this forum in April 2024.


Hi Nick
A customer reports a repeat error when going to shopping basket page:
round: Argument #1 (Snum) must be of type int|float, string given
File: /core-private/core/CORE_App/CORE_App.php Line: 2505 Error Number: 256
I can't replicate the error and have resolved by deleting an item from their basket.
Researching the error, it looks like the round function should include (int) for php 8.0
I have changed the line of code to:
return sprintf("%.{$places}f", round((float)$number, $places));
and do not have any issues/errors.
Is there anything wrong with what I have changed?
Should I change all round functions to include (float)?
Or, have you already changed in the latest release?


Thanks for the report. CORE_App::number_round() is where that mod was made. Looks good to me, although our coding conventions have us set the type using settype(), so I've modified that function (will be in the next update) to use 'settype($number,'float');' ahead of the 'if (empty($places)) {}' line, which I believe is a little safer because it ensures both return values are handled.



Board footer