From c6110fb2fb16a0a3ab943b83370d075465853bfe Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Wed, 14 Jan 2026 11:58:19 +0100 Subject: [PATCH] wip #7898 @0.5 --- .../fluidbook/cart/fluidbook.cart.kimplay.js | 7 ++++++- js/libs/fluidbook/fluidbook.cart.js | 21 +++++++++++++++++++ style/cart/kimplay.less | 19 +++++++++++++++++ 3 files changed, 46 insertions(+), 1 deletion(-) diff --git a/js/libs/fluidbook/cart/fluidbook.cart.kimplay.js b/js/libs/fluidbook/cart/fluidbook.cart.kimplay.js index 03e32446..6b998f70 100644 --- a/js/libs/fluidbook/cart/fluidbook.cart.kimplay.js +++ b/js/libs/fluidbook/cart/fluidbook.cart.kimplay.js @@ -86,7 +86,11 @@ FluidbookCartKimplay.prototype = { }, getItemsNumbers: function () { - return this.getItems().length; + let res = 0; + $.each(this.getItems(), function (i, item) { + res++; + }); + return res; }, getAllQuantities: function () { @@ -104,6 +108,7 @@ FluidbookCartKimplay.prototype = { }, updateIcon: function () { + console.log(this.getItemsNumbers()); $(this.fluidbook).trigger('fluidbook.cart.updateIcon', {number: this.getItemsNumbers()}); }, diff --git a/js/libs/fluidbook/fluidbook.cart.js b/js/libs/fluidbook/fluidbook.cart.js index 6d470492..c5f5291b 100644 --- a/js/libs/fluidbook/fluidbook.cart.js +++ b/js/libs/fluidbook/fluidbook.cart.js @@ -102,6 +102,27 @@ FluidbookCart.prototype = { $(this.fluidbook).on('fluidbook.links.ready', function () { $this.updateLinks(); }); + + $(this.fluidbook).on('fluidbook.cart.updateIcon', function (e, data) { + var n = data.number; + let l = $('div.link[data-action="basket"]'); + if ($(l).length > 0) { + if (n === 0) { + $(l).find('span.number').remove(); + } else { + if ($(l).find('span.number').length === 0) { + $(l).append(''); + } + $(l).find('span.number').text(n); + } + } + }); + + if (this.instance.updateIcon !== undefined) { + $(this.fluidbook).on('fluidbook.ready', function () { + $this.instance.updateIcon(); + }); + } }, hasItem: function (ref) { diff --git a/style/cart/kimplay.less b/style/cart/kimplay.less index e3c8d1a3..3a176b1c 100644 --- a/style/cart/kimplay.less +++ b/style/cart/kimplay.less @@ -78,4 +78,23 @@ cursor: pointer; } } +} + +div.link[data-action="basket"] { + position: relative; + + span.number { + position: absolute; + background-color: #e30613; + color: #fff; + text-align: center; + right: -10px; + bottom: -10px; + width: 20px; + height: 20px; + border-radius: 50%; + font-weight: bold; + font-size: 12px; + line-height: 20px; + } } \ No newline at end of file -- 2.39.5