Source of file SubtotalDiscountAction.php
Size: 0,977 Bytes - Last Modified: 2021-12-24T06:35:13+00:00
/var/www/docs.ssmods.com/process/src/src/Actions/SubtotalDiscountAction.php
1234567891011121314151617181920212223242526272829303132333435363738394041424344 | <?php namespace SilverShop\Discounts\Actions; use SilverShop\Discounts\Model\Discount; class SubtotalDiscountAction extends DiscountAction { protected $subtotal; public function __construct($subtotal, Discount $discount) { parent::__construct($discount); $this->subtotal = $subtotal; // for Amount discounts on Subtotals, prevent amount from ever being greater than the Amount $amount = $discount->getAmount(); if ($discount->Type === 'Amount' && $amount > $this->remaining) { $this->remaining = (float) $amount; $this->limited = true; } } public function perform() { $amount = $this->discount->getDiscountValue($this->subtotal); if ($amount > $this->subtotal) { $amount = $this->subtotal; } $amount = $this->limit($amount); return $amount; } public function isForItems() { return false; } } |