Question

In checkout It shows a summary with all costs, it also shows the tax costs (Steuer [german]).

Tax

How can I get the tax costs from PHP?

Was it helpful?

Solution

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();
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top