Support

Home Forums Event Espresso Premium SOLD OUT EVENTS

SOLD OUT EVENTS

Posted: December 4, 2017 at 5:24 pm

Viewing 3 reply threads


websynest

December 4, 2017 at 5:24 pm

I set up a site several years ago using EE3 and the EE calendar add-on. Somehow I set it so that sold out events displayed in gray and have the words SOLD OUT on them. http://smudgestudiosaustin.com/upcoming-events/

But client just noticed that it is not working on pages that show a calendar for a specific event category: http://smudgestudiosaustin.com/kids/camps/

(Almost all of the December Camps are sold out).

I have been digging and digging through the code trying to figure out how I even made it happen on the main calendar! Can anyone tell me how to make sure it does the same thing on category calendars?


Tony

  • Support Staff

December 4, 2017 at 5:57 pm

Hi there,

As it’s not something EE does by default, we don’t know how to apply the same logic to the ‘category calendars’, however as far as EE is concerned there’s no difference between a calendar showing all events and events its pulled in for a category, its just an array of events and uses the same function to loop through them and work out what to do.

So with that said I can tell you where I would start looking for custom code.

\espresso-calendar\espresso-calendar.php

The get_calendar_events function is used to pull the events and build an array of events to be json encoded for the calendar to use.

You’re setting the link href to # so check for what is happening with the $events[ $cntr ]['url'] element.

The title has sold out prepended, so checkout: $events[ $cntr ]['title']

$events[ $cntr ]['color'] is used for the background colour.

Compare whats happening with those elements in your calendar with the default version and it might help shed some light on how the calendar was edited.


websynest

December 4, 2017 at 8:45 pm

Actually it looks like I had hired someone to help me with this, which is why it was so over my head trying to figure out how it worked. 😉

I think it has to do with this added code:

//Reset category colors
$events[ $cntr ]['color'] = '';
$events[ $cntr ]['textColor'] = '';

global $this_event_id;

$this_event_id = $event->id;

//Get details about the category of the event
if ($use_categories) {
// extract info from separate array of category data ?
if ( isset( $event_categories[$event->id] ) ) {
// get first element of array without modifying original array
$primary_cat = $event_categories[$event->id];
$sort_cats = apply_filters( 'filter_hook_espresso_calendar_category_color_sort', 'asort' );
switch( $sort_cats ) {
case 'asort': usort($primary_cat, array($this, 'asort_by_cat_name'));
break;
case 'arsort': usort($primary_cat, array($this, 'arsort_by_cat_name'));
break;
case 'false': $primary_cat;
break;
}
$primary_cat = array_shift( $primary_cat );
$category_data['category_meta'] = unserialize($primary_cat->category_meta);
} else {
$category_data['category_meta'] = array();
}

//Assign colors to events by category
if ( $enable_cat_classes && isset($category_data['category_meta']['use_pickers']) && $category_data['category_meta']['use_pickers'] == 'Y') {
if ($sold_event == true && $wdm_hide_sold_events == 'true') {
$events[ $cntr ]['color'] = '#a9a9a9';
$events[ $cntr ]['textColor'] = '#FFFFFF';//$category_data['category_meta']['event_text_color'];

} else {
$events[ $cntr ]['color'] = $category_data['category_meta']['event_background'];
$events[ $cntr ]['textColor'] = $category_data['category_meta']['event_text_color'];
}

}
}


Tony

  • Support Staff

December 5, 2017 at 1:46 am

The code that is custom above would be:

if ($sold_event == true && $wdm_hide_sold_events == 'true') {
	$events[ $cntr ]['color'] = '#a9a9a9';
	$events[ $cntr ]['textColor'] = '#FFFFFF';//$category_data['category_meta']['event_text_color'];
} else {
	$events[ $cntr ]['color'] = $category_data['category_meta']['event_background'];
	$events[ $cntr ]['textColor'] = $category_data['category_meta']['event_text_color'];
}

Which basically checks if both the event is sold out and wdm_hide_sold_events are true, if so set the background colour to #a9a9a9 and the text colour #FFFFFF and if not, use the default colours you have set in the calendar settings.

So its likely this check:

if ($sold_event == true && $wdm_hide_sold_events == 'true') {

Is being done in various places to add additional content to the calendar, you’ll need to find those and work through to confirm the same happens for a normal ‘all eventrequest and acategory` request.

Have you checked that the shortcodes you are using for both the main calendar and the category calendar match? (Obviously other than the parameter to specify the category)

I didn’t write the code so I don’t know for sure but you may need to add wdm_hide_sold_events=true to the calendar shortcode for it to work.

If not you may need to contact WisdmLabs as it looks like they are the developers who added the functionality for you (the use wdm_ within their code), who are listed here:

https://eventespresso.com/developers/event-espresso-pros/

Viewing 3 reply threads

The support post ‘SOLD OUT EVENTS’ 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