# How do I set a custom item volume totalizer for shipping rates?

Shipping rates can define a custom item volume totalizer to control how item volumes are calculated when determining whether a rate is applicable.

For example, you may want to account for additional packaging space by applying a percentage allowance to the volume of each item.

First, define the packaging allowance on the shipping method:

```php
\Aero\Cart\Models\ShippingMethod::settings('extras', function (\Aero\Common\Settings\ModelSettingGroup $group) {
    $group->integer('packaging_allowance')->default(20);
});
```

The `setItemVolumeTotalizer` method can then apply the allowance when calculating the total volume:

```php
\Aero\Cart\Models\ShippingRate::setItemVolumeTotalizer(function ($items, \Aero\Cart\Models\ShippingRate $rate) {
    $packagingAllowance = 1 + ($rate->shippingMethod->setting('extras.packaging_allowance') / 100);

    return $items->sum(function (\Aero\Cart\Models\OrderItem $item) use ($packagingAllowance) {
        return $item->buyable->volume * $packagingAllowance;
    });
});
```

The totalizer receives the order items and the shipping rate as parameters and should return the total volume of the items or `null`.

<p class="callout info">Returning `null` means the default item volume totalizer will be used.</p>

---

### Parameters

<table border="1" id="bkmrk-parameter-type-descr" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 33.3333%;"></col><col style="width: 33.3333%;"></col><col style="width: 33.3333%;"></col></colgroup><tbody><tr><td>**Parameter**</td><td>**Type**</td><td>**Description**</td></tr><tr><td>`$items`  
</td><td>`\Aero\Common\Eloquent\JavaScriptableCollection`  
</td><td>The order items being evaluated.</td></tr><tr><td>`$rate`  
</td><td>`\Aero\Cart\Models\ShippingRate`  
</td><td>The shipping rate being evaluated.</td></tr></tbody></table>