Looking to hire Laravel developers? Try LaraJobs

coupons-for-laravel maintained by roundly-consulting

Description
Create, manage, and apply discount coupons in Laravel.
Last update
2026/10/03 20:11 (dev-main)
License
Downloads
0

Comments
comments powered by Disqus

Coupons for Laravel

Create, validate and redeem discount coupons in Laravel: fixed, percentage (optionally capped) and free-shipping discounts with currency locks, minimum spends, activation windows and global or per-customer usage limits. Redemption is atomic, and every amount is an exact money-for-laravel Money.

Installation

Requires PHP 8.4 (ext-bcmath), Laravel 12 or 13, and MySQL/MariaDB, PostgreSQL or SQLite.

composer require roundly-consulting/coupons-for-laravel
php artisan vendor:publish --tag="coupons-migrations"
php artisan migrate

If the models that redeem coupons have UUID/ULID keys, set COUPONS_KEY_TYPE before migrating.

Usage

Create a coupon through the facade. New coupons start inactive, so activate it:

use RoundlyConsulting\Coupons\Enums\DiscountType;
use RoundlyConsulting\Coupons\Facades\Coupons;

$coupon = Coupons::generate(DiscountType::Percentage, value: 2000, code: 'SUMMER', maxUsage: 100); // 20 % off
$coupon->activate()->save();

At checkout, check it, preview the discount and redeem it against the cart total:

use RoundlyConsulting\Money\Money;

$cart = Money::ofMinor(5000, 'EUR');                       // €50.00

Coupons::code('SUMMER')->check($cart, $user);              // null, or why not: Expired, AtMaxUsage, …
Coupons::code('SUMMER')->preview($cart);                   // 10.00 EUR, without redeeming

$result = Coupons::code('SUMMER')->redeem($cart, $user);   // atomic; throws a CouponException if refused

$result->discount;                                         // 10.00 EUR
$result->total;                                            // 40.00 EUR

Documentation

The full documentation — configuration, every feature and its API, and testing — lives on our website: roundly-consulting.com/open-source/docs/coupons-for-laravel

Release notes are in CHANGELOG.md. To contribute, see the contributing guide.

Support our work

This package is free and open source, built and maintained by Roundly Consulting. If it saves you time, please consider supporting our open-source work — a one-time donation, a monthly pledge on Patreon or a crypto donation helps fund maintenance, new features and new packages.

License

The MIT License (MIT). See LICENSE.md for details.