Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Discountify

Discountify Laravel Package

safemood/discountify

Laravel package for dynamic, condition-based discounts. Define custom conditions, apply percentage discounts, set global discount and tax rate, support coupon and class-based discounts, dynamic item field names, optional condition skipping, and event tracking for e-commerce totals.

View on GitHub
Deep Wiki
Context7

Laravel package for dynamic discounts with custom conditions.

Frequently asked questions about Discountify
How do I install and set up Discountify in a Laravel project?
Run `composer require safemood/discountify` to install the package, then publish the config file with `php artisan vendor:publish --tag=discountify-config`. The package requires no additional setup for basic usage, but you can customize field mappings (e.g., `price`, `quantity`) and global discount/tax rates in `config/discountify.php`.
What Laravel versions does Discountify support?
Discountify is designed for Laravel 8.x and 9.x. Check the package’s [Packagist page](https://packagist.org/packages/safemood/discountify) for the latest version compatibility. Always verify your Laravel version matches the package’s requirements before installation.
Can I define custom discount conditions beyond percentage-based rules?
Yes, Discountify supports both closure-based and class-based conditions. For example, you can create a `MinimumCartValueCondition` class or use anonymous functions to evaluate conditions like user roles, cart size, or temporal rules (e.g., discounts active only on weekends).
How does Discountify handle conflicting discounts (e.g., two coupons applying to the same cart)?
Discountify applies discounts in the order they are defined, with later discounts potentially overriding earlier ones. There’s no built-in priority system for competing discounts, so explicitly order your conditions or use coupon-specific logic (e.g., single-use coupons) to avoid conflicts.
Is Discountify suitable for high-traffic e-commerce sites with millions of users?
The package uses a JSON file for coupon storage by default, which isn’t scalable for high-volume systems. For production use, migrate coupons to a database (e.g., MySQL) and cache coupon data in Redis to reduce latency. Also, optimize condition logic to avoid CPU-intensive evaluations during peak traffic.
Can I use Discountify for fixed-amount discounts (e.g., $5 off) instead of just percentages?
Discountify currently supports percentage-based discounts only. For fixed-amount discounts, you’d need to extend the package or pre-calculate percentage equivalents (e.g., $5 off a $100 item = 5% discount). Consider submitting a feature request or contributing a pull request for native fixed-amount support.
How do I log discount applications for compliance or analytics?
Discountify fires events like `DiscountAppliedEvent` and `CouponAppliedEvent` when discounts are applied. Listen to these events in your `EventServiceProvider` to log details (e.g., discount type, amount, user ID) to a database or external service. For audit trails, pair events with Laravel’s logging or a dedicated analytics package.
Does Discountify support multi-tenancy (e.g., SaaS applications with tenant-specific discounts)?
The current design assumes a single-tenant environment. For multi-tenancy, you’ll need to extend the package to scope discounts by tenant ID (e.g., via middleware or a custom condition class). Override the `setItems()` method or use Laravel’s context binding to inject tenant-specific data.
How can I skip evaluating certain discount conditions for specific carts?
Use the `skipConditions()` method to exclude specific condition classes or IDs during calculation. For example, `Discountify::setItems($cart)->skipConditions(['MinimumCartValueCondition'])->calculateTotal()`. This is useful for bypassing conditions like minimum order values for VIP users.
Are there performance concerns with Discountify in production, and how can I mitigate them?
Discountify evaluates conditions sequentially for each cart update, which can become slow with complex or numerous conditions. Mitigate this by caching condition results (e.g., Redis) for static rules, optimizing closures, and using database indexes for coupon lookups. For high concurrency, wrap usage in a service class to avoid static method race conditions.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
codraw/entity-migrator
codraw/doctrine-extra
codraw/aws-tool-kit
codraw/validator
codraw/workflow
codraw/open-api
codraw/cron-job
codraw/process
codraw/log
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony