-
- iaps

-
Total Posts: 6
Joined: 2012-09-22
|
Yes, I changed getFinalPrice, which calls _calcProductTeirPricing, slightly so I can base the product price on the overall cart qty:
public function getFinalPrice($qty = null, $product) { if (is_null($qty) && !is_null($product->getCalculatedFinalPrice())) { return $product->getCalculatedFinalPrice(); }
$finalPrice = $this->getBasePrice($product, $qty); $product->setFinalPrice($finalPrice);
Mage::dispatchEvent(\'catalog_product_get_final_price\', array(\'product\' => $product, \'qty\' => $qty));
$finalPrice = $product->getData(\'final_price\');
// if tier prices are defined, also adapt them to configurable products // example: if a shirt is available in red and black and if you buy // three or more the price is eight euro, you can also buy one red and // two black shirts and you will get the tier price of eight euro. // based on https://www.magentocommerce.com/boards/viewthread/10743/ //* if ($product->getTierPriceCount() > 0) { $tierPrice = $this->_calcProductTierPricing($product); if ($tierPrice < $finalPrice) { $finalPrice = $tierPrice; } }//*/ $finalPrice = $this->_applyOptionsPrice($product, $qty, $finalPrice); $finalPrice = max(0, $finalPrice); $product->setFinalPrice($finalPrice); return $finalPrice; }
/** * Get product final price via configurable product\'s tier pricing structure. * Uses qty of parent item to determine price. * * @param Mage_Catalog_Model_Product $product * @return float */ protected function _calcProductTierPricing($product) { // CWS $tierPrice = 0; if ($items = Mage::getSingleton(\'checkout/session\')->getQuote()->getItemsCollection()) { // map mapping the IDs of the parent products with the quantities of the corresponding simple products $qty = 0; foreach ($items as $item) { $qty += $item->getQty(); } return $this->getBasePrice($product, $qty); } return $tierPrice; }
I took that change out of the equation and everything worked! Is there a better way of getting a list of all the products in the cart to determine the total cart qty?
I\’m going to try to get the total cart qty in a different way, instead of iterating through all the cart products..too much overhead it seems.
...
I tried the following, but I\’m still getting the nested function exception:
$qty = 0; $cart = Mage::getModel(\'checkout/cart\')->getQuote()->getData(); if(isset($cart[\'items_qty\'])) $qty = $cart[\'items_qty\']; return $this->getBasePrice($product, $qty);
|