From fd429b1f85eaa35ee9c4e3e0f259e55548f66b61 Mon Sep 17 00:00:00 2001 From: Stephen Cameron Date: Mon, 17 Oct 2022 17:13:43 +0200 Subject: [PATCH] Wait #5345 @0.75 --- .../fluidbook/cart/fluidbook.cart.bastide.js | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/js/libs/fluidbook/cart/fluidbook.cart.bastide.js b/js/libs/fluidbook/cart/fluidbook.cart.bastide.js index c11dcf50..e5079bd4 100644 --- a/js/libs/fluidbook/cart/fluidbook.cart.bastide.js +++ b/js/libs/fluidbook/cart/fluidbook.cart.bastide.js @@ -271,6 +271,13 @@ FluidbookCartBastide.prototype = { getColumns: function () { // Map of data key names to their display labels - this controls the order of the columns // Note: the key names here should match the first row column titles in the spreadsheet + // This can be overridden by specifying the cart_columns in the "Paramètres panier" field (cartExtraSettings) + // The format for the setting is: + // cart_columns=XLS COL NAME|Display label,XLS COL 2|Display label 2 + if (fluidbook.settings.cartColumns) { + return fluidbook.settings.cartColumns; + } + return { 'ARTICLE CODE': 'Réf', 'ARTICLE': 'Article', @@ -363,6 +370,9 @@ FluidbookCartBastide.prototype = { switch(key) { + case 'PRIX': + output += $this.formatPrice(value); + break; case 'QUANTITY': let min_quantity = 1; @@ -470,4 +480,29 @@ FluidbookCartBastide.prototype = { getMenuWidth: function () { return window.location.hash === '#/cart/validate' ? 990 : 1190; // Validate modal is narrower than main cart }, + + formatPrice: function (price) { + + if (typeof price !== 'number') { + price = this.parseFloat(price); + } + + return price.toLocaleString("fr-FR", { + style: "currency", + currency: "EUR", + minimumFractionDigits: 2, + maximumFractionDigits: 2 + }); + }, + + parseFloat: function (s) { + if (typeof s === 'number') { + return s; + } + if (s === undefined || s === null || s === '') { + return 0; + } + s = s.replace(/\s/g, ''); + return parseFloat(s); + }, }; -- 2.39.5