coercive / cart
Coercive Cart / Basket Handler
Installs: 1 344
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 0
Open Issues: 0
Requires
- php: >=7.4
- dev-master / 1.x-dev
- 0.0.8
- 0.0.7
- 0.0.6
- 0.0.5
- 0.0.4.13
- 0.0.4.12
- 0.0.4.11
- 0.0.4.10
- 0.0.4.9
- 0.0.4.8
- 0.0.4.7
- 0.0.4.6
- 0.0.4.5
- 0.0.4.4
- 0.0.4.3
- 0.0.4.2
- 0.0.4.1
- 0.0.4
- 0.0.3.8
- 0.0.3.7
- 0.0.3.6
- 0.0.3.5
- 0.0.3.4
- 0.0.3.3
- 0.0.3.2
- 0.0.3.1
- 0.0.3
- 0.0.2.9
- 0.0.2.8
- 0.0.2.7
- 0.0.2.6
- 0.0.2.5
- 0.0.2.4
- 0.0.2.3
- 0.0.2.2
- 0.0.2.1
- 0.0.2
- 0.0.1.9
- 0.0.1.8
- 0.0.1.7
- 0.0.1.6
- 0.0.1.5
- 0.0.1.4
- 0.0.1.3
- 0.0.1.2
- 0.0.1.1
- 0.0.1
This package is auto-updated.
Last update: 2024-10-22 06:28:56 UTC
README
Cart / Basket shopping handler
Get
composer require coercive/cart
Usage
<?php use Coercive\Shop\Cart\Cart; use Coercive\Shop\Cart\Item; use Coercive\Shop\Cart\Store\Session; include __DIR__ . "/dist/Store/Session.php"; include __DIR__ . "/dist/Ext/Entity.php"; include __DIR__ . "/dist/Ext/Collection.php"; include __DIR__ . "/dist/Ext/Address.php"; include __DIR__ . "/dist/Cart.php"; include __DIR__ . "/dist/User.php"; include __DIR__ . "/dist/Item.php"; include __DIR__ . "/dist/Shipping.php"; include __DIR__ . "/dist/Billing.php"; include __DIR__ . "/dist/Promo.php"; $cart = new Cart; $item = (new Item) ->setTitle('Example 1') ->setPrice(10) ->setQuantity(1) ->setRef(666); $cart->Items()->addItem($item, '#test123'); $item->Promo() ->setToken('#123456789ABCD') ->setPriceCut(3); $item = (new Item) ->setTitle('Tutu') ->setPrice('\MyClass\For\Calculate\PriceItem::price') ->setQuantity(3) ->setRef(777); $cart->Items()->addItem($item); $cart->User() ->setRef(42) ->setLanguage('EN') ->setFirstName('Example FName') ->setLastName('Example LName') ->setEmail('example@coercive.fr'); $cart->Shipping() ->setTitle('Example Shipping Title') ->setFirstName('Example FName') ->setLastName('Example LName') ->setAddress('Example Address') ->setZip('#12345') ->setTown('Example Town') ->setCountry('Example Country') ->setIsoCountry('EN'); $cart->Billing() ->setTitle('Example Billing Title') ->setFirstName('Example FName') ->setLastName('Example LName') ->setAddress('Example Address') ->setZip('#12345') ->setTown('Example Town') ->setCountry('Example Country') ->setIsoCountry('FR'); // -------------------------- ?> <h1># EXAMPLE START #</h1> <br /><br /> <p>User : <?= $cart->User()->getEmail() ?></p> <p>Shipping : <?= $cart->Shipping()->getTitle() ?></p> <p>Billing : <?= $cart->Billing()->getTitle() ?></p> <br /><?php foreach ($cart->Items()->keys() as $mId): $item = $cart->Items()->getItem($mId); ?> <p>----------------------------------------</p> <p>Title : <?= $item->getTitle() ?></p> <p>Price : <?= $item->getPrice() ?></p> <p>Quantity : <?= $item->getQuantity() ?></p> <p>Ref : <?= $item->getRef() ?></p><?php if($item->Promo()->isModified()): ?> <p>Token : <?= $item->Promo()->getToken() ?></p> <p>Price cut : <?= $item->Promo()->getPriceCut() ?></p> <p>New item price : <?= $item->Promo()->calc($item->getPrice()) ?></p><?php endif; endforeach ?> <br /><br /> <h1># EXAMPLE END #</h1><?php # Storage in session $session = new Session; $session->store($cart); # Retrieve from session $cart = $session->retrieve();