Download the PHP package kingpabel/shoppingcart without Composer

On this page you can find all versions of the php package kingpabel/shoppingcart. 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 shoppingcart

LaravelShoppingcart

Build Status Total Downloads

A simple shoppingcart implementation for Laravel 4.

Installation

Install the package through Composer. Edit your project's composer.json file by adding:

From Laravel 4.2 to Laravel 5.2

Next, run the Composer update command from the Terminal:

composer update

Now all you have to do is add the service provider of the package and alias the package. To do this open your app/config/app.php file.

Add a new line to the service providers array:

'Kingpabel\Shoppingcart\ShoppingcartServiceProvider'

And finally add a new line to the aliases array:

'Cart'            => 'Kingpabel\Shoppingcart\Facades\Cart',

Now you're ready to start using the shoppingcart in your application.

Overview

Look at one of the following topics to learn more about LaravelShoppingcart

Usage

The shoppingcart gives you the following methods to use:

Cart::add()

Cart::update()

Cart::remove()

Cart::get()

Cart::content()

Cart::destroy()

Cart::total()

Cart::subtotal()

Cart::discount()

Cart::setCustomDiscount(5.00)

Cart::customDiscount()

Cart::count()

Cart::search()

Collections

As you might have seen, the Cart::content() and Cart::get() methods both return a Collection, a CartCollection and a CartRowCollection.

These Collections extends the 'native' Laravel 4 Collection class, so all methods you know from this class can also be used on your shopping cart. With some addition to easily work with your carts content.

Instances

Now the packages also supports multiple instances of the cart. The way this works is like this:

You can set the current instance of the cart with Cart::instance('newInstance'), at that moment, the active instance of the cart is newInstance, so when you add, remove or get the content of the cart, you work with the newInstance instance of the cart. If you want to switch instances, you just call Cart::instance('otherInstance') again, and you're working with the otherInstance again.

So a little example:

N.B. Keep in mind that the cart stays in the last set instance for as long as you don't set a different one during script execution.

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

Models

A new feature is associating a model with the items in the cart. Let's say you have a Product model in your application. With the new associate() method, you can tell the cart that an item in the cart, is associated to the Product model.

That way you can access your model right from the CartRowCollection!

Here is an example:

The key to access the model is the same as the model name you associated (lowercase). The associate() method has a second optional parameter for specifying the model namespace.

Exceptions

The Cart package will throw exceptions if something goes wrong. This way it's easier to debug your code using the Cart package or to handle the error based on the type of exceptions. The Cart packages can throw the following exceptions:

Exception Reason
ShoppingcartInstanceException When no instance is passed to the instance() method
ShoppingcartInvalidItemException When a new product misses one of it's arguments (id, name, qty, price)
ShoppingcartInvalidPriceException When a non-numeric price is passed
ShoppingcartInvalidQtyException When a non-numeric quantity is passed
ShoppingcartInvalidRowIDException When the $rowId that got passed doesn't exists in the current cart
ShoppingcartUnknownModelException When an unknown model is associated to a cart row

Events

The cart also has events build in. There are five events available for you to listen for.

Event Fired
cart.add($item) When a single item is added
cart.batch($items) When a batch of items is added
cart.update($rowId) When an item in the cart is updated
cart.remove($rowId) When an item is removed from the cart
cart.destroy() When the cart is destroyed

Example

Below is a little example of how to list the cart content in a table:


All versions of shoppingcart with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4.0
illuminate/support Version ~5.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 kingpabel/shoppingcart contains the following files

Loading the files please wait ....