Create, manage, and apply discount coupons in Laravel.
roundly-consulting/coupons-for-laravel is a Laravel package for create, manage, and apply discount coupons in laravel..
It currently has 5 GitHub stars and 49 downloads on Packagist (latest version 1.1.2).
Install it with composer require roundly-consulting/coupons-for-laravel.
Discover more Laravel packages by roundly-consulting
or browse all Laravel packages to compare alternatives.
Last updated
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.
Requires PHP 8.4 (ext-bcmath), Laravel 12 or 13, and MySQL or PostgreSQL.
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.
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
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.
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.
The MIT License (MIT). See LICENSE.md for details.