From cf3364d20582082f6856ec576dbb236ff412662d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?DALL=27AGNOLA=20C=C3=A9dric?= Date: Fri, 5 Apr 2019 08:28:59 +0200 Subject: [PATCH] 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 --- htdocs/cashdesk/class/Facturation.class.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/cashdesk/class/Facturation.class.php b/htdocs/cashdesk/class/Facturation.class.php index 07d514b95f1..bb6d94e9788 100644 --- a/htdocs/cashdesk/class/Facturation.class.php +++ b/htdocs/cashdesk/class/Facturation.class.php @@ -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;