Web Component: j-ShoppingCart
j-ShoppingCart
- jComponent
v19|v20
- singleton
- supports discount
- data are stored in localStorage
Configuration:
discount
{Number}
a discount in percentage (optional, default:0
)expiration
{String}
data expiration (default:6 days
)
Output:
{
items: [
{
name: String,
price: Number,
total: Number,
count: Number,
date: Date
}
],
price: Number,
total: Number,
count: Number
}
Methods
instance.add(id, price, count, [name])
adds new product or increase count if the product existsinstance.upd(id, [count], [price], [name])
updates product's datainstance.buy(id, price, count, [name])
creates/updates productinstance.rem(id)
removes productinstance.has(id)
checks productinstance.read(id)
reads productinstance.clear()
clears all productsinstance.clean()
removes all products with zero countinstance.sync(function(array_id_products, meta) {})
create data for synchronization with the server
Global Events
ON('shoppingcart.add', function(item) {})
ON('shoppingcart.upd', function(item) {})
ON('shoppingcart.rem', function(id) {})
ON('shoppingcart.sum', function(data) {})
ON('shoppingcart.clear', function() {})
Author
- Peter Širka petersirka@gmail.com
- License
Created
30. august 2017
Updated
04. september 2024
jComponent library
19 | 20
Version
v1
License
https://www.totaljs.com/license/
Responsive
Yes
Author
Peter Širka
Email
petersirka@gmail.com