Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?xml version="1.0"?>
- <config>
- <modules>
- <TimgMage_CustomAddToCart>
- <version>0.0.1</version>
- </TimgMage_CustomAddToCart>
- </modules>
- <global>
- <models>
- <TimgMage_CustomAddToCart>
- <class>TimgMage_CustomAddToCart_Model</class>
- </TimgMage_CustomAddToCart>
- </models>
- <events>
- <!-- START: Add to cart actions -->
- <checkout_cart_product_add_after>
- <observers>
- <timgmage_customaddtocart_model_observer>
- <class>TimgMage_CustomAddToCart_Model_Observer</class>
- <method>checkoutCartProductAddAfter</method>
- <type>singleton</type>
- </timgmage_customaddtocart_model_observer>
- </observers>
- </checkout_cart_product_add_after>
- </events>
- </global>
- </config>
- <?php
- class TimgMage_CustomAddToCart_Model_Observer
- {
- public function checkoutCartProductAddAfter(Varien_Event_Observer $observer) {
- Mage::log('Entered to checkoutCartProductAddAfter.', null, 'timgmage.log');
- /* @var $item Mage_Sales_Model_Quote_Item */
- $item = $observer->getQuoteItem();
- if ($item->getParentItem()) {
- $item = $item->getParentItem();
- }
- // Discounted 25% off
- $percentDiscount = 0.25;
- // This makes sure the discount isn't applied over and over when refreshing
- $specialPrice = $item->getOriginalPrice() - ($item->getOriginalPrice() * $percentDiscount);
- // Make sure we don't have a negative
- if ($specialPrice > 0) {
- $item->setCustomPrice($specialPrice);
- $item->setOriginalCustomPrice($specialPrice);
- $item->getProduct()->setIsSuperMode(true);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement