Magento obtains the number and price code of the shopping cart product. This article will show you how to get the quantity and price of the shopping cart products and how to use Magento. I will give you a detailed introduction below. This article will show you how to get the quantity and price of all products in the shopping cart and show them to anyone who uses Magento. next I will give you a detailed introduction.
Obtain information about all products in the shopping cart.
The code is as follows: |
|
// $ 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 obtain the number of all items of the current user and the number of products! Below is a quick function of magento!
The code is as follows: |
|
$ TotalItems = Mage: getModel ('checkout/cart')-> getQuote ()-> getItemsCount (); $ TotalQuantity = Mage: getModel ('checkout/cart')-> getQuote ()-> getItemsQty (); |
The following method is used to obtain the subtotal price and grand price.
The code is as follows: |
|
$ SubTotal = Mage: getModel ('checkout/cart')-> getQuote ()-> getSubtotal (); $ GrandTotal = Mage: getModel ('checkout/cart')-> getQuote ()-> getGrandTotal () |
In this way, you can quickly obtain the details of the current shopping cart to facilitate data operations and display the information of the shopping cart !!
It is generally used for shopping cart information in the upper right corner, or ajax shopping cart!
Bytes. Get all products in the shopping cart...