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();
}
}
}
?>
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 continue this great work and I look forward to more of your awesome blog posts. ac supplier
i am always looking for some free stuffs over the internet. there are also some companies which gives free samples.sesso fetale
Excellent post. I was always checking this blog, and I’m impressed! Extremely useful info specially the last part, I care for such information a lot. I was exploring this particular info for a long time. Thanks to this blog my exploration has ended. earth tone finishes
Keukenpunt is your pathway to a beautiful, affordable kitchen. Our personalized approach ensures your kitchen becomes the central hub of your home. Quality and service are our hallmarks, making us the best choice for your new kitchen. Discover the joy of cooking with us. Leeuwarden keukens
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