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 ...