how to show individual discount applied while chackout? - magento

I have applied shopping cart rules in my magento store successfully, but in cart when total is calculated it shows directly total discount.
It doesn't show individual discount price applied to which product.
How to show individual discount to let customer know that on which product I got discount?

To get the individual discount amount for each product while checkout, you can do as below :
$quote = Mage::getSingleton('checkout/session')->getQuote();
foreach ($quote->getAllItems() as $item){
$discount = $item->getDiscountAmount();
// $discount is the discount amount for the individual item
}

Related

Display the product price without tax and tax of single product in Magento

I would like to display the product price without tax and the tax amount of a single product from a order in Magento.
I have the item already loaded:
$qty =$item->getData('qty_ordered');
$sku =$item->getSku();
$name =$item->getName();
$tax =$item->getTaxAmount()/$qty;
$price_incl_tax =$item->getPriceInclTax();
$price_excl_tax =$price_incl_tax-$tax;
This is working but I don't think this is a good solution. Is there a easier way without calculating the price in PHP by myself?
Thanks in advance!
Edit: I need this:
$_product = $item->getProduct();
$finalPriceExcludingTax =
Mage::helper('tax') ->getPrice($_product, $_product->getFinalPrice(), false );
usable on ordered items, with the price the customers has payed.
try to use tax helper:
$_product = $item->getProduct()
$finalPriceExcludingTax = $this->helper('tax')
->getPrice($_product, $_product->getFinalPrice(), false );

Getting list of all applied discounts in magento cart

I am writing am extension for my magento shop which basically gives 5% discount to all newsletter subscribed customers. the extension is working but now problem is it doesn't show the promotion code discounts entered by customers.
I am using this code to get discount:
$address->setDiscountAmount($total - $discountAmount);
$address->setDiscountDescription("5% Discounted Subtotal");
$address->setBaseDiscountAmount($total - $discountAmount);
I was wondering if there is any magento method or functions which gets an array of all applied discounts for the cart.
Or if anyone can tell me where can i find list of all the available functions in magento.
To get total discount for all the items in the cart, you can try this,
$quote2 = Mage::getSingleton('checkout/session')->getQuote();
$discountTotal = 0;
foreach ($quote2->getAllItems() as $item){
$discountTotal += $item->getDiscountAmount();
}

magento i need to apply discount 20% for the total if above 50euros but not to the discounted items

magento i need to apply discount 20% for the total if above 50euros but not to the discounted items if customers selects some already discounted items that should not include in the total can any one help
Thanks in advance
You need to create a custom module or say shopping cart price rule and an event observer to check whether the "special price" is zero or not. If it is "Zero" that means it is not a already discounted product or you can even check the "final price" with the "price" , if the final price is lesser than price it is already discounted.
If these conditions are satisfied get the prices of remaining products prices and discount them then add the already discounted products price to make the total amount.
I hope You understood this concept and write your own module.
you have to use a check in view page.
for example
$price = $product->getPrice();
$specialprice = $product->getFinalPrice();
if(!empty($specialprice)){
//then your price would be same
}
elseif(empty($specialprice)){
then price would be = $price*20/100;
}
hope this would help you and don't forget to like if it was helpful

How to get discount applied on cart line item individually?

How can I get the discount applied on cart line item individually?
Is this possible to get total unit price after applying discount?
To discount applied on cart line item you can use
$item->getDiscountAmount();
To calculate the price subtracting the discount amount $item->getDiscountAmount(), use below
$price = $item->getPrice() - $item->getDiscountAmount();
This will give you the total unit price after discount.

How to access to the discount price in Magento?

I'm trying to rewrite a template for the cart.
I need to retrieve the discount amount but I was not able to find where.
Ie If my coupon code gives me $10 discount I want to retrieve 10, if I have a discount of 5% I want to retrieve 5 if the total price is $100.
Thank you.
you can debug your object by printing it out and observing what values it contains
print_r($this->getQuote()->getData());
I used the following code to access discount price. I was accessing the details of last order in a phtml file. For the last order if there was a discount coupon used then I used following code to access the Discount Amount.
$lastOrderId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
$order=Mage::getModel('sales/order')->loadByIncrementID($lastOrderId);
if($lastOrderId) //If order was placed then only display coupon code
{
$coupon=$order->getCouponCode();
echo "<b>Discount coupon used during order:</b>".$coupon;
$disAmount=$order->getDiscountAmount();
echo "<br/>Discount Amount: ".$disAmount;
}

Resources