PHPackages                             autepos/discount - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. autepos/discount

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

autepos/discount
================

Flexible discount interface

011PHP

Since Apr 2Pushed 3y ago1 watchersCompare

[ Source](https://github.com/autepos/discount)[ Packagist](https://packagist.org/packages/autepos/discount)[ RSS](/packages/autepos-discount/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Introduction
============

[](#introduction)

A flexible discounting library for PHP with zero dependency. It is typically used to provide discounts on products, but can be used for any kind of discounting where flexibility is required.

Features
========

[](#features)

- Zero dependency
- Flexible discounting
- Extensible
- Supports multiple discount types:
    - Percentage
    - Fixed amount
    - BOGO / Buy N get M free / Buy N for the Price of M
    - Buy N at a price
- Discount stacking: any type/multiple discounts can be applied to a single/multiple items. Zero limitation.
- Restricting discounts:
    - to specific items
    - to a minimum purchase amount
    - to minimum quantity
- etc.

Installation
============

[](#installation)

Install the latest version with

```
composer require autepos/discount

```

Basic Usage
===========

[](#basic-usage)

```
use Autepos\Discount\Processors\LinearDiscountProcessor;
use Autepos\Discount\Contracts\DiscountableDevice;
use Autepos\Discount\Contracts\DiscountInstrument;

class Order implements DiscountableDevice
{
    //...
}

class PromotionCode implements DiscountInstrument
{
    //...
}

$discountableDevice = new Order();
$discountInstrument = new PromotionCode();

$processor = new LinearDiscountProcessor();
$processor->addDiscountableDevice($discountableDevice)
          ->addDiscountInstrument($discountInstrument);
$discountLineList = $processor->calculate();

// Get the discount amount
$discountAmount = $discountLineList->amount();

// Persist the discount
$discountLineList->redeem();
```

Adding a custom discount processor
==================================

[](#adding-a-custom-discount-processor)

```
use Autepos\Discount\Processors\Contracts\DiscountProcessor;

class CustomDiscountProcessor implements DiscountProcessor
{
    public function getProcessor(): string
    {
        return 'custom';
    }

    //...
}
```

###  Health Score

14

—

LowBetter than 2% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity22

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/f80490689224856c80359c0a0ac4a409118f9275cc062cc2b51dc379db28e70f?d=identicon)[bethelchika](/maintainers/bethelchika)

---

Top Contributors

[![osuagwu](https://avatars.githubusercontent.com/u/20265860?v=4)](https://github.com/osuagwu "osuagwu (15 commits)")

### Embed Badge

![Health badge](/badges/autepos-discount/health.svg)

```
[![Health](https://phpackages.com/badges/autepos-discount/health.svg)](https://phpackages.com/packages/autepos-discount)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
