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.
Related
we want a discount to be applied when user add to cart 10 M size t-shirts, 10 L size t-shirts and 5 XL size t-shirts (same product) - so total quantity is 25. & we want to give discount only for the product whose quality is 25 or greater?
You can try to create "Shopping Cart Price Rule" with condition on "Quantity in Cart". Does it help you?
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
}
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 does custom options price calculation work for a fixed and percent price?
I want to change percent calculation functionality from base price to total price.
Currently it's calculating price from base price.
How to change this from base price to total price?
For example:
base price = $10
custom option1 = $10
custom option2 = 10%
default Magento calculation:
Total price = Base price + selected custom option1 + selected custom option.
Total price = $10+$10+ 10% of $10(baseprice) = $21.
But we need this Total price after selecting the custom option:
Total price = $10+$10 = $20.
Total price after select custom option2
Total price = $20 + (10% of Total price)
Total price = $20 + (10% of $20).
Total price = $20 + $2 = $22.
I need to calculate the percentage from the total price, not from the base price. Please advise.
This is done in
Mage_Catalog_Model_Product_Type_Price::_applyOptionsPrice
If this applies only to special products, you might want to create an own product type with a customer price handler.
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;
}