I need help to obtain the following data of the shopping cart products:

  • First name
  • Sku
  • quantity in the cart
  • final price (after the discount)

I have the following code to obtain that data:

Mage::getSingleton("core/session", array("name" => "frontend"));
$cart = Mage::getSingleton('checkout/session')->getQuote();
foreach ($cart->getAllItems() as $item) {
    $productName = $item->getProduct()->getName();
    $productPrice = $item->getProduct()->getPrice();
    $productSku = $item->getProduct()->getSku();
    $productQty = $item->getQty();
    $productFinalPrice = $item->getProduct()->getFinalPrice();
    $productAmountDiscount = $item->getProduct()->getDiscountAmount();

but when I try this code the final price and the discount returns them as null values How can I get that data with that model?


discountAmount is not a product attribute. Try $item->getDiscountAmount() instead.

| improve this answer | |
  • I already try that and only get 0.00 as answer. Also i tried $item->getFinalPrice() and $item->getProduct()->getFinalPrice() , but get the same price as $item->getProduct()->getPrice(). – José Alan Luna Carreón Jun 28 '18 at 20:05
  • I know that the products in the store have a discount, because after that price there is one less at the checkout. How can I get it? – José Alan Luna Carreón Jun 28 '18 at 20:06
  • how is the discount applied? using a coupon, or a special price? – subroutines Jun 28 '18 at 23:29
  • a special price? – José Alan Luna Carreón Jun 29 '18 at 21:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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