Magento 2: Get details of shopping cart all items, subtotal, grand total, billing and shipping address.

We can fetch details of all shopping cart items, subtotal and billing/shipping address from the current session.
Create Block file, ShoppingCart.php

Call in template(.phtml) file, 

call function getQuoteData() and based on that we can get getAllVisibleItems() of cart.

Using getAllVisibleItems() we can get all the visible items data. For configurable product only main item data will be available, Child item data will be not display in for loop using getAllVisibleItems method.

If you want to get all the items, like for a configurable product, the main item with child item data, will be displayed if you use $quote->getAllItems() function. getAllItems() returns all the quote item data.

 

Leave a Reply

Your email address will not be published. Required fields are marked *