Skip to content

Framework independent cart extension. Use in project whatever you want!

License

Notifications You must be signed in to change notification settings

atakajlo/shopping-cart

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Shopping cart

Framework independent cart extension. Use in project whatever you want!

Build Status Latest Stable Version Total Downloads Latest Unstable Version License

Installation

The preferred way to install this extension is through composer.

Either run

$ composer require atakajlo/shopping-cart

or add

"atakajlo/shopping-cart": "^1.2"

to the require section of your composer.json.

Usage

  1. Configure cart extension
use atakajlo\cart\cost\calculator\SimpleCalculator;
use atakajlo\cart\Cart;
use atakajlo\cart\item\CartItem;
use atakajlo\cart\storage\SessionStorage;
use atakajlo\cart\sort\IdComparator;

$cart = new Cart(
    new SessionStorage(),
    new SimpleCalculator(),
    new IdComparator() //optional
);
  1. Add items
$cartItem = new CartItem(1, 100, 1);
$cart->add($cartItem);
  1. Update item quantity
$cart->changeQuantityById($cartItem->getId(), 5);
  1. Get all items
$items = $cart->getItems();
  1. Get cart total cost
$totalCost = $cart->getCost()->getTotal();

Tests

$ ./vendor/bin/phpunit

License

This project is released under the terms of the MIT license.

Copyright (c) 2018, Dmytry Fedorenko

About

Framework independent cart extension. Use in project whatever you want!

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages