Download the PHP package treestoneit/shopping-cart without Composer

On this page you can find all versions of the php package treestoneit/shopping-cart. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package shopping-cart

A Database Driven Shopping Cart for Laravel

Latest Version on Packagist Total Downloads Build Status StyleCI Scrutinizer Code Quality

This is a simple shopping cart implementation for Laravel 6/7/8. It automatically serializes your cart to the database and loads the related product models.

Usage

To get started, add the Buyable interface to your model.

Make sure you implement the getBuyableDescription and getBuyablePrice methods with the respective product description and product price.

Now you can add products to the cart.

To retrieve the cart contents:

To retrieve the total:

You can update the quantity of an item in the cart. The first argument is the primary id of the related CartItem.

Or remove the item completely.

Options

To add item-specific options (such as size or color) to an item in the cart, first register available options in your Buyable instance.

Then you just pass an associative array as the third parameter of Cart::add.

Any invalid options will be silently removed from the array.

You can also add or change options of an item currently in the cart by calling Cart::updateOption.

The options array will be available on the CartItem instance as $item->options.

Attaching to Users

You can attach a cart instance to a user, so that their cart from a previous session can be retrieved. Attaching a cart to a user is acheived by calling the attachTo method, passing in an instance of Illuminate\Contracts\Auth\Authenticatable.

Then when the user logs in, you can call the loadUserCart method, again passing the user instance.

Dependency Injection

If you're not a facade person, you can use the container to inject the shopping cart instance by type-hinting the Treestoneit\ShoppingCart\CartManager class, or the Treestoneit\ShoppingCart\CartContract interface.

Tax

The shopping cart can calculate the total tax of the items in the cart. Just call

You can also set a default tax rate in the included config file.

Then just call Cart::tax without a parameter.

If some of your items have different tax rates applicable to them, or are tax-free, no problem. First modify the config file:

Then, set the tax rate per item by implementing the Taxable interface and defining a getTaxRate method.

Now your items will have their custom tax rate applied to them when calling Cart::tax.

Installation

You can install the package via composer:

To publish the config file and migrations, run

And run the included database migrations.

Testing

Starter (demo) Repository

If you would like to see a starter/demo implementation using this shopping cart please check out our laravel-commerce repository

Roadmap

Some things I didn't get around to yet:

Credits

License

The MIT License (MIT). Please see the License File for more information.

Laravel Package Boilerplate

This package was generated using the Laravel Package Boilerplate.


All versions of shopping-cart with dependencies

PHP Build Version
Package Version
Requires php Version ^7.3|^8.0|^8.1
ext-json Version *
illuminate/config Version ^6.0|^7.0|^8.0|^9.0
illuminate/database Version ^6.20.26|^7.30.5|^8.40.0|^9.0
illuminate/support Version ^6.0|^7.0|^8.0|^9.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package treestoneit/shopping-cart contains the following files

Loading the files please wait ....