What I am trying to do is applying discount ONLY to bundled product according to the quantity of the selections it has.My Bundled products have one option, checkbox with multiple simple products and you can choose the quantity of each.So if a customer buys more than ten I want to apply a 25% discount. The idea is get the bundle product,count the individual products,if more than ten apply the discount.
I have an observer for checkout_cart_product_add_after
and with that code I am trying to get the price and change it accordingly:
public function applyDiscount(Varien_Event_Observer $observer) {
/* @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);
Zend_Debug::dump($item->getOriginalPrice());
die('price ');
// Make sure we don't have a negative
if ($specialPrice > 0) {
$item->setCustomPrice ( $specialPrice );
$item->setOriginalCustomPrice ( $specialPrice );
$item->getProduct ()->setIsSuperMode ( true );
}
}
1) The problem is that the price comes with 0.
2) Also even if I manually put a number to $specialPrice
it still doesn't change the cost on the cart.
The product is bundled and the price is dynamic.
Any other idea how to implement that discount that I need is welcome. Thanks