Fountain

SalesAnalytics

totalEarnings()

$salesAnalytics->totalEarnings();

Returns: string
Get total earnings (minus refunds) formatted as a price string.


totalFees()

$salesAnalytics->totalFees();

Returns: string
Get total fees (minus refund fees) formatted as a price string.


totalOrders()

$salesAnalytics->totalOrders();

Returns: int
Get total number of orders from all transactions.


last7Days()

$salesAnalytics->last7Days();

Returns: string
Get earnings from the last 7 days (minus refunds) formatted as a price string.


last30Days()

$salesAnalytics->last30Days();

Returns: string
Get earnings from the last 30 days (minus refunds) formatted as a price string.


recentName()

$salesAnalytics->recentName();

Returns: string
Get the name of the customer from the most recent order. Returns 'n/a' if no orders exist or customer not found.


recentDate()

$salesAnalytics->recentDate();

Returns: string
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.


recentProduct()

$salesAnalytics->recentProduct();

Returns: string
Get the product(s) from the most recent order as a comma-separated string. Returns 'n/a' if no orders exist.


mostPopular()

$data = $salesAnalytics->mostPopular();
$data->gold()->name();

Returns: Kirby\Toolkit\Obj
Get the top 3 most popular products by counting occurrences in transactions. Returns object with:

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

popularProduct()

$salesAnalytics->popularProduct();

Returns: Kirby\Toolkit\Obj
Calculate most popular products by counting occurrences in transactions. Returns top 3 products with:

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

getEmptyData()

SalesAnalytics::getEmptyData();

Returns: Kirby\Toolkit\Obj (static method)
Return empty dashboard data structure with default values when database is unavailable or contains no data. All metrics return 0 or 'n/a'.