outmart / php-pricing-rules
创建当指定的条件匹配时生效的定价规则。
0.1.0
2022-11-30 17:22 UTC
Requires
- php: >=8.1
Requires (Dev)
- phpunit/phpunit: ^9.5
README
PHP 定价规则
创建当指定的条件匹配时生效的定价规则。
安装
composer require outmart/php-pricing-rules
示例:-
use OutMart\PricingRules\Lay; $lay = new Lay; $lay->setTotal(100); $lay->setShippingMethod('COD'); $lay->setPaymentMethod('PayPal'); $lay->rule(function ($attributes) { if ($attributes['total'] >= 100) { return true; } return false; }, function ($operations) { $total = $operations->getTotal(); $total = $total * 0.9; $operations->setTotal($total); }); return $lay->getTotal(); // 90