public function generate(IsotopeProduct $objProduct, array $arrOptions = array()) { $arrData = deserialize($objProduct->{$this->field_name}); if (is_array($arrData) && $arrData['unit'] > 0 && $arrData['value'] != '') { $objBasePrice = \Isotope\Model\BasePrice::findByPk((int) $arrData['unit']); if (null !== $objBasePrice && null !== $objProduct->getPrice()) { return sprintf($objBasePrice->getLabel(), Isotope::formatPriceWithCurrency($objProduct->getPrice()->getAmount() / $arrData['value'] * $objBasePrice->amount), $arrData['value']); } } return ''; }
public function generate(IsotopeProduct $objProduct, array $arrOptions = array()) { $objPrice = $objProduct->getPrice(); if (null === $objPrice) { return ''; } return $objPrice->generate($objProduct->getRelated('type')->showPriceTiers()); }
public function generate(IsotopeProduct $objProduct, array $arrOptions = array()) { $objPrice = $objProduct->getPrice(); if (null === $objPrice || !$objPrice->hasTiers()) { return ''; } $arrTiers = array(); foreach ($objPrice->current()->getTiers() as $min => $price) { $arrTiers[] = array('min' => $min, 'price' => $price, 'tax_class' => $objPrice->tax_class); } $order = $arrOptions['order']; if ($order != '' && in_array($order, array_keys($arrTiers[0]))) { usort($arrTiers, function ($a, $b) use($order) { return strcmp($a[$order], $b[$order]); }); } return $this->generateTable($arrTiers, $objProduct); }
/** * Return calculated price for this attribute option * * @param IsotopeProduct $objProduct * * @return float * * @deprecated Deprecated since Isotope 2.2.6, to be removed in 3.0. * This method can result in an endless loop, use getAmount() instead. */ public function getPrice(IsotopeProduct $objProduct = null) { if ($this->isPercentage() && null !== $objProduct) { /** @type ProductPrice|ProductPrice[] $objPrice */ $objPrice = $objProduct->getPrice(); if (null !== $objPrice) { if ($objPrice instanceof ProductPriceCollection) { $fltPrice = null; foreach ($objPrice as $objPriceModel) { $fltAmount = $objPriceModel->getAmount(); if (null === $fltPrice || $fltAmount < $fltPrice) { $fltPrice = $fltAmount; } } } else { $fltPrice = $objPrice->getAmount(); } return $fltPrice / 100 * $this->getPercentage(); } } else { /** @type ProductPrice|ProductPrice[] $objPrice */ if (null !== $objProduct && ($objPrice = $objProduct->getPrice()) !== null) { return Isotope::calculatePrice($this->price, $this, 'price', $objPrice->tax_class); } else { return Isotope::calculatePrice($this->price, $this, 'price'); } } return $this->price; }