| Total Complexity | 8 |
| Total Lines | 46 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 8 | class ProductDataExtension extends DataExtension |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * @var array |
||
| 12 | */ |
||
| 13 | private static $belongs_many_many = [ |
||
|
|
|||
| 14 | 'Discounts' => Discount::class, |
||
| 15 | ]; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * @return bool|float|int|mixed |
||
| 19 | */ |
||
| 20 | public function getDiscountPrice() |
||
| 21 | { |
||
| 22 | if ($discount = $this->getActiveDiscount()) { |
||
| 23 | $price = $this->owner->Price - ($this->owner->Price * ($this->getActiveDiscount()->Percentage / 100)); |
||
| 24 | return $price; |
||
| 25 | } |
||
| 26 | return false; |
||
| 27 | } |
||
| 28 | |||
| 29 | /** |
||
| 30 | * @return mixed |
||
| 31 | */ |
||
| 32 | public function getActiveDiscount() |
||
| 54 | } |
||
| 55 | } |
||
| 56 |