Support

Home Forums Event Espresso Premium recommending another event when one is sold out

recommending another event when one is sold out

Posted: September 3, 2015 at 4:41 am

Viewing 1 reply thread


Rob Orr

September 3, 2015 at 4:41 am

We use EE to do bookings for our bike tours. One tour is a tour where part of it starts using another attraction and we have no control over when that sells out. We handle that easily enough on the site in EE by making the event inactive.

What we would like to do is make a recommendation for another tour if that event is set to inactive. Customers can still do one of our other tours if the other attraction is sold out so we would like to point them to another tour when this one is inactive. Is that currently possible? Can you make a recommendation on how we can make that happen based on whether or not this one tour is active or not?


Dean

September 3, 2015 at 5:25 am

Hi Rob,

Couple of options.

1) you could try using one of the various recommended post plugins (if they work with Custom Post Types and Custom Taxonomies). You would likely need some custom code to hide it when the event is open though.

2) just use custom code.

Here is an example (not supported, just an example to get you started)

function eeyarpp($post) {

if( $post->EE_Event->is_sold_out() ) {
    $terms = wp_get_post_terms( $post->ID, 'espresso_event_categories' );

    $term_array =array();

    foreach ($terms as $term) {
        $term_array[] = $term->term_id;
    }

    $args = array(
        'post_type' => 'espresso_events',
        'tax_query' => array(
                              array(
                              'taxonomy' => 'espresso_event_categories',
                              'field' => 'id',
                              'terms' => $term_array
                               )
                        )
    );

    $query = new WP_Query( $args );
    echo "<ul>";
    while ( $query->have_posts() ) : $query->the_post(); ?>

       <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    <?php
    endwhile;
    echo "</ul>";
    wp_reset_postdata();

}

}
add_action('AHEE_event_details_after_the_content', 'eeyarpp');

That code hooks into the bottom of an event, if the event is sold out it finds the events categories and then finds events in the same categories and lists their titles out.

Obviosuly that’s fairly basic and doesn’t cover all eventualities, nor is the design any good, nor does it limit the number of events shown, but it should give you a good idea of one way to proceed.

Viewing 1 reply thread

The support post ‘recommending another event when one is sold out’ 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