Show error message when adding a product of price 0.
To restrict products having price zero from shopping we need to create a observer on
checkout_cart_product_add_after event such that on every add to cart it will check the
product price and then add to cart.
Create a module and in etc/config.xml define the observer under event node.
Here Our module name is zeroprice under Letsknowit namespace.
File path : app/code/local/Letsknowit/zeroprice/etc/config.xml
singleton
zeroprice/observer
checkProductPrice
Now in Model folder we need to create observer with function name checkProductPrice.
File path : app/code/local/Letsknowit/zeroprice/Model/Observer.php
Class Letsknowit_Zeroprice_Model_Observer {
public function checkProductPrice(Varien_Event_Observer $observer) {
if ($observer->getProduct()->getFinalPrice() == 0) {
Mage::getSingleton('core/session')->addError('Sorry, you cannot purchase "'.$observer->getProduct()->getName().'" product.Write to us if any query!'));
$url = Mage::getModel('core/url')->getUrl('checkout/cart/index');
Mage::app()->getResponse()->setRedirect($url);
Mage::app()->getResponse()->sendResponse();
exit();
}
}
}
?>
Thank you for helping people get the information they need. Great stuff as usual. Keep up the great work!!! movers dubai
Master the world of cryptocurrency with CRYPTO30X! Our simplified reports and analysis keep you updated on Bitcoin, Ethereum, and beyond. Explore the metaverse and unravel digital tokens with our user-friendly content.Crypto30x Coinbase
The mechanical Turning Carbide Inserts clamping type avoids Vargus Inserts the influence and limitation of the welding process, facilitates the selection of inserts of various materials according to the processing object, and fully exerts its cutting performance, thereby improving the cutting carbide Insert efficiency.
It is a fantastic post – immense clear and easy to understand. I am also holding out for the sharks too that made me laugh.SaaS Law Firm
Thanks for taking the time to share this with us. brick mason near me
Thanks for taking the time to discuss this, I feel strongly about it and love learning more on this topic. If possible, as you gain expertise, would you mind updating your blog with more information? It is extremely helpful for me. 안전놀이터 추천
Awesome blog. I enjoyed reading your articles. This is truly a great read for me. I have bookmarked it and I am looking forward to reading new articles. Keep up the good work 다시보기 사이트
I really like your writing style, great information, thankyou for posting.roof damage
Many game modes, many maps, many cars to choose from.Drift Hunters Playing is never boring.
Revitalize your appearance with Ultherapy®! This FDA-approved non-surgical facelift utilizes microfocused ultrasound to stimulate collagen production deep within the skin. Enjoy a lifting effect that lasts up to 2 years without scalpels or needles. With Ultherapy®'s precise ultrasound probe, treatment is targeted and effective, revealing firmer, smoother skin.Ultrasuoni microfocalizzati Milano
This is a brilliant blog! I'm very happy with the comments!..ftmç
Great content material and great layout. Your website deserves all of the positive feedback it’s been getting.ae888top
You completed a few fine points there. I did a search on the subject and found nearly all persons will go along with with your blog. gaming vpn
This is the type of information I’ve long been trying to find. Thank you for writing this information.ae888city
Impressive web site, Distinguished feedback that I can tackle. Im moving forward and may apply to my current job as a pet sitter, which is very enjoyable, but I need to additional expand. Regards.https://188.166.232.208/
Please rotate your device
We don't support landscape mode on your device. Please rotate to portrait mode for the best view of our site