Skip to content

Commit b231b92

Browse files
committed
Fixed column typo and XSS
1 parent dc3642f commit b231b92

File tree

3 files changed

+34
-3
lines changed

3 files changed

+34
-3
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Release Notes for Craft Commerce
22

3+
## Unreleased
4+
5+
- Fixed a bug where the order’s table was showing the incorrect column heading on the Edit User page.
6+
- Fixed XSS vulnerabilities.
7+
38
## 4.10.1 - 2025-12-31
49

510
- Fixed a bug where settings were being saved to the project config incorrectly. ([#4006](https://github.com/craftcms/commerce/issues/4006))

src/controllers/OrdersController.php

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,8 +387,26 @@ public function actionUserOrdersTable(): Response
387387
$orderQuery->search($search);
388388
}
389389

390+
$orderQuery->orderBy('dateOrdered DESC');
390391
if ($sort) {
391-
[$field, $direction] = explode('|', $sort);
392+
if (is_array($sort)) {
393+
$field = $sort[0]['sortField'];
394+
$direction = $sort[0]['direction'];
395+
} else {
396+
[$field, $direction] = explode('|', $sort);
397+
}
398+
399+
// Validate sorting
400+
if (!in_array($direction, ['asc', 'desc']) ||
401+
!in_array($field, [
402+
'reference',
403+
'dateOrdered',
404+
'totalPrice',
405+
])
406+
) {
407+
$field = null;
408+
$direction = null;
409+
}
392410

393411
if ($field && $direction) {
394412
$orderQuery->orderBy($field . ' ' . $direction);
@@ -399,7 +417,6 @@ public function actionUserOrdersTable(): Response
399417

400418
$orderQuery->offset($offset);
401419
$orderQuery->limit($limit);
402-
$orderQuery->orderBy('dateOrdered DESC');
403420
$orders = $orderQuery->all();
404421

405422
$rows = [];
@@ -557,6 +574,15 @@ public function actionPurchasablesTable(): Response
557574
// Apply sorting if required
558575
if ($sort && strpos($sort, '|')) {
559576
[$column, $direction] = explode('|', $sort);
577+
578+
if (!in_array($column, [
579+
'description',
580+
'sku',
581+
'price',
582+
])) {
583+
$column = null;
584+
}
585+
560586
if ($column && in_array($direction, ['asc', 'desc'], true)) {
561587
$sqlQuery->orderBy([$column => $direction == 'asc' ? SORT_ASC : SORT_DESC]);
562588
}

src/templates/_includes/users/_ordersTable.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
var orderColumns = [
1313
{ name: '__slot:title', title: Craft.t('commerce', 'Order'), sortField: 'reference' },
1414
{ name: 'date', title: Craft.t('commerce', 'Order Date'), sortField: 'dateOrdered' },
15-
{ name: 'total', title: Craft.t('commerce', 'Total Paid'), sortField: 'totalPaid' },
15+
{ name: 'total', title: Craft.t('commerce', 'Total'), sortField: 'totalPrice' },
1616
{ name: 'orderStatus', title: Craft.t('commerce', 'Status'),
1717
callback: function(value) {
1818
return value;

0 commit comments

Comments
 (0)