Source of file LineItemExtension.php
Size: 0,923 Bytes - Last Modified: 2021-12-23T10:24:29+00:00
/var/www/docs.ssmods.com/process/src/src/extensions/LineItemExtension.php
123456789101112131415161718192021222324252627282930313233343536373839 | <?php namespace SilverCommerce\Discounts\Extensions; use SilverStripe\ORM\DataExtension; use SilverCommerce\Discounts\Model\AppliedDiscount; class LineItemExtension extends DataExtension { private static $belongs_many_many = [ 'Discounts' => AppliedDiscount::class ]; /** * Get the amount of tax for a single unit of this item * * @return float */ public function updateUnitTax(&$total) { $percent = $this->getOwner()->TaxPercentage; $price = $this->getOwner()->UnitPrice; $total = (($price - $this->getDiscountTotal()) / 100) * $percent; return $total; } public function getDiscountTotal() { $parent = $this->getOwner()->Parent(); $total = $parent->getDiscountTotal(); $count = $parent->getTotalItems(); if ($count > 0) { return $total/$count; } return 0; } } |