2 min. read
Categories: Technical
How to issue an invoice in Sylius?

All aboard the plugin train! What if once you have ordered some products and completed the payment process you would receive an email with a pdf document as a proof of placing the order? What’s more, this file would also contain both your and shop’s name, address and company. Does this dataset sound familiar? That’s right – here comes the Invoicing Plugin!

What is Invoicing Plugin?

Invoicing plugin is one of several Sylius extensions developed by Sylius Core Team. It reflects a significant amount of business features that are listed below:

  • Creating an invoice automatically once the checkout process is completed
  • An invoice providing data on the customer and the company (name, billing data)
  • Browsing and filtering invoices in the administration panel
  • Downloading invoices as pdf files by both customer and administrator
  • Sending an invoice to the customer via email once an order is paid
  • Resending an invoice to the customer from admin panel
  • Setting shop billing data globally on channel

How does it work code-wise?

All magic included in Invoicing Plugin source code begins where custom post-insert event listener receives an order in the completed state. What happens next? Let me describe the main plugin logic in a few steps:

  • The event listener receives an instance of order in the completed state
  • The event listener dispatches OrderPlacedEvent
  • The event is caught by CreateInvoiceOnOrderPlacedListener
  • Order’s data is transformed into invoice-related models, i.e. Address into BillingData or OrderItem into LineItem
  • Previously prepared data is set on the newly created invoice and inserted into the database
  • Since Invoice class is a Resource, now the invoice is visible and editable in the Admin panel
  • Once the order is paid, the invoice is sent to the customer via email as a pdf file
  • The document can be sent to the customer manually by an administrator any time

A lot of Sylius plugins are based on the concept of Resource and Invoicing Plugin is not an exception in that matter. Thus, the plugin’s configuration is split between config.yml and routing.yml files. Custom actions such as sending an invoice email or downloading the document as pdf file are driven by single action controllers.

How to get it?

It’s free! Try it out by visiting the plugin’s repository and following a few simple installation steps. Like any other official Sylius plugin, Invoicing Plugin offers two ways of installation – manual one and based on Symfony Flex. See which solution is more tailored to your needs and then require the package by Composer. As usual, if you come up with an opinion or idea that will help us make the plugin even more valuable, let us know. But for now…

Happy invoicing!

More from our blog
Business News Technical 2 min read 28.09.2020
Get ready for global sales & operations with the most advanced payment solution from the famous fintech giant, now available in Sylius out of the box. Read More
Business News 2 min read 14.09.2020
We proudly present to you the latest version of the Sylius eCommerce Platform – 1.8, which comes with a brand new, unified API powered by API Platform, Loyalty points system for Sylius Plus, and as you can probably see, a brand new sylius.com website! Numbers This new release is a… Read More
Business Ecosystem News 2 min read 13.08.2020
Read why the French market leader trusted Sylius in a strategic re-platforming process to get a competitive eCommerce advantage. Read More