I have 5 with same product id.

I want to set first 4 item price as 9.99 and 5th item onwards will have of 20% discount on original price.

I have set first 4 items as club_item and 5th product onwards as other product(using my custom table).

If I add only 4 items, then all the 4 product's price is showing correctly as 9.99;

But when I add all 5 items, then all the 5 items price is changing and it is the price of last item added. Means all items are showing price = (actual_productprice - 20% discount).

How can I show different price for only 5th Item.

I have below event


And my observer function is :-

    public function updatePrice($observer)
        $event = $observer->getEvent();
        $product = $event->getProduct();
        $quote_item = $event->getQuoteItem();

        $productId = $quote_item->getProductId();

        if(Mage::getSingleton('customer/session')->isLoggedIn()) {
             $customerData = Mage::getSingleton('customer/session')->getCustomer();
              $customer_id = $customerData->getId();

        $_customModel = Mage::getModel('custom/custom')->getCollection()
                ->addFieldToFilter('product_id', array('eq'=>$productId))
                ->addFieldToFilter('customer_id', array('eq'=>$customer_id));

        $_customData = $_customModel->getData();

        $actualPrice = $quote_item->getProduct()->getFinalPrice();

        /* this is for separating each line item in cart */
              "code" => "random",
              "value" => serialize(array(time()))

        $new_price = 0; 
        foreach ($_customData as $_customDataValue) {
            $_isClubProductId   = $_customDataValue['product_id'];
            $_isClubItem        = $_customDataValue['is_club_item'];

            /* Here I am differentiting the products with variable $_isClubItem */

            if($productId == $_isClubProductId && $_isClubItem == 1){
                $customPrice = 9.99;
                $new_price = round($customPrice, 4);
                $new_price = (float)number_format($actualPrice * ((100-20) / 100),2);



1 Answer 1


I think you can do this with a shopping cart price rule. You can set the Requirements as minimum quantity in cart of 4, and apply a 20% discount on the products. The price rule will be only applied on the fifth product, and onwards.

  • Actually I am creating cart programatically.
    – Nitz
    Mar 8, 2017 at 14:12

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.