All Projects → overtrue → Laravel Shopping Cart

overtrue / Laravel Shopping Cart

Licence: mit
🛒 Shopping cart for Laravel Application.

Projects that are alternatives of or similar to Laravel Shopping Cart

Ecommerce Open Api
果酱小店:基于 Laravel + swoole + 小程序的开源电商系统,优雅与性能兼顾 : )
Stars: ✭ 546 (+47.97%)
Mutual labels:  shopping-cart, laravel
Laravel Shopping Cart
Laravel shopping cart package
Stars: ✭ 69 (-81.3%)
Mutual labels:  shopping-cart, laravel
Laravelshoppingcart
Shopping Cart Implementation for Laravel Framework
Stars: ✭ 853 (+131.17%)
Mutual labels:  shopping-cart, laravel
Shopping Cart
An easy-to-use shopping cart for Laravel
Stars: ✭ 57 (-84.55%)
Mutual labels:  shopping-cart, laravel
Grosir Obat
Sebuah sistem kasir dan manajemen produk obat untuk penjualan Grosir
Stars: ✭ 147 (-60.16%)
Mutual labels:  shopping-cart, laravel
Aimeos
Integrated online shop based on Laravel 8 and the Aimeos e-commerce framework
Stars: ✭ 2,354 (+537.94%)
Mutual labels:  laravel, shopping-cart
Laravel Ecommerce
AvoRed an Open Source Laravel Shopping Cart
Stars: ✭ 1,151 (+211.92%)
Mutual labels:  shopping-cart, laravel
Aimeos Laravel
Laravel ecommerce package for professional, ultra fast online shops, complex B2B applications and #gigacommerce
Stars: ✭ 5,204 (+1310.3%)
Mutual labels:  laravel, shopping-cart
Laracom
Laravel FREE E-Commerce Software
Stars: ✭ 1,570 (+325.47%)
Mutual labels:  shopping-cart, laravel
Ecommerce Laravel Bootstrap
Responsive, Multi-Vendor, MultiLanguage Online Store Platform (shopping cart solution)
Stars: ✭ 99 (-73.17%)
Mutual labels:  shopping-cart, laravel
Laravel Ecommerce Iyzico
Iyzico intigrated e-Commerce system that could be developed easily in simple level.
Stars: ✭ 81 (-78.05%)
Mutual labels:  shopping-cart, laravel
Laravel Shopr
A developer-friendly e-commerce foundation for your Laravel app
Stars: ✭ 196 (-46.88%)
Mutual labels:  shopping-cart, laravel
Microweber
Drag and Drop Website Builder and CMS with E-commerce
Stars: ✭ 2,226 (+503.25%)
Mutual labels:  shopping-cart, laravel
S Cart
This project has been replaced by https://github.com/s-cart/s-cart
Stars: ✭ 258 (-30.08%)
Mutual labels:  shopping-cart, laravel
Uniquewith Validator
Custom Laravel Validator for combined unique indexes
Stars: ✭ 352 (-4.61%)
Mutual labels:  laravel
Laravel Feed
Laravelium Feed package for Laravel.
Stars: ✭ 356 (-3.52%)
Mutual labels:  laravel
Laravel Swoole
High performance HTTP server based on Swoole. Speed up your Laravel or Lumen applications.
Stars: ✭ 3,726 (+909.76%)
Mutual labels:  laravel
Laravel Json Api Paginate
A paginator that plays nice with the JSON API spec
Stars: ✭ 351 (-4.88%)
Mutual labels:  laravel
News.laravel China.org
Source Code of the https://news.laravel-china.org/ website, build on top of Laravel 5.1. Laravel 资讯网站源代码,使用 Laravel 5.1 构建
Stars: ✭ 363 (-1.63%)
Mutual labels:  laravel
Laravel Enterprise Starter Kit
👔 Enterprise Web application starter kit or template using Laravel
Stars: ✭ 356 (-3.52%)
Mutual labels:  laravel

Laravel Shopping Cart

Shopping cart for Laravel Application.

Build Status Latest Stable Version Latest Unstable Version Scrutinizer Code Quality Code Coverage Total Downloads License

Installation

$ composer require "overtrue/laravel-shopping-cart:~2.0"

or add the following line to your project's composer.json:

"require": {
    "overtrue/laravel-shopping-cart": "~2.0"
}

then

$ composer update

After completion of the above, add the follow line to the section providers of config/app.php:

Overtrue\LaravelShoppingCart\ServiceProvider::class,

And add the follow line to the section aliases:

'ShoppingCart'      => Overtrue\LaravelShoppingCart\Facade::class,

Usage

Add item to cart

Add a new item.

Item | null ShoppingCart::add(
                    string | int $id,
                    string $name,
                    int $quantity,
                    int | float $price
                    [, array $attributes = []]
                 );

example:

$row = ShoppingCart::add(37, 'Item name', 5, 100.00, ['color' => 'red', 'size' => 'M']);
// Item:
//    id       => 37
//    name     => 'Item name'
//    qty      => 5
//    price    => 100.00
//    color    => 'red'
//    size     => 'M'
//    total    => 500.00
//    __raw_id => '8a48aa7c8e5202841ddaf767bb4d10da'
$rawId = $row->rawId();// get __raw_id
$row->qty; // 5
...

Update item

Update the specified item.

Item ShoppingCart::update(string $rawId, int $quantity);
Item ShoppingCart::update(string $rawId, array $arrtibutes);

example:

ShoppingCart::update('8a48aa7c8e5202841ddaf767bb4d10da', ['name' => 'New item name']);
// or only update quantity
ShoppingCart::update('8a48aa7c8e5202841ddaf767bb4d10da', 5);

Get all items

Get all the items.

Collection ShoppingCart::all();

example:

$items = ShoppingCart::all();

Get item

Get the specified item.

Item ShoppingCart::get(string $rawId);

example:

$item = ShoppingCart::get('8a48aa7c8e5202841ddaf767bb4d10da');

Remove item

Remove the specified item by raw ID.

boolean ShoppingCart::remove(string $rawId);

example:

ShoppingCart::remove('8a48aa7c8e5202841ddaf767bb4d10da');

Destroy cart

Clean Shopping Cart.

boolean ShoppingCart::destroy();
boolean ShoppingCart::clean(); // alias of destroy();

example:

ShoppingCart::destroy();// or ShoppingCart::clean();

Total price

Returns the total of all items.

int | float ShoppingCart::total(); // alias of totalPrice();
int | float ShoppingCart::totalPrice();

example:

$total = ShoppingCart::total();
// or
$total = ShoppingCart::totalPrice();

Count rows

Return the number of rows.

int ShoppingCart::countRows();

example:

ShoppingCart::add(37, 'Item name', 5, 100.00, ['color' => 'red', 'size' => 'M']);
ShoppingCart::add(37, 'Item name', 1, 100.00, ['color' => 'red', 'size' => 'M']);
ShoppingCart::add(37, 'Item name', 5, 100.00, ['color' => 'red', 'size' => 'M']);
ShoppingCart::add(127, 'foobar', 15, 100.00, ['color' => 'green', 'size' => 'S']);
$rows = ShoppingCart::countRows(); // 2

Count quantity

Returns the quantity of all items

int ShoppingCart::count($totalItems = true);

$totalItems : When false,will return the number of rows.

example:

ShoppingCart::add(37, 'Item name', 5, 100.00, ['color' => 'red', 'size' => 'M']);
ShoppingCart::add(37, 'Item name', 1, 100.00, ['color' => 'red', 'size' => 'M']);
ShoppingCart::add(37, 'Item name', 5, 100.00, ['color' => 'red', 'size' => 'M']);
$count = ShoppingCart::count(); // 11 (5+1+5)

Search items

Search items by property.

Collection ShoppingCart::search(array $conditions);

example:

$items = ShoppingCart::search(['color' => 'red']);
$items = ShoppingCart::search(['name' => 'Item name']);
$items = ShoppingCart::search(['qty' => 10]);

Check empty

bool ShoppingCart::isEmpty();

Specifies the associated model

Specifies the associated model of item before you add items to cart.

Cart ShoppingCart::associate(string $modelName);

example:

ShoppingCart::associate('App\Models\Product');

ShoppingCart::add(37, 'Item name', 5, 100.00, ['color' => 'red', 'size' => 'M']);

$item = ShoppingCart::get('8a48aa7c8e5202841ddaf767bb4d10da');
$item->product->name; // $item->product is instanceof 'App\Models\Product'

The Collection And Item

Collection and Overtrue\LaravelShoppingCart\Item are instanceof Illuminate\Support\Collection, Usage Refer to:Collections - Laravel doc.

properties of Overtrue\LaravelShoppingCart\Item:

  • id - your goods item ID.
  • name - Name of item.
  • qty - Quantity of item.
  • price - Unit price of item.
  • total - Total price of item.
  • __raw_id - Unique ID of row.
  • __model - Name of item associated Model.
  • ... custom attributes.

And methods:

  • rawId() - Return the raw ID of item.

Events

Event Name Parameters
shopping_cart.adding ($attributes, $cart);
shopping_cart.added ($attributes, $cart);
shopping_cart.updating ($row, $cart);
shopping_cart.updated ($row, $cart);
shopping_cart.removing ($row, $cart);
shopping_cart.removed ($row, $cart);
shopping_cart.destroying ($cart);
shopping_cart.destroyed ($cart);

You can easily handle these events, for example:

Event::listen('shopping_cart.adding', function($attributes, $cart){
    // code
});

PHP 扩展包开发

想知道如何从零开始构建 PHP 扩展包?

请关注我的实战课程,我会在此课程中分享一些扩展开发经验 —— 《PHP 扩展包实战教程 - 从入门到发布》

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].