Download the PHP package daikazu/flexicart without Composer
On this page you can find all versions of the php package daikazu/flexicart. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download daikazu/flexicart
More information about daikazu/flexicart
Files in daikazu/flexicart
Package flexicart
Short Description A flexible shopping cart package for Laravel
License MIT
Homepage https://github.com/daikazu/flexicart
Informations about the package flexicart
FlexiCart
A flexible shopping cart package for Laravel with support for session or database storage, conditional pricing, cart merging, rules engine, and custom product attributes.
Table of Contents
- Features
- Installation
- Basic Usage
- Adding Items
- Updating Items
- Removing Items
- Cart Totals
- Conditions
- Understanding Conditions
- Adding Conditions
- Removing Conditions
- Non-Taxable Items
- Tax Conditions and the
taxableFlag
- Documentation
- Testing
- Troubleshooting
- Changelog
- Contributing
- Security Vulnerabilities
- Credits
- License
Features
- Flexible Storage: Use session storage (default) or database storage
- Cart Item Conditions: Apply discounts, fees, or any adjustments to items
- Percentage-based adjustments (e.g., 10% discount)
- Fixed-amount adjustments (e.g., $5 off, $2 add-on fee)
- Stack multiple conditions on the same item
- Rules Engine: Advanced promotional rules with cart context access
- Buy X Get Y deals
- Threshold-based discounts
- Tiered volume discounts
- Quantity-based rules
- Cart Merging: Flexible strategies for merging carts (guest to user, wishlist to cart)
- Event System: Hook into cart lifecycle for analytics, inventory, and integrations
- Custom Product Attributes: Store any item-specific attributes (color, size, etc.)
- Global Cart Conditions: Apply conditions to the cart subtotal or only to taxable items
- Precise Price Handling: Uses Brick/Money for accurate currency calculations
- Taxable Item Support: Mark specific items as taxable or non-taxable
- Easy Integration: Simple API with Laravel Facade
Installation
Requirements
- PHP 8.3 or higher
- Laravel 11.0 or higher
- Brick/Money package (automatically installed)
Install the Package
Publish Configuration
Database Storage (Optional)
Then update your .env file:
Basic Usage
Adding Items to the Cart
Updating Items in the Cart
Removing Items from the Cart
Getting Cart Content and Calculations
Conditions
Understanding Conditions
Conditions are adjustments that can be applied to cart items or the entire cart:
- Percentage Conditions: Apply percentage-based adjustments (e.g., 10% discount)
- Fixed Conditions: Apply fixed-amount adjustments (e.g., $5 off)
- Tax Conditions: Special conditions for tax calculations
Conditions can target:
- Individual Items: Applied to specific cart items
- Cart Subtotal: Applied to the entire cart subtotal
- Taxable Items: Applied only to items marked as taxable
Adding Conditions
Removing Conditions
Marking Items as Non-Taxable
Tax Conditions and the taxable Flag
Use PercentageTaxCondition or FixedTaxCondition to apply tax. Tax is calculated on a tax base composed of:
- The subtotal of items whose
taxableattribute istrue, plus - Any conditions (cart-level or item-level) whose
taxableflag istrue.
Conditions default to taxable: false, which means they do not affect the tax base. Set taxable: true on a condition when its amount should be taxed (e.g. a taxable shipping fee) or when a discount should reduce the tax base.
Summary
| Condition | Effect on total | Effect on tax base |
|---|---|---|
Fee with taxable: false (default) |
Adds to total | No change |
Fee with taxable: true |
Adds to total | Adds full fee amount |
Discount with taxable: false |
Reduces total | No change |
Discount with taxable: true |
Reduces total | Reduces by full amount |
The same rule applies to item-level conditions: an item condition with taxable: false is included in the item's subtotal but excluded from the tax base.
Documentation
For detailed documentation on specific features, see the following guides:
| Guide | Description |
|---|---|
| Configuration | Storage options, currency settings, cleanup, and all config options |
| Rules Engine | Advanced promotional rules: Buy X Get Y, thresholds, tiered discounts |
| Cart Merging | Merge strategies for guest-to-user carts, wishlists, and cart recovery |
| Events | Cart lifecycle events for analytics, inventory, and integrations |
| Working with Prices | Price object API, arithmetic operations, and formatting |
| Blade Templates | Examples for displaying cart data in Blade views |
| Extending FlexiCart | Custom conditions, storage drivers, models, and merge strategies |
Testing
Troubleshooting
Common Issues
Cart data not persisting between requests
- Ensure sessions are properly configured in your Laravel application
- If using database storage, verify migrations have been run
- Check that the
CART_STORAGEenvironment variable is set correctly
Price calculation errors
- Verify that all price values are numeric
- Ensure currency codes are valid ISO codes
Condition not applying correctly
- Verify condition targets are set appropriately
- Check condition order values if multiple conditions exist
- Ensure condition values are properly signed (negative for discounts)
Memory issues with large carts
- Consider implementing cart item limits
- Don't use session storage due to cookie size limits
- Use database storage for better memory management
- Implement cart cleanup for old/abandoned carts
Changelog
Please see CHANGELOG for more information on what has changed recently.
Future Roadmap
- API endpoints
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- Mike Wall
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of flexicart with dependencies
ext-bcmath Version *
ext-intl Version *
brick/math Version >=0.14.2 <2.0
brick/money Version >=0.11 <1.0
illuminate/contracts Version ^10.0||^11.0||^12.0||^13.0
illuminate/session Version ^10.0||^11.0||^12.0||^13.0
illuminate/support Version ^10.0||^11.0||^12.0||^13.0
spatie/laravel-package-tools Version ^1.16