jmrashed/ecommerce

Laravel应用的高级电子商务工具包

2.0.3 2024-05-26 11:36 UTC

This package is auto-updated.

Last update: 2024-09-28 04:10:30 UTC


README

Latest Version on Packagist Total Downloads License

Laravel的电子商务工具包是一个模块化包,提供构建电子商务网站所需的基本功能。该包包括管理产品目录、购物车、结账系统、支付网关集成和订单管理的功能。

功能

  • 产品目录:轻松管理产品列表、分类和属性。
  • 购物车:使用会话管理添加、更新和删除购物车中的商品。
  • 结账系统:具有可定制步骤的简化结账流程。
  • 支付网关集成:支持多个支付网关(例如,Stripe、PayPal)。
  • 订单管理:从创建到履行的订单跟踪和管理。
  • 多语言和货币支持:通过本地化功能满足全球受众。
  • 响应式设计:确保在所有设备上提供无缝体验。

文件夹结构

ecommerce
├── config
│   └── ecommerce.php
├── database
│   ├── factories
│   │   └── ProductFactory.php
│   ├── migrations
│   │   └── 2024_05_25_000099_create_pkg_customers_table.php
│   │   └── 2024_05_25_000100_create_pkg_brands_table.php
│   │   └── 2024_05_25_000101_create_pkg_categories_table.php
│   │   └── 2024_05_25_000102_create_pkg_products_table.php
│   │   └── 2024_05_25_000103_create_pkg_orders_table.php
│   │   └── 2024_05_25_000105_create_pkg_order_items_table.php
│   │   └── 2024_05_25_000106_create_pkg_reviews_table.php 
│   └── seeders
│       └── DatabaseSeeder.php
├── resources
│   ├── assets
│   │   ├── css
│   │   │   └── ecommerce.css
│   │   └── js
│   │       └── ecommerce.js
│   ├── lang
│   │   └── en
│   │       └── ecommerce.php
│   └── views
│       ├── layouts
│       │   └── app.blade.php
│       └── products
│           └── index.blade.php
├── routes
│   └── web.php
├── src
│   ├── Console
│   │   └── Commands
│   │       └──InstallEcommercePackage.php
│   ├── Http
│   │   ├── Controllers
│   │   │   └── ProductController.php
│   │   └── Middleware
│   │       └── CheckCart.php
│   ├── Models
│   │   └── Brand.php
│   │   └── Category.php
│   │   └── Customer.php
│   │   └── OrderItem.php
│   │   └── Product.php
│   │   └── Review.php 
│   ├── Providers
├── ├── EcommerceServiceProvider.php
│   ├── Repositories
│   │   └── ProductRepository.php
│   └── Services
│       └── ProductService.php 
├── .gitignore
├── composer.json
├── LICENSE
├── README.md
└── CODE_OF_CONDUCT.md

数据流图

用例图

数据库设计

安装

要安装包,请使用Composer

composer require jmrashed/ecommerce

安装后,发布包资源

php artisan vendor:publish --provider="Jmrashed\Ecommerce\EcommerceServiceProvider"

运行迁移以设置必要的数据库表

php artisan migrate

配置

发布包资源后,您可以通过编辑位于 config/ecommerce.php 的配置文件来配置包。

return [
    'currency' => 'USD',
    'payment_gateways' => [
        'stripe' => [
            'api_key' => env('STRIPE_API_KEY'),
        ],
        'paypal' => [
            'client_id' => env('PAYPAL_CLIENT_ID'),
            'client_secret' => env('PAYPAL_CLIENT_SECRET'),
        ],
    ],
];

用法

产品管理

要创建新产品,请使用提供的模型和控制器

use Jmrashed\Ecommerce\Models\Product;

$product = new Product();
$product->name = 'Sample Product';
$product->price = 19.99;
$product->description = 'This is a sample product.';
$product->save();

购物车操作

将商品添加到购物车

use Jmrashed\Ecommerce\Facades\Cart;

Cart::add($productId, $quantity);

从购物车检索商品

$items = Cart::content();

结账流程

通过重定向到结账路由来启动结账流程

return redirect()->route('ecommerce.checkout');

通过提供的控制器和路由处理支付和订单处理。

贡献

欢迎贡献!请按照以下步骤进行贡献

  1. 仓库分叉。
  2. 创建一个新的分支(git checkout -b feature/your-feature)。
  3. 提交您的更改(git commit -am 'Add some feature')。
  4. 将更改推送到分支(git push origin feature/your-feature)。
  5. 打开一个拉取请求。

请遵守行为准则

许可

Laravel电子商务工具包是开源软件,受MIT许可证许可。

支持

如果您遇到任何问题或有任何疑问,请随时在GitHub上打开一个问题或联系维护者jmrashed@gmail.com

统计数据

GitHub repo size GitHub issues GitHub stars

感谢您使用Laravel电子商务工具包!我们希望它能帮助您构建出色的电子商务网站。