# How do I set a custom order validator for shipping methods?

Shipping methods can define an order validator to determine whether they are available for a particular order.

For example, you may only want to offer some shipping methods on certain days.

First we will define an availability setting for each day:

```php
$days = collect([
    'sunday' => false,
    'monday' => true,
    'tuesday' => true,
    'wednesday' => true,
    'thursday' => true,
    'friday' => true,
    'saturday' => false,
]);

\Aero\Cart\Models\ShippingMethod::settings('availability', function (\Aero\Common\Settings\ModelSettingGroup $group) use ($days) {
    $days->each(function (bool $available, string $day) use ($group) {
        $group->boolean("{$day}_delivery")->default($available);
    });
});
```

The `setOrderValidator` method can then use these settings to determine whether the shipping method is available today:

```php
\Aero\Cart\Models\ShippingMethod::setOrderValidator(function (\Aero\Cart\Models\ShippingMethod $method) use ($days) {
    $day = $days->keys()[now()->dayOfWeek];

    return $method->setting("availability.{$day}_delivery");
});
```

The validator receives the shipping method, order and order item group and should return `true` when it can be used for the order, or `false` when it should be excluded.

---

### Parameters

<table border="1" id="bkmrk-parameter-type-descr" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 33.3731%;"></col><col style="width: 33.3731%;"></col><col style="width: 33.3731%;"></col></colgroup><tbody><tr><td>**Parameter**</td><td>**Type**</td><td>**Description**</td></tr><tr><td>`$method`</td><td>`\Aero\Cart\Models\ShippingMethod`</td><td>The shipping method being validated.</td></tr><tr><td>`$order`</td><td>`\Aero\Cart\Models\Order`</td><td>The order being validated.</td></tr><tr><td>`$orderItemGroup`</td><td>`string|null`</td><td>The order item group being validated (`null` when not in a group).</td></tr></tbody></table>

<div id="bkmrk--1"></div>