Class: Cart

Cart()

new Cart()

Class managing the shopping cart state using Local Storage.

Source:

Methods

getItems(product, quantityToAddopt)

Adds an item to the cart or increments its quantity.

Parameters:
Name Type Attributes Default Description
product Object

The product object (must have getName, getId, getPrice, etc.).

quantityToAdd number <optional>
1

The number of units to add.

Source:

getTotalItemsCount() → {number}

Calculates the total count of all items in the cart.

Source:
Returns:

The total quantity of items.

Type
number

getTotalPrice() → {number}

Calculates the total price of all items in the cart.

Source:
Returns:

The total price.

Type
number