The Enstore cart is a javascript object that can hold products, calculate totals and provide checkout. The Enstore cart object is available on every template in the Enstore namespace by accessing enstore.cart. If you want to use the Enstore cart on your own pages you can include the cart yourself. The cart depends on jQuery and some configuration variables, see the example below.
<head> ... <script type="text/javascript" charset="utf-8"> // The store handle to access the api var STORE_HANDLE = "store-handle"; // The store currency var CURRENCY = "USD"; </script> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script> <script src="http://www.enstore.com/static/js/cart.v1.js" type="text/javascript"></script> </head>
| Function | Description |
|---|---|
| enstore.cart.addItem(uuid) | Adds a product by uuid with quantity 1. |
| enstore.cart.updateItem(uuid, quantity) | Update a product by uuid with a given quantity. Setting quantity to zero will remove the product from the cart. |
| enstore.cart.removeItem(uuid) | Removes a product from the cart by uuid. |
| enstore.cart.clear() | Empty the cart. |
| enstore.cart.checkout() | Take the user to the checkout page and start a session with the contents of the cart. |
The currency formatter tries to format all currencies that are wrapped in an element with the currency class. After conversion the class will be set to formattedCurrency.
| Function | Description |
|---|---|
| enstore.formatCurrencies() | Format all currencies on the page based on the store currency |