PHPackages                             dilab/cart - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. dilab/cart

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

dilab/cart
==========

Shopping Cart Library

72.5kPHPCI failing

Since Feb 3Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/Spacebib/cart)[ Packagist](https://packagist.org/packages/dilab/cart)[ RSS](/packages/dilab-cart/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (1)Used By (0)

Cart
====

[](#cart)

[![Build Status](https://camo.githubusercontent.com/6c45a71f6eb5070d615d71cba74b74fdc1668b0acf9e9c3f0f098d8492f25113/68747470733a2f2f7777772e7472617669732d63692e6f72672f53706163656269622f636172742e7376673f6272616e63683d6d6173746572)](https://www.travis-ci.org/Spacebib/cart)

A Shopping Cart Abstraction

Usage
-----

[](#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
--------

[](#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

```
$cart->getCoupon()
```

```
$cart->setCoupon(Coupon $coupon)
```

```
$cart->applyCoupon()
```

```
$cart->cancelCoupon()
```

```
$cart->getDiscount()
```

```
$cart->usedCouponQuantity()
```

- Get currency

```
$cart->currency()
```

Registration API
----------------

[](#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();
```

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance54

Moderate activity, may be stable

Popularity21

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity34

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/465cbccb0942f3dfafdb393d46757720fe99af53ac04c6ae1d82b97c2f0e2b18?d=identicon)[xuding](/maintainers/xuding)

---

Top Contributors

[![dilab](https://avatars.githubusercontent.com/u/218813?v=4)](https://github.com/dilab "dilab (27 commits)")

### Embed Badge

![Health badge](/badges/dilab-cart/health.svg)

```
[![Health](https://phpackages.com/badges/dilab-cart/health.svg)](https://phpackages.com/packages/dilab-cart)
```

###  Alternatives

[dr-que/polynomial-regression

Calculates and returns coefficients for polynomial regression.

22214.6k3](/packages/dr-que-polynomial-regression)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
