public function getPrice($product, $qty = null) { if (ITwebexperts_Payperrentals_Helper_Data::isReservationAndRental($product)) { $selectedAttributes = array(); $isBuyout = false; $configurableParent = null; if ($product->getCustomOption('attributes')) { $selectedAttributes = unserialize($product->getCustomOption('attributes')->getValue()); } if ($product->getCustomOption(ITwebexperts_Payperrentals_Model_Product_Type_Reservation::START_DATE_OPTION)) { $from_date = $product->getCustomOption(ITwebexperts_Payperrentals_Model_Product_Type_Reservation::START_DATE_OPTION)->getValue(); } if ($product->getCustomOption(ITwebexperts_Payperrentals_Model_Product_Type_Reservation::END_DATE_OPTION)) { $to_date = $product->getCustomOption(ITwebexperts_Payperrentals_Model_Product_Type_Reservation::END_DATE_OPTION)->getValue(); } if ($product->getCustomOption(ITwebexperts_Payperrentals_Model_Product_Type_Reservation::BUYOUT_PRICE_OPTION)) { $isBuyout = $product->getCustomOption(ITwebexperts_Payperrentals_Model_Product_Type_Reservation::BUYOUT_PRICE_OPTION)->getValue(); $configurableParent = $product; } if ($product->isConfigurable()) { $product = Mage::getModel('catalog/product_type_configurable')->getProductByAttributes($selectedAttributes, $product); if (is_object($product)) { $product = Mage::getModel('catalog/product')->load($product->getId()); } } $price = 0; if (is_null($qty) || $qty <= 0) { $qty = 1; } if (isset($from_date) && isset($to_date) && is_object($product)) { $customerGroup = $this->_getCustomerGroupId($product); $price = ITwebexperts_Payperrentals_Helper_Price::calculatePrice($product, $from_date, $to_date, $qty, $customerGroup); $product->setData('final_price', $price); } if ($isBuyout) { $priceTemp = ITwebexperts_Payperrentals_Helper_Price::getBuyoutPrice($product, $configurableParent); $product->setData('final_price', $priceTemp); $price = $priceTemp; } return $price; } else { return parent::getPrice($product, $qty); } }
public function getPrice($product) { if ($this->getPriceModel()->isSubscriptionPriceSet($product) && $product->getAwSarpEnabled()) { $priceWithShippingCost = Mage::helper('sarp')->getSarpSubscriptionPrice($product); if ($product->getCustomOption('aw_sarp_subscription_type') && ($typeId = $product->getCustomOption('aw_sarp_subscription_type')->getValue())) { if ($typeId == AW_Sarp_Model_Period::PERIOD_TYPE_NONE) { return parent::getPrice($product); } else { return $priceWithShippingCost; } } elseif ($product->getTypeInstance()->getDefaultSubscriptionPeriodId() != AW_Sarp_Model_Period::PERIOD_TYPE_NONE) { return $priceWithShippingCost; } } else { // Probably category page $_product = Mage::getModel('catalog/product')->load($product->getId()); $priceWithShippingCost = Mage::helper('sarp')->getSarpSubscriptionPrice($_product); if ($_product->getTypeInstance()->requiresSubscriptionOptions($_product)) { if ($priceWithShippingCost) { $price = $priceWithShippingCost; $product->setData('final_price', $price); return $price; } } } return parent::getPrice($product); }