• Resolved rossfabio

    (@rossfabio)


    This topic is related to this other one.

    I was looking to implement the same solution but found it outdated, since i solved it and got it to work for me i thought to share it ??

    Original topic was asking for a way to only show RSVP block when the event was sold out, this is useful when you need to use it as a waiting list.

    @sjaure suggested to:

    create a custom template for this template part: wp-content/plugins/event-tickets/src/views/v2/rsvp.php, then use the method tribe_events_count_available_tickets() to get the count of available tickets. If it is = 0 then you render the RSVP block, otherwise you return false. 

    This would have been a good solution if tickets and RSVP where counted separately, unfortunately RSVPs capacities are added to tickets capacities in the count, therefore when adding an RSVP the count will never be 0 unless the RSVP is at capacity too.

    To achieve the result i instead added the following code after the IF statement on line 24:

    DISCLAIMER: i am no professional, use the following code at your own risk, i do not assume any responsability for any issue that its use could create.

    //we don't display anything if the event isn't sold out
    $event = tribe_get_event ($post_id);
     if (! $event->tickets->sold_out()) {
    	 return false;
     }

    we gather the event object from the post id, then we check if the sold out value is not true, if that is the case we return false to displaying the rsvp block

    i would suggest to also provide an override so that you can manually display the rsvp block even when the event is not sold out (you never know until you need it). You can do this with the custom fields of events calendar pro, if you have it, or with a custom post meta from wordpress by changing the code as follows:

    /*SOLUTION WITH EVENTS CALENDAR PRO*/
    
    //you have to create a custom checkbox and name it RSVPoverride for it to work or modify accordingly
    
    
    //retrieve event object
    $event = tribe_get_event ($post_id);
    //retrieve custom fields array
    $fields = tribe_get_custom_fields($event->ID);
     
    //we don't display anything if the event isn't sold out unless override is true
    if (! $event->tickets->sold_out() && empty( $fields['RSVPoverride'] )) {
    	 return false;
     }

    or like this if you don’t have calendar pro

    /*SOLUTION WITH WORDPRESS CUSTOM FIELDS*/
    
    //you have to create a custom field and name it RSVPoverride for it to work or modify accordingly
    
    //write anything except 'false' in the custom field to override
    
    //retrieve event object
    $event = tribe_get_event ($post_id);
    //retrieve custom fields array
    $RSVPoverride = get_post_meta($post_id,'RSVPoverride',true);
     
    //we don't display anything if the event isn't sold out and the override is empty or false
    if (! $event->tickets->sold_out() && ! $RSVPoverride ) {
    	 return false;
     }

    hope it helped ??

    • This topic was modified 1 year, 7 months ago by rossfabio.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Darian

    (@d0153)

    Hi @rossfabio

    Thank you for taking the time to share such a thorough integration. I’m sure many other users will find it incredibly helpful. Your willingness to share your knowledge is appreciated.

    Thread Starter rossfabio

    (@rossfabio)

    my pleasure, I have been tailoring the plugin to my needs for quite some time and thought I’d help by sharing some of my progress that can be useful to others ??

    if that’s ok I’ll post other snippets of code every now and then (I’ll open a new thread when I have a piece of new code that I think it’s worth sharing)

    cheers ??

    Plugin Support Darian

    (@d0153)

    Hi @rossfabio

    That’s awesome! Thank you so much for sharing your progress with the plugin. I’m sure many others will find it useful as well. Please feel free to post other snippets of code whenever you can. We appreciate your willingness to contribute and help the community.

    Plugin Support Erica

    (@eeide)

    Hi @rossfabio,

    Thanks again for your helpful contributions!

    This thread has been inactive for a while so we’re going to go ahead and mark it Resolved.

    Thank you,
    Erica

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Hide RSVP/Waitlist Until Tickets are sold out’ is closed to new replies.