moirei/laravel-pricing
Composer 安装命令:
composer require moirei/laravel-pricing
包简介
Easily manage complex pricing.
关键字:
README 文档
README
Manage complex pricing for your eloquent models.
To use in frontend or Node.js, checkout moirei/complex-pricing.
Documentation
All documentation is available at the documentation site.
Example
... $product = Product::find(1); $product->pricing([ 'model' => 'volume', 'tiers' => [ [ 'max' => 5, 'unit_amount' => 3.6, ], [ 'max' => 10, 'unit_amount' => 3.3, ], [ 'max' => 'infinity', // or `-1` 'unit_amount' => 3.1, 'flat_amount' => 1.2, ], ] ], ]); $price = $product->price; // price for 1 item $price = $product->price(4); // price = 4 x 3.6 = 14.4 $price = $product->price(7); // price = 7 x 3.3 = 23.1 $price = $product->price(15); // price = (15 x 3.1) + 1.2 = 47.7
Installation
composer require moirei/laravel-pricing
Concept
In large applications, pricing for provided goods or service are often not straight forward. For instance, you might want to charge $10 on an item for every 5 units purchased in AU, while at the same time, for your customers in US, regressively charge $50, $40, $30 for every quantity ranged between 0-30, 31-40, 50-infinity respectively.
This package has the concept of standard, package, volume, and graduated pricing intended to cover most (if not all) complex pricing scenarios. It also allows naming for multi-currency and multi-region use cases.
Changelog
Please see CHANGELOG.
Credits
Tests
composer run test
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 713
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 10
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-06-16