Welcome to the eCommerce Cart repository! This lightweight Laravel shopping cart library allows you to build a flexible and efficient shopping cart for your applications. It supports custom Eloquent models, events, and tax calculations, making it an ideal choice for any eCommerce project.
- Lightweight: Designed to be simple and efficient.
- Custom Eloquent Models: Easily integrate your own models.
- Event Support: Trigger events at various stages of the cart lifecycle.
- Tax Calculation: Built-in support for tax calculations based on your needs.
- Laravel Compatibility: Fully compatible with Laravel applications.
To install the eCommerce Cart library, you can use Composer. Run the following command in your terminal:
composer require dubey-anuj/ecommerce.cartAfter installation, you can publish the configuration file by running:
php artisan vendor:publish --provider="DubeyAnuj\EcommerceCart\ServiceProvider"This command will create a configuration file in the config directory.
Once installed, you can start using the shopping cart in your Laravel application. Hereβs a basic example of how to add items to the cart:
use DubeyAnuj\EcommerceCart\Facades\Cart;
Cart::add([
'id' => 1,
'name' => 'Product Name',
'qty' => 1,
'price' => 100.00,
]);To retrieve the cart contents, use:
$cartContents = Cart::content();You can also remove items from the cart:
Cart::remove($itemId);The configuration file allows you to customize various aspects of the cart. You can find it in the config/ecommerce_cart.php file. Here are some of the key settings:
- tax_rate: Set the default tax rate for your cart.
- currency: Define the currency used in the cart.
- item_limit: Specify the maximum number of items allowed in the cart.
Adjust these settings according to your project's requirements.
The eCommerce Cart library provides several events that you can listen to. These events allow you to execute custom logic when certain actions occur. Here are some common events:
- CartItemAdded: Triggered when an item is added to the cart.
- CartItemRemoved: Triggered when an item is removed from the cart.
- CartUpdated: Triggered when the cart is updated.
You can listen to these events in your event service provider:
protected $listen = [
'DubeyAnuj\EcommerceCart\Events\CartItemAdded' => [
'App\Listeners\SendCartItemAddedNotification',
],
];The library supports tax calculations based on the settings you configure. You can set a default tax rate in the configuration file. When items are added to the cart, the tax will be calculated automatically.
To calculate tax for a specific item, you can use:
$tax = Cart::tax($item);This will return the tax amount based on the configured rate.
We welcome contributions to the eCommerce Cart library! If you would like to contribute, please follow these steps:
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Make your changes and commit them.
- Push your branch to your forked repository.
- Submit a pull request.
Please ensure your code follows the existing coding standards and includes appropriate tests.
This project is licensed under the MIT License. See the LICENSE file for details.
For the latest releases, please visit the Releases section. You can download the latest version from there and execute it in your application.
If you have any questions or need further assistance, feel free to check the issues section of this repository. We are here to help!
Thank you for checking out the eCommerce Cart library! We hope it helps you build amazing eCommerce solutions.