diff --git a/app/Policies/OrderPolicy.php b/app/Policies/OrderPolicy.php index 99bbd9d..a6f988d 100644 --- a/app/Policies/OrderPolicy.php +++ b/app/Policies/OrderPolicy.php @@ -82,6 +82,8 @@ class OrderPolicy extends Policy { // phpcs:enable if ( + // ! Limit to only order where mail has been sent (order-tunnel has completed). + $order->mail_sent and $order->validation_status->equals(ValidationStatus::cancelled()) or $order->delivery_status->value >= DeliveryStatus::ready()->value ) { @@ -102,6 +104,8 @@ class OrderPolicy extends Policy { $transaction = $order->getTransactionUsedForPayment(); if ( + // ! Limit to only order where mail has been sent (order-tunnel has completed). + !$order->mail_sent or $order->validation_status->equals(ValidationStatus::cancelled()) or !$transaction ) { @@ -121,7 +125,11 @@ class OrderPolicy extends Policy */ public function changeDeliveryStatus(User $user, Order $order): Response { - if ($order->validation_status->equals(ValidationStatus::pending())) { + if ( + // ! Limit to only order where mail has been sent (order-tunnel has completed). + !$order->mail_sent or + $order->validation_status->equals(ValidationStatus::pending()) + ) { return Response::deny(); } // phpcs:enable @@ -141,6 +149,8 @@ class OrderPolicy extends Policy // phpcs:enable $transaction = $order->getTransactionUsedForPayment(); if ( + // ! Limit to only order where mail has been sent (order-tunnel has completed). + !$order->mail_sent or !$order->can_be_refund or !$transaction or $transaction->payment_mode->equals(PaymentModeEnum::inShop())