Feat: Shipping functionalities redesign, elta courier integration, commenting out acs since no integration can happen, flow updates
This commit is contained in:
@@ -29,6 +29,18 @@ use Modules\Core\Order\Events\OrderStatusChanged;
|
||||
*/
|
||||
class OrderStatusWriter
|
||||
{
|
||||
/**
|
||||
* The cause of the write in progress, so OrderObserver can put it on
|
||||
* the generic OrderStatusUpdated event (null for writes that don't go
|
||||
* through here, e.g. tinker).
|
||||
*/
|
||||
private static ?string $currentCause = null;
|
||||
|
||||
public static function currentCause(): ?string
|
||||
{
|
||||
return self::$currentCause;
|
||||
}
|
||||
|
||||
public function write(Order $order, string $to, string $causeClass): void
|
||||
{
|
||||
$from = $order->status;
|
||||
@@ -37,7 +49,13 @@ class OrderStatusWriter
|
||||
return;
|
||||
}
|
||||
|
||||
$order->update(['status' => $to]);
|
||||
self::$currentCause = $causeClass;
|
||||
|
||||
try {
|
||||
$order->update(['status' => $to]);
|
||||
} finally {
|
||||
self::$currentCause = null;
|
||||
}
|
||||
|
||||
OrderStatusChanged::dispatch($order, $from, $to, $causeClass);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user