function event_espresso_add_item_to_session()
 {
     do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, '');
     global $wpdb;
     // echo "<pre>", print_r( $_POST ), "</pre>";
     $events_in_session = isset($_SESSION['espresso_session']['events_in_session']) ? $_SESSION['espresso_session']['events_in_session'] : event_espresso_clear_session(TRUE);
     /*
      * added the cart_link_# to the page to prevent element id conflicts on the html page
      *
      */
     $id = str_replace('cart_link_', '', sanitize_text_field($_POST['id']));
     $direct_to_cart = isset($_POST['direct_to_cart']) ? $_POST['direct_to_cart'] : 0;
     $moving_to_cart = isset($_POST['moving_to_cart']) ? urldecode($_POST['moving_to_cart']) : __('Please wait redirecting to cart page', 'event_espresso');
     //One link, multiple events
     if (strpos($id, "-")) {
         $event_group = explode("-", $id);
         foreach ($event_group as $event) {
             $event_title = get_event_field('event_name', EVENTS_DETAIL_TABLE, ' WHERE id = ' . $event);
             event_espresso_add_event_process((int) $event, $event_title);
         }
     } else {
         //one event per click
         event_espresso_add_event_process($id, $_POST['name']);
     }
     $r = event_espresso_cart_link(array('event_id' => $id, 'view_cart' => TRUE, 'event_page_id' => $_POST['event_page_id'], 'direct_to_cart' => $direct_to_cart, 'moving_to_cart' => $moving_to_cart));
     echo event_espresso_json_response(array('html' => $r, 'code' => 1));
     //echo '<a href="' . site_url() . '/events/?regevent_action=show_shopping_cart">' . __( 'View Cart', 'event_espresso' ) . '</a>';
     die;
 }
        ?>
</span> <?php 
        echo get_number_of_attendees_reg_limit($event_id, 'available_spaces');
        ?>
</p>
            <?php 
    }
    /**
     * Load the multi event link.
     * */
    //Un-comment these next lines to check if the event is active
    //echo event_espresso_get_status($event_id);
    //print_r( event_espresso_get_is_active($event_id));
    if ($multi_reg && event_espresso_get_status($event_id) == 'ACTIVE') {
        $params = array('event_id' => $event_id, 'anchor' => __("Add to Cart", 'event_espresso'), 'event_name' => $event_name, 'separator' => __(" or ", 'event_espresso'));
        $cart_link = event_espresso_cart_link($params);
    }
    if ($display_reg_form == 'Y') {
        ?>

            <p id="register_link-<?php 
        echo $event_id;
        ?>
" class="register-link-footer">
                <a class="a_register_link" id="a_register_link-<?php 
        echo $event_id;
        ?>
" href="<?php 
        echo $registration_url;
        ?>
" title="<?php