In this tutorial we will pull some “Custom Data” elements into an invoice template.
- First we setup our data by going to Settings > Custom Data and creating a new data store. We will call this one “Commission Rates”. Our aim is to show the text “Dave: 10%” on our final invoice.
- Next we want to link one of these “Commission Rates” with a customer account. This will allow us to show our Custom Data text on any invoice generated for that customer. So we create a new extra field for customers and call it “Commission” like so:
- Then we go to Settings > Extra Fields > Commission in order to change the settings for this new extra field. We change the field type from “plain text” over to “ajax lookup” like this:
- To find the “Ajax Lookup” value we go back to Settings > Custom Data > Commission. and then choose the field you want to search on. I want to search based on the “Staff” name, so I open the settings for “Staff” and copy the “Extra Lookup” value from the bottom:
- Copy this value into the “Extra Settings” area like so:
- Now if you go to the Customer Edit page you can select one of your Custom Data commission rates from the extra field. Yay!
- Now to get this information displayed on the Invoice we go to Settings > Templates and open the external_invoice template. Add this text to the template:
Commission Rate {COMMISSION.STAFF NAME} at {COMMISSION.COMMISSION}
The first “{COMMISSION.” part references the extra field named “Commission” on the customer.
The second “.STAFF NAME}” part references the name of the custom data field. - This means {COMMISSION.STAFF NAME} will print Dave in the invoice template.
And {COMMISSION.COMMISSION} will print 10% in the invoice template.