aiarmada / promotions
Automatic promotions and discount campaigns for commerce
v1.0.0
2026-03-20 14:42 UTC
Requires
- php: ^8.4
- aiarmada/commerce-support: v1.0.0
- illuminate/database: ^12.0|^13.0
- illuminate/support: ^12.0|^13.0
- spatie/laravel-activitylog: ^4.9
- spatie/laravel-data: ^4.0
Suggests
- aiarmada/products: For product/category targeting in promotions
README
Automatic promotional discounts and campaigns for commerce applications.
Features
- Promotion Types — Percentage off, fixed amount, and Buy X Get Y discounts
- Automatic Promotions — Code-free promotions that apply automatically
- Promo Codes — Optional code-based promotions
- Usage Limits — Total usage and per-customer limits
- Scheduling — Start and end dates for time-limited campaigns
- Stacking — Control whether promotions can stack with others
- Priority — Define which promotions take precedence
- Targeting — Apply conditions via commerce-support targeting engine
- Multi-tenancy — Owner scoping for multi-tenant applications
- Activity Logging — Track promotion changes via Spatie ActivityLog
Requirements
- PHP 8.4+
- Laravel 12+
- commerce-support package
Installation
composer require aiarmada/promotions
Publish and run migrations:
php artisan vendor:publish --tag=promotions-migrations php artisan migrate
Optionally publish the config:
php artisan vendor:publish --tag=promotions-config
Quick Start
use AIArmada\Promotions\Models\Promotion; use AIArmada\Promotions\Enums\PromotionType; // Create a 20% off promotion $promotion = Promotion::create([ 'name' => 'Summer Sale', 'type' => PromotionType::Percentage, 'discount_value' => 20, // 20% 'is_active' => true, 'starts_at' => now(), 'ends_at' => now()->addMonth(), ]); // Create a promo code $codePromo = Promotion::create([ 'name' => 'Welcome Discount', 'code' => 'WELCOME10', 'type' => PromotionType::Fixed, 'discount_value' => 1000, // $10.00 in cents 'usage_limit' => 100, 'is_active' => true, ]); // Calculate discount $discount = $promotion->calculateDiscount(5000); // 1000 cents ($10)
Configuration
// config/promotions.php return [ 'database' => [ 'table_prefix' => '', 'tables' => [ 'promotions' => 'promotions', 'promotionables' => 'promotionables', ], 'json_column_type' => 'json', ], 'features' => [ 'owner' => [ 'enabled' => false, 'include_global' => true, ], ], 'targeting' => [ 'cache_ttl' => 3600, ], ];
Promotion Types
| Type | Description |
|---|---|
Percentage |
Percentage discount (e.g., 20% off) |
Fixed |
Fixed amount in cents (e.g., $10 off) |
BuyXGetY |
Buy X items, get Y free |
License
MIT License. See LICENSE for details.