Magento Get shopping Cart Product quantity and Price program code _php Tutorial

Source: Internet
Author: User
This article to give you the use of Magento friends to introduce how to get the shopping cart product quantity and price and display, below I will give you the students detailed introduction.

Get all the product information of the shopping cart

The code is as follows Copy Code

$items = Mage::getmodel (' Checkout/cart ')->getquote ()->getallitems ();
$items = Mage::getsingleton (' checkout/session ')->getquote ()->getallitems (); foreach ($items as $item) {
Echo ' ID: '. $item->getproductid (). '
';
Echo ' Name: '. $item->getname (). '
';
Echo ' Sku: '. $item->getsku (). '
';
Echo ' Quantity: '. $item->getqty (). '
';
Echo ' Price: '. $item->getprice (). '
';
echo "
";
}

Of course, you can also quickly get the current user of all the item number and the number of products! Here is a quick function of Magento!

The code is as follows Copy Code

$totalItems = Mage::getmodel (' Checkout/cart ')->getquote ()->getitemscount ();
$totalQuantity = Mage::getmodel (' Checkout/cart ')->getquote ()->getitemsqty ();

Here's how to get subtotal price and grand price

The code is as follows Copy Code

$subTotal = Mage::getmodel (' Checkout/cart ')->getquote ()->getsubtotal ();
$grandTotal = Mage::getmodel (' Checkout/cart ')->getquote ()->getgrandtotal ()

So you can quickly get the details of the current shopping cart, easy to manipulate the data, display the shopping cart information!!

Generally used in the upper right corner of the shopping cart information mostly, or Ajax shopping cart!

http://www.bkjia.com/PHPjc/631526.html www.bkjia.com true http://www.bkjia.com/PHPjc/631526.html techarticle This article to give you the use of Magento friends to introduce how to get the shopping cart product quantity and price and display, below I will give you the students detailed introduction. Get all the shopping cart products ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.