From 848a170a8e38e0c19906ed6357e8a9480fc45829 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Fri, 13 Apr 2018 16:55:47 +0200 Subject: [PATCH] wip #1927 @2.5 --- .../cart/fluidbook.cart.remarkable.js | 51 ++++++++++++++++--- js/libs/fluidbook/fluidbook.cart.js | 6 +++ js/libs/fluidbook/fluidbook.nav.js | 2 - style/fluidbook.less | 47 +++++++++++++++++ 4 files changed, 97 insertions(+), 9 deletions(-) diff --git a/js/libs/fluidbook/cart/fluidbook.cart.remarkable.js b/js/libs/fluidbook/cart/fluidbook.cart.remarkable.js index 566c5802..46f9ab25 100644 --- a/js/libs/fluidbook/cart/fluidbook.cart.remarkable.js +++ b/js/libs/fluidbook/cart/fluidbook.cart.remarkable.js @@ -85,28 +85,65 @@ FluidbookCartRemarkable.prototype = { }, getCartContent: function () { + if (this.getItemsNumbers() == 0) { + return '
' + this.fluidbook.l10n.__('your cart is empty') + '
'; + } var $this = this; var content = ''; + var totalht = 0; + var totalttc = 0; $.each(this.items, function (ref, quantity) { var item = $this.getItemData(ref); + var ht = item.price * quantity; + var ttc = ht * (1 + item.tax); content += ''; content += ''; content += ''; content += ''; - content += ''; - content += ''; - content += ''; + content += ''; + content += ''; + content += ''; content += ''; + + totalht += ht; + totalttc += ttc; }); + + var fpv = 0; + var fp = 'OFFERTS'; + + if (totalht <= 99) { + fpv = 8.3; + fp = $this.formatPrice(fpv, 'HT'); + } + var htfp = totalht + fpv; + var totalttcfp = totalttc + (fpv * 1.2); + var tva = totalttcfp - htfp; + + content += '
' + item.name + '' + $this.formatPrice(item.price, 'HT') + '' + $this.formatPrice(item.price * quantity, 'HT') + '' + $this.formatPrice((item.price * quantity) * (1 + item.tax), 'TTC') + '' + $this.formatPrice(ht, 'HT') + '' + $this.formatPrice(ttc, 'TTC') + '' + getSpriteIcon('interface-close') + '
'; + content += ''; + content += ''; + content += ''; + content += ''; + content += ''; + content += ''; content += '
Total HT' + $this.formatPrice(totalht, 'HT') + '
Frais de port' + fp + '
TVA' + $this.formatPrice(tva) + '
Total TTC' + $this.formatPrice(totalttcfp, 'TTC') + '
'; return content; }, - updateCart: function () { + updateCart: function (getQtyFromField) { + if (getQtyFromField == undefined) { + getQtyFromField = true; + } var $this = this; - $(".cartqty").each(function () { - $this.setQuantity($(this).attr('name'), parseInt($(this).val()), 'set'); - }); + if (getQtyFromField) { + $(".cartqty").each(function () { + $this.setQuantity($(this).attr('name'), parseInt($(this).val()), 'set'); + }); + } + $('[data-menu="cart"] .content').html(this.getCartContent()); + $('input[type="number"]').inputNumber(); + resize(); }, formatPrice: function (price, suffix) { diff --git a/js/libs/fluidbook/fluidbook.cart.js b/js/libs/fluidbook/fluidbook.cart.js index 67df20e8..ed1242bd 100644 --- a/js/libs/fluidbook/fluidbook.cart.js +++ b/js/libs/fluidbook/fluidbook.cart.js @@ -14,6 +14,12 @@ FluidbookCart.prototype = { this.enabled = true; this.instance = this.createInstance(); + $(document).on('click', '[data-cart-delete]', function () { + $this.instance.removeFromCart($(this).data('cart-delete')); + $this.instance.updateCart(false); + return false; + }); + $(document).on('click', '[data-cart-ref]', function () { $this.instance.addToCart($(this).data('cart-ref')); $this.fluidbook.tooltip.displayTooltip($this.fluidbook.l10n.__("the item has been added to your cart")); diff --git a/js/libs/fluidbook/fluidbook.nav.js b/js/libs/fluidbook/fluidbook.nav.js index 8aabeeab..1769bd1e 100644 --- a/js/libs/fluidbook/fluidbook.nav.js +++ b/js/libs/fluidbook/fluidbook.nav.js @@ -404,7 +404,6 @@ FluidbookNav.prototype = { if ($(l).find('span.number').length === 0) { $(l).append(''); } - console.log($(l).find('span.number')); $(l).find('span.number').text(n); } }); @@ -532,7 +531,6 @@ FluidbookNav.prototype = { if (foundLink == undefined) { continue; } - console.log(foundLink); link = $(foundLink).find('a').append(linkIcon); if (navType == 'menu') { var tooltip = $(link).data('tooltip'); diff --git a/style/fluidbook.less b/style/fluidbook.less index 4fec0b54..ed813cd6 100644 --- a/style/fluidbook.less +++ b/style/fluidbook.less @@ -860,6 +860,10 @@ a.bookmark { } [data-menu="cart"] { + .cart-empty { + padding: 50px; + } + table { width: 1004px; margin-left: 10px; @@ -874,6 +878,26 @@ a.bookmark { &.price { font-weight: 700; } + &.price, &.price_excluding_taxes, &.price_unit { + text-align: right; + } + &.delete { + a { + display: inline-block; + width: 23px; + height: 23px; + background-color: @menu-button-background; + position: relative; + top: 1px; + left: -5px; + padding: 0 6px; + svg { + width: 11px; + height: 11px; + display: inline-block; + } + } + } } .input-number { position: relative; @@ -899,7 +923,30 @@ a.bookmark { font-size: 30px; } } + + &.cart-totals { + width: 250px; + margin: 18px; + float: right; + clear: both; + td.hr { + height: 2px; + background-color: #fff; + padding: 0; + } + tr.total { + td { + font-weight: 700; + + } + } + td { + padding: 6px 12px; + text-align: right; + } + } } + } // Hack for #1433 -- 2.39.5