PHPackages                             taskinbirtan/ecommerce.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. [Database &amp; ORM](/categories/database)
4. /
5. taskinbirtan/ecommerce.cart

ActiveLibrary[Database &amp; ORM](/categories/database)

taskinbirtan/ecommerce.cart
===========================

00PHP

Since May 19Pushed 11mo ago1 watchersCompare

[ Source](https://github.com/taskinbirtan/ecommerce.cart)[ Packagist](https://packagist.org/packages/taskinbirtan/ecommerce.cart)[ RSS](/packages/taskinbirtan-ecommercecart/feed)WikiDiscussions dev Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel E-Commerce Cart Package
===============================

[](#laravel-e-commerce-cart-package)

This package is a **modular** and **extensible** library designed to strengthen **cart** management within the Laravel ecosystem. It is classified under the following headings:

- **Core Cart**: Functions to add, remove, update quantity, and clear cart items.
- **Persistence Layer**: Durable storage via a migration for `cart_items` with a JSON-enabled `options` column and the `CartItem` model.
- **Interface &amp; Contracts**: Abstractions through `CartInterface`, `ProductResolverInterface`, and `TaxCalculatorInterface`.
- **Events System**: `ItemAdded`, `ItemUpdated`, `ItemRemoved`, and `CartCleared` events.
- **Calculators**: Subtotal, tax, and total calculation via `DefaultCartCalculator` and `DefaultTaxCalculator`.
- **Configurable Resolver**: Configure the model and tax rate (`tax_rate`) in `config/cart.php`.
- **Actions**: Extendable action framework with examples like `MailAction` for sending emails.
- **Facade &amp; Helpers**: Provides a `Cart` facade and helper functions.

📦 Features
----------

[](#-features)

- **Cart Management**

    - Add/remove/update/clear items (`addItem`, `removeItem`, `updateQuantity`, `clear`)
    - List items (`items`) and calculate total (`total`)
- **Database Support**

    - `cart_items` table: `cart_id` (UUID), `item_id`, `quantity`, `unit_price`, `options` (JSON), timestamps
- **Event Dispatch**

    - `ItemAdded`, `ItemUpdated`, `ItemRemoved`, `CartCleared`
- **Actions**

    - Example `MailAction`—send email with sender, recipient, subject, and content parameters
- **Configuration**

    - Configure model and `tax_rate` via `config/cart.php`
- **Calculators**

    - `DefaultCartCalculator`: subtotal, tax, and grand total
    - `DefaultTaxCalculator`: percentage-based tax calculation
- **Facade**

    - Provides the `Cart` facade

⚙️ Installation
---------------

[](#️-installation)

1. Require the package via Composer:

    ```
    composer require taskinbirtan/ecommerce.cart
    ```
2. Register the service provider and facade (if auto-discovery is disabled) in `config/app.php`:

    ```
    Taskinbirtan\EcommerceCart\CartServiceProvider::class,

    'Cart' => Taskinbirtan\EcommerceCart\Facades\Cart::class,
    ```
3. Publish the configuration file:

    ```
    php artisan vendor:publish --provider="Taskinbirtan\EcommerceCart\CartServiceProvider" --tag=config
    ```
4. Run the migrations:

    ```
    php artisan migrate
    ```

> **Note:** The default migration file is named `1919_05_19_commemorate_ataturk.php` in honor of **Atatürk** and to celebrate **Youth and Sports Day**, commemorating the beginning of the Turkish War of Independence and marking the date this project was initiated.

⚙️ Configuration
----------------

[](#️-configuration)

`config/cart.php`:

```
return [
    'product_model' => App\\Models\\Product::class,
    'tax_rate'      => 18, // percentage
];
```

🛠️ Usage
--------

[](#️-usage)

### Add an Item to the Cart

[](#add-an-item-to-the-cart)

```
use Cart;

Cart::addItem($productId, $quantity = 1, ['color' => 'red']);
```

### Remove an Item

[](#remove-an-item)

```
Cart::removeItem($productId);
```

### Update Quantity

[](#update-quantity)

```
Cart::updateQuantity($productId, $newQuantity);
```

### Clear the Cart

[](#clear-the-cart)

```
Cart::clear();
```

### List Items and Calculate Total

[](#list-items-and-calculate-total)

```
$items = Cart::items();
$total = Cart::total();
```

🔔 Events
--------

[](#-events)

You can listen to the following events to react to cart changes:

- `Taskinbirtan\EcommerceCart\Events\ItemAdded`
- `Taskinbirtan\EcommerceCart\Events\ItemUpdated`
- `Taskinbirtan\EcommerceCart\Events\ItemRemoved`
- `Taskinbirtan\EcommerceCart\Events\CartCleared`

Example listener:

```
public function handle(ItemAdded $event)
{
    // $event->item
}
```

📋 Test
------

[](#-test)

This package can be tested with Pest &amp; PHPUnit:

```
vendor/bin/pest
```

📝 Roadmap
---------

[](#-roadmap)

In future versions, we aim to cover **e-commerce components beyond Cart** with the following modules:

- **Product Catalog**: CRUD operations, detail pages, variation support (color, size, etc.)
- **Category Management**: Multi-level category/ subcategory hierarchy and category-based filtering
- **Inventory &amp; Stock Tracking**: Warehouse-based stock management, critical stock alerts
- **Order Management**: Creating orders, status updates, and customer notifications
- **Payment Integrations**: Stripe, PayPal, local banks, and installment options
- **Shipping &amp; Logistics**: Carrier API integration, shipment tracking
- **Coupons &amp; Discounts**: Percentage- and amount-based promo codes, usage rules
- **Customer Accounts**: Registration/login, profile, address book, order history
- **Invoicing &amp; Returns**: PDF invoice generation, return request management
- **Multi-Language &amp; Multi-Currency**: Localization infrastructure, currency rate updates
- **Reporting &amp; Analytics**: Sales, customer, and stock reports with graphical displays
- **Search &amp; Filtering Infrastructure**: Elasticsearch/Algolia integration, advanced filters
- **UI/UX Components**: Responsive theme and demo components (Tailwind, jQuery)
- **Security &amp; Performance**: Rate limiting, cache (Redis), scalable architecture recommendations

🤝 Contributing
--------------

[](#-contributing)

- Fork the repository
- Create a new branch (`git checkout -b feature/fooBar`)
- Commit your changes (`git commit -am 'Add some fooBar'`)
- Push to the branch (`git push origin feature/fooBar`)
- Open a pull request

☕ Buy Me a Coffee
-----------------

[](#-buy-me-a-coffee)

If you like this package and want to support its development, you can buy me a coffee! ☕

[Buy Me a Coffee](https://www.buymeacoffee.com/taskinbirtan)

📝 License
---------

[](#-license)

MIT © taskinbirtan

###  Health Score

15

—

LowBetter than 3% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity14

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/e3eb898f4a64a72e19502b97e338f2dea92e9cfe4675010cc23421bcc973c1c2?d=identicon)[meta](/maintainers/meta)

---

Top Contributors

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

---

Tags

cartcomposerecommerceeloquenteventslaravellaravel-packagephpshopping-carttax-calculation

### Embed Badge

![Health badge](/badges/taskinbirtan-ecommercecart/health.svg)

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

###  Alternatives

[doctrine/orm

Object-Relational-Mapper for PHP

10.2k285.3M6.2k](/packages/doctrine-orm)[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k115.1M102](/packages/jdorn-sql-formatter)[illuminate/database

The Illuminate Database package.

2.8k52.4M9.3k](/packages/illuminate-database)[mongodb/mongodb

MongoDB driver library

1.6k64.0M543](/packages/mongodb-mongodb)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

90340.3M209](/packages/ramsey-uuid-doctrine)[reliese/laravel

Reliese Components for Laravel Framework code generation.

1.7k3.4M16](/packages/reliese-laravel)

PHPackages © 2026

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