Support

Home Forums Event Espresso Premium EE3 – Start Time in Invoice PDF?

EE3 – Start Time in Invoice PDF?

Posted: December 19, 2014 at 1:44 pm

Viewing 8 reply threads


Ryan DesRoches

December 19, 2014 at 1:44 pm

Hi guys, I have got pretty good at modifying the invoice template to print out custom questions from the registration form and other info. However I am having a major issue with getting the start time of the event to show up properly.

After searching through old topics, it looked like this:
$startTime = event_espresso_get_time($event_id, $format = ‘start_time’);

Should have given me a value, but it seems to always come out as a blank string.

Am I missing something?

Thanks
Ryan


Josh

  • Support Staff

December 19, 2014 at 2:31 pm

Hi Ryan,

It matters where the code is placed. I tried the same code and put it inside the loop that starts with foreach ($tmp_attendees as $tmp_attendee) { and it’s working for me. Can you try it there?


Ryan DesRoches

December 19, 2014 at 2:32 pm

OK, this is strange – I got it to display a time – but its not the right time for the event!

Here is my code:

$startTime = event_espresso_get_time($event_id, $format = ‘start_time’);
$startTime = date(‘g:i a’, strtotime($start_time));
$startTimeMsg = “The check-in time for this event is ” . $startTime;
$pdf->Cell(50, 5, $startTimeMsg, 0, 1, ‘L’);

The start time that I sent in the event is 8:00 am
The time I get back from this function is 7:00 pm!

When I look up in the wp_events_start_end table the start time for the event_id I have, its correct in the table saying 8:00

I’m confused at what is going on.


Ryan DesRoches

December 19, 2014 at 2:38 pm

Josh,

I have tried the code (see above) in that loop and outside of it. It just seems like its pulling the wrong time for some reason.

Ryan


Josh

  • Support Staff

December 19, 2014 at 2:44 pm

Hi Ryan,

If you look at the event_espresso_get_time() in Event Espresso core, you’ll see that it calls another function that returns a formatted date, it doesn’t return a string. So you do not need to run strtotime on it.

I think you can remove this line and it will display the correct time:

$startTime = date('g:i a', strtotime($start_time));


Ryan DesRoches

December 19, 2014 at 2:44 pm

One other thing – it seems to always display 7:00 for all events – so no matter the event ID – its giving me 7:00 for some reason.


Ryan DesRoches

December 19, 2014 at 2:47 pm

Sorry for the quickfire replies. I tried getting rid of $startTime = date(‘g:i a’, strtotime($start_time));

And I get nothing back (empty string)

if I just use $startTime = date(‘g:i a’, strtotime($start_time)); I get 7:00 again.

Where is the core function (what file/directory?) I would like to take a look


Josh

  • Support Staff

December 19, 2014 at 3:14 pm

Can you do a project search in your IDE? That’s the quickest way to find it. Otherwise, you can open up /event-espresso/includes/functions/time_date.php.


Ryan DesRoches

December 20, 2014 at 1:43 pm

Josh,

Looks like I got a fix. The second parameter was throwing it off for some reason, and when I looked at the source code for the function, I noticed it was optional anyway.

So my fix was to simply change this line:
$startTime = event_espresso_get_time($event_id, $format = ‘start_time’);

to
$startTime = event_espresso_get_time($event_id);

Thanks for the help!

Viewing 8 reply threads

The support post ‘EE3 – Start Time in Invoice PDF?’ 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