Support

Home Forums Event Espresso Premium Optional Thank You Page Message

Optional Thank You Page Message

Posted: March 7, 2019 at 10:47 am

Viewing 5 reply threads


Antenna Digital

March 7, 2019 at 10:47 am

For my event, the user can pay by credit card or get invoiced and pay by check. If they pay by CC I want to display some optional information. If they pay by check then they should not see the information.

I have the optional information showing on the page as desired….just need to determine how to get payment status into a variable I can use that in the if statement.

Using this function

function ee_course_materials_section_thank_you_page( $registration ) {
  if ( $registration instanceof EE_Registration ) {
    if( get_field('passkey_event_code', $registration->event()->ID()) ):
  ?>
......

So this line needs to be something like:
if( get_field('passkey_event_code', $registration->event()->ID()) <strong>AND PAYMENT_COMPLETED</strong> )

Just don’t know how to get that PAYMENT_COMPLETED info….


Antenna Digital

March 7, 2019 at 10:47 am

For my event, the user can pay by credit card or get invoiced and pay by check. If they pay by CC I want to display some optional information. If they pay by check then they should not see the information.

I have the optional information showing on the page as desired….just need to determine how to get payment status into a variable I can use that in the if statement.

Using this function
function ee_course_materials_section_thank_you_page( $registration ) {
if ( $registration instanceof EE_Registration ) {
if( get_field('passkey_event_code', $registration->event()->ID()) ):
?>
......

So this line needs to be something like:
if( get_field('passkey_event_code', $registration->event()->ID()) AND PAYMENT_COMPLETED )

Just don’t know how to get that PAYMENT_COMPLETED info….


Tony

  • Support Staff

March 7, 2019 at 2:53 pm

Hi there,

Pulling the information from our model system is easy enough, however, there’s a little more to this than it seems.

Before going into details, which payment method are users selecting when they want to pay via check, Invoice?

Is it specifically the payment you want to check, or if a registration has been Approved?

What do you want to happen if say a user that selected Check, pays via check, you apply it to the transaction and then the user manages to revisit the thank you page for their registration, should it show the details then?

Registrations are automatically Approved with an Online payment method (Card payments) once the user has paid in full, or if you have the ‘Default Registration Status set to Approved and they finalize a registration. Note that it IS possible for a user to return to the thank you pag at a later date.

With our models, you can pull the last payment method selected (meaning you would know if they selected a specific offline payment method), you can pull the payment object(s) from the transaction to check the status of specific payment, the transaction and its satatus (which is based off the payments made) and/or the registration status. It all depends on the amount of control you want and the exact conditions you want to show the details.

For the majority of users, the last payment method, transaction status and/or Registration status gives you enough details for this type of condition.


Antenna Digital

March 7, 2019 at 6:14 pm

Users who pay by check will choose Invoice. The thank you page shows a REG Status of “Pending Payment”. If a user sends a check and it’s applied, and then later returns to the Thank You page they should indeed see the information.

Admittedly I don’t yet understand how to use the models very well. How would I go about getting the last payment method, as well as the payment object….since that seems like it would give me the status so once the check is applied and the status changes from Pending Payment to Approved they could come back to the page and get the hotel registration link (which provides a deal….which is why they client does not want them to see the link until they have paid in full)


Tony

  • Support Staff

March 8, 2019 at 2:27 am

To be honest, it sounds like you just need the Registration Status rather than anything concerning payments, but I’ll show you a few different methods.

Using the models makes a lot of this easy and I’d advise looking over the documentation for them HERE.

So anything to do with the registration, you already have in $registration which will be an instance of EE_Registration.

The check I would use is simply:

if( 
    get_field('passkey_event_code', $registration->event()->ID())
    && $registration->status_ID() === EEM_Registration::status_id_approved 
)

Which checks if the current registrations status is ‘Approved’. You posted this:

The thank you page shows a REG Status of “Pending Payment”.

Which means you are using the default value for the ‘Default Registration Status’, which is Pending Payment. So registrations become Approved either way payment is made in full using an online payment method, or the admin, manually changes it to Approved.

So the registration status can be used to do what you need, although again, the option for finer control is available as you have the registration object, you can pull the EE_Transaction related to it, like so:

$transaction = $registration->transaction();

$transaction should now be an instance of EE_Transaction (I recommend you do instanceof check on the objects before using them, simply to prevent a fatal error if for some reasons you don’t get the object you are expecting).

Check the status of a transaction:

if($transaction->status_ID() === EEM_Transaction::complete_status_code) {
    //A complete statues means all monies owed are paid, if it's a free ticket, no monies are own so it will also show complete.
}

To pull the last payment method used on a transaction:

$last_payment_method = $transaction->payment_method();

Now you have a payment method object, you can check if it’s a specific payment method (like invoice)

An array of payment objects from the transaction:

$payments = $transaction->payments();

Throw $payments in a for each loop and loop over each one to check for whatever you please on each specific payment object.

I recommend using Kint Debugger, wrapping the object you have in d() and then using that to view all of the available methods you have on the object, it helps to see what you can do.


Antenna Digital

March 8, 2019 at 10:42 am

Thanks Tony. I very much appreciate the thoughtful explanation beyond just providing the answer of adding && $registration->status_ID() === EEM_Registration::status_id_approved. Which worked great for my use case.

The extra details will help build my understanding of EE, since this is our first project using EE it’s been a bit uphill.


Tony

  • Support Staff

March 8, 2019 at 1:50 pm

You’re most welcome.

If you do have any questions just let us know, we can’t write code for you but we can at least help point you in the right direction 🙂

Viewing 5 reply threads

The support post ‘Optional Thank You Page Message’ 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