# com.beasys.commerce.ebusiness.shoppingcart
ShoppingCart Interface

public interface ShoppingCart
extends `Belonging`

The ShoppingCart is used to contain a list of `ShoppingCartLines`. Each `ShoppingCartLine` contains a unique item. If the customer adds a `ProductItem` that is already in the shopping cart, the quantity of the existing `ShoppingCartLine` is increased.

Related Topics

``ShoppingCartHome``
``ShoppingCartLine``

All Known Implementing Classes
  `ShoppingCartImpl`

All Superinterfaces
  `Belonging`, `BusinessSmartComponent`, `Cloneable`, `Comparable`, `Serializable`

## Method Summary

`public void` | `addItemsFromShoppingCart`(`ShoppingCart` items) Add the ShoppingCartLines from the specified ShoppingCart to this ShoppingCart.
`public `ShoppingCartLine`` | `addProductItem`(`ProductItem` item, double quantity) Add an Item to the ShoppingCart.
`public `ShoppingCartLine`` | `addProductItem`(`ProductItem` item, double quantity, `Money` unitMoney) Add an Item to the ShoppingCart.
`public boolean` | `addShoppingCartLine`(`ShoppingCartLine` element) Ensures that this collection contains the specified element (optional operation).
`public boolean` | `addShoppingCartLineCollection`(`Collection` collection) Adds all of the elements in the specified collection to this collection (optional operation).
`public void` | `clearShoppingCartLineCollection`() Removes all of the elements from this collection (optional operation).
`public boolean` | `containsShoppingCartLine`(`ShoppingCartLine` element) Returns true if this collection contains the specified element.
`public boolean` | `containsShoppingCartLineCollection`(`Collection` c) Returns true if this collection contains all of the elements in the specified collection.
`public `ShoppingCartLine`` | `createShoppingCartLine`() Used internally by the ShoppingCart to create ShoppingCartLines.
`public boolean` | `equalsShoppingCartLineCollection`(`Object` object) Compares the specified object with this collection for equality.
`public `ShoppingCartLine`` | `findShoppingCartLine`(`String` productIdentifier) Find the ShoppingCartLine associated with the specified Item.
`public double` | `getCategoryQuantity`(`String` categoryId) Count the number of products that belong to a category.
`public double` | `getNumberOfUnits`() Count the total quantity of items by summing the quantity on each line.
`public `ArrayList`` | `getOrderDiscountPresentations`() Gets the order level discount list
`public `Money`` | `getShipping`() Get the value of shipping
`public `ArrayList`` | `getShippingDiscountPresentations`() Accessor method for the presentation of the discounts applied to the shipping, used by JSP pages for instance
`public `Collection`` | `getShoppingCartLineCollection`() Returns the entire collection
`public `Money`` | `getSubtotal`() Get the value of Subtotal
`public `Money`` | `getTotal`() Get the value of total
`public `Money`` | `getTotal`(int totalType) Gets the shopping cart total for the given total type.
`public `Money`` | `getTotalPrice`() Gets the overal shopping cart total
`public boolean` | `isEmpty`() Returns true if the shopping cart has no items
`public boolean` | `isShoppingCartLineCollectionEmpty`() Returns true if this collection contains no elements.
`public void` | `removeAllProductItems`() Removes all ShoppingCartLines.
`public `ProductItem`` | `removeProductItem`(`String` productIdentifier) Remove the ShoppingCartLine associated with the Item specified.
`public boolean` | `removeShoppingCartLine`(`ShoppingCartLine` element) Removes a single instance of the specified element from this collection, if it is present (optional operation).
`public boolean` | `removeShoppingCartLineCollection`(`Collection` collection) Removes all this collection's elements that are also contained in the specified collection (optional operation).
`public boolean` | `retainShoppingCartLineCollection`(`Collection` collection) Retains only the elements in this collection that are contained in the specified collection (optional operation).
`public void` | `setOrderDiscountPresentations`(`ArrayList` discountPresentations) sets the order level discount list
`public void` | `setProductItemQuantity`(`ProductItem` item, double quantity) Sets the Quantity of the ShoppingCartLine associated with this Item.
`public void` | `setShipping`(`Money` shipping) Set the value of shipping
`public void` | `setShippingDiscountPresentations`(`ArrayList` discountPresentations) sets Order Discount Description
`public void` | `setShoppingCartLineCollection`(`Collection` collection) Sets the entire collection
`public void` | `setSubtotal`(`Money` subtotal) Set the value of subtotal
`public void` | `setTotal`(`Money` total) Set the value of total
`public int` | `shoppingCartLineCollectionHashCode`() Returns the hash code value for this collection.
`public `Iterator`` | `shoppingCartLineCollectionIterator`() Returns an iterator over the elements in this collection.
`public int` | `shoppingCartLineCollectionSize`() Returns the number of elements in this collection.

Methods from interface `com.beasys.commerce.foundation.`Belonging``
``clone`, `equals`, `interfaceName`, `setByValue`, `value``

Methods from interface `java.lang.`Comparable``
`compareTo`

## Method Detail

### addItemsFromShoppingCart(ShoppingCart) Method

    public void addItemsFromShoppingCart(ShoppingCart items)
         throws InvalidArgumentException

Add the ShoppingCartLines from the specified ShoppingCart to this ShoppingCart.

#### Exceptions

``InvalidArgumentException``

### addProductItem(ProductItem, double) Method

    public ShoppingCartLine addProductItem(ProductItem item,
                                           double quantity)
         throws InvalidArgumentException

Add an Item to the ShoppingCart. If the Item is already in the ShoppingCart, increase its quantity.

#### Exceptions

``InvalidArgumentException``

### addProductItem(ProductItem, double, Money) Method

    public ShoppingCartLine addProductItem(ProductItem item,
                                           double quantity,
                                           Money unitMoney)
         throws InvalidArgumentException

Add an Item to the ShoppingCart. If the Item is already in the ShoppingCart, increase its quantity.

#### Exceptions

``InvalidArgumentException``

### addShoppingCartLine(ShoppingCartLine) Method

    public boolean addShoppingCartLine(ShoppingCartLine element)

Ensures that this collection contains the specified element (optional operation).

### addShoppingCartLineCollection(Collection) Method

    public boolean addShoppingCartLineCollection(Collection collection)

Adds all of the elements in the specified collection to this collection (optional operation).

### clearShoppingCartLineCollection() Method

    public void clearShoppingCartLineCollection()

Removes all of the elements from this collection (optional operation).

### containsShoppingCartLine(ShoppingCartLine) Method

    public boolean containsShoppingCartLine(ShoppingCartLine element)

Returns true if this collection contains the specified element.

### containsShoppingCartLineCollection(Collection) Method

    public boolean containsShoppingCartLineCollection(Collection c)

Returns true if this collection contains all of the elements in the specified collection.

### createShoppingCartLine() Method

    public ShoppingCartLine createShoppingCartLine()

Used internally by the ShoppingCart to create ShoppingCartLines. If ShoppingCart is used to manage a list of lines that extend ShoppingCartLine, this method should be overridden to return an instance of the appropiate sub class.

### equalsShoppingCartLineCollection(Object) Method

    public boolean equalsShoppingCartLineCollection(Object object)

Compares the specified object with this collection for equality.

### findShoppingCartLine(String) Method

    public ShoppingCartLine findShoppingCartLine(String productIdentifier)
         throws ItemNotInShoppingCartException, InvalidArgumentException

Find the ShoppingCartLine associated with the specified Item. Throws an ItemNotInShoppingCartException if the Item cannot be found.

#### Parameters

productIdentifier
  (See productItem.getKey( ).getIdentifier( ) )

#### Exceptions

``ItemNotInShoppingCartException``
``InvalidArgumentException``

### getCategoryQuantity(String) Method

    public double getCategoryQuantity(String categoryId)
         throws RemoteException

Count the number of products that belong to a category.

#### Exceptions

``RemoteException``

### getNumberOfUnits() Method

    public double getNumberOfUnits()

Count the total quantity of items by summing the quantity on each line.

### getOrderDiscountPresentations() Method

    public ArrayList getOrderDiscountPresentations()

Gets the order level discount list

### getShipping() Method

    public Money getShipping()

Get the value of shipping

#### Returns

shipping.

### getShippingDiscountPresentations() Method

    public ArrayList getShippingDiscountPresentations()

Accessor method for the presentation of the discounts applied to the shipping, used by JSP pages for instance

### getShoppingCartLineCollection() Method

    public Collection getShoppingCartLineCollection()

Returns the entire collection

### getSubtotal() Method

    public Money getSubtotal()

Get the value of Subtotal

#### Returns

Subtotal.

### getTotal() Method

    public Money getTotal()

Get the value of total

#### Returns

total.

### getTotal(int) Method

    public Money getTotal(int totalType)
         throws InvalidArgumentException

Gets the shopping cart total for the given total type. Valid values are one or more of :

- LINE_UNIT_PRICE_TIMES_QUANTITY
- LINE_SHIPPING
- LINE_TAX
- SHOPPING_CART_SHIPPING

#### Parameters

totalType
  type

#### Exceptions

``InvalidArgumentException``

### getTotalPrice() Method

    public Money getTotalPrice()

Gets the overal shopping cart total

### isEmpty() Method

    public boolean isEmpty()

Returns true if the shopping cart has no items

### isShoppingCartLineCollectionEmpty() Method

    public boolean isShoppingCartLineCollectionEmpty()

Returns true if this collection contains no elements.

### removeAllProductItems() Method

    public void removeAllProductItems()

Removes all ShoppingCartLines. This resets the entire ShoppingCart.

### removeProductItem(String) Method

    public ProductItem removeProductItem(String productIdentifier)
         throws InvalidArgumentException

Remove the ShoppingCartLine associated with the Item specified.

#### Parameters

productIdentifier
  (See productItem.getKey( ).getIdentifier( ) )

#### Exceptions

``InvalidArgumentException``

### removeShoppingCartLine(ShoppingCartLine) Method

    public boolean removeShoppingCartLine(ShoppingCartLine element)

Removes a single instance of the specified element from this collection, if it is present (optional operation).

### removeShoppingCartLineCollection(Collection) Method

    public boolean removeShoppingCartLineCollection(Collection collection)

Removes all this collection's elements that are also contained in the specified collection (optional operation).

### retainShoppingCartLineCollection(Collection) Method

    public boolean retainShoppingCartLineCollection(Collection collection)

Retains only the elements in this collection that are contained in the specified collection (optional operation).

### setOrderDiscountPresentations(ArrayList) Method

    public void setOrderDiscountPresentations(ArrayList discountPresentations)

sets the order level discount list

### setProductItemQuantity(ProductItem, double) Method

    public void setProductItemQuantity(ProductItem item,
                                       double quantity)
         throws InvalidArgumentException

Sets the Quantity of the ShoppingCartLine associated with this Item. A new ShoppingCartLine is created if the Item is not present. This differs from addItem in that this method explicitly sets the absolute Quantity of a ShoppingCartLine rather than incrementing the existing value .

#### Exceptions

``InvalidArgumentException``

### setShipping(Money) Method

    public void setShipping(Money shipping)

Set the value of shipping

#### Parameters

shipping
  shipping to be set

### setShippingDiscountPresentations(ArrayList) Method

    public void setShippingDiscountPresentations(ArrayList discountPresentations)

sets Order Discount Description

### setShoppingCartLineCollection(Collection) Method

    public void setShoppingCartLineCollection(Collection collection)

Sets the entire collection

### setSubtotal(Money) Method

    public void setSubtotal(Money subtotal)

Set the value of subtotal

#### Parameters

subtotal
  subtotal to be set

### setTotal(Money) Method

    public void setTotal(Money total)

Set the value of total

#### Parameters

total
  total to be set

### shoppingCartLineCollectionHashCode() Method

    public int shoppingCartLineCollectionHashCode()

Returns the hash code value for this collection.

### shoppingCartLineCollectionIterator() Method

    public Iterator shoppingCartLineCollectionIterator()

Returns an iterator over the elements in this collection.

### shoppingCartLineCollectionSize() Method

    public int shoppingCartLineCollectionSize()

Returns the number of elements in this collection.