Stat
- Type
- Abstract Class
- Namespace
- craft\commerce\base
- Inherits
- craft\commerce\base\Stat
- Implements
- craft\commerce\base\StatInterface
- Uses traits
- craft\commerce\base\StatTrait
- Extended by
- craft\commerce\stats\AverageOrderTotal, craft\commerce\stats\NewCustomers, craft\commerce\stats\RepeatCustomers, craft\commerce\stats\TopCustomers, craft\commerce\stats\TopProductTypes, craft\commerce\stats\TopProducts, craft\commerce\stats\TopPurchasables, craft\commerce\stats\TotalOrders, craft\commerce\stats\TotalOrdersByCountry, craft\commerce\stats\TotalRevenue
- Since
- 3.0
Stat
View source (opens new window)
# Public Properties
Property | Description |
---|---|
cache | boolean (opens new window) |
cacheDuration | integer (opens new window) – How long to cache the data, in seconds. |
dateRange | string (opens new window), null (opens new window) |
weekStartDay | integer (opens new window) |
# Protected Properties
Property | Description |
---|---|
_handle | string (opens new window) |
# Public Methods
Method | Description |
---|---|
__construct() | Stat constructor. |
get() | |
getChartQueryOptionsByInterval() | |
getData() | |
getDateRangeInterval() | |
getDateRangeWording() | |
getEndDate() | |
getHandle() | |
getOrderStatuses() | |
getStartDate() | |
prepareData() | |
setEndDate() | |
setOrderStatuses() | Set order statuses to limit stat query. Accepts array of OrderStatus models, handle strings or uid strings. |
setStartDate() |
# __construct()
Stat constructor.
View source (opens new window)
Arguments
$dateRange
(string (opens new window), null (opens new window))$startDate
(DateTime (opens new window), boolean (opens new window), null (opens new window))$endDate
(DateTime (opens new window), boolean (opens new window), null (opens new window))
Throws
# get()
View source (opens new window)
Returns
mixed
Throws
# getChartQueryOptionsByInterval()
View source (opens new window)
Arguments
$interval
# getDateRangeInterval()
View source (opens new window)
# getDateRangeWording()
View source (opens new window)
# getEndDate()
View source (opens new window)
Returns
mixed
# getHandle()
View source (opens new window)
# getOrderStatuses()
- Since
- 4.2.0
View source (opens new window)
Returns
array (opens new window), null (opens new window)
Throws
# getStartDate()
View source (opens new window)
Returns
mixed
# prepareData()
View source (opens new window)
Arguments
$data
Returns
mixed
# setEndDate()
View source (opens new window)
Arguments
$date
# setOrderStatuses()
- Since
- 4.2.0
Set order statuses to limit stat query. Accepts array of OrderStatus
models, handle strings or uid strings.
View source (opens new window)
Arguments
$orderStatuses
(craft\commerce\models\OrderStatus[], string (opens new window)[], null (opens new window))
Returns
void
# setStartDate()
View source (opens new window)
Arguments
$date
# Protected Methods
Method | Description |
---|---|
_createChartQuery() | |
_createStatQuery() | Generate base stat query |
# _createChartQuery()
View source (opens new window)
Arguments
$select
(array (opens new window))$resultsDefaults
(array (opens new window))$query
(null (opens new window), craft\db\Query (opens new window))
Returns
array (opens new window), null (opens new window)
Throws
# _createStatQuery()
Generate base stat query