SalesAnalytics
SalesAnalytics class for generating sales dashboard data
This class handles database queries for sales metrics, refund calculations,
and recent order information for the admin dashboard.
Information
| Property | Value |
|---|---|
| Namespace | NymarkType\Fountain |
__construct()
No documentation available.
getData()
No documentation available.
totalEarnings()
Get total earnings (minus refunds) formatted as a price string.
$salesAnalytics->totalEarnings();
- Returns:
string
totalFees()
Get total fees (minus refund fees) formatted as a price string.
$salesAnalytics->totalFees();
- Returns:
string
totalOrders()
Get total number of orders from all transactions.
$salesAnalytics->totalOrders();
- Returns:
int
last7Days()
Get earnings from the last 7 days (minus refunds) formatted as a price string.
$salesAnalytics->last7Days();
- Returns:
string
last30Days()
Get earnings from the last 30 days (minus refunds) formatted as a price string.
$salesAnalytics->last30Days();
- Returns:
string
recentName()
Get the name of the customer from the most recent order. Returns 'n/a' if no orders exist or customer not found.
$salesAnalytics->recentName();
- Returns:
string
recentDate()
Get the date of the most recent order formatted as 'Y-m-d H:i' in local timezone. Returns 'n/a' if no orders exist.
$salesAnalytics->recentDate();
- Returns:
string
recentProduct()
Get the product(s) from the most recent order as a comma-separated string. Returns 'n/a' if no orders exist.
$salesAnalytics->recentProduct();
- Returns:
string
mostPopular()
Get the top 3 most popular products by counting occurrences in transactions. Returns object with gold, silver and bronze properties, each with name and count.
| Property | Type | Info |
|---|---|---|
gold |
Kirby\Toolkit\Obj |
Most popular product with name and count properties |
silver |
Kirby\Toolkit\Obj |
Second most popular product with name and count properties |
bronze |
Kirby\Toolkit\Obj |
Third most popular product with name and count properties |
$data = $salesAnalytics->mostPopular();
$data->gold()->name();
- Returns:
Kirby\Toolkit\Obj— gold, silver, bronze — each withname()andcount()
getEmptyData()
Return empty dashboard data structure with default values when database is unavailable or contains no data. All metrics return 0 or 'n/a'.
SalesAnalytics::getEmptyData();
- Returns:
Obj
Source: /classes/SalesAnalytics.php