Support

Home Forums Event Espresso Premium Show Sold Out tickets in listing

Show Sold Out tickets in listing

Posted: July 2, 2020 at 6:50 pm


mobile kino 2

July 2, 2020 at 6:50 pm

Hello,

We have created a custom template to show the available events, and to not show the expired events, successfully.

We now have the issue that the sold out events are not being listed on the template.

Here is our code:


// set up show expired = false
$where = array(
'Datetime.DTT_EVT_end' => array( '>=', current_time( 'mysql' )),
'status' => 'publish',
);

// run the query
if ( class_exists( 'EE_Registry' ) ) :
$events = EE_Registry::instance()->load_model( 'Event' )->get_all( array(
$where,
'limit' => 100,
'order_by' => 'Datetime.DTT_EVT_start',
'order' => 'ASC',
'group_by' => 'EVT_ID'
));

I understand that because the status is “published”, it won’t show the sold out tickets, however – I can’t seem to find around your documentation as it not very simple to look into it.

If you could please help me, with my query code. Just need changing it so that we an also list the sold out events too. (But not the expired ones)

Thank you


Tony

  • Support Staff

July 3, 2020 at 9:29 am

Hi there,

You just need to change the status param to include both the ‘publish’ and ‘sold_out’ status, so change:

'status' => 'publish',

To

'status' => array('IN', array('publish', EEM_Event::sold_out)),

You can find some details on using IN (and other operators) within where_params here:

https://github.com/eventespresso/event-espresso-core/blob/master/docs/G–Model-System/model-query-params.md#different-operators

The support post ‘Show Sold Out tickets in listing’ 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