Feature: Minor Updates to Order Shipping And Order Statuses
This commit is contained in:
@@ -21,6 +21,7 @@ class OrderViewExtension extends ViewPageExtension
|
||||
public function headerActions(array $actions): array
|
||||
{
|
||||
$actions[] = $this->createShipmentAction();
|
||||
$actions[] = $this->markPickedUpAction();
|
||||
|
||||
return $actions;
|
||||
}
|
||||
@@ -93,10 +94,41 @@ class OrderViewExtension extends ViewPageExtension
|
||||
->success()
|
||||
->send();
|
||||
})
|
||||
->visible(fn (Order $record) => $record->shipments()->exists() === false
|
||||
->visible(fn (Order $record) => $record->status === 'ready-for-dispatch'
|
||||
&& ! $record->isStorePickupOrder()
|
||||
&& $record->shipments()->exists() === false
|
||||
&& $this->resolveFulfillmentService($record) !== null);
|
||||
}
|
||||
|
||||
/**
|
||||
* The store-pickup mirror of createShipmentAction() — a store-pickup
|
||||
* order never gets a Shipment record (no carrier is ever involved), so
|
||||
* it needs its own way to close out of 'ready-for-pickup' once the
|
||||
* customer has actually collected it. Sets status directly to
|
||||
* 'completed', same terminal status DeriveOrderDeliveredFromShipment
|
||||
* writes for a carrier order once tracking confirms delivery — see
|
||||
* that listener's own docblock.
|
||||
*/
|
||||
private function markPickedUpAction(): Action
|
||||
{
|
||||
return Action::make('mark_picked_up')
|
||||
->label('Mark Picked Up')
|
||||
->icon('heroicon-o-check-circle')
|
||||
->color('success')
|
||||
->requiresConfirmation()
|
||||
->modalDescription('Confirms the customer has collected this order in store.')
|
||||
->action(function (Order $record) {
|
||||
$record->update(['status' => 'completed']);
|
||||
|
||||
Notification::make()
|
||||
->title('Order marked as picked up.')
|
||||
->success()
|
||||
->send();
|
||||
})
|
||||
->visible(fn (Order $record) => $record->status === 'ready-for-pickup'
|
||||
&& $record->isStorePickupOrder());
|
||||
}
|
||||
|
||||
private function resolveCarrier(Order $record): ?string
|
||||
{
|
||||
$code = $record->shippingAddress?->shipping_option;
|
||||
|
||||
Reference in New Issue
Block a user