I had an option Payment Methods > Zero Subtotal Checkout > Automatically Invoice All Items enabled in my Magento Admin Panel. But it didn't do a thing. Say what?
Zero Subtotal Checkout > Automatically Invoice All Items
For years already I have been running a Magento 2 shops for selling various things - in the past some books, in recent years event tickets (MageTestFest, Reacticon, MageUnconference NL) and courses (on-demand, classroom, bulk). Gradually, the amount of custom work just grew - like printing out attendee lists, mailing registered attendees.
To me, it made sense to also register people for my free Magento CSP webinar via Magento as well. However, every order with subtotal that came in, was saved with the status pending
, even though the configuration setting Payment Methods > Zero Subtotal Checkout > Automatically Invoice All Items was enabled. What plays?
payment/free/payment_action
field has been removed in 2.4.0
As a developer, I simply just open up the Magento code in PHPStorm to answer this question: The option payment/free/payment_action
was still there in the Magento Admin Panel and I quickly found the code that was using it:
The \Magento\Payment\Helper\Data
class (which is used quite a bit everywhere) had a method getZeroSubTotalPaymentAutomaticInvoice
that referred to this configuration option. However, PHPStorm did not report this method to be used anywhere.
Is it really not used?
The online CHANGELOG also reported that the field was removed in 2.4.0. However, you can never be too sure. I have a lot of composer replacements in my shop that could be removing code that was actually calling upon this method. However, temporarily undoing the composer replacements did not show everything. Plus I have for development purposes, many up-to-date and out-of-date Magento environments lying around and none of them called upon getZeroSubTotalPaymentAutomaticInvoice
.
Apperently, the method was only there for legacy sake. (Which leaves me to ponder how much unused fluff is there in Magento just for legacy sake, slowing down things - but that's a different story.)
So let's create it anyway: Yireo AutoInvoiceZeroSubtotalOrders
Because I needed the functionality anyway and because I had a vision that this would be peanuts to create, I sat down and 15 minutes later had a working module: Yireo_AutoInvoiceZeroSubtotalOrders
Hope you like it.
About the author
Jisse Reitsma is the founder of Yireo, extension developer, developer trainer and 3x Magento Master. His passion is for technology and open source. And he loves talking as well.