How to get value from quote_address table for checkout and cart page in Magento2. Need values for guest and login user both in Magento2 cart and checkout page
1 Answer
If you have quote
object.
You can access quote_address
data like:
echo $quote->getBillingAddress()->getId(); // billing address id
echo $quote->getBillingAddress()->getEmail();
echo $quote->getShippingAddress()->getId(); // shipping address id
echo $quote->getShippingAddress()->getShippingMethod();
If you have $quoteId
protected $quoteRepository;
public function __construct(
...
\Magento\Quote\Api\CartRepositoryInterface $quoteRepository,
....
) {
....
$this->quoteRepository = $quoteRepository;
....
}
then can get quote by:
$quote = $this->quoteRepository->get($quoteId);