]> _ Git - cubeextranet.git/commitdiff
Wait #5345 @1
authorstephen@cubedesigners.com <stephen@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Mon, 17 Oct 2022 15:12:57 +0000 (15:12 +0000)
committerstephen@cubedesigners.com <stephen@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Mon, 17 Oct 2022 15:12:57 +0000 (15:12 +0000)
inc/ws/Util/html5/master/class.ws.html5.compiler.php

index b9e2515cce2c49e33d42f417767b632634704234..2e527df9c3da0f5705bc9c65a5deb4b40ec2ded6 100644 (file)
@@ -875,6 +875,30 @@ class wsHTML5Compiler
         }
 
         $this->config->basketReferences = $references;
+
+        // Allow individual Fluidbooks to override the columns shown in the cart
+        $extra = wsHTML5Link::parseExtras($this->book->parametres->cartExtraSettings, true);
+
+        if (!empty($extra['cart_columns'])) {
+            // In the "Paramètres panier" field (cartExtraSettings), the cart columns can be defined in this format:
+            // cart_columns=XLS COL NAME|Display name,XLS COL 2|Display name 2
+            // This setting needs to be trimmed and converted into an associative array with column_name => display_name
+            // Split by commas, then by pipes |
+            $columns = array_map(function ($heading) {
+                return explode('|', $heading);
+            }, explode(',', $extra['cart_columns']));
+            $processed_columns = [];
+            foreach ($columns as $column) {
+                $processed_columns[strtoupper(trim($column[0]))] = trim($column[1] ?? '');
+            }
+
+            // Ensure that special QUANTITY and DELETE columns are present (see getColumns() in fluidbook.cart.bastide.js)
+            $processed_columns['QUANTITY'] = $processed_columns['QUANTITY'] ?? 'Quantité';
+            $processed_columns['DELETE'] = '';
+
+            $this->config->cartColumns = $processed_columns;
+        }
+
     }
 
     public function writeCartConfig()