Download the PHP package bahaaalhagar/shoppingcart without Composer

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

ShoppingCart

Latest Version on Packagist Build Status Coverage Status Quality Score Total Downloads

a Simple ShoppingCart impelementaion for Laravel.

Install

Install the package through Composer.

If you're using Laravel 5.5, this is all there is to do. if you're using Laravel 5.4 or less version then you have the register the package service provider and the package alias in your app. open config/app.php file. Add a new line to the providers array:

And add a new line to the aliases array:

Usage

The ShoppingCart gives you the following methods to use:

Cart::add()

Adding an item to the cart is really simple, you just use the add() method, which accepts a variety of parameters.

In its most basic form you can specify the product Model, quantity ($qty) you'd like to add to the cart. note that the Product model must have a price column.

if you didnt specify the $qty the cart will assume its 1 item.

As an optional third parameter you can pass it options, so you can add multiple items with the same id, but with (for instance) a different size or color for example.

The add() method will return CartItem array of the item you just added to the cart.

Cart::modify()

To modify an item in the cart, you'll first need the uinqueIndex of the item.

the uniqueIndex is the item offset in the cart Model items array.

Next you can use the modify() method to modify it.

If you simply want to modify the quantity, you'll pass the modify method the uinqueIndex and the new quantity:

Cart::reduceOneItem()

to reduce certain Cart item quantity by 1, you'll first need the uinqueIndex of the item.

then

Cart::remove()

To remove an item for the cart, you'll again need the uniqueIndex. This uniqueIndex you simply pass to the remove() method and it will remove the item from the cart.

Cart::getContent()

Of course you also want to get the carts content. This is where you'll use the getContent method. This method will return a Cart model which you can iterate over and show the content to your customers.

Cart::destroy()

If you want to completely remove the content of a cart, you can call the destroy method on the cart. This will remove the cart from Session.

Cart::total()

The total() method can be used to get the calculated total of all items in the cart, given there price and quantity.

Cart::count()

If you want to know how many items there are in your cart, you can use the count() method. This method will return the total number of items in the cart. So if you've added 2 books and 1 shirt, it will return 3 items.

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
CartIsEmptyException When trying to modify or reduce a cart item and the cart already empty
InvalidUniqueIndexException When the uniqueIndex that got passed doesn't exists in the cart
InvalidQuantityException When you try to add negative or float quantity.

Events

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

Event Fired Parameter
cartItem.added When an item was added to the cart. The CartItem that was added.
cartItem.modified When an item in the cart was modified or reduced by 1. The CartItem that was modified.
cartItem.removed When an item is removed from the cart. The CartItem that was removed.
cart.destroyed When the content of a cart was destroyed. return the removed Cart Model.

Change log

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CODE_OF_CONDUCT for details.

Security

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

Credits

License

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


All versions of shoppingcart with dependencies

PHP Build Version
Package Version
Requires illuminate/support Version ~5.1
illuminate/console Version ~5
illuminate/filesystem Version ~5
php Version ~5.6|~7.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 bahaaalhagar/shoppingcart contains the following files

Loading the files please wait ....