In my Carrier class for my custom shipping method, I have tried calling $request->getAllItems()
as well as injecting an instance of Magento\Checkout\Model\Session
and calling getAllItems
as well. All that is returned is an array of empty objects. No matter what I do, they are empty. I am just trying to get the items in the cart to send to our shipping rate service to calculate the rates.
I referred to this as well to guide me: Magento 2 – How to get all items in cart?
Best Answer
It is very strange, because I can see in debug all items directly in the request, and they is not empty:
Try to get items from the quote, like:
It should work, since all items are constantly stored in the quote.