0

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?

1 Answer 1

0

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

4
  • 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(). Jun 28, 2018 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? Jun 28, 2018 at 20:06
  • how is the discount applied? using a coupon, or a special price? Jun 28, 2018 at 23:29
  • a special price? Jun 29, 2018 at 21:02

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.