Cart session manager

Package info

github.com/AbstractEverything/cart

pkg:composer/abstracteverything/cart

Statistics

Installs: 18

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2017-06-02 12:56 UTC

Requires

Requires (Dev)

Suggests

None

Provides

None

Conflicts

None

Replaces

None

MIT 70928938db77f9158d5d5b63dfdc8d47cd3d4fce

  • R Franks <ru.franks.woop@gmail.com>

This package is not auto-updated.

Last update: 2026-06-18 14:32:03 UTC


README

Manage cart items using sessions.

Install

Run composer require abstracteverything/cart or add:

{
 "require": {
 "abstracteverything/cart": "dev-master"
 }
}

to your composer.json file and run composer update.

Add AbstractEverything\Cart\CartServiceProvider to your providers array.

Export the config file using php artisan vendor:publish.

Usage

// Add cart items:

$cart->add(123abc, 'Grapes', 12.50, 2, [
 'variety' => 'green',
 'type' => 'seedless',
]);

// Add more than one item to the cart

$cart->addMany([
 [
 'id' => 'item1',
 'name' => 'Test item 1',
 'price' => 123,
 'quantity' => 1,
 'options' => [],
 ],
 [
 'id' => 'item2',
 'name' => 'Test item 2',
 'price' => 234,
 'quantity' => 2,
 'options' => [],
 ],
]);

// Find cart item by its id:

$cart->find(123abc);

// Get all the items in the cart:

$cart->all();

// Calculate total price of all items:

$cart->subtotal();

// Calculate the total tax of all items:

$cart->tax();

// Calculate total price with tax of all items:

$cart->subtotalWithTax();

// Remove an item by its id:

$cart->remove(123);

// Count the number of items in the cart:

$cart->count();

// Remove all items from the cart:

$cart->clear();