priceIsPercent()) { return $price; } return Money::inDefaultCurrency($price); } public function priceIsPercent() { return $this->price_type === 'percent'; } public function priceIsFixed() { return $this->price_type === 'fixed'; } public function priceForProduct(Product $product) { if ($this->priceIsFixed()) { return $this->price; } return $this->getPercentOf($product->selling_price->amount()); } private function getPercentOf($productPrice) { return Money::inDefaultCurrency(($this->price / 100) * $productPrice); } public function formattedPriceForProduct(Product $product, $forSelectOption = false) { $price = $this->priceForProduct($product); if ($price->isZero()) { return; } $formattedPrice = $price->convertToCurrentCurrency()->format(); if ($forSelectOption) { return "+ {$formattedPrice}"; } return "+ {$formattedPrice}"; } }