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

Shipping rates can define a custom item price totalizer to control how the total item price is calculated when determining whether a rate is applicable.

For example, you may want to calculate the shipping rate's price threshold using the original item prices rather than the discounted prices.

First, add settings to control whether discounts should be excluded:

```php
\Aero\Cart\Models\ShippingRate::settings('extras', function (\Aero\Settings\Models\ModelSettingGroup $group) {
    $group->boolean('exclude_discount_from_total');
});
```

The `setItemPriceTotalizer` method can then calculate the total using the items' original prices when both the shipping rate has this option enabled:

```
\Aero\Cart\Models\ShippingRate::setItemPriceTotalizer(function ($items, \Aero\Cart\Models\ShippingRate $rate) {
    if (! $rate->setting('extras.exclude_discount_from_total')) {
        return null;
    }

    $total = $items->sum(function (\Aero\Cart\Models\OrderItem $item) {
        return $item->subtotal_price->inc()->value;
    });

    return round($total);
});
```

The totalizer receives the order items and the shipping rate as parameters and should return the total in pence or `null`

<p class="callout info">Returning `null` means the default item price 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>