https://github.com/apsdehal/jcart
Plugin for shopping cart simplification
https://github.com/apsdehal/jcart
Last synced: 8 months ago
JSON representation
Plugin for shopping cart simplification
- Host: GitHub
- URL: https://github.com/apsdehal/jcart
- Owner: apsdehal
- License: mit
- Created: 2014-01-29T13:39:02.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2014-02-27T20:47:44.000Z (over 12 years ago)
- Last Synced: 2025-10-14T19:03:30.984Z (8 months ago)
- Language: JavaScript
- Homepage:
- Size: 227 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
#Shopping Cart jQuery Plugin
Shopping Cart simplified
###About
Shopping Cart plugin has been created with essence to simplify the process of making shopping carts for the websites that need a proper interface for customers. With number of functions available, it all works as a breeze.
Code is heavily commented for easy understanding.
###Usage
Include the plugin as follows:-
```html
```
All the methods for the cart are available through `$.cart` variable.
There is an orderid defined for each item along with its quantity.
Functions available are as documentated below:
```javascript
$.cart.set( orderId, count );
//To set an order with quantity = count in the cart.
//Important: If item is already present this count will be added to current quantity
$.cart.get();
//Get an object containing orders with attributes id and count
$.cart.getJSON();
//Get a JSON string of the orders.
$.cart.total();
//Get total number of types of items in cart.
$.cart.totalQty();
//Get total nuber of items in cart.
/* For example:- If you have bought 2 Lays' and 1 Uncle Chipps
$.cart.total() will be 2 and $.cart.totalQty() will be 3
*/
$.cart.remove( orderId, count );
//To remove a certain amount of count from item with id = orderId.
$.cart.removeItem ( orderId );
//To remove whole quantity of a particular item.
$.cart.clear();
//To clear the whole cart
$.cart.change( orderId, count );
//To change the quantity of the orderId to count.
$.cart.removeCookie();
//To remove the cookie in which all the data of cart is stored.
```
By default orders are stored in cookie named 'orders'.
You can override it by setting $.cookie.defaults.
$.cookie object is also available to play with cookies all over.
###License
MIT License
Copyright (c) 2014 Amanpreet Singh