},
save: function () {
- this.fluidbook.cache.set('cart', this.items);
+ this.fluidbook.cache.set('cart', this.getItems());
this.fluidbook.cart.updateLinks();
},
+
+ getItems: function () {
+ var res = [];
+ $(this.getItems()).each(function (i, ref) {
+ if ($this.data[ref] !== undefined && $this.data[ref] !== null) {
+ res.push(ref);
+ }
+ });
+ return res;
+ },
+
+
getItemsReferences: function () {
- return this.items;
+ return this.getItems();
},
getItemsNumbers: function () {
- return this.items.length;
+ return this.getItems().length;
},
getAllQuantities: function () {
return this.getItemsNumbers();
content += '<th></th>';
content += '</tr></thead>';
content += '<tbody>';
- $.each(this.items, function (i, ref) {
+ $.each(this.getItems(), function (i, ref) {
var item = $this.data[ref];
if (item === undefined) {
return;
var subject = 'Ma liste de Noël'
var body = 'Ma liste de Noël : ' + "\n\n";
- $.each(this.items, function (i, ref) {
+ $.each(this.getItems(), function (i, ref) {
var item = $this.fluidbook.settings.basketReferences[ref];
if (item === undefined) {
return;
},
addToCart: function (ref, quantity) {
- if (this.items.indexOf(ref) === -1) {
+ if (this.items.getItems().indexOf(ref) === -1) {
this.items.push(ref);
this.save();
+ return true;
+ } else {
+ this.removeFromCart(ref);
+ return false;
}
- return true;
},
removeFromCart: function (key) {
},
save: function () {
- this.fluidbook.cache.set('cart', this.items);
+ this.fluidbook.cache.set('cart', this.getItems());
this.fluidbook.cart.updateLinks();
},
getItemsReferences: function () {
- return this.items;
+ return this.getItems();
},
getItemsNumbers: function () {
- return this.items.length;
+ return this.getItems().length;
},
getAllQuantities: function () {
return this.getItemsNumbers();
return ['Catalogue', 'Catégorie', 'Ligne', 'Sexe', 'Modèle', 'Couleur', 'Désignation', 'Tarif', 'PVC', 'Image', 'PACK'];
},
+ getItems: function () {
+ var res = [];
+ $(this.getItems()).each(function (i, ref) {
+ if ($this.data[ref] !== undefined && $this.data[ref] !== null) {
+ res.push(ref);
+ }
+ });
+ return res;
+ },
+
getCartContent: function () {
if (this.getItemsNumbers() == 0) {
return '<div class="cart-empty">' + this.fluidbook.l10n.__('your cart is empty') + '</div>';
content += '<th></th>';
content += '</tr></thead>';
content += '<tbody>';
- $.each(this.items, function (i, ref) {
+ $.each(this.getItems(), function (i, ref) {
content += '<tr>';
$.each(columns, function (k, v) {
var value = $this.data[ref][v];
});
sheet.columns = columns;
- $.each(this.items, function (i, ref) {
+ $.each(this.getItems(), function (i, ref) {
var row = {};
$.each(columnsLabels, function (k, v) {
if (v === 'Image') {