chuckbe/chuckcms-module-ecommerce
Composer 安装命令:
composer require chuckbe/chuckcms-module-ecommerce
包简介
E-commerce module for use in ChuckCMS
README 文档
README
Extend ChuckCMS with ecommerce
Add this package as a module to your ChuckCMS installation to add ecommerce functionality. The package requires ChuckCMS and a functioning ecommerce template (look into chuckbe/chuckcms-template-london).
How to install?
Use Composer to install
composer require chuckbe/chuckcms-module-ecommerce
Publish assets
php artisan vendor:publish --tag=chuckcms-module-ecommerce-public --force
Publish config files
php artisan vendor:publish --tag=chuckcms-module-ecommerce-config --force
In the published file config/chuckcms-module-ecommerce.php you can change business details, language and currency settings among other general configuration.
Add the module to ChuckCMS
Use the following command to publish the module to ChuckCMS. You can use the same command to update an existing installation but be aware that all your settings will be overriden.
php artisan chuckcms-module-ecommerce:install
Installing the ecommerce module will conflict with your current users' role. Go to the DB and navigate to the 'model_has_roles' table. Change all the 'model_type' values into
Chuckbe\ChuckcmsModuleEcommerce\Models\User
For the authentication to be working you need to update the
config/chuckcms.php. Change all the controllers' namespace fromChuckbe\Chuckcms\...intoChuckbe\ChuckcmsModuleEcommerce\....
Migrate tables
php artisan migrate
List
- Add Mollie webhook URL to excepted on VerifyCsrfToken
Interfaces
ChuckCart
This facade controls everything related to the cart functionality:
- Cart
- CartItems
- CartItemDiscount
- CartItemExtras
- CartItemOptions
Cart
A cart can contain items and discounts, these are stored in the session and can be stored in the database using the appropriate methods.
Methods
CartItem
A cart item can have options, extras, and discounts besides the given attributes.
Attributes
$cartItem->rowId
Returns the unique identifier.
$cartItem->id
Returns the given id (non-unique).
$cartItem->name
Returns the given name.
$cartItem->qty
Returns the quantity.
$cartItem->price
Returns the price including or excluding tax (settings dependent) without discounts.
$cartItem->tax
Returns the final tax for the whole item.
$cartItem->_discount
Returns the discount value for the total price.
$cartItem->total
Returns the subtotal * unit price.
$cartItem->options
Returns the given options (selected attributes) of the item.
$cartItem->extras
Returns the given extras of the item.
$cartItem->discounts
Returns a collection of CartItemDiscount linked to the item.
-
$cartItem->model -
$cartItem->taxRate
Returns the given model of the item or null.
$cartItem->isSaved
Example of calculation:
// NEW CART ITEM
// TAXED = TRUE
// UNIT BASE = 4.00 = $ITEM->PRICE
// TAXRATE = 21 = $ITEM->TAXRATE
// UNIT EXTRAS = 2.12 = $ITEM->EXTRAS->TOTAL
// UNIT RAW = 6.120000 = UNIT BASE + UNIT EXTRAS
// UNIT = 6.12 = round(UNIT RAW)
// QTY = 6 = $ITEM->QTY
// TOTAL BASE = 24.00 = QTY * UNIT BASE
// TOTAL EXTRAS = 12.72 = QTY * UNIT EXTRAS
// TOTAL RAW = 36.720000 = QTY * UNIT RAW
// TOTAL = 36.72 = QTY * UNIT
// DISCOUNT BASE = 2.400 = calculateDiscount(TOTAL BASE)
// DISCOUNT EXTRAS = 1.272 = calculateDiscount(TOTAL EXTRAS)
// DISCOUNT RAW = 3.672 = calculateDiscount(TOTAL RAW)
// DISCOUNT = 3.67 = round(calculateDiscount(TOTAL))
// FINAL BASE = 21.60 = round(TOTAL BASE - DISCOUNT BASE)
// FINAL EXTRAS = 11.45 = round(TOTAL EXTRAS - DISCOUNT EXTRAS)
// FINAL RAW = 33.048 = TOTAL RAW - DISCOUNT RAW
// FINAL = 33.05 = round(TOTAL RAW - DISCOUNT RAW)
// TAX BASE = 3.75 = round( TAX BASE RAW )
// TAX BASE RAW = 3.74876033 = ((TOTAL BASE - DISCOUNT BASE) / (100 + TAXRATE)) * TAXRATE
// TAX EXTRAS = 0.65 = round( TAX EXTRAS RAW )
// TAX EXTRAS RAW = 0.65026415 = ((TOTAL EXTRAS - DISCOUNT EXTRAS) / (100 + TAXRATE)) * TAXRATE
// TAX RAW = 4.40 = TAX BASE RAW + TAX EXTRAS RAW
// TAX = 4.40 = round(TAX RAW)
// TAX RATES = [21, 6] = taxRates()
// TAX FOR RATE[21] = 3.75 = taxForRate(21)
// TAX FOR RATE[6] = 0.65 = taxForRate(6)
chuckbe/chuckcms-module-ecommerce 适用场景与选型建议
chuckbe/chuckcms-module-ecommerce 是一款 基于 Blade 开发的 Composer 扩展包,目前已累计 198 次下载、GitHub Stars 达 1, 最近一次更新时间为 2020 年 05 月 24 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「cms」 「laravel」 「chuckbe」 「chuckcms」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 chuckbe/chuckcms-module-ecommerce 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 chuckbe/chuckcms-module-ecommerce 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 chuckbe/chuckcms-module-ecommerce 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
GraphQL authentication for your headless Craft CMS applications.
Set Links with a specific language parameter
Supercharged text field validation.
Integrate with Snipcart.
Follow, Favourite, Bookmark, Like & Subscribe.
Alfabank REST API integration
统计信息
- 总下载量: 198
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2020-05-24