I have a custom controller which can also update the cart:

namespace Vendor\Module\Controller\Index;

class Index extends \Magento\Checkout\Controller\Cart\UpdatePost
    public function execute()
        if (!$this->_formKeyValidator->validate($this->getRequest())) {
            return $this->resultRedirectFactory->create()->setPath('checkout/cart/');


        $quote = $this->_checkoutSession->getQuote();

        $address = $quote->isVirtual() ? $quote->getBillingAddress() : $quote->getShippingAddress();

        $grandTotal = $address->getGrandTotal();
        $subTotal = $address->getSubtotalInclTax();
        $tax = $address->getTaxAmount();
        $shipping = $address->getShippingInclTax();

        // …

Judging by this code I thought it should be easy to get the correct amounts for the grand total (incl. tax), sub total (incl. tax), the total tax itself and the shipping (incl. tax).

However, with this code:

  1. the grand total is always without shipping
  2. the tax amount is always without the shipping tax
  3. the shipping amount is always zero

The cart of Magento itself shows the correct values for grand total, tax & shipping. But how can I get to these values myself in my custom controller?

  • Why don't you get that values from $quote object? Nov 8, 2018 at 12:16
  • It made no difference. $quote->getGrandTotal() also excludes the shipping amount (shipping tax), $quote->getTaxAmount() also excludes the shipping tax and $quote->getShippingInclTax() returns 0.00. That's why I thought I would have to fetch the totals etc. from the billing or shipping address, in order to get the shipping amount included everywhere as well.
    – fritzmg
    Nov 8, 2018 at 13:05


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.