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!

Share:
More from our blog
Cloud 2 min read 17.06.2024
We are thrilled to announce that we just signed a strategic partnership with Platform.sh, and as a result, we are extending our offer with Sylius Cloud powered by Platform.sh. Platform.sh is a modern Platform-as-a-Service (PaaS) solution that allows businesses to leverage the cloud environment without losing access to the code… Read More
Technical 2 min read 11.06.2024
Abstract 1.12 released in Q4 2022 1.13 on Apr 23rd, 2024 (a year later than we anticipated while releasing 1.12) 3859 commits 23 contributors A stabilized Sylius API powered by API Platform It’s been a long and bumpy road. Having it behind our backs was a highway that led Sylius… Read More
Business Ecosystem News 2 min read 06.06.2024
Welcome to the May summary! As an open-source eCommerce framework, Sylius continues to evolve with significant contributions from our vibrant community and valuable product updates. Apart from describing the technical changes, we will also quickly summarize the Sylius Technical Fundamentals & Sylius Polish Community Meetup and eCommerce Day Kaunas, as… Read More
Comments