outmart / php-pricing-rules
Create pricing rules that apply if the specified case matches.
0.1.0
2022-11-30 17:22 UTC
Requires
- php: >=8.1
Requires (Dev)
- phpunit/phpunit: ^9.5
README
PHP Pricing Rules
Create pricing rules that apply if the specified case matches.
Install
composer require outmart/php-pricing-rules
Example:-
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