Magento 2 - Get tax sum
-
15-04-2021 - |
Solução
Assuming you have the quote:
$totals = $quote->getTotals();
$tax = (isset($totals['tax'])) ? $totals['tax']->getValue(): 0;
If you do not have the quote you can inject \Magento\Checkout\Model\Session $checkoutSession to your constructor and get the quote using:
$quote = $checkoutSession->getQuote();
Licenciado em: CC-BY-SA com atribuição
Não afiliado a magento.stackexchange