/** * @param \Magento\Framework\Pricing\SaleableInterface $product * @return float */ public function resolvePrice(\Magento\Framework\Pricing\SaleableInterface $product) { $selectedConfigurableOption = $product->getSelectedConfigurableOption(); if ($selectedConfigurableOption) { $price = $this->priceResolver->resolvePrice($selectedConfigurableOption); } else { $price = null; foreach ($this->configurable->getUsedProducts($product) as $subProduct) { $productPrice = $this->priceResolver->resolvePrice($subProduct); $price = $price ? min($price, $productPrice) : $productPrice; } } $priceInCurrentCurrency = $this->priceCurrency->convertAndRound($price); return $priceInCurrentCurrency ? (double) $priceInCurrentCurrency : false; }
/** * Get value from array * * @param array $value * @param string $priceCode * @return float */ protected function getPricingValue(array $value, $priceCode) { if ($value['is_percent'] && !empty($value['pricing_value'])) { return $this->preparePrice($value, $priceCode); } else { return $this->priceCurrency->convertAndRound($value['pricing_value']); } }
/** * @param float $amount * @param null|bool|string $exclude * @param null|array $context * @return AmountInterface|bool|float */ public function getCustomAmount($amount = null, $exclude = null, $context = []) { if (null !== $amount) { $amount = $this->priceCurrency->convertAndRound($amount); } else { $amount = $this->getValue(); } return $this->calculator->getAmount($amount, $this->getProduct(), $exclude, $context); }
/** * @param int|Product $product * @return bool|float */ public function isMinimalPriceLessMsrp($product) { if (is_numeric($product)) { $product = $this->productRepository->getById($product, false, $this->storeManager->getStore()->getId()); } $msrp = $product->getMsrp(); $price = $product->getPriceInfo()->getPrice(\Magento\Catalog\Pricing\Price\FinalPrice::PRICE_CODE); if ($msrp === null) { if ($product->getTypeId() !== \Magento\GroupedProduct\Model\Product\Type\Grouped::TYPE_CODE) { return false; } else { $msrp = $product->getTypeInstance()->getChildrenMsrp($product); } } if ($msrp) { $msrp = $this->priceCurrency->convertAndRound($msrp); } return $msrp > $price->getValue(); }
/** * Obtain amount * * @param SaleableInterface $saleableItem * @return float */ protected function getAmount(SaleableInterface $saleableItem) { $weeeAmount = $this->weeeHelper->getAmount($saleableItem); $weeeAmount = $this->priceCurrency->convertAndRound($weeeAmount); return $weeeAmount; }