Support

Home Forums Event Espresso Premium DateTime 'Places Left' conflict – with EE4 versions after 4.4.6

DateTime 'Places Left' conflict – with EE4 versions after 4.4.6

Posted: September 23, 2015 at 8:06 am

Viewing 10 reply threads


Cuillin

September 23, 2015 at 8:06 am

Our ‘Places Left’ (remaining tickets) script has stopped working after EE ver 4.4.6 and fails to calculate dates and ticket numbers.

We use a personalised script to calculate the remaining number of tickets for each event (Training Course) that we sell. I have read through the recent datetime changes but, as I am not an experienced developer, I am not understanding how to change my script to work with the new EE versions. It’s probably something simple so I apologise for my lack of knowledge.

In order for our site to still operate I have temporarily left it with EE ver 4.4.6 (WP 4.3.1) whilst setting up a development site with EE ver 4.8.9.p (WP 4.3.1) to demonstrate the problems.

I have purchased a Support Token


Josh

  • Support Staff

September 23, 2015 at 9:11 am

Hi there,

We’re reviewing the files on your theme and we’ll update you with what we find. Thanks.


Josh

  • Support Staff

September 23, 2015 at 11:10 am

Hi there,

Here’s how you can update your code to work with later versions of Event Espresso 4:

1) Where you currently have this:

$date_raw      = $post->DTT_EVT_start;
$date_raw_end  = $post->DTT_EVT_end;

You change it to this:

$datetimes = EEM_Datetime::instance()->get_datetimes_for_event_ordered_by_start_time( 
    $post->ID, 
    true, 
    false, 
    1 
);
$datetime = end( $datetimes );
$date_raw      = $datetime->get_date('DTT_EVT_start', 'Y-m-d H:i:s');
$date_raw_end  = $datetime->get_date('DTT_EVT_end', 'Y-m-d H:i:s');

2) Then for the Places Left code, you change this:

$ticket_total   = $post->DTT_reg_limit;
$ticket_sold    = $post->DTT_sold;

to this:

$ticket_total   = $datetime->get('DTT_reg_limit');
$ticket_sold    = $datetime->get('DTT_sold');

Hope that helps!


Cuillin

September 23, 2015 at 11:14 am

Hi

Thanks for the quick response Josh – much appreciated. I’ll try that in my code right away.

Lesley


Josh

  • Support Staff

September 23, 2015 at 11:42 am

You’re welcome.


Cuillin

September 24, 2015 at 4:03 am

Hi Josh

The code is working perfectly on the individual course pages now, which is great!.

I am still having a problem on other pages however – specifically the homepage, the event listing page and the event archive page – where the courses are displayed in ‘card’ view. I have tried to alter the code for these pages myself, based on your earlier example, but I can either get the date to be correct or the ‘Places Left’ to be correct but not both – not sure how to proceed so would value your input.

Pages where the courses are displayed in card view:
http://staging5.tourismgrowth.co.uk/
http://staging5.tourismgrowth.co.uk/training-courses-events/
http://staging5.tourismgrowth.co.uk/archive-training-courses-events/
(includes display of ‘Featured Events’ on pages)

Files:
…/staging/5/wp-content/themes/creative-tourismgrowth/

=> t-5-courses.php
=> zzz-defer-page.php

…/staging/5/wp-content/themes/creative-tourismgrowth/_/inc/

=> cn-single-related-event.php

/……………………………/
https://www.dropbox.com/sh/kmkcjm5h7incp99/AAAQCilV3sLcuzvNanMfIOD5a?dl=0
/……………………………/

Really hope you can help.
Many thanks
Lesley


Josh

  • Support Staff

September 24, 2015 at 8:04 am

Hi Lesley,

For that t-5-courses.php and similar templates, the date variables look like they should still work, because the espresso_event_date() function will still return an event date. You should be able to leave that code as-is.

For the $ticket_total and $ticket_sold variables, you’ll need to change the way you get those variables.

So, where you have this currently:

$ticket_total   = $post->DTT_reg_limit;
$ticket_sold    = $post->DTT_sold;

You can change it to this:

$datetimes = EEM_Datetime::instance()->get_datetimes_for_event_ordered_by_start_time(
    $post->ID, 
    true, 
    false, 
    1 
);
$datetime = end( $datetimes );                        
$ticket_total   = $datetime->get('DTT_reg_limit');
$ticket_sold    = $datetime->get('DTT_sold');


Cuillin

September 24, 2015 at 8:57 am

Hi Josh

That’s excellent – thanks for getting back to me so quickly 🙂
I’ll check it out right away.

Lesley


Josh

  • Support Staff

September 24, 2015 at 9:29 am

You’re welcome.


Cuillin

September 24, 2015 at 9:39 am

Everything is working perfectly now – thanks again for all your help.

Have a great day 😉

Lesley


Josh

  • Support Staff

September 24, 2015 at 9:58 am

You too!

Viewing 10 reply threads

The support post ‘DateTime 'Places Left' conflict – with EE4 versions after 4.4.6’ 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