Support

Home Forums Event Espresso Premium Add field to Bill To section on invoice

Add field to Bill To section on invoice

Posted: November 11, 2016 at 1:37 pm

Viewing 18 reply threads


Jean Watson

November 11, 2016 at 1:37 pm

Hello EE

I need to add a custom field (Hospital or Affiliation) to the invoice Bill To Section.

I have searched the forums and found this thread, but I am not sure what template they are modifying.

https://eventespresso.com/topic/invoice-edit-to-add-a-question-company-name/

I do not find an invoice template in plugins/event-espresso/templates directory.

Can you help me add this field?

I am using EE Version 3.1.37.9.P

Thank you!


Josh

  • Support Staff

November 11, 2016 at 2:01 pm

In that particular thread they were modifying the invoice template found in /event-espresso/gateways/invoice/template.php.


Jean Watson

November 11, 2016 at 2:09 pm

Ok, there is nothing in that directory. Can you help me add a line to the Bill To section of the invoice? I’m not sure where to locate the template file. Appreciate your help!


Josh

  • Support Staff

November 11, 2016 at 2:30 pm

You’ll need to locate the invoice template first, and that’s in wp-content/event-espresso/gateways/invoice/template.php


Jean Watson

November 11, 2016 at 3:50 pm

Ok, I’ve located invoice_vars.php.
I’m not sure where I need to make the change and what I need to add.
And I’m not sure where I need to upload the updated template.
Sorry, I’m not familiar/comfortable with .php. :/
Thanks for your help!


Josh

  • Support Staff

November 11, 2016 at 3:59 pm

You actually don’t change anything in invoice_vars.php, the file you are going to edit is template.php. The changes to make are outlined in Dean’s reply here:

https://eventespresso.com/topic/invoice-edit-to-add-a-question-company-name/#post-58301


Jean Watson

November 11, 2016 at 4:19 pm

Thanks Josh – however, the field I need to insert is not organization name, the field label is Hospital or Affiliation. I tried inserting $organization_name but it just created a white space on the invoice. I also tried adding $hospital_or_affiliation and that didn’t work either; it created a white space as well. Not sure how to reference that field…


Josh

  • Support Staff

November 11, 2016 at 4:28 pm

You’ll need to follow Dean’s directions carefully. The part where he wrote:

replace the 2 with your question id (20).

is important because that’s how you reference the Hospital or Affiliation field. If you don’t know the field ID, you can get that field by going to Event Espresso > Questions, then go to edit that field. The field ID will appear in the URL of the page where you edit that question.


Jean Watson

November 11, 2016 at 4:51 pm

Ok, I didn’t realize that is how you locate the field ID.
So I have that now – it’s 11.
So, when I follow Dean’s notes, he has duplicated the email line and changed the variable to $organization_name
Since I’m not using organization name, I’m not sure what to change that variable to. Should it be $hospital_or_affiliation
I tried that and $organization_name and both resulted in a white space…


Josh

  • Support Staff

November 11, 2016 at 4:56 pm

The actually variable name itself isn’t important as long as it’s unique (not already in use for something else) and it’s also important that you consistently use that name. So to keep things simple, you can use $organization_name and that will follow the code in the other thread more closely.


Jean Watson

November 11, 2016 at 5:11 pm

Ok, I am using $organization_name and I still have a white space on my invoice; it isn’t grabbing that field for some reason…


Josh

  • Support Staff

November 11, 2016 at 6:53 pm

Can you post the full contents of your modified template into a paste bin or a gist, then post a link to that code here? Then we can take a look at that code.


Jean Watson

November 12, 2016 at 5:06 am

thanks Josh
here’s a link to a .docx file and .pdf
https://www.watsoncaringscience.org/files/invoicetemplate.docx
https://www.watsoncaringscience.org/files/invoicetemplate.pdf


Tony

  • Support Staff

November 14, 2016 at 7:49 am

The problem is the query to pull in the custom question is commented out.

Lines 90 through 98 have:

/* $q_sql = "SELECT ea.answer, eq.question
  FROM " . EVENTS_ANSWER_TABLE . " ea
  LEFT JOIN " . EVENTS_QUESTION_TABLE . " eq ON eq.id = ea.question_id
  WHERE ea.registration_id = '".$registration_id."'";
  $q_sql .= " AND ea.question_id = '11' ";
  $q_sql .= " ORDER BY eq.sequence asc ";
  $wpdb->get_results($q_sql);

  $organization_name = $wpdb->last_result[0]->answer;//question_id = '9' */

The /* and */ are multi line comments, they comment out all of the code between them, remove those and $organization_name should be answer for question id 11.

When posting code we recommend either creating a gist here:

https://gist.github.com/

Or you can use something like pastebin:

http://pastebin.com/

Then post the URL for us to view here as MS Word (and other word processors) adds its own formatting to the code.


Jean Watson

November 14, 2016 at 12:17 pm

Thank you very much! That solved the issue! Appreciate your help and guidance with this.
Now, do I need to save this template.php in a separate directory so it will not be overwritten with updates?


Josh

  • Support Staff

November 15, 2016 at 6:38 am

You actually copy the entire invoice folder over to /wp-content/uploads/espresso/gateways so your changes do not get overwritten on an update.


Jean Watson

November 15, 2016 at 11:18 am

Thank you Josh. However, when I transferred the folder I received a file upload error stating “no such directory” ??

Command: cd “/wp-content/uploads/espresso/gateways/invoice”
Error: Directory /wp-content/uploads/espresso/gateways/invoice: no such file or directory
Command: cd “/wp-content/uploads/espresso/gateways”
Response: New directory is: “/wp-content/uploads/espresso/gateways”
Command: mkdir “invoice”
Error: mkdir /wp-content/uploads/espresso/gateways/invoice: permission denied


Josh

  • Support Staff

November 15, 2016 at 11:20 am

You’ll probably need to contact your host and ask about how to fix the file/folder permissions there.


Jean Watson

November 15, 2016 at 11:25 am

Will do. Thanks again for your help!

Viewing 18 reply threads

The support post ‘Add field to Bill To section on invoice’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso