PHPackages                             ozdemir/aurora - 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. ozdemir/aurora

ActiveLibrary

ozdemir/aurora
==============

Shopping Cart for Laravel

2.0.9(7mo ago)346MITPHPPHP ^8.3CI passing

Since Jun 3Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/n1crack/aurora)[ Packagist](https://packagist.org/packages/ozdemir/aurora)[ Docs](https://github.com/ozdemir/aurora)[ GitHub Sponsors](https://github.com/n1crack)[ RSS](/packages/ozdemir-aurora/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (3)Versions (17)Used By (0)

Aurora Shopping Cart for Laravel
================================

[](#aurora-shopping-cart-for-laravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/1076ff9b787e95f789c6830cae384468a6acb4c761beceea9f26afbc0818c641/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6f7a64656d69722f6175726f7261)](https://packagist.org/packages/ozdemir/aurora)[![GitHub Tests Action Status](https://camo.githubusercontent.com/b972d1e52adcc45adb6e46b198457283128805d9482194e1ca8647384cc9ffb5/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6e31637261636b2f6175726f72612f72756e2d74657374732e796d6c)](https://github.com/n1crack/aurora/actions)[![GitHub](https://camo.githubusercontent.com/3f504f49125629094df1ac4c006ebcfcf14466a0ee4a6b25af753fccfe72f203/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6e31637261636b2f6175726f7261)](https://github.com/n1crack/aurora/blob/main/LICENSE.md)

Aurora Cart is a flexible and feature-rich shopping cart library for Laravel.

Features
--------

[](#features)

- **Cart Management**: Easily manage the shopping cart for both guest and authenticated users.
- **Item Addition**: Add items to the cart with quantity and options support.
- **Item Modification**: Adjust item quantity, remove items, and update options.
- **Calculators**: Implement custom calculators for shipping, tax, or any other additional costs.
- **MetaData**: Attach meta information to the entire cart or individual items.
- **Snapshot and Rollback**: Save and restore the cart state for scenarios like order creation.
- **Validation**: Validate the cart integrity using checksums.

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

[](#installation)

Install the package using Composer:

```
composer require ozdemir/aurora
```

Configuration
-------------

[](#configuration)

To configure Aurora Cart, publish the configuration file:

```
php artisan vendor:publish --tag="aurora-config"
```

This will create a cart.php file in your config directory. Here's an example configuration file with explanations:

```
// config/cart.php

use Ozdemir\Aurora\Cart;
use Ozdemir\Aurora\Generators\GenerateChecksum;
use Ozdemir\Aurora\Generators\GenerateSessionKey;
use Ozdemir\Aurora\Storages\SessionStorage;

return [
    'instance' => 'cart',

    'cart_class' => Cart::class,

    'storage' => SessionStorage::class,

    'cache_store' => env('CART_STORE', config('cache.default')),

    'monetary' => [
        'precision' => env('CART_CURRENCY_PRECISION', 2),
    ],

    'session_key_generator' => GenerateSessionKey::class,

    'checksum_generator' => GenerateChecksum::class,

    'calculate_using' => [
        // Custom calculators go here
    ],
];
```

Basic Usage
-----------

[](#basic-usage)

```
// Create a product class implementing the Sellable interface
class SellableProduct implements Sellable
{
    use SellableTrait;
}
// Adding an item to the cart
$product = new SellableProduct(); // Replace with your actual product model
$cartItem = new CartItem($product, quantity: 2);
Cart::add($cartItem);

// Retrieving cart information
$total = Cart::total();
$itemCount = Cart::count();
$items = Cart::items();
$itemQuantity = Cart::quantity(); // total quantity

// Adding an item with options to the cart
Cart::add(
       (new CartItem($product, quantity: 1))->withOption('color', 'blue')
                 ->withOption('material', 'metal', price: 5)
                 ->withOption('size', 'large', weight: 4)
         );

// Updating item quantity
Cart::update($cartItem->hash(), quantity: 3);

// Removing an item from the cart
Cart::remove($cartItem->hash());
```

Aurora Cart supports custom calculators for calculating totals. You can add your custom calculators to the config/cart.php file under the calculate\_using key.

### Example

[](#example)

```
return [
    // ...
    'calculate_using' => [
        // discounts etc..
        ShippingCalculator::class
        TaxCalculator::class
    ],
];
```

```
class ShippingCalculator
{
    public function handle($payload, Closure $next)
    {
        [$price, $breakdowns] = $payload;

        $shippingPrice = Shipping::first()->amount;

        $price = $price + $shippingPrice;

        $breakdowns[] = [
            'type' => 'shipping',
            'amount' => $shippingPrice,
            // any additional values..
        ];

        return $next([$price, $breakdowns]);
    }
}
```

```
class TaxCalculator
{
    public function handle($payload, Closure $next)
    {
        [$price, $breakdowns] = $payload;

        $taxPrice = Tax::first()->amount;

        $price = $price + $taxPrice;

        $breakdowns[] = [
            'type' => 'tax',
            'amount' => $taxPrice,
            // any additional values..
        ];

        return $next([$price, $breakdowns]);
    }
}
```

Now, your cart will use these custom calculators to calculate totals, including shipping and tax. Adjust the logic in the calculators based on your specific business requirements.

Breakdowns
----------

[](#breakdowns)

You can retrieve the breakdowns of your cart using the Cart::breakdowns() method. Breakdowns provide a detailed summary of how the total amount is calculated, including contributions from various components such as shipping, tax, and any custom calculators you've added.

Example

```
$breakdowns = Cart::breakdowns();

// Output the breakdowns
print_r($breakdowns);
```

The breakdowns() method returns an array where each element represents a breakdown item. Each breakdown item typically includes a label and value, providing transparency into how different factors contribute to the overall total.

Here's a hypothetical example output:

```
Array (
    [0] => Array (
        [label] => Shipping
        [value] => 10
    )
    [1] => Array (
        [label] => Tax
        [value] => 15
    )
    // Additional breakdown items based on your custom calculators
    // ...
)
```

Adjust the output format and contents as needed for your specific use case.

Changelog
---------

[](#changelog)

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

Credits
-------

[](#credits)

- [Yusuf Özdemir](https://github.com/n1crack)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

44

—

FairBetter than 92% of packages

Maintenance78

Regular maintenance activity

Popularity11

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 79.6% 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 ~65 days

Recently: every ~3 days

Total

14

Last Release

232d ago

Major Versions

1.0.2 → v2.x-dev2023-11-28

PHP version history (3 changes)1.0.0PHP ^8.1

2.0.2PHP ^8.2

2.0.4PHP ^8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/0124f2d35be25c3386c1b0614c41112c20313f7b4acc46a502b475d5f6308403?d=identicon)[n1crack](/maintainers/n1crack)

---

Top Contributors

[![n1crack](https://avatars.githubusercontent.com/u/712404?v=4)](https://github.com/n1crack "n1crack (129 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (20 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (13 commits)")

---

Tags

laravelcartshoppingLaravel cartozdemir

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/ozdemir-aurora/health.svg)

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

###  Alternatives

[lukepolo/laracart

A simple cart for Laravel

583135.4k1](/packages/lukepolo-laracart)[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)[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)[syscover/shopping-cart

Shopping Cart package

299.1k1](/packages/syscover-shopping-cart)[yabhq/laravel-cart

Simple yet customizable Laravel shopping cart

213.0k](/packages/yabhq-laravel-cart)

PHPackages © 2026

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