Search by

yasinsvr / cart

yasinsvr

Laravel shopping cart

v1.1.0 2025-06-05 16:04 UTC

This package is auto-updated.

Last update: 2026-09-02 14:00:00 UTC


README

πŸ›’ Laravel Shopping Cart

A simple and reusable shopping cart package for Laravel applications.

Latest Version Total Downloads PHP Version Laravel License

πŸ“– About

Laravel Shopping Cart is a lightweight shopping cart package designed for Laravel applications.

The package provides a simple API for managing cart items without requiring a large amount of application-level code.

It can be installed through Composer and integrated into a Laravel application as a reusable package.

✨ Features

  • πŸ›’ Add items to the cart
  • πŸ”„ Update cart items
  • πŸ—‘οΈ Remove items
  • πŸ“¦ Retrieve cart contents
  • πŸ’° Calculate cart totals
  • 🧩 Item attributes and options
  • ⚑ Simple and reusable API
  • πŸ”Œ Laravel service provider integration
  • 🎯 Facade support
  • πŸ§ͺ PHPUnit test structure
  • βš™οΈ Publishable package configuration

πŸ“¦ Requirements

  • PHP ^8.1
  • Laravel 10.x, 11.x or 12.x

πŸš€ Installation

Install the package using Composer:

composer require yasinsvr/cart

After installation, Laravel will automatically discover the package.

βš™οΈ Configuration

If you want to publish the package configuration:

php artisan vendor:publish \
    --provider="YasinSVR\Cart\CartServiceProvider" \
    --tag="config"

This allows you to customize the package configuration for your application.

πŸ› οΈ Basic Usage

Add an Item

use YasinSVR\Cart\Facades\Cart;

Cart::add(
    id: 1,
    name: 'Product',
    quantity: 2,
    price: 150000
);

Get Cart Contents

$items = Cart::content();

Update an Item

Cart::update($rowId, [
    'quantity' => 3,
]);

Remove an Item

Cart::remove($rowId);

Get Cart Total

$total = Cart::total();

The exact method signatures may vary depending on the installed package version. See the source code and tests for the complete API.

🧱 Architecture

The package follows a modular package-oriented structure.

src/
β”œβ”€β”€ Cart.php
β”œβ”€β”€ CartServiceProvider.php
β”œβ”€β”€ Facades/
β”œβ”€β”€ Contracts/
β”œβ”€β”€ Models/
└── ...

The package separates cart functionality from the Laravel application itself, making the cart logic reusable across different projects.

πŸ§ͺ Testing

The project includes a PHPUnit test suite.

Run the tests with:

composer test

Or, if PHPUnit is configured directly:

vendor/bin/phpunit

πŸ”„ Supported Laravel Versions

Laravel PHP
10.x ^8.1
11.x ^8.1
12.x ^8.1

πŸ“š Package

The package is available through Packagist:

yasinsvr/cart

composer require yasinsvr/cart

πŸ—ΊοΈ Roadmap

Planned improvements may include:

  • More complete API documentation
  • More usage examples
  • Improved test coverage
  • Additional cart operations
  • Better documentation for advanced use cases

🀝 Contributing

Contributions, suggestions and bug reports are welcome.

If you find a bug or have an idea for improving the package, feel free to open an issue or submit a pull request.

πŸ“„ License

This package is open-sourced software licensed under the MIT License.

Made with ❀️ by Yasin Zolfaghari