0

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.

2 Answers 2

2

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.

1

We had a similar issue, but it was that the discount code didn't show, it just stated "Discount ()" when we created a custom PDF output. In order to fix this, we created our own implementation of insertTotals() from Sales/Model/Order/Pdf/Abstract.php

You could try there and see if the discount line is being thrown out. It could also be that an extension / plugin is removing the content.

1
  • Our issue is during creation of the invoice in the backend (so before the PDF stage). Thanks for the suggestion though, it seems that Magento\Sales\Model\Order\collectTotals properly loads the discount. So I'm guessing it's a display issue in the xml/phtml. I'll have a look through those
    – sduif
    Mar 1, 2018 at 11:20

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.