Home Backend Development PHP Tutorial Magento Get Shopping Cart Product Quantity and Price Program Code_PHP Tutorial

Magento Get Shopping Cart Product Quantity and Price Program Code_PHP Tutorial

Jul 13, 2016 pm 04:57 PM
magento product code price use and quantity article friend of program Obtain shopping cart

This article will introduce to friends who use Magento how to get the quantity and price of shopping cart products and display them. Now I will give you a detailed introduction.

Get all product information 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 "
";
}

Copy code

 代码如下 复制代码

$totalItems = Mage::getModel('checkout/cart')->getQuote()->getItemsCount();
$totalQuantity = Mage::getModel('checkout/cart')->getQuote()->getItemsQty();

// $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 "
";
}

 代码如下 复制代码

$subTotal = Mage::getModel('checkout/cart')->getQuote()->getSubtotal();
$grandTotal = Mage::getModel('checkout/cart')->getQuote()->getGrandTotal()

Of course, you can also quickly get the number of all items and products of the current user! Below is a quick function from 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 the 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()
In this way, you can quickly get the detailed information of the current shopping cart, conveniently operate the data, and display the shopping cart information! ! Generally used for shopping cart information in the upper right corner, or ajax shopping cart!
http://www.bkjia.com/PHPjc/631526.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/631526.htmlTechArticleThis article will introduce to friends who use Magento how to get the quantity and price of shopping cart products and display them, as follows Let me give you a detailed introduction. Get all products in shopping cart...
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1664
14
PHP Tutorial
1268
29
C# Tutorial
1247
24
How to make Google Maps the default map in iPhone How to make Google Maps the default map in iPhone Apr 17, 2024 pm 07:34 PM

The default map on the iPhone is Maps, Apple's proprietary geolocation provider. Although the map is getting better, it doesn't work well outside the United States. It has nothing to offer compared to Google Maps. In this article, we discuss the feasible steps to use Google Maps to become the default map on your iPhone. How to Make Google Maps the Default Map in iPhone Setting Google Maps as the default map app on your phone is easier than you think. Follow the steps below – Prerequisite steps – You must have Gmail installed on your phone. Step 1 – Open the AppStore. Step 2 – Search for “Gmail”. Step 3 – Click next to Gmail app

Red Magic 9spro price officially announced Red Magic 9spro price officially announced Jul 11, 2024 pm 12:38 PM

The Red Magic 9spro will be officially released at 19:00 today, July 3. This is a mobile phone targeting AI e-sports games. The price of the Red Magic 9spro has not yet been officially announced. The editor estimates that the starting price is 4,699 yuan. Let’s learn more about it with the editor below! The official price of the Red Magic 9spro has been announced. The starting price is 4,699 yuan. When will the Red Magic 9spro be launched? The latest news about the Red Devils 9spro in July 2024. On July 3, according to official news from the Red Devils mobile phone, the Red Devils will hold a new product launch conference for the Red Devils Esports Universe at 19:00 on the evening of July 3. At that time, Red Magic 9S Pro AI gaming phone, Red Magic gaming notebook, Red Magic Ice Mechanical Keyboard, Red Magic Mirror QD-OLED gaming monitor (32 inches), Red Magic Radiator 5

Clock app missing in iPhone: How to fix it Clock app missing in iPhone: How to fix it May 03, 2024 pm 09:19 PM

Is the clock app missing from your phone? The date and time will still appear on your iPhone's status bar. However, without the Clock app, you won’t be able to use world clock, stopwatch, alarm clock, and many other features. Therefore, fixing missing clock app should be at the top of your to-do list. These solutions can help you resolve this issue. Fix 1 – Place the Clock App If you mistakenly removed the Clock app from your home screen, you can put the Clock app back in its place. Step 1 – Unlock your iPhone and start swiping to the left until you reach the App Library page. Step 2 – Next, search for “clock” in the search box. Step 3 – When you see “Clock” below in the search results, press and hold it and

When will vivoX200Pro be sold? When will vivoX200Pro be sold? Jun 26, 2024 am 11:39 AM

When will vivo X200 Pro be released? The vivo X200 Pro will be unveiled in October and will be available in November. It should be available for purchase during Double 11 this year. It is reported that vivo X200 Pro appeared in the IMEI database today, and its model number is V2413. Let’s learn more about it with the editor below! When will vivo X200 Pro be released? What is the price of vivo X200 Pro in November 2024? The latest news about vivo X200 Pro starts at 5,499 yuan. Today, vivo X200 Pro appeared in the IMEI database, and its model number is V2413.

BTCC tutorial: How to bind and use MetaMask wallet on BTCC exchange? BTCC tutorial: How to bind and use MetaMask wallet on BTCC exchange? Apr 26, 2024 am 09:40 AM

MetaMask (also called Little Fox Wallet in Chinese) is a free and well-received encryption wallet software. Currently, BTCC supports binding to the MetaMask wallet. After binding, you can use the MetaMask wallet to quickly log in, store value, buy coins, etc., and you can also get 20 USDT trial bonus for the first time binding. In the BTCCMetaMask wallet tutorial, we will introduce in detail how to register and use MetaMask, and how to bind and use the Little Fox wallet in BTCC. What is MetaMask wallet? With over 30 million users, MetaMask Little Fox Wallet is one of the most popular cryptocurrency wallets today. It is free to use and can be installed on the network as an extension

When will OPPO A3 be launched? Launch time and price When will OPPO A3 be launched? Launch time and price Jul 01, 2024 pm 02:26 PM

When will OPPO A3 be launched? The new phone will be officially released at 14:00 on July 2 and is expected to go on sale in the same month. The official mall has opened reservations. The price has not been disclosed yet. The editor estimates it to be around 2,000 yuan. Let’s learn more about it with the editor below! When will OPPO A3 be launched? It will be released at 14:00 on July 2, 2024 and will go on sale in the same month. OPPO A3 price starts at 1,599 yuan According to news on June 28, today, OPPO announced that it will release OPPO A3 on July 2, focusing on "double-sided drop resistance and wear resistance." OPPO introduced that OPPO A3 is a durable war god. It is rare in the same range and has simultaneously passed the Swiss SGS gold standard five-star complete machine anti-fall certification and the national military standard impact resistance.

Can't allow access to camera and microphone in iPhone Can't allow access to camera and microphone in iPhone Apr 23, 2024 am 11:13 AM

Are you getting "Unable to allow access to camera and microphone" when trying to use the app? Typically, you grant camera and microphone permissions to specific people on a need-to-provide basis. However, if you deny permission, the camera and microphone will not work and will display this error message instead. Solving this problem is very basic and you can do it in a minute or two. Fix 1 – Provide Camera, Microphone Permissions You can provide the necessary camera and microphone permissions directly in settings. Step 1 – Go to the Settings tab. Step 2 – Open the Privacy & Security panel. Step 3 – Turn on the “Camera” permission there. Step 4 – Inside, you will find a list of apps that have requested permission for your phone’s camera. Step 5 – Open the “Camera” of the specified app

Xiaomi Mi Pad 7pro launch date and price Xiaomi Mi Pad 7pro launch date and price Jul 19, 2024 am 11:56 AM

The latest official news from Xiaomi Mi Pad 7 pro is that Xiaomi Mi Pad 7 pro and Mi Pad 7 have been successfully registered. The launch time is expected to be launched simultaneously with the Xiaomi 15 series in October this year, and the price is about 3,000 yuan. As a brand full of black technology This tablet can not only be connected to mobile phones and computers, but also supports Xiaomi SU7 cars, so look forward to it. Xiaomi Tablet 7 pro launch time: Around October 2024 The latest official news of Xiaomi Tablet 7 pro Price: starting price is about 3,000 yuan On June 5, PHP Chinese website noticed that the whistleblower "Digital Chat Station" published an article saying: "Mi Tablet 7 and Mipan 7 Pro have been registered, codenamed UKE and MUYU respectively, see

See all articles