# Volume-based pricing

> Volume-based pricing is a pricing strategy in which the unit price decreases as the purchase quantity increases, incentivizing larger orders by offering tiered discounts tied to volume thresholds.

To realize volume-based pricing you need to make the price of your product dynamic.

## Create a custom product page model

If you don’t already have one, create your own product model that extends Merx’ [`ProductPage`](https://merx2.wagnerwagner.de/reference/classes/product-page.md) class.

First, use the [`price()`](https://merx2.wagnerwagner.de/reference/classes/product-page/price.md) method of the parent [`ProductPage`](https://merx2.wagnerwagner.de/reference/classes/product-page.md) class to get the [`$price`](https://merx2.wagnerwagner.de/reference/classes/price.md) object. Then use this object to update the price using [`updatePrice()`](https://merx2.wagnerwagner.de/reference/classes/price/update-price.md) or [`updatePriceNet()`](https://merx2.wagnerwagner.de/reference/classes/price/update-price-net.md).

In the following example, the price is reduced by 5% when a cart line holds 10 or more items of this product.

```php title="/site/models/product.php"
<?php

use Wagnerwagner\Merx\Price;
use Wagnerwagner\Merx\PricingRule;

class ProductPage extends Wagnerwagner\Merx\ProductPage
{
  public function price(null|string|PricingRule $pricingRule = null, null|float $quantity = null): ?Price
  {
    $price = parent::price($pricingRule, $quantity);
    if ($price !== null && $quantity >= 10) {
      $price->updatePrice($price->price * 0.95);
    }
    return $price;
  }
}
```

That’s all you need to do — the cart uses this price method and passes the quantity of the line automatically. Without a price for the pricing rule, `parent::price()` returns `null`, so check for it before you change the price.

## Display reduced price

You can use the same price method to show the reduced price on the product page.

```php title="/site/templates/product.php"
<?php /** @var ProductPage $page */ ?>
<p class="callout">
If you buy 10 items or more, 
the price per item is reduced to 
<?= $page->price(quantity: 10) ?>.
</p>
```
