All Projects → melihovv → Laravel Shopping Cart

melihovv / Laravel Shopping Cart

Licence: mit
Laravel shopping cart package

Projects that are alternatives of or similar to Laravel Shopping Cart

Ecommerce Laravel Bootstrap
Responsive, Multi-Vendor, MultiLanguage Online Store Platform (shopping cart solution)
Stars: ✭ 99 (+43.48%)
Mutual labels:  shopping-cart, laravel
Laravel Ecommerce
AvoRed an Open Source Laravel Shopping Cart
Stars: ✭ 1,151 (+1568.12%)
Mutual labels:  shopping-cart, laravel
Laracom
Laravel FREE E-Commerce Software
Stars: ✭ 1,570 (+2175.36%)
Mutual labels:  shopping-cart, laravel
Grosir Obat
Sebuah sistem kasir dan manajemen produk obat untuk penjualan Grosir
Stars: ✭ 147 (+113.04%)
Mutual labels:  shopping-cart, laravel
Aimeos Laravel
Laravel ecommerce package for professional, ultra fast online shops, complex B2B applications and #gigacommerce
Stars: ✭ 5,204 (+7442.03%)
Mutual labels:  laravel, shopping-cart
Laravel Ecommerce Iyzico
Iyzico intigrated e-Commerce system that could be developed easily in simple level.
Stars: ✭ 81 (+17.39%)
Mutual labels:  shopping-cart, laravel
Microweber
Drag and Drop Website Builder and CMS with E-commerce
Stars: ✭ 2,226 (+3126.09%)
Mutual labels:  shopping-cart, laravel
Aimeos
Integrated online shop based on Laravel 8 and the Aimeos e-commerce framework
Stars: ✭ 2,354 (+3311.59%)
Mutual labels:  laravel, shopping-cart
Laravel Shopping Cart
🛒 Shopping cart for Laravel Application.
Stars: ✭ 369 (+434.78%)
Mutual labels:  shopping-cart, laravel
S Cart
This project has been replaced by https://github.com/s-cart/s-cart
Stars: ✭ 258 (+273.91%)
Mutual labels:  shopping-cart, laravel
Laravel Shopr
A developer-friendly e-commerce foundation for your Laravel app
Stars: ✭ 196 (+184.06%)
Mutual labels:  shopping-cart, laravel
Laravelshoppingcart
Shopping Cart Implementation for Laravel Framework
Stars: ✭ 853 (+1136.23%)
Mutual labels:  shopping-cart, laravel
Ecommerce Open Api
果酱小店:基于 Laravel + swoole + 小程序的开源电商系统,优雅与性能兼顾 : )
Stars: ✭ 546 (+691.3%)
Mutual labels:  shopping-cart, laravel
Shopping Cart
An easy-to-use shopping cart for Laravel
Stars: ✭ 57 (-17.39%)
Mutual labels:  shopping-cart, laravel
Backup
MySQL Database backup package for Laravel
Stars: ✭ 66 (-4.35%)
Mutual labels:  laravel
Gupayment
GuPayment é um pacote para o Laravel que fornece uma interface para controlar assinaturas e pagamentos com o iugu.com
Stars: ✭ 67 (-2.9%)
Mutual labels:  laravel
Prequel
Prequel for Laravel. Clear and concise database management.
Stars: ✭ 1,141 (+1553.62%)
Mutual labels:  laravel
Groups
A Laravel 5 user groups package
Stars: ✭ 66 (-4.35%)
Mutual labels:  laravel
Laravel Api Boilerplate Jwt
A Laravel 5.8 API Boilerplate to create a ready-to-use REST API in seconds.
Stars: ✭ 1,155 (+1573.91%)
Mutual labels:  laravel
Dreamfactory
DreamFactory API Management Platform
Stars: ✭ 1,148 (+1563.77%)
Mutual labels:  laravel

Laravel Shopping Cart

GitHub Workflow Status styleci

Packagist Packagist Packagist

Install

Install via composer

composer require melihovv/laravel-shopping-cart

Publish configuration file and migrations

php artisan vendor:publish --provider="Melihovv\ShoppingCart\ServiceProvider"

Run migrations

php artisan migrate

Overview

Usage

Regiser facade in config/app.php

'Cart' => 'Melihovv\ShoppingCart\Facades\ShoppingCart',

or

use Melihovv\ShoppingCart\Facades\ShoppingCart as Cart;

in the below examples.

The shopping cart gives you the following methods to use:

Cart::add()

Add an item to the shopping cart.

$cartItem = Cart::add($id, $name, $price, $quantity);
$cartItem = Cart::add($id, $name, $price, $quantity, [
    'color' => 'white',
]);

Cart::remove()

Remove the item with the specified unique id from the shopping cart. Unique id is used to store items with the same $id, but different $options.

$cartItem = Cart::add($id, $name, $price, $quantity);

// ...

Cart::remove($cartItem->getUniqueId())

Cart::has()

Check if the shopping cart contains the item with the specified unique id.

$cartItem = Cart::add($id, $name, $price, $quantity);

// ...

if (Cart::has($cartItem->getUniqueId())) {
    // Do smth.
}

Cart::get()

Get an item in the shopping cart by its unique id.

$cartItem = Cart::add($id, $name, $price, $quantity);

// ...

$cartItem = Cart::get($cartItem->getUniqueId());

Cart::content()

Get all items in the shopping cart.

Cart::clear()

Clear the shopping cart.

Cart::count()

Return number of items in the shopping cart. This method does not summarize quantities of item. For example, there are 3 books and 1 iPhone in the shopping cart, so this method returns 2.

Cart::getTotal()

Return total price of all items in the shopping cart.

Cart::add(1, 'iPhone 7', 500, 1);
Cart::add(1, 'iPad Pro', 700, 2);
Cart::getTotal(); // return 1900

Instances

The package supports multiple instances of the cart. Some examples:

Cart::instance('shopping')->add('192ao12', 'Product 1', 100, 10);

// Store and get the content of the 'shopping' cart
Cart::store->content();

Cart::instance('wishlist')->add('sdjk922', 'Product 2', 50, 1, ['size' => 'medium']);

// Store and get the content of the 'wishlist' cart
Cart::store()->content();

// If you want to get the content of the 'shopping' cart again
Cart::instance('shopping')->restore()->content();

The default cart instance is called default, so when you're not using instances,Cart::content(); is the same as Cart::instance('default')->content().

Cart::instance()

Set current instance name.

Cart::currentInstance()

Get current instance name.

Storage

Currently there are two possible storage to persist shopping cart:

  • Database
  • Redis

You can choose one by specifying repository class name in config

// config/shopping-cart.php

'repository' => \Melihovv\ShoppingCart\Repositories\ShoppingCartDatabaseRepository::class,
// or
'repository' => \Melihovv\ShoppingCart\Repositories\ShoppingCartRedisRepository::class,

In order to use redis storage you also need to install predis/predis package.

Cart::store()

Persist current shopping cart instance to storage.

Cart::store($user->id);
Cart::instance('cart')->store($user->id);
Cart::instance('wishlist')->store($user->id);

Cart::restore()

Restore shopping cart instance to storage.

Cart::restore($user->id);
Cart::instance('cart')->restore($user->id);
Cart::instance('wishlist')->restore($user->id);

Cart::destroy()

Remove shopping cart instance from storage.

Cart::destroy($user->id);
Cart::instance('cart')->destroy($user->id);
Cart::instance('wishlist')->destroy($user->id);

Coupons

You can easily add discount coupons to shopping cart. Currently there are two types of coupons:

  • FixedDiscountCoupon
  • PercentDiscountCoupon

Related methods:

Cart::addCoupon()

Add coupon to cart.

Cart::addCoupon(new FixedDiscountCoupon($name, $discount));
Cart::addCoupon(new PercentDiscountCoupon($name, 0.1)); // 10% discount

Cart::coupons()

Returns all coupons.

Cart::getTotalWithCoupons()

Returns total price with applied coupons.

Cart::add(1, 'iPhone 7', 500, 1);
Cart::add(1, 'iPad Pro', 700, 2);
Cart::addCoupon(new FixedDiscountCoupon($name, 300));
Cart::getTotal(); // return 1900 - 300 = 1600

Security

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

Credits

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