Download the PHP package yabhq/laravel-cart without Composer
On this page you can find all versions of the php package yabhq/laravel-cart. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download yabhq/laravel-cart
More information about yabhq/laravel-cart
Files in yabhq/laravel-cart
Package laravel-cart
Short Description Simple yet customizable Laravel shopping cart
License MIT
Homepage https://github.com/yabhq/laravel-cart
Informations about the package laravel-cart
Laravel Shopping Cart
A simple yet customizable Laravel shopping cart implementation.
Provides RESTful API endpoints out of the box to help with front-end / SPA integrations.
Table of Contents
Requirements
Installation
Usage
The Checkout Class
Customization
License
Requirements
- PHP 8+
- Laravel 8.x
Installation
The package publishes some migrations, routes (for optional use) and classes for further customizing your store logistics.
Full list of published files:
- database/migrations/2020_12_13_000001_create_carts_table
- database/migrations/2020_12_13_000002_create_cart_items_table
- routes/checkout.php
- config/checkout.php
- app/Logistics/CartLogistics.php
- app/Logistics/ShippingLogistics.php
- app/Logistics/TaxLogistics.php
- app/Logistics/DiscountLogistics.php
Usage
First, simply implement the Purchaseable interface on your product (or other purchaseable) model.
app/Models/Product.php
Next we should implement the Purchaser interface on the model representing the end customer.
app/Models/Customer.php
If you would like to use the built-in cart API endpoints, you can simply include the published checkout.php in your existing routes file.
routes/api.php (optional)
The Checkout Class
The package comes with a Checkout class which allows you to interact with the shopping cart.
Creating or retrieving a checkout instance:
Getting the ID of an existing checkout:
Adding a custom field for a checkout:
Deleting a checkout:
Interacting with the underlying cart model and query builder:
Adding, updating or removing cart items:
Optionally set a purchaser entity (class must implement Purchaser interface):
Getting the shipping, subtotal, taxes and total:
Customization
Not every e-commerce store is the same. This package provides several "logistics" classes which allow you to hook into the core package logic and perform some common customizations. For example, you may specify how the tax, shipping and discount amounts are determined:
app/Logistics/TaxLogistics.php
app/Logistics/ShippingLogistics.php
app/Logistics/DiscountLogistics.php
app/Logistics/CartLogistics.php
License
The MIT License (MIT). Please see License File for more information.