Magento 2.2.2 Invoice – Discount Code Not Showing

admincoupon-codesinvoicemagento2magento2.2.2

I have a store running on Magento 2.2.2 which has various cart price rules configured. Including many with coupon codes attached to them. These codes work fine when adding them to an order (both frontend and backend).

Unfortunately however, they do not seem to appear on invoices. For example an order with the following totals:

Subtotal €27.90
Discount (coupon_code) -€5.58
Grand Total €22.32

Will get the following totals when we create an invoice through the Magento backend

Subtotal €27.90
Grand Total €22.32

As you can see, the coupon code just "disappears" but the discount is still applied in the grand total. According to this issue on Github this was supposed to be fixed in 2.2.2. Am I missing something?

The store was upgraded from an earlier version of Magento and all static files have been refreshed since the update.

Best Answer

Managed to get this resolved. The issue was not with Magento Core, but with the MageWorx Magento 2 Gift Cards Extension. The extension came with a custom discount model to use in $invoice->collectTotals() which reset the the discount amount (and description) to 0.

Found it by putting debug code in Magento\Sales\Model\Order\Invoice->collectTotals() to see which models were manipulating the data.

Related Topic