Home Forums Event Espresso Premium Sequential Invoice Numbers – yet again contd.

Sequential Invoice Numbers – yet again contd.

Posted: July 16, 2018 at 4:29 am


July 16, 2018 at 4:29 am

Hi Tony,

this is a continuation of the already closed thread:

I had to wait a couple of weeks to see if the changes I implemented were successful (lines 53-62):

Unfortunately they are not. I did as you mentioned last time check the old_txn_status, unfortunately I am still getting non-sequential invoice numbers. After my analysis this is still due to some transactions being aborted mid-way, such as this one (this should also answer your last question in the last post: yes, when the user starts a registration and then stops halfway through?):

Registration Step Progress
Attendee Information : initialised 16.07.2018 09:54
Payment Options : Never initialised
Finalize Registration : Never initialised

What kind of status do such transactions have? TAB (Aborted) would be my guess (TFL – failed would be for payment gateways, correct?).

Writing this, maybe I should not be checking for the old_txn_status, as this can be incomplete and then end up in aborted, correct? Guess I am trying to understand the flow of status for each transaction. Does it start off with initial status TIN (incomplete) and then stays there until either the transaction failed (TFL), is aborted (TAB), is completed (TCM – paid amount = price) or overpaid (TOP)? If so I guess I would have to check for the following in order to exit the function and not increment the invoice number / assign the number to the custom question:

        if ($transaction->old_txn_status() !== 'TIN' && $transaction->txn_status() !== 'TIN') {
            return true;

I’m not sure at what point your current code would increment when a transaction is canceled?

That’s the point. It should not. It should only increment the invoice number when the transaction is successful from a registrants perspective (i.e. entered the name, chosen payment method and displayed invoice).

Thanks for your continued support. If we get this to work, you are more than welcome to pull in the code base 🙂



  • Support Staff

July 16, 2018 at 7:33 am

Hi Frank,

Here are the stages of every transaction:

Stage 1) When the ticket selections are submitted, before the registration form is submitted -> Transaction Failed (TFL)
Stage 2) After the registration form is submitted -> Transaction Abandoned (TAB)
Stage 3) Three possible outcomes when completing the third stage:
a) Transaction’s status stays as Transaction Abandoned (TAB) -> Example: If there’s an offsite payment method (like PayPal Express) and that’s selected and they never return to your site from
b) Transaction Incomplete (TIN) -> Example: If there’s an offline payment method, it’s selected, and Finalize Registration button is submitted
c) Transaction Complete (TCM) -> Payment is completed


July 16, 2018 at 11:56 am

Hi Frank, Hi Josh,

I have recently been working on the same problem and I was also planning to re-open this discussion.

I’ve been using the code from the previous thread as a starting point and I also added some code for an extra condition that was mentioned by Tony on the previous thread:

So for your function to work it sounds like you need to add a check to your function to confirm the registration has a status of ‘Approved’ (which happens when payment it complete it full, the default registration is set to ‘Approved’ or the admin manually Approves the registration) and then assigned the Invoice number to primary registrant.

I got access to the status of the registration by finding the primary registrant associated with the transaction.

So in addition to the stages of the transaction (listed above) you can also check against the following statuses for the registration:

RAP – Approved
RCN – Cancelled
RDC – Declined
RIC – Incomplete
RNA – Not Approved
RPP – Pending Payment
RWL – Wait List

Furthermore, I found a way to include an extra column on the Registrations Admin page, this displays the answers to the hidden question (i.e. the invoice number)

I will share the code for these shortly using pastebin or something similar

In the meantime, there is already one limitation that I’ve discovered when using this approach to checking against the registration status.

The issue I am having is that when an admin manually approves the registration from the Registrations admin page, it doesn’t trigger the hook to create the invoice number:


the hook can be triggered from the Transactions admin page, meaning we can still manually update the Registrant’s status from here, but it’s not ideal because it also requires the admin to update the payment status on the transaction for example by applying a payment of 00.00

I believe if there is a way to trigger this from the registrations page it could provide a solution for creating the invoice number after manually approving the registration

Josh, is this something that you could advise me about? I will be happy to continue working on it and to post the results here. It would also be great to hear more about the approach that you mentioned in the previous thread about saving generated invoices to the messages table when they are generated. This would be useful information in order to evaluate which approach is worth pursuing

Please let me know if it’s better to open a new thread for this or if we can continue the discussion here..


July 17, 2018 at 6:26 am

I’ve uploaded the code to pastebin for you to take a look:

This is similar to what Frank was doing previously, with the extra step of getting the registration status as well as a check to see if the invoice answer was already updated

This is still a work in progress. I’m currently trying to find out if there is a way to trigger this hook from the Registrations admin page when an admin manually updates the Registration status.

Any advice and suggestions will be greatly appreciated.


July 17, 2018 at 6:33 am

Here is another snippet for adding a new column on the transactions admin page and displaying invoice numbers from primary registrant’s answer

It’s also a work in progress but this can be useful for keeping an overview of invoice numbers in the admin section


  • Support Staff

July 17, 2018 at 9:50 am



The issue I am having is that when an admin manually approves the registration from the Registrations admin page, it doesn’t trigger the hook to create the invoice number:

Another hook, that will fire when manually approving the registration on a single registration page, is

This hook will not fire if manually approving from the Registrations list table though. That would likely require adding a new hook.


July 30, 2018 at 8:59 am

@josh Thank you! That hook solves the issue that I mentioned and allows us to assign the number from the registrations page once the reg. has been approved

The support post ‘Sequential Invoice Numbers – yet again contd.’ 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.

Support forum for Event Espresso 3 and Event Espresso 4.
Documentation for EE3 and EE4
Documentation for Event Espresso 3

Documentation for Event Espresso 4

Status: closed

Updated by  ThomasHowie 1 year, 8 months ago ago

Topic Tags


This topic is:
Do NOT follow this link or you will be banned from the site!