PHPackages                             adarshhaldar/unicart - 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. [Payment Processing](/categories/payments)
4. /
5. adarshhaldar/unicart

ActiveLibrary[Payment Processing](/categories/payments)

adarshhaldar/unicart
====================

A PHP cart library for checkout calculations, summary and invoice generation.

v1.1.2(10mo ago)07MITPHPPHP ^7.4

Since Apr 22Pushed 10mo ago1 watchersCompare

[ Source](https://github.com/adarshhaldar/unicart)[ Packagist](https://packagist.org/packages/adarshhaldar/unicart)[ RSS](/packages/adarshhaldar-unicart/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)Dependencies (1)Versions (5)Used By (0)

Unicart
=======

[](#unicart)

**Unicart** is a robust, object-oriented PHP shopping cart system designed for flexibility, modularity, and precision. It allows developers to manage individual items or full carts with support for detailed pricing operations such as discounts, taxes, and delivery charges at both item and cart levels as well as empowers developers to generate invoices based on the cart.

---

Features
--------

[](#features)

- Add, manage, and calculate totals for products
- Apply item-level and cart-level:
    - Discounts
    - Taxes
    - Delivery charges
- Built-in state enforcement to prevent pricing conflicts
- Fully encapsulated `Item` class for independent item operations
- Structured output formatting (array, object, JSON)
- Centralized validation logic using traits
- Extensible and well-documented object-oriented design
- Custom Exceptions: UnicartException and ItemException for precise error handling.
- Conditional Logic Support: when() and unless() methods for conditional operation execution using callbacks or boolean values.
- Discount Stacking Toggle: Enable or restrict stacking of discounts independently at both item and cart levels.
- Rounding Mode Configuration: Set custom rounding behavior on totals for both items and the cart.
- Item Override Control: Prevent or allow overriding items with the same ID.
- Meta Data Support: Attach developer-defined meta information for item.
- Locale system: Multi-language error handling
- Invoice generation: Styled HTML invoice with full cart summary, company details, and optional PDF download with RTL/LTR rendering.

---

Documentation
-------------

[](#documentation)

For full documentation, usage and explanation, please visit

---

Installation
------------

[](#installation)

To install Unicart, use Composer:

```
composer require adarshhaldar/unicart
```

---

Usage
-----

[](#usage)

```
use Unicart\Unicart;

try {
    $cart = new Unicart();

    $cart->addItem('item_1', 200, 2);    // (id, price, quantity)

    $cart->applyFlatDiscountOnItem('item_1', 10);    // (id, discount)
    $cart->applyDeliveryChargeOnCart(50); // delivery charge

    $summary = $cart->toArray(); // Also available: toJson(), toObject()
    print_r($summary);
} catch (Exception $e) {
    echo $e->getMessage();
}
```

Author
------

[](#author)

Developed by Adarsh Haldar

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance54

Moderate activity, may be stable

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Every ~26 days

Total

4

Last Release

312d ago

PHP version history (2 changes)v1.0.0PHP &gt;=7.4

v1.1.2PHP ^7.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/4865278ab36da2f64b4d26a7274d743ade290e196eddfad13f64d6940b3cce5a?d=identicon)[adarshhaldar](/maintainers/adarshhaldar)

---

Top Contributors

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

---

Tags

phpinvoiceecommercecartshoppingshopping cartcheckouttaxecommerce librarypricingdiscountCart managementphp cartdelivery chargeorder summarycart systemunicartdiscount engineorder calculation

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/adarshhaldar-unicart/health.svg)

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

###  Alternatives

[amsgames/laravel-shop

Package set to provide shop or e-commerce functionality (such as CART, ORDERS, TRANSACTIONS and ITEMS) to Laravel for customizable builds.

4845.9k](/packages/amsgames-laravel-shop)[realrashid/cart

Meet Cart — your ultimate solution for seamless shopping cart functionality in Laravel applications. Cart simplifies the complexities of shopping cart operations, from product additions to total calculations, ensuring a frictionless user experience.

1093.6k](/packages/realrashid-cart)

PHPackages © 2026

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