Support

Home Forums Event Espresso Premium EE4 Recommended method of changing wording/content on PDF Invoice

EE4 Recommended method of changing wording/content on PDF Invoice

Posted: February 20, 2014 at 3:33 pm


Chris Stambaugh

February 20, 2014 at 3:33 pm

Hi,

As per the title, what is the recommended way in EE4 of changing the wording and/or content on the PDF invoice?

Thanks,

Paul


Josh

  • Support Staff

February 20, 2014 at 5:13 pm

Hi Paul,

It depends on the parts of the invoice you want to change are. If it’s a few phrases that are in the template and if they’re wrapped in translation functions (most are) these can be translated using the WordPress gettext filter. The payment instructions text can be changed in the invoice settings.

If that’s not enough information can you let us know what parts of the invoice you’re looking to change?


Chris Stambaugh

February 21, 2014 at 11:00 am

I had tried editing the invoice template php file but every time there is an upgrade it gets whiped out and it is a drag to have to re-do it each time.

I want to change the word “INVOICE” to “RECEIPT” and I want to change “VAT/Tax Number:” to “GST Number:”


Josh

  • Support Staff

February 21, 2014 at 3:35 pm

Hi Paul,

The first one should be translatable via a gettext function and the string to match is:

‘ Invoice #’

The second one managed to be the one string that did not get wrapped in a translation function. It will be in the next hotfix release. So if you change what’s now on line 19 in the invoice_body.template.php file to read:

<div class="vat"><?php _e('VAT/Tax Number:', 'event_espresso')?> [vat]</div>

You’ll be able to translate that one too and you won’t lose anything in the next update.


Chris Stambaugh

February 24, 2014 at 8:49 am

Hi,

My only issue with using the translattable gettext function is that it is my understanding that the code goes in the functions.php file of my theme. But each time the theme gets updated that file can get wiped out and I have to re-do the work.

I’d appreciate consideration of a more elegant solution for changing these types of things in the future.

Paul


Josh

  • Support Staff

February 24, 2014 at 9:24 am

Hi Paul,

The code does not need to go into your theme’s functions.php file. I’d argue that it should not be placed there for the very reason you cite.

It turns out that you can place the custom gettext function along with all your other custom functions in their own little site-specific plugin that is safe from getting overridden on an update. Please see this article for more info on how to create a site-specific plugin and some example code to get you started:

http://ottopress.com/2011/creating-a-site-specific-snippets-plugin/

We will be adding the ability to override the entire invoice template from an alternate location. That said, I think that if all you need to do is change the wording of two text strings the gettext function is the most elegant solution because it’s the easiest to maintain. Overriding the entire template file would be best used if you’re doing more than changes a few labels.


Chris Stambaugh

February 25, 2014 at 11:01 am

Josh,

That’s a great idea and I’ve tried it.

I created a folder called pauls_plugin and created a similarly named file inside of it with the recommended php code and code snippet we used previously to do text translation and I’d love to test it, but the plugin doesn’t show up with an option to activate it. Is that an issue?


Josh

  • Support Staff

February 25, 2014 at 11:48 am

Yes, you’ll need to be able to activate the plugin for this to work.

The first thing you’ll want to check is make sure your pauls_plugin folder is inside the wp-content/plugins/ folder along with all the other plugins.

Then you’ll want to make sure that you have something like this at the very beginning of the file that’s inside the pauls_plugin folder:

<?php
/*
Plugin Name: Paul's Plugin
Description: A collection of code snippets
*/

The support post ‘EE4 Recommended method of changing wording/content on PDF 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