public function getPrice($product) { $product->load($product->getId()); // Mage::log($product->debug(), null, 'test.log'); $data = $product->getData(); $total = $this->getCartTotal(); # Fixed price $price = (double) parent::getPrice($product); # Percent price if ($price_percent = $data['cartproducts_price_percent']) { $price_percent = $total * (double) $price_percent / 100; } # Range price if ($price_range = $data['cartproducts_price_range']) { $range = explode(',', $price_range); foreach ($range as $pair) { $pair = explode('=', $pair); if ($total <= $pair[0]) { return $price_range = (double) $pair[1]; } } } $price = max($price, $price_percent); return $price; }
public function testGetPrice() { $this->assertEquals('test', $this->_model->getPrice(new Varien_Object(array('price' => 'test')))); }
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); }