Support

Home Forums Event Espresso Premium How to display number of available seats on the event registration page

How to display number of available seats on the event registration page

Posted: September 14, 2012 at 11:54 am


Wesley

September 14, 2012 at 11:54 am

New to Event Espresso and I am having a difficult time navigating through the documentation.

We are trying to edit registration_page_display.php to include the number of remaining seats.

Is this possible?
If so, could you help point us in the right direction to generating the appropriate code?

Thank you!


Wesley

September 17, 2012 at 1:22 pm

We’ve been working on including the Available Seats in our registration page all weekend. The following code is the best we have come up with. Can anyone explain why it causes an error?

The following code was taken from the event_list_display file, where it works fine. I have only closed the php tags to make it fit in the registration_page_display file.` = $reg_limit) {
?>
<p id="available_spaces-“>

        &lt;p id=&quot;register_link-" class="register-link-footer"&gt;&lt;a class=&quot;a_register_link&quot; id=&quot;a_register_link-" href="" title=""&gt;</a>
                    &lt;p id=&quot;available_spaces-" class="spaces-available"&gt; 

`

Once we put this into the registration_page_display file, we get a syntax error on line 311.

Here is the full code with our attempts to include the available seats:

&lt;h3 class=&quot;event_title ui-widget-header ui-corner-top&quot; id=&quot;event_title-"&gt;  &lt;?php echo $is_active[&#039;status&#039;] == &#039;EXPIRED&#039; ? &#039; - Event Expired' : ''; ?&gt; &lt;?php echo $is_active[&#039;status&#039;] == &#039;PENDING&#039; ? &#039; - Event is Pending' : ''; ?&gt; &lt;?php echo $is_active[&#039;status&#039;] == &#039;DRAFT&#039; ? &#039; - Event is a Draft' : ''; ?&gt; 

<div class="event_espresso_form_wrapper event-data-display ui-widget-content “>

                        <strong>

                        </strong>

                        <strong>

                        </strong>                                                       
                        &lt;?php
                    }
                    echo event_date_display($start_date, get_option(&#039;date_format&#039;));                      
                    if ($end_date !== $start_date) {                            
                        echo &#039;';
                        ?&gt;
                        <strong>

                        </strong> &lt;?php echo event_date_display($end_date, get_option(&#039;date_format&#039;));
                        echo &#039;';
                    }?&gt;



                    &lt;?php //This block of code is used to display the times of an event in either a dropdown or text format.
                        if (isset($time_selected) &amp;&amp; $time_selected == true) {//If the customer is coming from a page where the time was preselected.
                            echo event_espresso_display_selected_time($time_id); //Optional parameters start, end, default
                        } else {
                            echo event_espresso_time_dropdown($event_id);
                        }//End time selected





                    echo &#039;';   
                        ?&gt;                   




    &lt;?php // echo &#039;'; ?&gt;
    &lt;?php // echo &#039;' . __('Venue Details', 'event_espresso') . ''; ?&gt;
    &lt;?php // echo $venue_title != &#039;&#039;?&#039;'.stripslashes_deep($venue_title).'':''?&gt;
    &lt;?php // echo $venue_address != &#039;&#039;?&#039;'.stripslashes_deep($venue_address).'':''?&gt;
    &lt;?php // echo $venue_address2 != &#039;&#039;?&#039;'.stripslashes_deep($venue_address2).'':''?&gt;
    &lt;?php // echo $venue_city != &#039;&#039;?&#039;'.stripslashes_deep($venue_city).'':''?&gt;
    &lt;?php // echo $venue_state != &#039;&#039;?&#039;'.stripslashes_deep($venue_state).'':''?&gt;
    &lt;?php // echo $venue_zip != &#039;&#039;?&#039;'.stripslashes_deep($venue_zip).'':''?&gt;
    &lt;?php // echo $venue_country != &#039;&#039;?&#039;'.stripslashes_deep($venue_country).'':''?&gt;
    &lt;?php // echo &#039;'; ?&gt;







        &lt;?php
    }//End display description

    switch ($is_active[&#039;status&#039;]) {
        case &#039;EXPIRED&#039;: //only show the event description.
            _e(&#039;This event has passed.', 'event_espresso');
            break;

        case 'REGISTRATION_CLOSED': //only show the event description.
            // if todays date is after $reg_end_date
            ?&gt;




                    <strong>

                    </strong>


                    <strong>
                        &lt;?php _e(&#039;Please <a href="contact" title="contact us">contact us</a> if you would like to know if spaces are still available.', 'event_espresso'); ?&gt;
                    </strong>






                    <strong>

                    </strong>


                    <strong>

                    </strong>



            &lt;form method=&quot;post&quot; action=&quot;/?page_id=" id="registration_form"&gt;

                    &lt;p class=&quot;event_address&quot; id=&quot;event_address-"&gt; 

















                        = $reg_limit) { 
    ?&gt;
    &lt;p id=&quot;available_spaces-"&gt; 

        &lt;p id=&quot;register_link-" class="register-link-footer"&gt;&lt;a class=&quot;a_register_link&quot; id=&quot;a_register_link-" href="" title=""&gt;</a>
                    &lt;p id=&quot;available_spaces-" class="spaces-available"&gt; 






                                    &lt;input type=&quot;text&quot; name=&quot;seat_id&quot; value=&quot;&quot; class=&quot;ee_s_select_seat required&quot; title=&quot;" event_id="" readonly="readonly"  /&gt;
                                    get_row("select * from " . EVENTS_SEATING_CHART_TABLE . " where id = $seating_chart_id");
                                    if (trim($seating_chart-&gt;image_name) != "" &amp;&amp; file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'seatingchart/images/' . $seating_chart-&gt;image_name)) {
                                        ?&gt;

                                        &lt;a href=&quot;image_name; ?&gt;" target="_blank"&gt;</a>








                         1));
                        ?&gt;

                     1) {

                        //This returns the additional attendee form fields. Can be overridden in the custom files addon.
                        echo event_espresso_additional_attendees($event_id, $additional_limit, $number_available_spaces, __('Number of Tickets', 'event_espresso'), true, $event_meta);
                    } else {
                        ?&gt;
                        &lt;input type=&quot;hidden&quot; name=&quot;num_people&quot; id=&quot;num_people-" value="1"&gt;

                    &lt;input type=&quot;hidden&quot; name=&quot;regevent_action&quot; id=&quot;regevent_action-" value="post_attendee"&gt;
                    &lt;input type=&quot;hidden&quot; name=&quot;event_id&quot; id=&quot;event_id-" value=""&gt;

                        &lt;p class=&quot;event_form_field&quot; id=&quot;captcha-"&gt;



                    &lt;p class=&quot;event_form_submit&quot; id=&quot;event_form_submit-"&gt;
                        &lt;input class=&quot;btn_event_form_submit ui-button ui-button-big ui-priority-primary ui-state-default ui-state-hover ui-state-focus ui-corner-all&quot; id=&quot;event_form_field-" type="submit" name="Submit" value=""&gt;

<?php echo '’ . espresso_edit_this($event_id) . ” ?>


Wesley

September 17, 2012 at 1:23 pm

Here’s the line with the syntax error:

&lt;?php echo &#039;' . espresso_edit_this($event_id) . '' ?&gt; 


Wesley

September 17, 2012 at 4:34 pm

Hi, I don’t know how to edit my post. I see the preview is below the reply box now. I was looking for a preview button.

The code above looks like it came out like gibberish. I’m not sure if anyone can tell what’s going on with it, but it worked to display the Available Spaces, as we wanted. I just had to delete a small section that was causing problems. I now have the Available Seats listed in the form, but everything below the Available Seats in the form is gone.

The working code looks like this:


<p id="available_spaces-">

<p id="register_link-"class="register-link-footer">
<a class="a_register_link"
id="a_register_link-"
href=""
title="">

<p id="available_spaces-"
class="spaces-available">

        &lt;?php
    } 

I can’t tell in the below preview if my code is showing right or not. I’ve put it in a notepad in order to remove formatting, and also put line breaks in it that are not actually there, in order to get it to fit in the post field properly. And I’ve used the tag instead of the brackets graphic. I'll post it again without the line breaks, if this doesn't make it readable.


Wesley

September 17, 2012 at 4:36 pm

That didn’t work at all. I’ll search how to post code in a forum. I don’t know how anyone can help, if they can’t see the code.


Wesley

September 17, 2012 at 4:50 pm

This is a link to the code.

The entire file is there to look at. The problem is the rest of the Registration Form not showing after the Available Seats. I apologize for all the messy posts above.


Dean

September 18, 2012 at 3:00 am

Hi Wesley,

Dont worry about the messy posts it happens.

It looks like the code you supplied was missing some of the code to begin with and also a closing }

this should do what you were trying to achieve

<?php         
    $num_attendees = get_number_of_attendees_reg_limit($event_id, 'num_attendees'); //Get the number of attendees. Please visit https://eventespresso.com/forums/?p=247 for available parameters for the get_number_of_attendees_reg_limit() function.
    if ($num_attendees >= $reg_limit) { ?> 

        <p id="available_spaces-<?php echo $event_id ?>"><span class="section-title"><?php _e('Available Spaces:', 'event_espresso') ?> </span><?php echo get_number_of_attendees_reg_limit($event_id, 'available_spaces', 'All Seats Reserved') ?></p>

        <?php if ($overflow_event_id != '0' && $allow_overflow == 'Y') { ?>
            <p id="register_link-<?php echo $overflow_event_id ?>" class="register-link-footer"><a class="a_register_link" id="a_register_link-<?php echo $overflow_event_id ? rel="nofollow">" href="<?php echo espresso_reg_url($overflow_event_id); ?>" title="<?php echo stripslashes_deep($event_name) ?>"><?php _e('Join Waiting List', 'event_espresso'); ?></a></p>
            <?php
        }
    } else {
        if ($display_reg_form == 'Y' && $externalURL == '') {
            ?>          <p id="available_spaces-<?php echo $event_id ?>" class="spaces-available"><span class="section-title"><?php _e('Available Spaces:', 'event_espresso') ?></span> <?php echo get_number_of_attendees_reg_limit($event_id, 'available_spaces') ?></p>
            <?php
        } 
    }
  • This reply was modified 11 years, 7 months ago by  Dean.


Wesley

September 18, 2012 at 6:29 pm

Thank you Dean!

The support post ‘How to display number of available seats on the event registration page’ 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