Download the PHP package davidiwezulu/ecommerce without Composer
On this page you can find all versions of the php package davidiwezulu/ecommerce. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download davidiwezulu/ecommerce
More information about davidiwezulu/ecommerce
Files in davidiwezulu/ecommerce
Package ecommerce
Short Description A flexible e-commerce package for Laravel
License MIT
Informations about the package ecommerce
🎉 Laravel E-Commerce Package
Introduction
After letting this gem sit in a private repository for way too long, I decided it was time to dust it off, give it a serious makeover, and finally share it with everyone. What started as a personal side project has now evolved into a full-fledged e-commerce package 🚀.
Overview
An extensible Laravel package providing robust e-commerce functionalities, including cart management, order processing, admin operations, flexible tax calculations, and seamless payment gateway integration (Stripe and PayPal). Designed without a predefined UI to offer maximum flexibility, allowing integration with any Laravel backend, controllers, or views.
Laravel Version Compatibility
This package is compatible with the following Laravel versions:
Laravel Version | Supported |
---|---|
8.x | ✅ Yes |
9.x | ✅ Yes |
10.x | ✅ Yes |
Requirements
- PHP: >= 8.0
- Laravel: 8.x, 9.x, or 10.x
- Database: MySQL, PostgreSQL, SQLite, or any Laravel-supported database.
Table of Contents
- Features
- Installation
- Configuration
- Important Note
- Currency Settings
- Tax Settings
- Payment Gateways
- Stripe Configuration
- PayPal Configuration
- Custom Models
- Database Migrations
- Usage
- Cart Management
- Adding or Updating Cart Items
- Removing Cart Items
- Retrieving Cart Items
- Clearing the Cart
- Admin Operations
- Adding a New Product with Tax Rate
- Updating an Existing Product
- Updating Inventory
- Order Processing
- Stripe Payment Example
- PayPal Payment Example
- Tax Calculations
- Cart Management
- Extending the Package
- Custom Models
- Extend Package Models (Optional)
- Adding Custom Payment Gateways
- Custom Models
- License
- Conclusion
Features
- Cart Management: Add, update, remove, and retrieve cart items with tax calculations.
- Order Processing: Create, process, and manage orders with tax-inclusive totals.
- Admin Operations: Create and manage products, update inventory, and set specific tax rates per product.
- Payment Gateway Integration: Supports Stripe and PayPal, with options for customization.
- Flexible Tax System: Configure default tax rates, specify per-product tax rates, and choose whether taxes are included in prices.
- Currency Configuration: Define default currency symbol and code.
- Model Customization: Extend and override default models through configuration.
- Extensibility: Implement custom payment gateways by adhering to the provided interface.
- Payment Status Handling: Handle successful and failed payments with appropriate responses.
- Automatic Inventory Tracking: Automatically updates product inventory levels upon successful order placements.
- Seamless Integration: Designed to integrate with any Laravel application without enforcing any specific frontend or UI.
Installation
Step 1: Install the Package
Use Composer to install the package into your Laravel application:
Step 2: Publish Configuration and Migrations
Important: Before running migrations, ensure you have configured the package according to your application's needs. This includes setting up currency, tax settings, payment gateways, and customizing models if necessary.
Publish the package's configuration file and migrations:
Step 3: Configure the Package
Edit the config/ecommerce.php
file to suit your application's requirements. Ensure all configurations are set correctly before proceeding to migrations.
Step 4: Run Migrations
Run the migrations to create the necessary database tables:
Configuration
The package provides a configuration file located at config/ecommerce.php
, allowing you to customize various aspects.
Important Note
Configure the package before running migrations. This ensures that your custom settings, such as table names and model classes, are correctly applied during the migration process.
Currency Settings
Set your application's default currency in the .env
file:
Or directly in config/ecommerce.php:
Tax Settings
Configure tax settings in the .env file:
Or directly in config/ecommerce.php:
Payment Gateways
Stripe Configuration
In your .env file:
In config/ecommerce.php:
PayPal Configuration
In your .env file:
In config/ecommerce.php:
Custom Models
You can override the default models used by the package in config/ecommerce.php:
Database Migrations
The package provides migrations for creating necessary database tables. If you've customized table names or models, ensure that these are correctly set in the configuration before running migrations.
Important: Always back up your database before running new migrations, especially in production environments.
Usage
Cart Management
Manage cart items using the Cart
facade.
Adding or Updating Cart Items
Removing Cart Items
Retrieving Cart Items
Clearing the Cart
Admin Operations
Admins can manage products and inventory using the Admin facade.
Adding a New Product with Tax Rate
Updating an Existing Product
Updating Inventory
Order Processing
Use the Order facade to create orders and process payments.
Stripe Payment Example
PayPal Payment Example
Step 1: Initiate PayPal Payment
Step 2: Handle PayPal Return (After User Approval)
Create routes in your web.php:
Implement the controller methods:
Tax Calculations
The package supports flexible tax calculations, including per-product tax rates and configurable default tax rates.
Adding a Product with a Specific Tax Rate
Calculating Tax in Cart Items
When you add or update items in the cart, the tax amount is automatically calculated based on the product's tax rate or the default tax rate.
Extending the Package
Custom Models
Benefit of Custom Models: Defining models in the configuration allows you to override or extend the default models provided by the package with your own custom models. This provides flexibility to add custom methods, relationships, and business logic specific to your application.
Extend Package Models (Optional)
You can extend the package's default models if you want to retain the base functionality while adding your customizations.
Example:
Update Configuration:
In config/ecommerce.php:
Explanation:
By extending BaseProduct, you retain all the original functionality provided by the package. You can add new relationships, methods, accessors, and mutators in your custom Product model. The package will use your custom model throughout its operations.
Adding Custom Payment Gateways
You can add new payment gateways by implementing the PaymentGatewayInterface.
Create a Custom Gateway Class
Register the Custom Gateway
In config/ecommerce.php:
License
This package is open-sourced software licensed under the MIT license.
Conclusion
The Laravel E-commerce package provides a comprehensive solution for implementing e-commerce functionality in your Laravel application. With features like flexible tax calculations, seamless payment gateway integration, and customizable models, it offers a solid foundation for building robust online stores.
Important: Remember to configure the package appropriately before running migrations to ensure a smooth integration with your application.
For any questions or contributions, feel free to open an issue or submit a pull request on GitHub.
Thank you for choosing the Laravel E-commerce package!
All versions of ecommerce with dependencies
illuminate/support Version ^8.0|^9.0|^10.0
paypal/paypal-checkout-sdk Version ^1.0
stripe/stripe-php Version ^10.0