j-ShoppingCart
- Singleton
- Ondersteunt de korting
- De gegevens worden opgeslagen in localStore
Configuratie:
discount {Number}een korting in percentage (optional, standaard:0)- Datascheiding van
expiration {String}(default:6 days)
Uitgang:
{
items: [
{
name: String,
price: Number,
total: Number,
count: Number,
date: Date
}
],
price: Number,
total: Number,
count: Number
}Methoden
instance.add(id, price, count, [name])voegt een nieuw product toe of verhoogt het aantal als het product bestaatinstance.upd(id, [count], [price], [name])productgegevens bijwerkeninstance.buy(id, price, count, [name])creëert/updates productinstance.rem(id)verwijdert het productinstance.has(id)productcontroleinstance.read(id)lees het productinstance.clear()reinigt alle producteninstance.clean()verwijdert alle producten met nul getalinstance.sync(function(array_id_products, meta) {})maakt gegevens voor synchronisatie met de server
Globale evenementen
ON('shoppingcart.add', function(item) {})ON('shoppingcart.upd', function(item) {})ON('shoppingcart.rem', function(id) {})ON('shoppingcart.sum', function(data) {})ON('shoppingcart.clear', function() {})
Gebruik het met <ui-component name="shoppingcart">Wanneer de component nog niet is geladen, jComponent Download het op eerste gebruik van het adres in DEF.fallback (De Componentator Schrijver: Peter Širka. bron: de Componentator Componenten repository, MIT licentie.
<ui-component name="shoppingcart" path="common.shoppingcart"></ui-component>
<script>
var common = {};
</script>