Skip to content

Simple shopping cart is a class to store items collection and has methods for working with them.

Notifications You must be signed in to change notification settings

maxxdev/simple-shopping-cart

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

Simple Shopping Cart

SimpleShoppingCart.js is a class to store items collection and has methods for working with them. Store is localStorage

How to use

  • Include via script <script src="src/SimpleShoppingCart.js"></script>
  • cart must be init like that: const cart = new SimpleShoppingCart()

The name of localStorage can be changed by passing custom name to constructor like that:

new SimpleShoppingCart('myCustomCart')

By default class is using "simpleShoppingCart" as name

Features

  • getItems() - returns list of items including calculated price, total cost

  • getById(id) - returns object by item id

  • addItem(item) - add 1 item to cart

  • putItem(item, qty) - add quantity items to cart

  • isItemInCart(item) - returns true if item is in cart

  • removeItem(id) - removes item from cart by item id

  • totalCost() - returns total cost of cart

  • totalQty() - returns total quantity of cart

  • clear() - clears cart

Example

/examles folder contains example how to use SimpleShoppingCart with JQuery

About

Simple shopping cart is a class to store items collection and has methods for working with them.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published