Skip to main content
Orders · Revision #2

How do I unblock orders?

How do I unblock orders?

You can remove an existing blocker from an order using the unsetBlocker method.

For example, you can make it so some customer groups are exempt from being blocked

\Aero\Common\Facades\Settings::group('checkout', static function (\Aero\Common\Settings\SettingGroup $group) {
    $group->eloquent('exempt_customer_groups', \Aero\Account\Models\CustomerGroup::class)->multiple()->dontLoadModels()->section('Fraud');
});

Middleware can then be added to the checkout payment page to unblock the order for customers of that group:

\Aero\Checkout\Http\Responses\CheckoutPaymentPage::middleware(function (\Illuminate\Http\Request $request, \Closure $next) {
    $order = \Aero\Cart\Facades\Cart::order();

    $customerGroupId = optional($order->customer)->customer_group_id ?? null;

    if (in_array($customerGroupId, setting('checkout.exempt_customer_groups'))) {
        collect($order->blockers)->keys()
            ->each(function (string $key) use ($order) {
                $order->unsetBlocker($key);
            });
    }

    return $next($request);
});

Parameters

Parameter Type Description
$key
string
The key of the blocker to unset.