fix: count throws an error when parameter is null

At the first connection, $_SESSION['poscart'] is empty or null and when you try to add an item to the cart in cashdesk you got this:

Warning: count(): Parameter must be an array or an object that implements Countable in /homepages/35/d523563538/htdocs/clickandbuilds/dolibarr/afds/cashdesk/class/Facturation.class.php on line 145

Warning: Cannot modify header information - headers already sent by (output started at /homepages/35/d523563538/htdocs/clickandbuilds/dolibarr/afds/cashdesk/class/Facturation.class.php:145) in /homepages/35/d523563538/htdocs/clickandbuilds/dolibarr/afds/cashdesk/facturation_verif.php on line 234
This commit is contained in:
DALL'AGNOLA Cédric 2019-04-05 08:28:59 +02:00 committed by GitHub
parent fff9b7db9d
commit cf3364d205
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -142,7 +142,11 @@ class Facturation
$this->montantRemise($montant_remise_ht);
$newcartarray=$_SESSION['poscart'];
$i=count($newcartarray);
$i = 0;
if (!is_null($newcartarray) && !is_empty($newcartarray)) {
$i=count($newcartarray);
}
$newcartarray[$i]['id']=$i;
$newcartarray[$i]['ref']=$product->ref;