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.

 

How to override cart/item/default.phtml in Magento 2?

For override default.phtml file in Magento 2, We need to create the plugin for it. We need to override Magento\Checkout\Block\Cart\AbstractCart Block file to override default.phtml in the module.
create the file at the location in your module.

I have created a module with Rbj/CartItem as {Namespace/Modulename},
app/code/Rbj/CartItem/etc/di.xml file,

Create plugin file at below location in your module,
app/code/Rbj/CartItem/Plugin/Cart/AbstractCart.php

Create template file in your module view folder,
app/code/Rbj/CartItem/view/frontend/templates/cart/item/default.phtml
Keep your content in default.phtml file to override Cart module default template.