getItemsNumbers: function () {
return Object.size(this.items);
},
+ getAllQuantities: function () {
+ var res = 0;
+ $.each(this.items, function (ref, quantity) {
+ res += quantity;
+ });
+ return res;
+ },
+ hasItem: function (itemReference) {
+ var res = false;
+ $.each(this.items, function (ref, quantity) {
+ if (ref == itemReference) {
+ res = true;
+ return true;
+ }
+ });
+ return res;
+ },
updateIcon: function () {
- $(this.fluidbook).trigger('fluidbook.cart.updateIcon', {number: this.getItemsNumbers()});
+ $(this.fluidbook).trigger('fluidbook.cart.updateIcon', {number: this.getAllQuantities()});
},
openMenu: function (p1, p2, callback) {
totalttc += ttc;
});
- var fpv = 0;
- var fp = 'OFFERTS';
+ var port = this.getShippingFees(totalht);
- if (totalht <= 99) {
- fpv = 8.3;
- fp = $this.formatPrice(fpv, 'HT');
- }
- var htfp = totalht + fpv;
- var totalttcfp = totalttc + (fpv * 1.2);
+ var htfp = totalht + port.value;
+ var totalttcfp = totalttc + (port.value * 1.2);
var tva = totalttcfp - htfp;
content += '</table>';
content += '<table class="cart-totals">';
content += '<tr><td>Total HT</td><td>' + $this.formatPrice(totalht, 'HT') + '</td></tr>';
- content += '<tr><td>Frais de port</td><td>' + fp + '</td></tr>';
+ if (port.display != 'hidden') {
+ content += '<tr><td>Frais de port</td><td>' + port.display + '</td></tr>';
+ }
content += '<tr><td>TVA</td><td>' + $this.formatPrice(tva) + '</td></tr>';
content += '<tr><td colspan="2" class="hr"></td></tr>';
content += '<tr class="total"><td>Total TTC</td><td>' + $this.formatPrice(totalttcfp, 'TTC') + '</td></tr>';
return content;
},
+ getShippingFees: function (totalht) {
+ var fpv = 0;
+ var fp = 'OFFERTS';
+
+ if (totalht <= 99 && !this.hasItem('COL') && !this.hasItem('CT10')) {
+ fpv = 8.3;
+ fp = this.formatPrice(fpv, 'HT');
+ }
+
+ if (this.hasItem('MAJCOL') && this.getItemsNumbers() == 1) {
+ fpv = 0;
+ fp = 'hidden';
+ }
+ return {value: fpv, display: fp};
+
+ },
+
updateCart: function (getQtyFromField) {
if (getQtyFromField == undefined) {
getQtyFromField = true;
totalht += ht;
});
- var fp = 0;
- var fpv = 'OFFERTS';
- if (totalht < 99) {
- fp = 8.3;
- fpv = this.formatPrice(fp);
- }
- var totalttcfp = this.formatPrice(totalttc + (fp * 1.2));
+ var port = this.getShippingFees(totalht);
+
+
+ var totalttcfp = this.formatPrice(totalttc + (port.value * 1.2));
$.ajax({
url: 'https://workshop.fluidbook.com/services/orderRemarkable',
method: 'post',
data: {
'items': items,
- 'fpv': fpv,
+ 'fpv': port.display,
'totalttc': totalttcfp,
'details': this.fluidbook.cache.get('shipping-details')
},