I want to display the discount amount including tax on cart overview page (totals summary).

  • Magento 2.1.8

Relevant settings:

  • Catalog prices: Excluding tax
  • Apply Customer Tax: After discount
  • Apply Discount On Prices: Excluding tax

Current situation in total summary within cart: totals summary

I cannot set Apply Discount On Prices to Including Tax, because Magento then calculates wrong totals. So in short I need to calculate discount amounts excluding tax but displaying including tax.

2 Answers 2


Please check the warning message in the Magento Back office in Configuration -> Sales -> Tax -> Calculation Settings -> Apply Discount On Prices:

To apply the discount on prices including tax and apply the tax after discount, set Catalog Prices to “Including Tax”.

To do what you want, you need to customize the Magento Tax module


I tried to implement observer for this. Maybe it help to someone.

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
    <event name="sales_quote_address_collect_totals_after">
        <observer name="vendor_module_fix_total_discount_amount" instance="Vendor\Module\Observer\FixTotalDiscountAmount" />

and its implementation


namespace Vendor\Module\Observer;

use Magento\Framework\Event\Observer;
use Magento\Framework\Event\ObserverInterface;
use Magento\Framework\Pricing\PriceCurrencyInterface;
use Magento\Quote\Model\Quote;
use Magento\Quote\Model\Quote\Address\Total;
use Magento\Tax\Model\Config as TaxConfig;

class FixTotalDiscountAmount implements ObserverInterface
    private TaxConfig $taxConfig;

    private PriceCurrencyInterface $priceCurrency;

    public function __construct(TaxConfig $taxConfig, PriceCurrencyInterface $priceCurrency)
        $this->taxConfig = $taxConfig;
        $this->priceCurrency = $priceCurrency;

    public function execute(Observer $observer)
        /** @var Quote $quote */
        $quote = $observer->getData('quote');

        /** @var Total $total */
        $total = $observer->getData('total');

        if (!$this->taxConfig->displayCartPricesInclTax()) {
            // Don't need to add tax into discount.
        if (
            $this->taxConfig->applyTaxAfterDiscount() // Apply Tax After Discount
            && !$this->taxConfig->discountTax() // Apply Discount on Prices Excluding Tax
            && !$this->taxConfig->priceIncludesTax() // Catalog Prices Excluding Tax
        ) {
            // Add "missing" Discount Tax from all Items
            foreach ($quote->getAllVisibleItems() as $item) {
                $discountTax = $item->getRowTotalInclTax() - $item->getRowTotal() - $item->getTaxAmount();
                $baseDiscountTax = $item->getBaseRowTotalInclTax() - $item->getBaseRowTotal() - $item->getBaseTaxAmount();

                $discountAmount = $total->getDiscountAmount() - $discountTax; // minus because discounts are negative numbers
                $baseDiscountAmount = $total->getBaseDiscountAmount() - $baseDiscountTax;


Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.