Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 20 additions & 18 deletions core/components/minishop3/src/Services/Order/OrderStatusService.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,25 +146,27 @@ public function change(int $orderId, int $statusId, bool $skipNotifications = fa

$msOrder->set('status_id', $statusId);

if ($msOrder->save()) {
$this->orderLog->add($msOrder->get('id'), $statusId, 'status');

$response = $this->ms3->utils->invokeEvent('msOnChangeOrderStatus', [
'msOrder' => $msOrder,
'old_status' => $oldStatus?->get('id'),
'status' => $statusId,
]);
if (!$response['success']) {
return $response['message'];
}
if (!$msOrder->save()) {
return $this->modx->lexicon('ms3_err_unknown');
}

// Send notifications via NotificationManager (unless skipped)
// Use output buffering to prevent any stray output from Fenom/pdoTools
if (!$skipNotifications) {
ob_start();
$this->sendNotifications($msOrder, $status, $oldStatus);
ob_end_clean();
}
$this->orderLog->add($msOrder->get('id'), $statusId, 'status');

$response = $this->ms3->utils->invokeEvent('msOnChangeOrderStatus', [
'msOrder' => $msOrder,
'old_status' => $oldStatus?->get('id'),
'status' => $statusId,
]);
if (!$response['success']) {
return $response['message'];
}

// Send notifications via NotificationManager (unless skipped)
// Use output buffering to prevent any stray output from Fenom/pdoTools
if (!$skipNotifications) {
ob_start();
$this->sendNotifications($msOrder, $status, $oldStatus);
ob_end_clean();
}

return true;
Expand Down