]> _ Git - fluidbook-html5.git/commitdiff
Wait #5345 @0.75
authorStephen Cameron <stephen@cubedesigners.com>
Mon, 17 Oct 2022 15:13:43 +0000 (17:13 +0200)
committerStephen Cameron <stephen@cubedesigners.com>
Mon, 17 Oct 2022 15:13:43 +0000 (17:13 +0200)
js/libs/fluidbook/cart/fluidbook.cart.bastide.js

index c11dcf50b30f0918172f5592ff1b702f1e1e30f9..e5079bd4aa6e6601043d6c4710f0f857fed3e425 100644 (file)
@@ -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);
+    },
 };