outmart/php-pricing-rules

Create pricing rules that apply if the specified case matches.

0.1.0 2022-11-30 17:22 UTC

This package is auto-updated.

Last update: 2024-10-29 06:06:51 UTC


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