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();
}
}
}
?>
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
I found your this post while searching for some related information on blog search...Its a good post..keep posting and update the information.https://vnwin79.com/
Keep up the good work , I read few posts on this web site and I conceive that your blog is very interesting and has sets of fantastic information. xo88
Elevate your Gangnam visit with our massage recommendation guide. Uncover diverse options for your well-being and reserve your preferred treatment. Enjoy a seamless experience in the heart of Gangnam's vibrant scene.다오안마
TrustShield Oasis, an oasis of trust in the Toto world. Our 2023 members cherish the commitment to security, making it a recommended choice. Revel in the excitement of betting, knowing that your safety is our top priority..토토사이트 추천
Your work is truly appreciated round the clock and the globe. It is incredibly a comprehensive and helpful blog. Structured Network Cabling Services
A very excellent blog post. I am thankful for your blog post. I have found a lot of approaches after visiting your post.thiên đường trò chơi
Delight your taste buds and mind with Psilocybin Chocolate in Australia. Experience the magic in every bite as you indulge in the rich flavors of our premium chocolate infused with psychedelic properties. Shipped discreetly for a seamless experience..magic mushroom kit australia
Jewelgalore is your premier destination for online Pakistani jewelry . Explore their exquisite collection and adorn yourself with intricately designed pieces that reflect the cultural richness and artistry of Pakistan.
Shalamar Hospital is your destination for top neurological care in Lahore, with the best neurologist in Lahore providing expert consultations and treatments.
Osh University and national state university are committed to shaping the future of medical professionals in Kyrgyzstan. Their partnership provides an excellent platform for students to excel in the healthcare field.
Discover unique and elegant velvet kaftan designs by Ammara Khan. Browse our collection of Pakistani velvet dresses and velvet kaftans for a truly luxurious and stylish look.
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