Using custom blocks

If you create a custom block in the Customizer of your Premium Templates plugin it is possible to show all sorts of data in your documents. You can add data in two ways:

  • Set the type of your custom block to text and add placeholders enclosed with double accolades.
  • Set the type of your custom block to custom field and and the meta key of your own custom field.

The first is the most flexible. Letting you add your own text and all kinds of order data. The second one lets you add the data of a specific custom field with the added advantage that you can hide this part in your document if it turns out to be empty. Be aware that this second option takes specific meta keys. If you are having trouble finding the meta key you would like to use please read the following: Finding WooCommerce custom fields

If you want to use data out of your order in one of your documents you can create a custom block. Go to your WordPress Dashboard > WooCommerce > PDF Invoices > Customizer and create a custom block in the Custom Block section. The most flexible way to show order data is to set the type of your custom block to text.

Choose the position where you want to show your custom output on the document. Give it the desired label. And in the text field enter one or multiple placeholders, which all should be enclosed with double accolades like this: {{placeholder}}. You can also add your own custom text here.

What order data can I use?

If you added a custom block with the type set to text you can use the following placeholders (including accolades):

  • {{invoice_number}} – the invoice number
  • {{invoice_date}} – the invoice date
  • {{status}} – the order status slug
  • {{version}} – the WooCommerce version
  • {{currency}} – the order currency
  • {{site_title}} – the site title
  • {{shipping_notes}} – the shipping / customer notes (entered by the customer in the checkout)
  • {{order_notes}} – the order notes
  • {{private_order_notes}} – the private order notes
  • {{order_number}} – the order number
  • {{date_created}} – the date the order was created
  • {{date_modified}} – the date the order was modified
  • {{order_date}} – the order date
  • {{order_time}} – the order time
  • {{order_weight}} – the total weight of all items in the order
  • {{order_qty}} – the total quantity of items in the order
  • {{date_paid}} – the date of payment
  • {{date_completed}} – the date when the order was completed
  • {{used_coupons}} – the coupons used in this order
  • {{formatted_order_total}} – the order total
  • {{formatted_subtotal}} – the subtotal
  • {{formatted_discount}} – the given discount
  • {{formatted_shipping}} – the shipping costs
  • {{formatted_order_total_ex}} – the total without taxes
  • {{formatted_subtotal_ex}} – the subtotal without taxes
  • {{formatted_discount_ex}} – the given discount without taxes
  • {{formatted_shipping_ex}} – the shipping costs without taxes
  • {{shipping_method}} – the shipping method name
  • {{payment_method_title}} – the payment method name

Billing address

  • {{billing_address}} – the full billing address, formatted by WooCommerce
  • {{billing_first_name}} – the first name of the billing address
  • {{billing_last_name}} – the last name of the billing address
  • {{billing_company}} – the company name of the billing address
  • {{billing_address_1}} – the first address line of the billing address
  • {{billing_address_2}} – the second address line of the billing address
  • {{billing_city}} – the city name of the billing address
  • {{billing_postcode}} – the ZIP code of the billing address
  • {{billing_country}} – name of the country of the billing address
  • {{billing_state}} – the name of the state of the billing address
  • {{billing_email}} – the email address of the billing address
  • {{billing_phone}} – the phone number of the billing address

Shipping address

  • {{shipping_address}} – the full shipping address, formatted by WooCommerce
  • {{shipping_first_name}} – the first name of the shipping address
  • {{shipping_last_name}} – the last name of the shipping address
  • {{shipping_company}} – the company name of the shipping address
  • {{shipping_address_1}} – the first address line of the shipping address
  • {{shipping_address_2}} – the second address line of the shipping address
  • {{shipping_city}} – the name of the city of the shipping address
  • {{shipping_postcode}} – the ZIP code of the shipping address
  • {{shipping_country}} – the name of the country of the shipping address
  • {{shipping_state}} – the name of the state of the shipping address

Sure. If you have created a custom field you can easily add it to one of your documents. Go to your WordPress Dashboard > WooCommerce > PDF Invoices > Customizer and create a custom block in the Custom Block section.

Set the type to Custom field. Choose the position where you want to show your custom output on the document. Give it the desired label. And in the Field name / Meta key field enter your meta key. The meta key is the same as the name you have given your custom field. You can also choose to hide this field when it turns out to be empty.