5

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

1 Answer 1

2

You can configure a "shopping cart price rule" for your requirement.

Configure your Rule as follows:

+ Products subselection
  | if total quantity "eqals or greater than" "10" for subselection of items in catr matching "ALL" these conditions
  | {select a productAttribute of your choice which matches the products to give discount on them}

example of configured "shopping cart rule rule

and give discount percent

discount configuration

1
  • Tried but no luck!
    – Yeshu
    Commented Jun 29, 2016 at 20:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.