Class: ShoppingCart

ShoppingCart()

An Shopping Cart Library Add items and show a summary at checkout

Constructor

new ShoppingCart()

Source:

Methods

AddItem(cartId, itemId, qty, price) → {Promise}

Add an item to a cart
Parameters:
Name Type Description
cartId string
itemId string
qty number quantity
price number price
Source:
Returns:
cart item index Promise will resolve to type number.
Type
Promise

Clear(cartId)

Clear all items from a shopping cart
Parameters:
Name Type Description
cartId string
Source:

CountItems(cartId) → {Promise}

Count the items in a cart
Parameters:
Name Type Description
cartId string
Source:
Returns:
number of items Promise will resolve to type number.
Type
Promise

Create(storeId) → {Promise}

Create a new shopping cart
Parameters:
Name Type Description
storeId string
Source:
Returns:
cartId Promise will resolve to type string.
Type
Promise

GetCartSummary(cartId) → {Promise}

Get a summary for a shopping cart
Parameters:
Name Type Description
cartId string
Source:
Returns:
summary Promise will resolve to type object.
Type
Promise

ListItems(cartId) → {Promise}

Get a list of items in a cart
Parameters:
Name Type Description
cartId string
Source:
Returns:
array of item objects Promise will resolve to type array.
Type
Promise

RemoveItem(cartId, idx)

Remove an item from a cart
Parameters:
Name Type Description
cartId string
idx number item index
Source:

UpdateQty(cartId, idx, qty)

Update cart item quantity
Parameters:
Name Type Description
cartId string
idx number item index
qty number quantity
Source: