Overtrue\LaravelShoppingCart\Cart::add PHP Method

add() public method

Add a row to the cart.
public add ( integer | string $id, string $name = null, integer $qty = null, float $price = null, array $attributes = [] ) : string
$id integer | string Unique ID of the item
$name string Name of the item
$qty integer Item qty to add to the cart
$price float Price of one item
$attributes array Array of additional attributes, such as 'size' or 'color'...
return string
    public function add($id, $name = null, $qty = null, $price = null, array $attributes = [])
    {
        $cart = $this->getCart();
        $this->event->fire('cart.adding', [$attributes, $cart]);
        $row = $this->addRow($id, $name, $qty, $price, $attributes);
        $this->event->fire('cart.added', [$attributes, $cart]);
        return $row;
    }