A simple, elegant shopping cart supporting both Stripe and Paypal checkouts. Currently supports USD as a currency.
The only global variable and entry point.
Iterate through each Item passing it to the function argument.
Name | Type | Description |
---|---|---|
fn | Function | The function to run on each Item. |
Gets a saved Item.
Name | Type | Description |
---|---|---|
id | Number | The unique identifier of the Item. |
Gets the amount of saved Items.
Gets the accumulated sum of all Item quantities.
Gets the items that match the rules defined in the passed argument.
Name | Type | Description |
---|---|---|
properties | Object | The rules to match - keys and values map to Item. Values may be preceded by operators: "<=", ">=", "!=", "<", ">". Values can be a RegExp or any other type. |
Gets the cart as an object - keys are Item ids and values are the corresponding Item.
Updates the current cart values in the indexedDB database.
Indicates the cart loading status.
Removes all Items from the cart.
Gets or sets the Stripe API key.
Name | Type | Description |
---|---|---|
key | String (optional) | The API key. |
Gets or sets the Paypal API key.
Name | Type | Description |
---|---|---|
key | String (optional) | The API key. |
Gets or sets the cart currency.
Name | Type | Description |
---|---|---|
currency | String (optional) | The currency code. |
Gets or sets the tax rate percentage.
Name | Type | Description |
---|---|---|
tax | Number (optional, default: 7.75) | The tax rate. |
Gets or sets a flat discount amount.
Name | Type | Description |
---|---|---|
discountflat | Number (optional) | The discount amount. |
Gets the total cart price without tax.
Gets the total cart price with tax.
Creates a new Item.
Name | Type | Description |
---|---|---|
opts | Object (optional) | The properties to assign to the Item. |
Opens an indexedDB database and loads any values to the cart.
Name | Type | Description |
---|---|---|
dbname | String | The name of the database. |
Starts the checkout process.
Name | Type | Description |
---|---|---|
type | String | The checkout method - "stripe" or "paypal". |
opts | Object (optional) | The method specific checkout options. |
Name | Parameters | Description |
---|---|---|
load | Fired after the Stripal database is loaded. | |
item-cart | Item | Fired when an item has been added to the cart. |
item-remove | Item | Fired when an item has been removed from the cart. |
item-update | Item, Key, Value (optional) | Fired when an item is updated always passing the key and, if the attribute was not deleted, the value. |
paypal-checkout-start | Payment Options Object | Fired when a PayPal checkout process has started. |
paypal-checkout-end | Payment Data Object | |
stripe-checkout-start | Fired when a Stripe checkout process starts. | |
stripe-checkout-end | Token, Args | Fired when a Stripe checkout process ends. |
A stripal item.
Name | Type | Description |
---|---|---|
stripal_item | Boolean | Indicator of a stripal item. |
id | Number | The unique identifier. |
Saves the Item to the cart.
Gets or sets the option to emit events.
Name | Type | Description |
---|---|---|
quiet | Boolean (optional) | Determines event emission. |
Gets or sets the item name.
Name | Type | Description |
---|---|---|
name | String (optional) | The item name. |
Gets or sets the currency for the item.
Name | Type | Description |
---|---|---|
currency | String (optional, default: "USD") | The currency code. |
Gets or sets the price of the item.
Name | Type | Description |
---|---|---|
price | Number (optional) | The price of the item. |
Gets or sets the minimum quantity which must be purchased.
Name | Type | Description |
---|---|---|
minimum | Number (optional, default: 1) | The minimum quantity. |
Gets or sets the quantity.
Name | Type | Description |
---|---|---|
quantity | Number (optional, default: 1) | The quantity. |
Gets or sets the step when calling increment() and decrement()
Name | Type | Description |
---|---|---|
step | Number (optional, default: 1) | The quantity to increase and decrease by. |
Gets or sets the additional amount to add to the price of each item considering the quantity.
Name | Type | Description |
---|---|---|
add | Number (optional) | The amount to add. |
Gets or sets a flat, additional amount to add to the price of each item not considering quantity.
Name | Type | Description |
---|---|---|
addflat | Number (optional) | The flat amount to add. |
Gets or sets the additional amount to subtract from the price of each item considering the quantity.
Name | Type | Description |
---|---|---|
discount | Number (optional) | The amount to subtract. |
Gets or sets a flat amount to subtract from the price of each item not considering quantity.
Name | Type | Description |
---|---|---|
discountflat | Number (optional) | The flat amount to subtract. |
Increases the quantity by the passed value or by the step and returns the quantity.
Name | Type | Description |
---|---|---|
inc | Number (optional) | The amount to increase the quantity by. |
Decreases the quantity by the passed value or by the step and returns the quantity.
Name | Type | Description |
---|---|---|
dec | Number (optional) | The amount to decrease the quantity by. |
Gets the total price.
Adds the item to the cart.
Removes the item from the cart.
Sets or updates an attribute on the item.
Name | Type | Description |
---|---|---|
key | String | The attribute name. |
value | Any | The value. |
Gets the value of an attribute on the item.
Name | Type | Description |
---|---|---|
key | String | The attribute name. |
Removes an attribute from the item.
Name | Type | Description |
---|---|---|
key | String | The attribute name. |
Essentially "unwraps" the item and returns its current state as an object.
Name | Type | Description |
---|---|---|
added | Boolean | If true then the returned object will exclude default item properties |
Name | Parameters | Description |
---|---|---|
cart | Item | Fired when the item is added to the cart. |
remove | Item | Fired when the item is removed from the cart. |
update | Item, Key, Value (optional) | Fired when an item is updated always passing the key and, if the attribute was not deleted, the value. |