Posted: July 16, 2018 at 4:29 am
this is a continuation of the already closed thread: https://eventespresso.com/topic/sequential-invoice-numbers-yet-again/.
I had to wait a couple of weeks to see if the changes I implemented were successful (lines 53-62): https://gist.github.com/pwweb/1aa78165175ce19a16989e94d9a29845
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
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:
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 🙂
Here are the stages of every transaction:
Stage 1) When the ticket selections are submitted, before the registration form is submitted -> Transaction Failed (TFL)
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:
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
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..
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.
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
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.
@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.