0

I am set custom price for all product and its like a charm but when product as contain custom option is not update my custom price i don't know what is problem with my code.

1

For event you need to define similar to this code in config.xml file of your extension.

<frontend>
  <events>
    <add_to_cart_after>
                <observers>
                    <add_to_cart_after>
                        <class>[Your Obeserver Path]</class>
                        <method>[Your Observer Method Name]</method>
                    </add_to_cart_after>
                </observers>
            </add_to_cart_after>
    </events>
</frontend>

In observer you can do something like this :

$quoteData = Mage::getSingleton('checkout/session')->getQuote()->getAllItems();
   foreach ($quoteData as $quote_item) 
   {       
       $quote_item->setCustomPrice($price);
       $quote_item->setOriginalCustomPrice($price);
       $quote_item->getProduct()->setIsSuperMode(true);
       $quote_item->save();
  }
| improve this answer | |
0

Both Custom options and Custom price cannot work at a time. When any product has custom option, price is calculated based on options selection. So you need to modify your code according to this Magento structure. Try below code when you write custom code:

$quote = Mage::getSingleton('checkout/session')->getQuote()->getAllItems();
   foreach ($quote as $quoteItem) 
   {       
       $quoteItem->setCustomPrice($price);
     $quoteItem->setOriginalCustomPrice($price);
     $quoteItem->getProduct()->setIsSuperMode(true);
     $quoteItem->save();
  }
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.