UNPKG

decentralized-internet

Version:

An NPM library of programs to create decentralized web and distributed computing projects

3,522 lines (970 loc) 42.9 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>EcomCart - Documentation</title> <script src="scripts/prettify/prettify.js"></script> <script src="scripts/prettify/lang-css.js"></script> <!--[if lt IE 9]> <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <link type="text/css" rel="stylesheet" href="styles/prettify.css"> <link type="text/css" rel="stylesheet" href="styles/jsdoc.css"> <script src="scripts/nav.js" defer></script> <meta name="viewport" content="width=device-width, initial-scale=1.0"> </head> <body> <input type="checkbox" id="nav-trigger" class="nav-trigger" /> <label for="nav-trigger" class="navicon-button x"> <div class="navicon"></div> </label> <label for="nav-trigger" class="overlay"></label> <nav > <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="EcomCart.html">EcomCart</a><ul class='methods'><li data-type='method'><a href="EcomCart.html#addItem">addItem</a></li><li data-type='method'><a href="EcomCart.html#addProduct">addProduct</a></li><li data-type='method'><a href="EcomCart.html#clear">clear</a></li><li data-type='method'><a href="EcomCart.html#increaseItemQnt">increaseItemQnt</a></li><li data-type='method'><a href="EcomCart.html#removeItem">removeItem</a></li><li data-type='method'><a href="EcomCart.html#reset">reset</a></li><li data-type='method'><a href="EcomCart.html#save">save</a></li></ul></li></ul><h3>Modules</h3><ul><li><a href="module-@ecomplus_shopping-cart.html">@ecomplus/shopping-cart</a></li></ul><h3>Events</h3><ul><li><a href="EcomCart.html#event:addItem">addItem</a></li><li><a href="EcomCart.html#event:change">change</a></li><li><a href="EcomCart.html#event:clear">clear</a></li><li><a href="EcomCart.html#event:increaseItemQnt">increaseItemQnt</a></li><li><a href="EcomCart.html#event:removeItem">removeItem</a></li><li><a href="EcomCart.html#event:reset">reset</a></li><li><a href="EcomCart.html#event:save">save</a></li></ul><h3>Global</h3><ul><li><a href="global.html#ecomCart">ecomCart</a></li></ul> </nav> <div id="main"> <h1 class="page-title">EcomCart</h1> <section> <header> <h2> EcomCart </h2> </header> <article> <div class="container-overview"> <h4 class="name" id="EcomCart"><span class="type-signature"></span>new EcomCart<span class="signature">(storeId<span class="signature-attributes">opt</span>, storageKey<span class="signature-attributes">opt</span>, localStorage<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="constructor.js.html">constructor.js</a>, <a href="constructor.js.html#line35">line 35</a> </li></ul></dd> </dl> <div class="description"> Construct a new shopping cart instance object. </div> <h5>Examples</h5> <pre class="prettyprint"><code>// Default instance const ecomCart = new EcomCart()</code></pre> <pre class="prettyprint"><code>// Defining Store ID other than the configured on `$ecomConfig` const storeId = 2000 const customEcomCart = new EcomCart(storeId)</code></pre> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Attributes</th> <th>Default</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>storeId</code></td> <td class="type"> <span class="param-type">number</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> <code>$ecomConfig.get('store_id')</code> </td> <td class="description last">Preset Store ID number</td> </tr> <tr> <td class="name"><code>storageKey</code></td> <td class="type"> <span class="param-type">string</span> | <span class="param-type">null</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> <code>ecomShoppingCart</code> </td> <td class="description last">Item key to persist cart data</td> </tr> <tr> <td class="name"><code>localStorage</code></td> <td class="type"> <span class="param-type">object</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> <code>window.localStorage</code> </td> <td class="description last"><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage">Local Storage interface</a></td> </tr> </tbody> </table> </div> <h3 class="subsection-title">Members</h3> <h4 class="name" id=".ecomCart.Constructor"><span class="type-signature">(static) </span>ecomCart.Constructor<span class="type-signature"> :function</span></h4> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="constructor.js.html">constructor.js</a>, <a href="constructor.js.html#line44">line 44</a> </li></ul></dd> <dt class="tag-see">See:</dt> <dd class="tag-see"> <ul> <li><a href="EcomCart.html">EcomCart</a></li> </ul> </dd> </dl> <div class="description"> Construct a new shopping cart instance object. </div> <h5>Type:</h5> <ul> <li> <span class="param-type">function</span> </li> </ul> <h4 class="name" id=".ecomCart.data"><span class="type-signature">(static) </span>ecomCart.data<span class="type-signature"> :object</span></h4> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="constructor.js.html">constructor.js</a>, <a href="constructor.js.html#line77">line 77</a> </li></ul></dd> </dl> <h5 class="subsection-title">Properties:</h5> <table class="props"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>_id</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="description last">Cart object ID</td> </tr> <tr> <td class="name"><code>items</code></td> <td class="type"> <span class="param-type">array.&lt;object></span> </td> <td class="description last">List of cart items</td> </tr> <tr> <td class="name"><code>subtotal</code></td> <td class="type"> <span class="param-type">number</span> </td> <td class="description last">Cart subtotal value</td> </tr> </tbody> </table> <div class="description"> Shopping cart data following <a href="https://developers.e-com.plus/docs/api/#/store/carts/carts">E-Com Plus cart object model</a>. </div> <h5>Type:</h5> <ul> <li> <span class="param-type">object</span> </li> </ul> <h4 class="name" id=".ecomCart.localStorage"><span class="type-signature">(static) </span>ecomCart.localStorage<span class="type-signature"> :object</span></h4> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="constructor.js.html">constructor.js</a>, <a href="constructor.js.html#line66">line 66</a> </li></ul></dd> </dl> <div class="description"> <a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage">Storage interface</a>. </div> <h5>Type:</h5> <ul> <li> <span class="param-type">object</span> </li> </ul> <h4 class="name" id=".ecomCart.storageKey"><span class="type-signature">(static) </span>ecomCart.storageKey<span class="type-signature"> :string|null</span></h4> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="constructor.js.html">constructor.js</a>, <a href="constructor.js.html#line59">line 59</a> </li></ul></dd> </dl> <div class="description"> Item key to handle persistent JSON EcomCart#data with localStorage. </div> <h5>Type:</h5> <ul> <li> <span class="param-type">string</span> | <span class="param-type">null</span> </li> </ul> <h4 class="name" id=".ecomCart.storeId"><span class="type-signature">(static) </span>ecomCart.storeId<span class="type-signature"> :number</span></h4> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="constructor.js.html">constructor.js</a>, <a href="constructor.js.html#line51">line 51</a> </li></ul></dd> </dl> <div class="description"> Respective Store ID number. </div> <h5>Type:</h5> <ul> <li> <span class="param-type">number</span> </li> </ul> <h3 class="subsection-title">Methods</h3> <h4 class="name" id="addItem"><span class="type-signature"></span>addItem<span class="signature">(newItem, canSave<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {object|null}</span></h4> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="methods_add-item.js.html">methods/add-item.js</a>, <a href="methods_add-item.js.html#line5">line 5</a> </li></ul></dd> </dl> <div class="description"> Push new item to cart data and save. </div> <h5>Example</h5> <pre class="prettyprint"><code>ecomCart.addItem({ _id: '12300000000000000000000f', product_id: '123a5432109876543210cdef', sku: 's-MP_2B4', name: 'Mens Pique Polo Shirt', quantity: 4, price: 42.9, keep_item_price: false })</code></pre> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Attributes</th> <th>Default</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>newItem</code></td> <td class="type"> <span class="param-type">object</span> </td> <td class="attributes"> </td> <td class="default"> </td> <td class="description last">New cart item object valid for <a href="https://developers.e-com.plus/docs/api/#/store/carts/carts">E-Com Plus `cart.items`</a></td> </tr> <tr> <td class="name"><code>canSave</code></td> <td class="type"> <span class="param-type">boolean</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> <code>true</code> </td> <td class="description last">Save cart data</td> </tr> </tbody> </table> <h5>Returns:</h5> <div class="param-desc"> Returns the saved item object (with `_id`) or null when new item object is invalid. </div> <dl class="param-type"> <dt> Type </dt> <dd> <span class="param-type">object</span> | <span class="param-type">null</span> </dd> </dl> <h4 class="name" id="addProduct"><span class="type-signature"></span>addProduct<span class="signature">(product, variationId<span class="signature-attributes">opt</span>, quantity<span class="signature-attributes">opt</span>, canSave<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {object|null}</span></h4> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="methods_add-product.js.html">methods/add-product.js</a>, <a href="methods_add-product.js.html#line3">line 3</a> </li></ul></dd> </dl> <div class="description"> Parse product object to item, push to cart and save. </div> <h5>Example</h5> <pre class="prettyprint"><code>ecomCart.addProduct({ _id: '123a5432109876543210cdef', sku: 's-MP_2B4', commodity_type: 'physical', name: 'Mens Pique Polo Shirt', slug: 'mens-pique-polo-shirt', available: true, visible: true, price: 42.9, price_effective_date: { end: '2018-12-01T10:00:00.612Z' }, base_price: 60, currency_id: 'BRL', currency_symbol: 'R$', quantity: 100 })</code></pre> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Attributes</th> <th>Default</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>product</code></td> <td class="type"> <span class="param-type">object</span> </td> <td class="attributes"> </td> <td class="default"> </td> <td class="description last"><a href="https://developers.e-com.plus/docs/api/#/store/products/products">Product object</a></td> </tr> <tr> <td class="name"><code>variationId</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> </td> <td class="description last">ID of selected variation if any</td> </tr> <tr> <td class="name"><code>quantity</code></td> <td class="type"> <span class="param-type">number</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> <code>1</code> </td> <td class="description last">Item quantity added</td> </tr> <tr> <td class="name"><code>canSave</code></td> <td class="type"> <span class="param-type">boolean</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> <code>true</code> </td> <td class="description last">Save cart data</td> </tr> </tbody> </table> <h5>Returns:</h5> <div class="param-desc"> Returns the saved item object (with `_id`) or null when new item object is invalid. </div> <dl class="param-type"> <dt> Type </dt> <dd> <span class="param-type">object</span> | <span class="param-type">null</span> </dd> </dl> <h4 class="name" id="clear"><span class="type-signature"></span>clear<span class="signature">(canSave<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {self}</span></h4> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="methods_clear.js.html">methods/clear.js</a>, <a href="methods_clear.js.html#line1">line 1</a> </li></ul></dd> </dl> <div class="description"> Remove all items from cart and save. </div> <h5>Example</h5> <pre class="prettyprint"><code>ecomCart.clear()</code></pre> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Attributes</th> <th>Default</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>canSave</code></td> <td class="type"> <span class="param-type">boolean</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> <code>true</code> </td> <td class="description last">Save empty cart to local storage</td> </tr> </tbody> </table> <h5>Returns:</h5> <dl class="param-type"> <dt> Type </dt> <dd> <span class="param-type">self</span> </dd> </dl> <h4 class="name" id="increaseItemQnt"><span class="type-signature"></span>increaseItemQnt<span class="signature">(itemId, quantity<span class="signature-attributes">opt</span>, canSave<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {object|null}</span></h4> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="methods_increase-item-qnt.js.html">methods/increase-item-qnt.js</a>, <a href="methods_increase-item-qnt.js.html#line29">line 29</a> </li></ul></dd> </dl> <div class="description"> Increase quantity of specific item by ID and save cart. </div> <h5>Example</h5> <pre class="prettyprint"><code>ecomCart.increaseItemQnt('12300000000000000000000f', 3)</code></pre> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Attributes</th> <th>Default</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>itemId</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="attributes"> </td> <td class="default"> </td> <td class="description last">The unique object ID of item</td> </tr> <tr> <td class="name"><code>quantity</code></td> <td class="type"> <span class="param-type">integer</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> <code>1</code> </td> <td class="description last">Quantity to increase (can be negative)</td> </tr> <tr> <td class="name"><code>canSave</code></td> <td class="type"> <span class="param-type">boolean</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> <code>true</code> </td> <td class="description last">Save cart data</td> </tr> </tbody> </table> <h5>Returns:</h5> <div class="param-desc"> Returns the updated item object or null when item not found. </div> <dl class="param-type"> <dt> Type </dt> <dd> <span class="param-type">object</span> | <span class="param-type">null</span> </dd> </dl> <h4 class="name" id="removeItem"><span class="type-signature"></span>removeItem<span class="signature">(itemId, canSave<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {object|null}</span></h4> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="methods_remove-item.js.html">methods/remove-item.js</a>, <a href="methods_remove-item.js.html#line3">line 3</a> </li></ul></dd> </dl> <div class="description"> Remove specific item from cart by ID. </div> <h5>Example</h5> <pre class="prettyprint"><code>ecomCart.removeItem('12300000000000000000000f')</code></pre> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Attributes</th> <th>Default</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>itemId</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="attributes"> </td> <td class="default"> </td> <td class="description last">The unique object ID of item</td> </tr> <tr> <td class="name"><code>canSave</code></td> <td class="type"> <span class="param-type">boolean</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> <code>true</code> </td> <td class="description last">Save cart data</td> </tr> </tbody> </table> <h5>Returns:</h5> <div class="param-desc"> Returns the removed item object or null when item not found. </div> <dl class="param-type"> <dt> Type </dt> <dd> <span class="param-type">object</span> | <span class="param-type">null</span> </dd> </dl> <h4 class="name" id="reset"><span class="type-signature"></span>reset<span class="signature">(canSave<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {self}</span></h4> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="methods_reset.js.html">methods/reset.js</a>, <a href="methods_reset.js.html#line3">line 3</a> </li></ul></dd> </dl> <div class="description"> Reset all cart data and create new random ID. </div> <h5>Example</h5> <pre class="prettyprint"><code>ecomCart.reset()</code></pre> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Attributes</th> <th>Default</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>canSave</code></td> <td class="type"> <span class="param-type">boolean</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> <code>true</code> </td> <td class="description last">Save new cart to local storage</td> </tr> </tbody> </table> <h5>Returns:</h5> <dl class="param-type"> <dt> Type </dt> <dd> <span class="param-type">self</span> </dd> </dl> <h4 class="name" id="save"><span class="type-signature"></span>save<span class="signature">(canFixSubtotal<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {self}</span></h4> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="methods_save.js.html">methods/save.js</a>, <a href="methods_save.js.html#line3">line 3</a> </li></ul></dd> </dl> <div class="description"> Save cart object to local storage. </div> <h5>Example</h5> <pre class="prettyprint"><code>ecomCart.save()</code></pre> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Attributes</th> <th>Default</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>canFixSubtotal</code></td> <td class="type"> <span class="param-type">boolean</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> <code>true</code> </td> <td class="description last">Fix cart subtotal before saving</td> </tr> </tbody> </table> <h5>Returns:</h5> <dl class="param-type"> <dt> Type </dt> <dd> <span class="param-type">self</span> </dd> </dl> <h3 class="subsection-title">Events</h3> <h4 class="name" id="event:addItem">addItem</h4> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="methods_add-item.js.html">methods/add-item.js</a>, <a href="methods_add-item.js.html#line64">line 64</a> </li></ul></dd> </dl> <h5 class="subsection-title">Properties:</h5> <table class="props"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>data</code></td> <td class="type"> <span class="param-type">object</span> </td> <td class="description last">Shopping cart data</td> </tr> <tr> <td class="name"><code>item</code></td> <td class="type"> <span class="param-type">object</span> </td> <td class="description last">Item added to cart</td> </tr> </tbody> </table> <h5>Type:</h5> <ul> <li> <span class="param-type">object</span> </li> </ul> <h5>Example</h5> <pre class="prettyprint"><code>ecomCart.on('addItem', ({ data, item }) => { console.log(data, item) })</code></pre> <h4 class="name" id="event:change">change</h4> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="constructor.js.html">constructor.js</a>, <a href="constructor.js.html#line94">line 94</a> </li></ul></dd> </dl> <h5 class="subsection-title">Properties:</h5> <table class="props"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>data</code></td> <td class="type"> <span class="param-type">object</span> </td> <td class="description last">Shopping cart data</td> </tr> </tbody> </table> <h5>Type:</h5> <ul> <li> <span class="param-type">object</span> </li> </ul> <h5>Example</h5> <pre class="prettyprint"><code>ecomCart.on('change', ({ data }) => { console.log(data.items) })</code></pre> <h4 class="name" id="event:clear">clear</h4> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="methods_clear.js.html">methods/clear.js</a>, <a href="methods_clear.js.html#line24">line 24</a> </li></ul></dd> </dl> <h5 class="subsection-title">Properties:</h5> <table class="props"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>data</code></td> <td class="type"> <span class="param-type">object</span> </td> <td class="description last">Shopping cart data</td> </tr> </tbody> </table> <h5>Type:</h5> <ul> <li> <span class="param-type">object</span> </li> </ul> <h5>Example</h5> <pre class="prettyprint"><code>ecomCart.on('clear', ({ data }) => { console.log(data.subtotal === 0) })</code></pre> <h4 class="name" id="event:increaseItemQnt">increaseItemQnt</h4> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="methods_increase-item-qnt.js.html">methods/increase-item-qnt.js</a>, <a href="methods_increase-item-qnt.js.html#line14">line 14</a> </li></ul></dd> </dl> <h5 class="subsection-title">Properties:</h5> <table class="props"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>data</code></td> <td class="type"> <span class="param-type">object</span> </td> <td class="description last">Shopping cart data</td> </tr> <tr> <td class="name"><code>item</code></td> <td class="type"> <span class="param-type">object</span> </td> <td class="description last">Cart item changed</td> </tr> </tbody> </table> <h5>Type:</h5> <ul> <li> <span class="param-type">object</span> </li> </ul> <h5>Example</h5> <pre class="prettyprint"><code>ecomCart.on('increaseItemQnt', ({ data, item }) => { console.log(data, item) })</code></pre> <h4 class="name" id="event:removeItem">removeItem</h4> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="methods_remove-item.js.html">methods/remove-item.js</a>, <a href="methods_remove-item.js.html#line27">line 27</a> </li></ul></dd> </dl> <h5 class="subsection-title">Properties:</h5> <table class="props"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>data</code></td> <td class="type"> <span class="param-type">object</span> </td> <td class="description last">Shopping cart data</td> </tr> <tr> <td class="name"><code>item</code></td> <td class="type"> <span class="param-type">object</span> </td> <td class="description last">Cart item removed</td> </tr> </tbody> </table> <h5>Type:</h5> <ul> <li> <span class="param-type">object</span> </li> </ul> <h5>Example</h5> <pre class="prettyprint"><code>ecomCart.on('removeItem', ({ data, item }) => { console.log(data, item) })</code></pre> <h4 class="name" id="event:reset">reset</h4> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="methods_reset.js.html">methods/reset.js</a>, <a href="methods_reset.js.html#line25">line 25</a> </li></ul></dd> </dl> <h5 class="subsection-title">Properties:</h5> <table class="props"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>data</code></td> <td class="type"> <span class="param-type">object</span> </td> <td class="description last">Shopping cart data</td> </tr> </tbody> </table> <h5>Type:</h5> <ul> <li> <span class="param-type">object</span> </li> </ul> <h5>Example</h5> <pre class="prettyprint"><code>ecomCart.on('reset', ({ data }) => { console.log(data._id) })</code></pre> <h4 class="name" id="event:save">save</h4> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="methods_save.js.html">methods/save.js</a>, <a href="methods_save.js.html#line28">line 28</a> </li></ul></dd> </dl> <h5 class="subsection-title">Properties:</h5> <table class="props"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>data</code></td> <td class="type"> <span class="param-type">object</span> </td> <td class="description last">Shopping cart data</td> </tr> </tbody> </table> <h5>Type:</h5> <ul> <li> <span class="param-type">object</span> </li> </ul> <h5>Example</h5> <pre class="prettyprint"><code>ecomCart.on('save', ({ data }) => { console.log(data.subtotal) })</code></pre> </article> </section> </div> <br class="clear"> <footer> Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.3</a> on Sat Jan 25 2020 19:06:58 GMT-0300 (Brasilia Standard Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme. </footer> <script>prettyPrint();</script> <script src="scripts/polyfill.js"></script> <script src="scripts/linenumber.js"></script> </body> </html>