Dashboard widgets
If the dashboard (typo3/) is installed, the extension adds the
following widgets to the widget group "Cart":
- Orders per Day: number of paid but not shipped orders per day
- Turnover per Day: gross total of the orders per day, without canceled payments
- Latest Orders (paid, not shipped): the ten latest paid but not shipped orders with their total and a link to the order in the backend module. If the backend user may show only one storage folder with orders, the button "Show all orders" opens the order list of this folder, searched for paid but not shipped orders.
- Orders Today, Orders this Month: number of orders today or in the current month, without canceled payments
- Turnover Today, Turnover this Month: gross total of the orders today or in the current month, without canceled payments
The widgets only show orders in storage folders the backend user may show (page permissions and mount points), admins see all orders.
Configuration of the data providers
The data of the widgets comes from data providers, which are configured in the service configuration of the extension:
extcode.(cart. provider. orders_ per_ day Extcode)Cart Widgets Provider Orders Per Day Provider extcode.(cart. provider. turnover_ per_ day Extcode)Cart Widgets Provider Turnover Per Day Provider extcode.(cart. provider. payment_ paid_ shipping_ open Extcode)Cart Widgets Provider Order Items Provider extcode.andcart. provider. orders_ today extcode.(cart. provider. orders_ this_ month Extcode)Cart Widgets Provider Orders In Period Provider extcode.andcart. provider. turnover_ today extcode.(cart. provider. turnover_ this_ month Extcode)Cart Widgets Provider Turnover In Period Provider
To change the options, overwrite the service in the Configuration/
of your site package. The site package has to depend on extcode/, so its
service configuration is loaded afterwards.
<?php
declare(strict_types=1);
use Extcode\Cart\Widgets\Provider\TurnoverPerDayProvider;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (ContainerConfigurator $configurator): void {
$configurator->services()
->set('extcode.cart.provider.turnover_per_day')
->class(TurnoverPerDayProvider::class)
->autowire()
->arg('$options', [
'days' => 14,
'storagePids' => [105],
'filter' => [
'payment' => [
'status' => 'paid',
],
],
]);
};
The same way you can register further widgets with own identifiers, e.g. a second turnover widget for another storage folder.
Options of all providers
-
- Type
-
array
- Default
-
[]
Status the payment and/or the shipping of an order must have, e.g.
['payment' =>. All orders are taken into account if empty.['status' => 'paid'], 'shipping' => ['status' => 'open']] Several status are given as list or comma separated string; an order matches if it has one of them, e.g. only open and paid invoices:
['payment' =>or['status' => ['open', 'paid']]] ['payment' =>.['status' => 'open,paid']] The status of a payment are
open,pending,paidandcanceled. The turnover and number widgets show orders with the payment statusopen,pendingorpaidby default. A payment is canceled e.g. if the customer aborts the payment at the payment provider, so these orders are left out.
-
- Type
-
array or comma separated string of page uids
- Default
-
[]
Storage folders of the orders. All storage folders are taken into account if empty. In both cases only storage folders the backend user may show are used.
Fields of the following options are fields of the order
(tx_), with or without the table name. Other
fields throw an exception.
Options of the chart and number providers
These options apply to Orders, Turnover,
Orders and Turnover.
-
- Type
-
string
- Default
-
order_date
Date field of the order which assigns the order to a day or period.
Options of OrdersPerDayProvider and TurnoverPerDayProvider
-
- Type
-
int
- Default
-
28
Number of days before today shown in the chart.
Options of OrdersInPeriodProvider and TurnoverInPeriodProvider
-
- Type
-
string
- Default
-
today
Period up to the end of today:
today,week(since Monday),monthoryear. Other values throw an exception. Days, weeks, months and years start in the time zone of the server.
Options of TurnoverPerDayProvider and TurnoverInPeriodProvider
-
- Type
-
string
- Default
-
total_gross
Field of the order which is summed up, e.g.
total_.net
The turnover widgets add up the amounts of all orders regardless of their
currency. Restrict them with storage if a site uses its own storage
folder for orders in another currency.
Options of OrderItemsProvider
-
- Type
-
string
- Default
-
crdate
Field to sort the orders by.
-
- Type
-
string
- Default
-
desc
Sort direction,
ascordesc.
-
- Type
-
int
- Default
-
10
Number of orders in the list.
Button of the order list
The button "Show all orders" of the widget "Latest Orders" is configured as
service extcode.
(Extcode). It takes the
options filter and storage like the data provider, so both should get
the same values. Its option title sets the text of the button.
The button links to the order list, if the backend user may show exactly one storage folder with orders. The order list is searched for the status of the filter, if the filter has one status for payment or shipping. Former searches of the backend user in the order list are reset.
Number widgets
The number widgets use the widget Extcode. Like
the Number of the dashboard it shows a number with an icon
(option icon), but the options title and subtitle are optional, so the
title of the widget is not repeated. With a data provider implementing
Extcode, like the
Turnover, the number is shown as amount with currency. The
option currency takes the arguments of the currency ViewHelper
(f:), the default is 1..
The following example adds a widget "Turnover this Week" in US dollars:
<?php
declare(strict_types=1);
use Extcode\Cart\Widgets\NumberWidget;
use Extcode\Cart\Widgets\Provider\TurnoverInPeriodProvider;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symfony\Component\DependencyInjection\Reference;
use TYPO3\CMS\Backend\View\BackendViewFactory;
use TYPO3\CMS\Dashboard\Widgets\BarChartWidget;
return static function (ContainerConfigurator $configurator, ContainerBuilder $containerBuilder): void {
if (!$containerBuilder->hasDefinition(BarChartWidget::class)) {
return;
}
$services = $configurator->services();
$services->set('site_package.provider.turnover_this_week')
->class(TurnoverInPeriodProvider::class)
->autowire()
->arg('$options', [
'period' => 'week',
]);
$services->set('dashboard.widget.site_package.turnover_this_week')
->class(NumberWidget::class)
->arg('$backendViewFactory', new Reference(BackendViewFactory::class))
->arg('$dataProvider', new Reference('site_package.provider.turnover_this_week'))
->arg('$options', [
'icon' => 'actions-money',
'currency' => [
'currencySign' => '$',
'decimalSeparator' => '.',
'thousandsSeparator' => ',',
'prependCurrency' => true,
'separateCurrency' => false,
],
])
->tag('dashboard.widget', [
'identifier' => 'TurnoverThisWeek',
'groupNames' => 'cart',
'title' => 'Turnover this Week',
'description' => 'Gross total of all orders in the current week',
'iconIdentifier' => 'content-widget-number',
]);
};