[Solved] Can not get OOP to work correctly – Shopping Cart, PHP


There is an error in your function

    function showCart() {
        $cart = $_SESSION["cart"];
        if ($cart) {
            $output = explode(",",$cart);
            $content = array();
            // FAULT HERE MAYBE ?
            foreach ($products as $product) {

Your foreach used $products but you do not have this variable. You need to assign that variable the way you do in the first function. Instead of

$output = explode(",",$cart);

use

$products = explode(",",$cart);

The “s” at the beginning of the code is not a typo, it should change product into products if needed.

7

solved Can not get OOP to work correctly – Shopping Cart, PHP