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.

 

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

  1. Hi, Thanks for solution.
    But I am not able to get cart items when full page caching enabled. If we add cacheable=”false” in xml file then it will work,but full page caching gets disabled.
    So is there any solution for this?

  2. I am facing the same issue. I dont want to pass cacheable=”false” in my xml file is there any other solution

Leave a Reply