feat: update order timestamps when status is set to completed
This commit is contained in:
parent
31d286b702
commit
5927fc4e56
@ -427,6 +427,17 @@ public function updateStatus(Order $order, string $status): Order
|
||||
|
||||
$order->update(['status' => $status]);
|
||||
|
||||
if ($status === OrderStatus::COMPLETED->value) {
|
||||
$now = now();
|
||||
DB::table('orders')
|
||||
->where('id', $order->id)
|
||||
->update([
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
]);
|
||||
$order->refresh();
|
||||
}
|
||||
|
||||
if (in_array($status, [OrderStatus::CANCELLED->value, OrderStatus::REFUNDED->value]) && ! in_array($oldStatus, [OrderStatus::CANCELLED->value, OrderStatus::REFUNDED->value])) {
|
||||
$order->load('orderItems');
|
||||
$stockType = $order->orderItems->first()?->stock_quality?->value ?? ProductStockQuality::GOOD->value;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user