#StackBounty: #magento-1.9 #event-observer #onepage-checkout #msrp Magento 1.9 : Switch Poducts msrp/price in Onepage Checkout

Bounty: 50

I have created a custom module and created an observer method for “sales_quote_collect_totals_before” event. In this method, I check some of the quote data. Based on the current checkout data, I’d like to apply MSRP prices on products that are placed in the cart. Or switch products back to normal prices, if the criteria are not satisfied.

How can I do that?

Here’s a sample of the code:

public function changeQuotePrices(Varien_Event_Observer $observer){
    if (Mage::app()->getRequest()->getModuleName() == 'onepage'){
        $event = $observer->getEvent();
        $quote = $event->getQuote();
        $quoteShippingAddress = $quote->getShippingAddress();
        if (!is_null($quoteShippingAddress->getId())){
            $quoteShippingAddress->collectShippingRates()->save();
            $quoteShippingMethod = $quoteShippingAddress->getShippingMethod();
            if($quoteShippingMethod && $quoteShippingMethod = "payonpickup_payonpickup"){ 
                $cart = Mage::helper('checkout/cart')->getCart()->getQuote()->getAllItems();    
                foreach($cart as $item) {
                    $product = Mage::getModel('catalog/product')->load($item->getProductId()); 
                    $_msrpPrice = Mage::helper('core')->currency($product->getMsrp(),true,true);
                    if($_msrpPrice > 0){
                        /* apply msrp product prices */
                    }
                }
            }else{ 
                /* apply normal product prices */
            }

        }

    }
}


Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.