moltin / cart

Shopping cart composer package
Other
110 stars 62 forks source link

Example code #28

Open nikmauro opened 9 years ago

nikmauro commented 9 years ago

Hello i have implement this class with no success. Here my code, no errors, no warnings, only blank screen.

require_once('vendor/autoload.php');

use Moltin\Cart\Cart;
use Moltin\Cart\Storage\Session;
use Moltin\Cart\Identifier\Cookie;

function shopping_items()
{
    $cart = shopping_getCart();
    $cartItems = $cart->contents();
    $d = '';
    if (count($cartItems) > 0) {
        foreach ($cartItems as $item) {
            $d .= "<li>{$item->name} {$item->quantity}x{$item->price}</li>";
        }
    }
    return "<ul>$d</ul>";
}

function shopping_getCart()
{
    return  new Cart(new Session, new Cookie);
}

function shopping_add_item()
{

    $cart = shopping_getCart();
    $cart->insert(array(
    'id'       => 'foo',
    'name'     => 'bar',
    'price'    => 100,
    'quantity' => 1
));
}

shopping_add_item();
echo shopping_items();
outrunthewolf commented 9 years ago

Have you enabled your error reporting?

nikmauro commented 9 years ago

@outrunthewolf yes i have enabled the errors. i have check and log files.

error_reporting(E_ALL); ini_set("display_errors", 1);