2017 © Pedro Peláez
 

library cart

Shopping Cart Library

image

dilab/cart

Shopping Cart Library

  • Monday, July 23, 2018
  • by xuding
  • Repository
  • 1 Watchers
  • 1 Stars
  • 1,410 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 61 % Grown

The README.md

Cart

Build Status, (*1)

A Shopping Cart Abstraction, (*2)

Usage

  • Setup initial state
$event = Event::init($data)
  • Create Cart
$cart = new Cart('xuding@spacebib.com', $event)
  • Create Registration Form
$registration = new Registration($cart->getParticipants());

Cart API

  • Add ticket to cart
$cart->addTicket($event->getCategoryById(1), 1);
  • Get participants
$cart->getParticipants();
  • Get order details
$tickets = $cart->tickets()
$subTotal = $cart->subTotal()
$total = $cart->total()
  • Add product to cart
$cart->addProduct($product)
  • Remove product from cart
$cart->removeProduct($productId, $productVariantId)
  • Get product details
$cart->getProducts()  

$cart->countProducts()  

$cart->productsSubtotal()
  • Coupon

The cart can only use one coupon, but a coupon can be used for multiple tickets, (*3)

$cart->getCoupon()

```php $cart->setCoupon(Coupon $coupon), (*4)

```php
$cart->applyCoupon()

```php $cart->cancelCoupon(), (*5)

```php
$cart->getDiscount()

```php $cart->usedCouponQuantity(), (*6)


+ Get currency ```php $cart->currency()

Registration API

  • Render a form
$registration->renderParticipant($trackId);
  • Fill a form
$registration->fillParticipant($trackId, $data);
  • Get errors of a participant form
$registration->getErrors($trackId);
  • Redirect to next page
$registration->redirectTo();

The Versions

23/07 2018