Invoices 1.2

Easy Digital Downloads – Invoices 1.2 is a huge release, providing significant extensibility while maintaining backwards compatibility.

The CSS has been simplified and updated. The new invoices will look slightly different, as the overall appearance and font stack has been modernized, but out of the box, the new invoices should be very similar to the old.

Where version 1.2 really shines is that now, store owners can modify the invoice template. The following template files are now available:

  • invoice.php: This is the primary template, and consists only of the basic HTML markup, and some new custom hooks.
  • invoice-contacts.php: This template outputs the storefront and customer information.
  • invoice-table.php: This template outputs the primary “receipt” of the invoice.
  • invoice-additional-info.php: This template includes any custom notes added by the customer, as well as custom notes from the storefront (this is a new setting in 1.2).

As with any EDD templates, these can be overridden by copying them to a directory called edd_templates in the active theme folder.

In addition to the templates, EDD Invoices now includes multiple hooks in the invoice so that a store owner can add additional information wherever it’s needed:

  • edd_invoices_invoice_head: This hook fires in the head of the HTML output for the invoice. One new feature is that the invoice stylesheet is now output using this hook. The same hook can be used to load an additional custom stylesheet.
  • edd_invoices_invoice_header: This hook is used to output the invoice logo (if set), the invoice number, and (new in 1.2) the order status and purchase date.
  • edd_invoices_invoice_contacts: The invoice-contacts.php template is loaded in this hook.
  • edd_invoices_invoice_items_table: The invoice-table.php template is loaded in this hook.
  • edd_invoices_invoice_additional_info: The invoice-additional-info.php template is loaded in this hook.
  • edd_invoices_invoice_footer: EDD Invoices adds action buttons (print, back) using this hook. These are not included in the printed version of the invoice.

Each hook uses either the order object (in EDD 3.0) or the payment object (EDD 2.x).

Some invoice content is output directly in the templates, but some of it requires a bit more logic, so 1.2 also introduces some helper functions:

  • edd_invoices_get_order_items: This function gets the necessary information for each item in the order: the item ID, the price, the product name, and the price ID. The data is returned to the template as an array.
  • edd_invoices_get_order_discounts: This function gets the discounts applied to the order. In EDD 2.9/2.10, the discount code is displayed on the invoice. Because much more specific information is available in 3.0, those invoices will include the amount of each discount, and (for percentage discounts) the discount rate.
  • edd_invoices_get_custom_order_meta: This function gets the customer’s notes and/or VAT for the order. It works for the metadata in both EDD 2.x and 3.0.
  • edd_invoices_get_order_date: This function gets the order date, which is a different property in EDD 3.0, and requires a little more fallback work for renewal payments in 2.x.

Functions which output directly to the invoice are in the includes/template-functions.php file.

EDD Invoices 1.2 is ready for Easy Digital Downloads 3.0

Just as orders are stored in a custom database table in EDD 3.0, order meta will be as well. Invoices saves custom meta–the option VAT for the customer and any notes the customer adds to the invoice. Invoices 1.2 will migrate this custom meta to the new order meta table when you upgrade to EDD 3.0.

Additionally, the new templates and hooks use the order object in EDD 3.0. This is both more detailed and simpler than the comparable payment object, and allows store owners to access much more specific information about each order and order item.

One response... add one

Thanks for this update and the details. It’s nice being able to add additional information via settings instead of with code. I didn’t find any issues with backwards compatibility and could actually lighten my custom code. You’re doing a great job; very stable updates to EDD this past year.

Leave a Reply

Your email address will not be published.