PHPackages                             yiddishe-kop/laravel-commerce - 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. yiddishe-kop/laravel-commerce

ActiveLibrary

yiddishe-kop/laravel-commerce
=============================

Simple commerce package for Laravel

v2.3.0(2y ago)26390↓100%3[2 issues](https://github.com/Yiddishe-Kop/laravel-commerce/issues)MITPHPPHP ^8.0

Since Oct 14Pushed 1y ago1 watchersCompare

[ Source](https://github.com/Yiddishe-Kop/laravel-commerce)[ Packagist](https://packagist.org/packages/yiddishe-kop/laravel-commerce)[ Docs](https://github.com/yiddishe-kop/laravel-commerce)[ RSS](/packages/yiddishe-kop-laravel-commerce/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)Dependencies (6)Versions (10)Used By (0)

[![laravel-commerce](https://camo.githubusercontent.com/579f6485d69d854a953589a9c113fa4a61d91554a1f84ef36ec24fa928b81c64/68747470733a2f2f6c61726176656c2d636f6d6d657263652e79696464697368652d6b6f702e636f6d2f707265766965772d6c696768742e706e67)](https://laravel-commerce.yiddishe-kop.com/)

[![Open in Visual Studio Code](https://camo.githubusercontent.com/e1bdc73074d82f0adbaa34cdbaed2d5fe414dbcecf64dfe1a6d748f11f630c61/68747470733a2f2f6f70656e2e7673636f64652e6465762f6261646765732f6f70656e2d696e2d7673636f64652e737667)](https://open.vscode.dev/yiddishe-kop/laravel-commerce)

A simple commerce package for Laravel
=====================================

[](#a-simple-commerce-package-for-laravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/3c192c5cbbc0407e76f09597e1cf379957423e4ba2f3254374ca66accc60520f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f79696464697368652d6b6f702f6c61726176656c2d636f6d6d657263652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/yiddishe-kop/laravel-commerce)[![Total Downloads](https://camo.githubusercontent.com/a70e5bcadfa1f244a3337025b52649484b1feba3465c9a01f4daca54b74bf2ba/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f79696464697368652d6b6f702f6c61726176656c2d636f6d6d657263652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/yiddishe-kop/laravel-commerce)

After searching for a simple ecommerce package for Laravel and not finding a lightweight simple to use solution - I decided to attempt to create one myself.

Read the official documentation here:

### Features

[](#features)

- Cart (stored in the session - so guests can also have a cart)
- Orders
- Coupons
- Special Offers
- Multiple Currencies
- Multiple Payment Gateways

This package only implements the backend logic, and leaves you with full control over the frontend.

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

[](#installation)

You can install the package via composer:

```
composer require yiddishe-kop/laravel-commerce
```

To publish the `commerce.php` config file:

```
php artisan vendor:publish --provider="YiddisheKop\LaravelCommerce\CommerceServiceProvider" --tag="config"
```

You can also publish the migrations if you need to customize them:

```
php artisan vendor:publish --provider="YiddisheKop\LaravelCommerce\CommerceServiceProvider" --tag="migrations"
```

Usage
-----

[](#usage)

### Cart

[](#cart)

You can access the cart anywhere, regardless if the user is logged in or a guest, using the facade:

```
use YiddisheKop\LaravelCommerce\Facades\Cart;

$cart = Cart::get();
```

When the guest logs in, the cart will be attached to his account 👌.

**Note**: If you want the cart to still be available after logout, you need to override the following method in `Auth\LoginController`:

```
public function logout(Request $request) {
    $this->guard()->logout();

    // keep cart data for after logout
    $cartId = session()->get('cart');
    $request->session()->invalidate();
    $request->session()->regenerateToken();
    session()->put('cart', $cartId);

    if ($response = $this->loggedOut($request)) {
        return $response;
    }

    return $request->wantsJson()
        ? new JsonResponse([], 204)
        : redirect('/');
}
```

### Products

[](#products)

You can make any model purchasable - by implementing the `Purchasable` contract:

```
use YiddisheKop\LaravelCommerce\Contracts\Purchasable;
use YiddisheKop\LaravelCommerce\Traits\Purchasable as PurchasableTrait;

class Product implements Purchasable {
  use PurchasableTrait;

    // the title of the product
    public function getTitle(): string {
        return $this->name;
    }

    // the price
    public function getPrice(): int {
        return $this->price;
    }
}
```

##### Add products to cart

[](#add-products-to-cart)

Adding a product to the cart couldn't be simpler:

```
Cart::add(Purchasable $product, int $quantity = 1);
```

Alternatively:

```
$product->addToCart($quantity = 1);
```

If you add a product that already exists in the cart, we'll automatically just update the quantity 😎 .

##### Remove products from the cart

[](#remove-products-from-the-cart)

```
Cart::remove(Purchasable $product);
```

Alternatively:

```
$product->removeFromCart();
```

To empty the whole cart:

```
Cart::empty();
```

#### Access cart items

[](#access-cart-items)

You can access the cart items using the `items` relation:

```
$cartItems = $cart->items;
```

To access the Product model from the cartItem, use the `model` relation (morphable):

```
$product = $cart->items[0]->model;
```

### Calculate Totals

[](#calculate-totals)

To calculate and persist the totals of the cart, use the `calculateTotals()` method:

```
Cart::calculateTotals();
```

Now the cart has the following data up to date:

```
[
  "items_total" => 3552
  "tax_total" => 710.0
  "coupon_total" => "0"
  "grand_total" => 4262.0
]

```

Deleted products will automatically get removed from the cart upon calculating the totals.

Orders
------

[](#orders)

You can use the `HasOrders` trait on the User model, to get a `orders` relationship:

```
use YiddisheKop\LaravelCommerce\Traits\HasOrders;

class User {
  use HasOrders;
  // ...
}

// you can now get all the users' orders (status complete)
$orders = $user->orders;
```

### Testing

[](#testing)

This package has extensive tests - with the delightful Pest framework. To run the tests:

```
composer test
```

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

### Security

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Yehuda Neufeld](https://github.com/yiddishe-kop)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance32

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 95.5% 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 ~253 days

Total

5

Last Release

977d ago

Major Versions

v1.0.0 → v2.0.02023-06-23

PHP version history (2 changes)v1.0.0PHP ^7.4

v2.0.0PHP ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/a07b4083c2e16237bec01ae1b57edb4f78ce198a73e293eade5d9f7d668198ab?d=identicon)[Yehuda Neufeld](/maintainers/Yehuda%20Neufeld)

---

Top Contributors

[![Yiddishe-Kop](https://avatars.githubusercontent.com/u/36875437?v=4)](https://github.com/Yiddishe-Kop "Yiddishe-Kop (128 commits)")[![shayaulman](https://avatars.githubusercontent.com/u/47426218?v=4)](https://github.com/shayaulman "shayaulman (4 commits)")[![emargareten](https://avatars.githubusercontent.com/u/46111162?v=4)](https://github.com/emargareten "emargareten (2 commits)")

---

Tags

ecommerce-frameworklaravel-packageyiddishe-koplaravel-commerce

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/yiddishe-kop-laravel-commerce/health.svg)

```
[![Health](https://phpackages.com/badges/yiddishe-kop-laravel-commerce/health.svg)](https://phpackages.com/packages/yiddishe-kop-laravel-commerce)
```

###  Alternatives

[fumeapp/modeltyper

Generate TypeScript interfaces from Laravel Models

196277.9k](/packages/fumeapp-modeltyper)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

255.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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