moirei / laravel-pricing
轻松管理复杂的定价。
1.2.5
2023-07-20 14:27 UTC
Requires
- php: ^7.2|^8.0
- illuminate/database: ^7|^8|^9|^10
- laravel/helpers: ^1.5
Requires (Dev)
- orchestra/testbench: ^7.5
- pestphp/pest: ^1.21
- pestphp/pest-plugin-laravel: ^1.2
- thled/pest-plugin-shorthands: ^1.1
README
为您的eloquent模型管理复杂的定价。
在前端或Node.js中使用,请查看 moirei/complex-pricing。
文档
所有文档均可在文档网站找到。
示例
... $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
安装
composer require moirei/laravel-pricing
概念
在大型应用中,提供的商品或服务的定价通常并不直接。例如,您可能希望每在AU购买5个单位的产品时,对该产品收取10美元的费用,同时,对于您的美国客户,对0-30、31-40、50-无穷大区间的数量分别递减地收取50美元、40美元、30美元。
此包包含标准
、套餐
、批量
和阶梯
定价的概念,旨在覆盖大多数(如果不是全部)复杂的定价场景。它还允许命名多货币和多区域用例。
更新日志
请参阅更新日志。
致谢
测试
composer run test
许可证
MIT许可证(MIT)。有关更多信息,请参阅许可证文件。