diff --git a/Configuration/TypoScript/setup.typoscript b/Configuration/TypoScript/setup.typoscript index 7e37b949..634de343 100755 --- a/Configuration/TypoScript/setup.typoscript +++ b/Configuration/TypoScript/setup.typoscript @@ -383,6 +383,26 @@ lib { } } -module.tx_form.settings.yamlConfigurations { - 1543219101 = EXT:cart/Configuration/Yaml/FormSetup.yaml +module { + # settings of the backend module, Extbase reads them from the TypoScript setup (not from page TSconfig) + tx_cart { + settings { + format.currency { + currencySign = {$plugin.tx_cart.settings.format.currency.currencySign} + decimalSeparator = {$plugin.tx_cart.settings.format.currency.decimalSeparator} + thousandsSeparator = {$plugin.tx_cart.settings.format.currency.thousandsSeparator} + prependCurrency = {$plugin.tx_cart.settings.format.currency.prependCurrency} + separateCurrency = {$plugin.tx_cart.settings.format.currency.separateCurrency} + decimals = {$plugin.tx_cart.settings.format.currency.decimals} + } + + backend { + dateFormat = {$plugin.tx_cart.settings.backend.dateFormat} + } + } + } + + tx_form.settings.yamlConfigurations { + 1543219101 = EXT:cart/Configuration/Yaml/FormSetup.yaml + } } diff --git a/Configuration/page.tsconfig b/Configuration/page.tsconfig index 50d21819..a04b17b9 100644 --- a/Configuration/page.tsconfig +++ b/Configuration/page.tsconfig @@ -1,23 +1,2 @@ # Template path for dashboard widgets templates.typo3/cms-dashboard.1712899110 = extcode/cart:Resources/Private/ - -tx_cart { - persistence { - storagePid = {$module.tx_cart.persistence.storagePid} - } - - settings { - format.currency { - currencySign = {$plugin.tx_cart.settings.format.currency.currencySign} - decimalSeparator = {$plugin.tx_cart.settings.format.currency.decimalSeparator} - thousandsSeparator = {$plugin.tx_cart.settings.format.currency.thousandsSeparator} - prependCurrency = {$plugin.tx_cart.settings.format.currency.prependCurrency} - separateCurrency = {$plugin.tx_cart.settings.format.currency.separateCurrency} - decimals = {$plugin.tx_cart.settings.format.currency.decimals} - } - - backend { - dateFormat = {$plugin.tx_cart.settings.backend.dateFormat} - } - } -} diff --git a/Tests/Functional/Controller/Backend/Order/OrderControllerTest.php b/Tests/Functional/Controller/Backend/Order/OrderControllerTest.php index a41f76f7..1952a228 100644 --- a/Tests/Functional/Controller/Backend/Order/OrderControllerTest.php +++ b/Tests/Functional/Controller/Backend/Order/OrderControllerTest.php @@ -385,6 +385,23 @@ public function listActionRendersTheResetLinkOnlyIfThereIsAnActiveSearch(): void ); } + #[Test] + public function listActionFormatsPricesAndDatesWithTheSettingsOfTheTypoScriptOfCart(): void + { + $this->importPHPDataSet(__DIR__ . '/../../../../Fixtures/Orders.php'); + $this->includeTypoScriptOfCart(); + + $html = self::normalizeWhitespace( + (string)self::dispatchListAction(1, ['orderNumber' => 'O-20260222-1'])->getBody() + ); + + // order number and date, invoice number and date, total gross and net of the order in Tests/Fixtures/Orders.php + self::assertSame( + ['O-20260222-1', '2026-02-22', 'I-20260224-1', '2026-02-24', '21,52 €', '18,08 €'], + array_slice(self::getCellsOfOrderRow($html, 'O-20260222-1'), 3, 6) + ); + } + #[Test] public function listActionRendersOnlyTheOrdersOfTheMonthGivenAsOrderNumberSearchArgumentOnAllPages(): void { @@ -765,6 +782,41 @@ private function setItemsPerPage(int $itemsPerPage): void ); } + /** + * The static TypoScript of cart on the root page of the order storage, like a shop includes it. + */ + private function includeTypoScriptOfCart(): void + { + $this->getConnectionPool()->getConnectionForTable('sys_template')->insert( + 'sys_template', + [ + 'uid' => 1, + 'pid' => self::SHOP_ROOT_PID, + 'title' => 'Shop', + 'root' => 1, + 'clear' => 3, + 'include_static_file' => 'EXT:cart/Configuration/TypoScript', + ] + ); + } + + /** + * @return list the text of the cells of the row of the order in the order list + */ + private static function getCellsOfOrderRow(string $html, string $orderNumber): array + { + $orderList = mb_strstr($html, ']*>(?:(?!<\/tr>).)*' . preg_quote($orderNumber, '/') . '.*?<\/tr>/s', $orderList, $rowMatches); + self::assertArrayHasKey(0, $rowMatches, 'The order ' . $orderNumber . ' has not been rendered.'); + + preg_match_all('/]*>(.*?)<\/td>/s', $rowMatches[0], $cellMatches); + + return array_map( + static fn(string $cell): string => trim(str_replace("\u{a0}", ' ', html_entity_decode(strip_tags($cell)))), + $cellMatches[1] + ); + } + private function createOrders(int $numberOfOrders): void { $connectionPool = $this->getConnectionPool();