-
-
Notifications
You must be signed in to change notification settings - Fork 6
Description
Shop Home charts missing
Short description of the issue
Charts for Total Sales, Revenue, and AOV are not displaying after adding manual orders.
Expected behavior
After adding one or more manual orders in PWCommerce, the dashboard should display charts for:
- Total Sales
- Total Revenue
- Average Order Value
Actual behavior
Even after creating multiple manual orders, the dashboard canvas elements remain blank — no charts are rendered.
Steps to reproduce the issue
- If not installed yet Install PWCommerce by following all steps (making sure everything is ready to add products)
- If no order yet Navigate to Orders → Create manual order.
- If no order yet Complete and publish at least one order.
- Return/Go to the Shop Home dashboard.
- Observe that the chart canvases exist but are empty.
Possible fix
I attempted to debug this and found that chart data was not being rendered due to missing or misreferenced JS config values. Switching from the default PWCommerceProcessRenderShopHome to PWCommerceAdminRenderShopHome resolved it for me, but this is likely not the intended structure — hope it helps!
site/modules/ProcessWireCommerce/ProcessPWCommerce/ProcessPWCommerce.js
Around line 167
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHARTS JS
// @TODO: REPLACE THE HARDCODED DATA WITH PROCESSWIRE CONFIG ONES!
getProcessWireChartJSConfigs: function () {
// return ProcessWire.config.PWCommerceProcessRenderShopHome.chart_js_configs
return ProcessWire.config.PWCommerceAdminRenderShopHome.chart_js_configs
},
getProcessWireChartJSData: function () {
// return ProcessWire.config.PWCommerceProcessRenderShopHome.chart_js_data
return ProcessWire.config.PWCommerceAdminRenderShopHome.chart_js_data
},
getProcessWireChartJSLabels: function () {
// return ProcessWire.config.PWCommerceProcessRenderShopHome.chart_js_labels
return ProcessWire.config.PWCommerceAdminRenderShopHome.chart_js_labels
},
getChartMonths: function () {
const chartJSLabels = ProcessPWCommerce.getProcessWireChartJSLabels()
const monthsNames = chartJSLabels.months
//-------
return monthsNames
},
Mismatch in Total Revenue overview
I might need to check the behavior in a couple days to see what happens when covering another month
Short description of the issue
Total revenue totals in the dashboard may be inaccurate due to the $monthRevenueMoney variable not resetting for each month during iteration.
Expected behavior
The Total Revenue should be coherent with the added total of each order.
Actual behavior
Revenue from previous months may carry over, leading to incorrect totals. This happens because the $monthRevenueMoney object is declared outside the loop that iterates over each month.
Steps to reproduce the issue
- If no order yet Navigate to Orders → Create manual order.
- If no order yet Complete and publish at least one order.
- Return/Go to the Shop Home dashboard and view the Total Revenue per Month chart.
- Observe inflated revenue values for some months, likely due to accumulation across months.
Possible fix
Move the initialization of $monthRevenueMoney = $this->money(0); inside the month loop to ensure it resets properly each time.
Original snippet:
// DEFAULT
$monthRevenueMoney = $this->money(0);
foreach ($months as $monthName) {
// ...
$ordersRevenuesPerMonthMonies[$monthName] = $monthRevenueMoney;
}
Proposed fix:
foreach ($months as $monthName) {
// DEFAULT
$monthRevenueMoney = $this->money(0);
// ...
$ordersRevenuesPerMonthMonies[$monthName] = $monthRevenueMoney;
}
site/modules/ProcessWireCommerce/traits/utilities/TraitPWCommerceUtilitiesOrder.php
Around line 205
public function getMonthsOrdersRevenues($startDate = null, $endDate = null) {
// TODO: EITHER HERE OR LATER WE NEED TO COMPUTE AVERAGE FOR YEAR! REMEMBER TO AV BY 12 MONTHS IN THAT CASE
// get orders/sales (completed orders) for year grouped by month
$monthlySales = $this->getThisYearsSalesGroupedByMonth($startDate, $endDate);
$ordersRevenuesPerMonthMonies = [];
// ---------------
// get all months
$months = $this->getMonthsNames();
// loop through sales to compute average revenue for month
// i.e. total revenue for month / total sales for month
foreach ($months as $monthName) {
// DEFAULT
$monthRevenueMoney = $this->money(0);
$isInitialMonthRevenue = true;
// get revenue for each order in this month as MONEY
if (!empty($monthlySales[$monthName])) {
foreach ($monthlySales[$monthName] as $monthSales) {
// order_total_price
if (!empty($monthSales['order']['order_total_price'])) {
$orderRevenue = $monthSales['order']['order_total_price'];
if (!empty($isInitialMonthRevenue)) {
// FIRST/INITIAL MONTH AMOUNT TO START WITH
// create money object
$monthRevenueMoney = $this->money($orderRevenue);
} else {
// NOT INITIAL MONTH AMOUNT TO ADD
// amend money object > add to money object
$orderRevenueMoney = $this->money($orderRevenue);
$monthRevenueMoney = $monthRevenueMoney->add($orderRevenueMoney);
}
// ---------
$isInitialMonthRevenue = false;
}
}
} else {
// if no sales this month, keep €0
$monthRevenueMoney = $this->money(0);
}
// --------------
$ordersRevenuesPerMonthMonies[$monthName] = $monthRevenueMoney;
}
return $ordersRevenuesPerMonthMonies;
}

