PHP Fatal error: Uncaught Error: Unsupported operand types error

I am trying to make a system for office staff and delivery drivers so the office staff book the orders in and the delivery drivers are able to see what can see what orders there are for that day and for their lorry as will be multiple lorries/drivers. I am currently working on the sell product order page but I am getting the following error

It was working before I added extra code in so the customer name and lorry name is populated from the customers and lorries db table and when a customer name is selected, there is a next textarea box next to it that is populated with the customers address

[30-Oct-2024 15:30:07 UTC] PHP Fatal error: Uncaught Error: Unsupported operand types in /home/wwwbeechwoodsolu/public_html/sites/coal-lorry-system-two/sell_product.php:23
Stack trace:
#0 {main}
thrown in /home/wwwbeechwoodsolu/public_html/sites/coal-lorry-system-two/sell_product.php on line 23

On line 23 is

$_SESSION["cart_item"][$k]["quantity"] += $_POST["quantity"];

But don't think that line is the issue as was not showing any issue with that line or the code before I added extra code in

It's bit of long file to post the whole code here so I attached it as a txt file to this post

Below is the sections of code that contains the code I put in

//Code for Checkout
if(isset($_POST['checkout'])){
    $invoiceno= mt_rand(100000000, 999999999);
    $pid=$_SESSION['productid'];
    $quantity=$_POST['quantity'];
    $lorryname=$_POST['lorryname']; // I ADDED THIS LINE IN
    $customername=$_POST['customername']; // I ADDED THIS LINE IN
    $customeraddress=$_POST['customeraddress']; // I ADDED THIS LINE IN
    $pmode=$_POST['paymentmode'];
    $value=array_combine($pid,$quantity);
    foreach($value as $pdid=> $qty){
        $query=mysqli_query($con,"insert into tblorders(ProductId,Quantity,InvoiceNumber,LorryName,CustomerName,CustomerAddress,PaymentMode) values('$pdid','$qty','$invoiceno','$lorryname','$customername','$customeraddress','$pmode')") ; // I AMENDED THIS LINE TO ADD IN LORRYNAME, CUSTOMERNAME, CUSTOMERADDRESS
    }
    echo '<script>alert("Invoice generated successfully. Invoice number is "+"'.$invoiceno.'")</script>';  
    unset($_SESSION["cart_item"]);
    $_SESSION['invoice']=$invoiceno;
    echo "<script>window.location.href='invoice.php'</script>";

}



// I ADDED THIS CODE BLOCK IN
<div class="col-md-4 mb-10">
                                                    <label for="validationLorry03">Lorry</label>
                                                    <select  name="lorryname"  class="form-control" required>
                                                        <option value="">Select Lorry</option>
                                                        <?php
                                                $sql="SELECT * from  tbllorries";
                                                $query = $dbh -> prepare($sql);
                                                $query->execute();
                                                $results=$query->fetchAll(PDO::FETCH_OBJ);
                                                if($query->rowCount() > 0)
                                                {
                                                    foreach($results as $row)
                                                    {
                                                        ?> 
                                                        <option value="<?php  echo $row->lorryname;?>"><?php echo "Lorry Name: " . $row->lorryname . " | Area: " . $row->lorryarea . " | Day: " . $row->lorryday;?></option>
                                                        <?php 
                                                    }
                                                }
                                                        ?>
                                                    </select>
                                                </div>



// I ADDED THIS CODE BLOCK IN

<div class="col-md-4 mb-10">
                                                    <label for="validationLorry03">Lorry</label>
                                                    <select  name="lorryname"  class="form-control" required>
                                                        <option value="">Select Lorry</option>
                                                        <?php
                                                $sql="SELECT * from  tbllorries";
                                                $query = $dbh -> prepare($sql);
                                                $query->execute();
                                                $results=$query->fetchAll(PDO::FETCH_OBJ);
                                                if($query->rowCount() > 0)
                                                {
                                                    foreach($results as $row)
                                                    {
                                                        ?> 
                                                        <option value="<?php  echo $row->lorryname;?>"><?php echo "Lorry Name: " . $row->lorryname . " | Area: " . $row->lorryarea . " | Day: " . $row->lorryday;?></option>
                                                        <?php 
                                                    }
                                                }
                                                        ?>
                                                    </select>
                                                </div>

                                                <div class="col-md-4 mb-10">
                                                    <label for="validationCustom03">Customer Name</label>

                                                    <script>
                                                        function myFunction(){
                                                            var index = document.getElementById("customername").selectedIndex;
                                                            //alert(index);
                                                            var add = document.getElementById("customername").options[index].getAttribute("data-add");

                                                            document.getElementsByName("customeraddress")[0].value = add;
                                                        }
                                                    </script>

                                                    <select  name="customername" id="customername" class="form-control" required onchange="myFunction();">
                                                        <option value="">Select Customer</option>
                                                        <?php
                                                $sql="SELECT * from  tblcustomers";
                                                $query = $dbh -> prepare($sql);
                                                $query->execute();
                                                $results=$query->fetchAll(PDO::FETCH_OBJ);
                                                if($query->rowCount() > 0)
                                                {
                                                    foreach($results as $row)
                                                    {
                                                        ?> 
                                                        <option value="<?php echo $row->customername;?>" data-add="<?php echo $row->customeraddress;?>"><?php echo $row->customername;?></option>
                                                        <?php 
                                                    }
                                                }
                                                        ?>
                                                    </select>
                                                </div>
                                                <div class="col-md-4 mb-10">
                                                    <label for="validationCustom03">Customer Address</label>
                                                    <textarea rows=5 cols=5 name="customeraddress" class="form-control" placeholder="Enter Customer Address" required></textarea>
                                                </div>
CategoriesUncategorized