Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Apply discount when no other discount applied
 
luckyknight
Jr. Member
 
Total Posts:  22
Joined:  2010-09-10
 

I’m trying to create a 20% discount when no other discount gets applied. I can create an array of prices - but the problem I’ve got is that item->getDiscountAmount() returns the total discount for that line item and not __per__ item.

I can’t use tier prices as the discount needs to work on original prices only. Their needs to be a mix and match.

Has anyone got any idea of how to do this? This is really racking my brain!!!

So once this code below was run, I would apply a discount if discount_price was 0.

$prices = array();
        
$items = array();
                    
        foreach (
Mage::getModel('checkout/cart')->getItems() as $item)  {

            $price 
$item->getBasePrice() + ($item->getTaxAmount() / $item->getQty());

            
            for(
$i 0$i $item->getQty(); $i++) {

                $prices[] 
= array(
                    
'price'       => $item->getBasePrice(),
                    
'original_price' => Mage::getModel('catalog/product')->load($item->getProduct_id())->getPrice(),
                    
'discount_price' => $item->getDiscountAmount(),
                    
'id'          => $item->getId(),
                 );
                
                
$items[] $item->getId();
                
            
}

        }
        
        
// sort low to high
        
asort($prices); // indices still match
 
Magento Community Magento Community
Magento Community
Magento Community
 
luckyknight
Jr. Member
 
Total Posts:  22
Joined:  2010-09-10
 

Any idea what no_discount is for on sales_flat_quote_item table? Is it number of discounts?!?

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top