Support

Home Forums Event Espresso Premium Show available spaces in cart

Show available spaces in cart

Posted: January 23, 2017 at 8:08 am

Viewing 3 reply threads


Chester Bowl

January 23, 2017 at 8:08 am

I’d like to show available spaces in the cart (shopping_cart.php template), but it’s coming back as 0. I’m using this:

Available Spaces: <?php echo do_shortcode(‘[ATTENDEE_NUMBERS event_id=”‘.$event_id.'” type=”available_spaces”]’);?>

Any ideas?


Josh

  • Support Staff

January 23, 2017 at 2:48 pm

Hi there,

You’re trying to use a variable that’s not set. In this case the variable is
$event_id. If you look at the code in the shopping_cart.php template around line 60, you’ll see that there’s already a variable set for
$available_spaces, so why not use that instead?


Tony

  • Support Staff

January 23, 2017 at 2:49 pm

Hi there,

Have you setup an $event_id variable that contains the current event ID as that is not used within shopping_cart.php by default?

If you are within shopping_cart.php can I ask why you are using the shortcode and not the function it calls?

That shortcode uses the get_number_of_attendees_reg_limit() function so call that directly rather than parsing the shortcode to do it for you.

Like this:

`$available_spaces = get_number_of_attendees_reg_limit( $event_id, $type = ‘available_spaces’);

Assuming you have an $event_id variable setup but you’ll like want to use $r->id for the event id.

However within shopping_cart.php on line 60-62 you should have:

$num_attendees = apply_filters('filter_hook_espresso_get_num_attendees', $r->id);//Get the number of attendees
$available_spaces = apply_filters('filter_hook_espresso_available_spaces_text', $r->id);//Gets a count of the available spaces
$number_available_spaces = apply_filters('filter_hook_espresso_get_num_available_spaces', $r->id);//Gets the number of available spaces

That does all of this for you so you have those 3 variables you can echo out to get the value you’re looking for.

Available Spaces:

You don’t need the double quotes around the values unless there is a space, those can often cause problems. It could be the forum adding this formatting but there are multiple styles of quote within your text , ', that you need to watch out for.


Chester Bowl

January 24, 2017 at 8:23 am

Thanks! Super helpful. 🙂

Viewing 3 reply threads

The support post ‘Show available spaces in cart’ 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