All Projects → guojiangclub → laravel-shopping-cart

guojiangclub / laravel-shopping-cart

Licence: MIT license
e-commerce shopping cart for laravel application.

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to laravel-shopping-cart

Dotplant2
E-Commerce CMS - Yii Framework 2 (yii2, shop)
Stars: ✭ 636 (+1573.68%)
Mutual labels:  shopping-cart, e-commerce
Ryal
🏵 An e-commerce library for elixir; just to save you some pain, we're still in construction, so star us instead or donate!
Stars: ✭ 87 (+128.95%)
Mutual labels:  shopping-cart, e-commerce
Nopcommerce
The most popular open-source eCommerce shopping cart solution based on ASP.NET Core
Stars: ✭ 6,827 (+17865.79%)
Mutual labels:  shopping-cart, e-commerce
Aimeos
Integrated online shop based on Laravel 8 and the Aimeos e-commerce framework
Stars: ✭ 2,354 (+6094.74%)
Mutual labels:  shopping-cart, e-commerce
Laravel Shopr
A developer-friendly e-commerce foundation for your Laravel app
Stars: ✭ 196 (+415.79%)
Mutual labels:  shopping-cart, e-commerce
S Cart
This project has been replaced by https://github.com/s-cart/s-cart
Stars: ✭ 258 (+578.95%)
Mutual labels:  shopping-cart, e-commerce
Shopping Cart
An easy-to-use shopping cart for Laravel
Stars: ✭ 57 (+50%)
Mutual labels:  shopping-cart, e-commerce
shopping-cart
A full-fledged package to build an e-commerce application for iOS and Android similar to Myntra/JackThreads. Available with beautiful design and necessary features along with screen for Dashboard and Mobile app. Build using React Native, Expo, React, GraphQL, Apollo Client, Node and MongoDB.
Stars: ✭ 64 (+68.42%)
Mutual labels:  shopping-cart, e-commerce
Laracom
Laravel FREE E-Commerce Software
Stars: ✭ 1,570 (+4031.58%)
Mutual labels:  shopping-cart, e-commerce
Ecommerce Laravel Bootstrap
Responsive, Multi-Vendor, MultiLanguage Online Store Platform (shopping cart solution)
Stars: ✭ 99 (+160.53%)
Mutual labels:  shopping-cart, e-commerce
Aimeos Laravel
Laravel ecommerce package for professional, ultra fast online shops, complex B2B applications and #gigacommerce
Stars: ✭ 5,204 (+13594.74%)
Mutual labels:  shopping-cart, e-commerce
mytek
Django e-commerce web application with advanced features
Stars: ✭ 27 (-28.95%)
Mutual labels:  shopping-cart, e-commerce
TokoTokoan
No description or website provided.
Stars: ✭ 19 (-50%)
Mutual labels:  shopping-cart, e-commerce
Vuejs Firebase Shopping Cart
Shopping cart demo using Vuejs and Firebase
Stars: ✭ 274 (+621.05%)
Mutual labels:  shopping-cart, e-commerce
django ecommerce
Scalable Django E-Commerce, perfect to start one new online shop project.
Stars: ✭ 25 (-34.21%)
Mutual labels:  shopping-cart, e-commerce
Ecommerce Codeigniter Bootstrap
Responsive, Multi-Vendor, MultiLanguage Online Store Platform (shopping cart solution)
Stars: ✭ 788 (+1973.68%)
Mutual labels:  shopping-cart, e-commerce
storefront-app
Storefront by Fleetbase is an open source hyperlocal shopping or services app. Enables users to quickly launch their own shop or service booking app or setup a multi-vendor marketplace.
Stars: ✭ 40 (+5.26%)
Mutual labels:  shopping-cart, e-commerce
e-commerce-microservices
REST Microservices architecture for E-commerce with Spring boot, Cloud and multiple modules
Stars: ✭ 102 (+168.42%)
Mutual labels:  shopping-cart, e-commerce
Unchained
Headless & open-source e-commerce toolkit. The Unchained Engine is our core product and is written in Node.js ES6
Stars: ✭ 92 (+142.11%)
Mutual labels:  shopping-cart, e-commerce
Co Cart
🛒 CoCart is a flexible, open-source solution to enabling the shopping cart via the REST API for WooCommerce.
Stars: ✭ 198 (+421.05%)
Mutual labels:  shopping-cart, e-commerce

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

购物车在电商场景中基本是必须的一个模块,本包是基于 overtrue/laravel-shopping-cart 进行扩展开发,主要实现了以下扩展:

  1. 购物车数据支持 Database 存储
  2. Item 增加 Model 属性返回。因为购物车可能是SPU或者SKU,因此直接通过 model 属性直接返回相关对象。
  3. 支持多 Guard. 因为在果酱小店中有商城购物车和导购购物车。

已经完成了 Session 和 Database 模式下的单元测试,而且正在果酱小店产品线上使用中. 可放心使用.

Installation

composer require ibrand/laravel-shopping-cart:~1.0 -vvv
php artisan vendor:publish --provider="iBrand\Shoppingcart\ServiceProvider"

低于 Laravel5.5 版本

config/app.php 文件中 'providers' 添加

iBrand\Shoppingcart\ServiceProvider::class

config/app.php 文件中 'aliases' 添加

'Cart'=> iBrand\Shoppingcart\Facade::class

Usage

Select Storage

You can change data Storage in config/ibrand/cart.php file.

'storage' => \iBrand\Shoppingcart\Storage\DatabaseStorage::class,
  
'storage' => \iBrand\Shoppingcart\Storage\SessionStorage::class,

If you use Database Storage, you need to execute php artisan migrate

Add item to cart

Add a new item.

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

example:

$row = Cart::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 Cart::update(string $rawId, int $quantity);
Item Cart::update(string $rawId, array $arrtibutes);

example:

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

Get all items

Get all the items.

Collection Cart::all();

example:

$items = Cart::all();

Get item

Get the specified item.

Item Cart::get(string $rawId);

example:

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

Remove item

Remove the specified item by raw ID.

boolean Cart::remove(string $rawId);

example:

Cart::remove('8a48aa7c8e5202841ddaf767bb4d10da');

Destroy cart

Clean Shopping Cart.

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

example:

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

Total price

Returns the total of all items.

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

example:

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

Count rows

Return the number of rows.

int Cart::countRows();

example:

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

Count quantity

Returns the quantity of all items

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

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

example:

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

Search items

Search items by property.

Collection Cart::search(array $conditions);

example:

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

Check empty

bool Cart::isEmpty();

Specifies the associated model

Specifies the associated model of item.

Cart Cart::associate(string $modelName);

example:

Cart::associate('App\Models\Product');
$item = Cart::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
cart.adding ($attributes, $cart);
cart.added ($attributes, $cart);
cart.updating ($row, $cart);
cart.updated ($row, $cart);
cart.removing ($row, $cart);
cart.removed ($row, $cart);
cart.destroying ($cart);
cart.destroyed ($cart);

You can easily handle these events, for example:

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

果酱云社区

点击跳转

  • 全网真正免费的IT课程平台

  • 专注于综合IT技术的在线课程,致力于打造优质、高效的IT在线教育平台

  • 课程方向包含Python、Java、前端、大数据、数据分析、人工智能等热门IT课程

  • 300+免费课程任你选择

点击跳转

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].