Hi,
I am creating a shopping cart and having errors thrown when I click an “add to cart” button.
A PHP Error was encountered
Severity: Notice
Message: Undefined index: cart
Filename: models/morders.php
Line Number: 10
A PHP Error was encountered
Severity: Warning
Message: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\codeigniter\system\libraries\Exceptions.php:164)
Filename: libraries/Session.php
Line Number: 662
A PHP Error was encountered
Severity: Warning
Message: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\codeigniter\system\libraries\Exceptions.php:164)
Filename: helpers/url_helper.php
Line Number: 528
Line Number 10 of the morders model is
$cart = $_SESSION['cart'];
which is a session. When I refresh the error page, the item is added, and all subsequent items can be added, but if I go and delete the cookie from the computer and try to “add to cart” again the same error occurs.
This is my function…
function updateCart($productid,$fullproduct){
//pull in existing cart first!
$cart = $_SESSION[‘cart’];
$totalprice = 0;
if (count($fullproduct)){
if (isset($cart[$productid])){
$prevct = $cart[$productid][‘count’];
$prevname = $cart[$productid][‘name’];
$prevname = $cart[$productid][‘price’];
It says “pull in existing cart first!”. Maybe this is what is causing it because the cart session hasne’t been implemented.
Any idea how to fix this?
Thanks,
Clinton