Download the PHP package mike182uk/cart without Composer

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

⚠️ This project is no longer maintained

Cart

Packagist Build Status Scrutinizer Quality Score SensioLabs Insight Code Coverage Total Downloads License

A flexible and modern shopping cart package.

Prerequisites

Installation

Usage

Cart

Create a new cart

To create a new cart instance you must pass an id and a storage implementation to the cart constructor:

The storage implementation must implement Cart\Storage\Store.

The id is used for saving / restoring cart state via the storage implementation.

Add an item to the cart

Use the add method to add an item to the cart. A valid Cart\CartItem must be passed to this method.

If the item already exists in the cart, the quantity of the existing item will be updated to include the quantity of the item being added.

Remove an item from the cart

Remove an item from the cart by passing the item id to the remove method.

Update an item in the cart

To update a property of an item in the cart use the update method. You will need to pass the cart item id, the name of the property to update and the new value. This method will return the item id (in case it has changed due to the update).

If you try and update an item that does not exist in the cart a InvalidArgumentException will be thrown.

Retrieve an item in the cart

Retrieve an item from the cart by its id use the get method. If the item does not exist null is returned.

Retrieve all items in the cart

Retrieve all items in the cart using the all method. This will return an array of all the items in the cart.

Determine if an item exists in the cart

Determine if an item exists in the cart using the has method. Returns true or false.

Clear The Cart

Clear the cart using the clear method.

This will also clear the saved state for this cart in the store.

Save / restore cart state

Save the cart using the save method.

This will save the current cart items and cart id to the store.

Restore the cart using the restore method.

This will add any stored cart items back to the cart and set the cart id. If there is a problem restoring the cart a Cart\CartRestoreException will be thrown. This will only happen if:

Other Cart Methods

totalUniqueItems

Get the total number of unique items in the cart.

totalItems

Get the total number of items in the cart.

total

Get the total price of all the cart items including tax.

You can get the total excluding tax by using the totalExcludingTax method.

tax

Get the total tax of all the cart items.

toArray

Export the cart to an array.

Array will be structured like:

getId

Get the id of the cart.

getStore

Get the cart storage implementation.

Cart Item

Create a new Cart Item

Cart\CartItem implements ArrayAccess so properties can be assigned to the cart item as if accessing an array:

An array of data can also be passed to the cart item constructor to set the cart item properties:

If no quantity is passed to the cart item constructor, the quantity is set to 1 by default.

If no price is passed to the cart item constructor, the price is set to 0.00 by default.

If no tax is passed to the cart item constructor, the tax is set to 0.00 by default.

Cart Item ID

Each cart has a unique ID. This ID is generated using the properties set on the cart item. You can get the cart item ID using the method getId or by accessing the property id.

Changing a property on the cart item will change its ID.

Cart Item Methods

get

Get a piece of data set on the cart item.

This is the same as doing:

set

Set a piece of data on the cart item.

This is the same as doing:

If you are setting the item quantity, the value must be an integer otherwise an InvalidArgumentException is thrown.

If you are setting the item price or tax, the value must be numeric otherwise an InvalidArgumentException is thrown.

getTotalPrice

Get the total price of the cart item including tax ((item price + item tax) * quantity).

You can also get the total price excluding tax (item price * quantity) using the getTotalPriceExcludingTax method.

getSinglePrice

Get the single price of the cart item including tax (item price + item tax)

You can also get the single price excluding tax by using the getSinglePriceExcludingTax method.

getTotalTax

Get the total tax of the cart item (item tax * quantity).

getSingleTax

Get the single tax value of the cart item.

toArray

Export the item to an array.

Array will be structured like:

Cart Storage Implementation

A cart storage implementation must implement Cart\Storage\Store.

This package provides 2 basic storage implementations: Cart\Storage\SessionStore and Cart\Storage\CookieStore.

When the save method of the cart is called, the cart id and serialized cart data is passed to the put method of the storage implementation.

When the restore method of the cart is called, the cart id is passed to the get method of the storage implementation.

When the clear method of the cart is called, the cart id is passed to the flush method of the storage implementation.

An example session storage implementation may look like:


All versions of cart with dependencies

PHP Build Version
Package Version
Requires php Version >=5.6.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 mike182uk/cart contains the following files

Loading the files please wait ....