function event_espresso_add_attendees_to_db_multi() { global $wpdb, $org_options; //Added by Imon $primary_registration_id = NULL; $events_in_session = $_SESSION['espresso_session']['events_in_session']; if (event_espresso_invoke_cart_error($events_in_session)) { return false; } $count_of_events = count($events_in_session); $current_session_id = $_SESSION['espresso_session']['id']; //Debug //echo "<pre>", print_r($_SESSION), "</pre>"; //echo '<pre>'.print_r($_POST, true).'</pre>'; //echo "<pre>", print_r($events_in_session), "</pre>"; //echo "<pre>", print_r($org_options), "</pre>"; $event_name = $count_of_events . ' ' . $org_options['organization'] . __(' events', 'event_espresso'); $event_cost = $_SESSION['espresso_session']['grand_total']; $multi_reg = true; // If there are events in the session, add them one by one to the attendee table if ($count_of_events > 0) { //first event key will be used to find the first attendee $first_event_id = key($events_in_session); //Debug //echo '<pre>$events_in_session - '.print_r($events_in_session, true).'</pre>'; reset($events_in_session); foreach ($events_in_session as $key => $_event_id) { //Debug //echo '<p>$_event_id - '. $_event_id.'</p>'; //echo '<pre>'.print_r($_event_id, true).'</pre>'; $event_meta = event_espresso_get_event_meta($key); $event_attendees = $_event_id['event_attendees']; $session_vars['data'] = $_event_id; //Debug //echo '<p>$_event_id - '. $_event_id.'</p>'; //echo '<pre>'.print_r($session_vars['data'], true).'</pre>'; if (is_array($event_attendees)) { $counter = 1; foreach ($event_attendees as $k_price_id => $v_attendees) { //foreach price type in event attendees $session_vars['data'] = $_event_id; //Debug //echo '<pre>$session_vars[\'data\' - ]'.print_r($session_vars['data'], true).'</pre>'; foreach ($v_attendees as $vkey => $vval) { //Added by Imon $vval['price_id'] = $k_price_id; $session_vars['event_attendees'] = $vval; //this has all the attendee information, name, questions.... $session_vars['data']['price_type'] = $_event_id['price_id'][$k_price_id]['price_type']; if (isset($event_meta['additional_attendee_reg_info']) && $event_meta['additional_attendee_reg_info'] == 1) { //Getting he wrong number of attendees at this point //Debug //echo '<p>$_REQUEST[\'num_people\'] - '.$_REQUEST['num_people'].'</p>'; //echo '<p>$_event_id[\'price_id\'][$k_price_id] - '.$_event_id['price_id'][$k_price_id].'</p>'; //echo '<pre>$_event_id[\'price_id\'][$k_price_id] - '.print_r($_event_id['price_id'][$k_price_id]['attendee_quantity'], true).'</pre>'; //echo '<pre>'.print_r($_POST, true).'</pre>'; $num_people = $_event_id['price_id'][$k_price_id]['attendee_quantity']; $session_vars['data']['num_people'] = empty($num_people) || $num_people == 0 ? 1 : $num_people; //Debug //echo '<p>$session_vars[\'data\'][\'num_people\'] - '.$session_vars['data']['num_people'].'</p>'; } //Debug /* echo $key.'<br />'; echo '<pre>$session_vars - '.print_r($session_vars, true).'</pre>'; echo '<br />'; */ $tmp_registration_id = event_espresso_add_attendees_to_db($key, $session_vars); //Debug //echo 'tmp_registration_id =' . $tmp_registration_id.'<br />'; if ($primary_registration_id === NULL) { $primary_registration_id = $tmp_registration_id; } $c2_sql = "select * from " . EVENTS_MULTI_EVENT_REGISTRATION_ID_GROUP_TABLE . " where primary_registration_id = '{$primary_registration_id}' and registration_id = '{$tmp_registration_id}'"; //Debug //echo $c2_sql.'<br />'; $check = $wpdb->get_row($c2_sql); if ($check === NULL) { $tmp_data = array("primary_registration_id" => $primary_registration_id, "registration_id" => $tmp_registration_id); $wpdb->insert(EVENTS_MULTI_EVENT_REGISTRATION_ID_GROUP_TABLE, $tmp_data); } } $counter++; } } } //Post the gateway page with the payment options if ($event_cost != '0.00') { //find first registrant's name, email, count of registrants $sql = "SELECT id, fname, lname, email, address, city, state, zip, event_id, registration_id,\n\t\t\t\t\t\t(SELECT count( id )\n\t\t\t\t\t\t\tFROM " . EVENTS_ATTENDEE_TABLE . " WHERE attendee_session = '" . $wpdb->escape($current_session_id) . "'\n\t\t\t\t\t\t\t) AS quantity\n\t\t\t\t\t\t\tFROM " . EVENTS_ATTENDEE_TABLE . " WHERE event_id = " . $wpdb->escape($first_event_id) . " AND attendee_session = '" . $wpdb->escape($current_session_id) . "' LIMIT 1"; //echo $sql; $r = $wpdb->get_row($sql); $event_id = $r->event_id; $attendee_id = $r->id; $fname = $r->fname; $lname = $r->lname; $address = $r->address; $city = $r->city; $state = $r->state; $zip = $r->zip; $attendee_email = $r->email; $registration_id = $r->registration_id; $quantity = espresso_count_attendees_for_registration($r->registration_id); ?> <?php /* //removing edit links for now...will fix edit attendee page in 3.2 cb #830 <a href="?page_id=<?php echo $org_options['event_page_id']; ?>®event_action=show_shopping_cart"> <?php _e('Edit Cart', 'event_espresso'); ?> </a> <?php _e(' or ', 'event_espresso'); ?> <a href="?page_id=<?php echo $org_options['event_page_id']; ?>®event_action=load_checkout_page"> <?php _e('Edit Registrant Information', 'event_espresso'); ?></a> */ ?> <h3><?php _e('Your registration is not complete until payment is received.', 'event_espresso'); ?> </h3> <p><strong class="event_espresso_name"> <?php _e('Amount due: ', 'event_espresso'); ?> </strong> <span class="event_espresso_value"><?php echo $org_options['currency_symbol']; echo $event_cost; ?> </span></p> <p><?php echo $org_options['email_before_payment'] == 'Y' ? __('A confirmation email has been sent with additional details of your registration.', 'event_espresso') : ''; ?> </p> <?php //Show payment options if (file_exists(EVENT_ESPRESSO_GATEWAY_DIR . "gateway_display.php")) { require_once EVENT_ESPRESSO_GATEWAY_DIR . "gateway_display.php"; } else { require_once EVENT_ESPRESSO_PLUGINFULLPATH . "gateways/gateway_display.php"; } //Check to see if the site owner wants to send an confirmation eamil before payment is recieved. if ($org_options['email_before_payment'] == 'Y') { event_espresso_email_confirmations(array('session_id' => $_SESSION['espresso_session']['id'], 'send_admin_email' => 'true', 'send_attendee_email' => 'true', 'multi_reg' => true)); } } else { ?> <p><?php _e('Thank you! Your registration is confirmed for', 'event_espresso'); ?> <strong><?php echo stripslashes_deep($event_name); ?> </strong></p> <p><?php _e('A confirmation email has been sent with additional details of your registration.', 'event_espresso'); ?> </p> <?php event_espresso_email_confirmations(array('session_id' => $_SESSION['espresso_session']['id'], 'send_admin_email' => 'true', 'send_attendee_email' => 'true', 'multi_reg' => true)); event_espresso_clear_session(); } } }
function event_espresso_shopping_cart() { global $wpdb, $org_options; //session_destroy(); //echo "<pre>", print_r( $_SESSION ), "</pre>"; $events_in_session = $_SESSION['espresso_session']['events_in_session']; if (event_espresso_invoke_cart_error($events_in_session)) { return false; } if (count($events_in_session) > 0) { foreach ($events_in_session as $event) { // echo $event['id']; if (is_numeric($event['id'])) { $events_IN[] = $event['id']; } } $events_IN = implode(',', $events_IN); $sql = "SELECT e.* FROM " . EVENTS_DETAIL_TABLE . " e "; $sql .= " WHERE e.id in ({$events_IN}) "; $sql .= " AND e.event_status != 'D' "; $sql .= " ORDER BY e.start_date "; $result = $wpdb->get_results($sql); ?> <form action='?page_id=<?php echo $org_options['event_page_id']; ?> ®event_action=load_checkout_page' method='post' id="event_espresso_shopping_cart"> <?php $counter = 1; //Counter that will keep track of the first events foreach ($result as $r) { $num_attendees = get_number_of_attendees_reg_limit($r->id, 'num_attendees'); //Get the number of attendees $available_spaces = get_number_of_attendees_reg_limit($r->id, 'available_spaces'); //Gets a count of the available spaces $number_available_spaces = get_number_of_attendees_reg_limit($r->id, 'number_available_spaces'); //Gets the number of available spaces //echo "<pre>$r->id, $num_attendees,$available_spaces,$number_available_spaces</pre>"; ?> <div class="multi_reg_cart_block event-display-boxes ui-widget" id ="multi_reg_cart_block-<?php echo $r->id; ?> "> <h3 class="event_title ui-widget-header ui-corner-top"><?php echo stripslashes_deep($r->event_name); ?> <span class="remove-cart-item"> <img class="ee_delete_item_from_cart" id="cart_link_<?php echo $r->id; ?> " alt="Remove this item from your cart" src="<?php echo EVENT_ESPRESSO_PLUGINFULLURL; ?> images/icons/remove.gif" /> </span> </h3> <div class="event-data-display ui-widget-content ui-corner-bottom"> <table id="cart-reg-details" class="event-display-tables"> <thead> <tr> <th><?php _e('Date', 'event_espresso'); ?> </th> <th><?php _e('Time', 'event_espresso'); ?> </th> </tr> </thead> <tbody> <tr> <td><?php echo event_date_display($r->start_date, get_option('date_format')); ?> <?php /*_e( ' to ', 'event_espresso' ); ?> <?php echo event_date_display( $r->end_date, get_option( 'date_format' ) )*/ ?> </td> <td><?php echo event_espresso_time_dropdown($r->id, 0, 1, $_SESSION['espresso_session']['events_in_session'][$r->id]['start_time_id']); ?> </td> </tr> <tr> <td colspan="2"><?php echo event_espresso_group_price_dropdown($r->id, 0, 1, $_SESSION['espresso_session']['events_in_session'][$r->id]['price_id']); ?> </td> </tr> </table> <?php //Coupons if (function_exists('event_espresso_coupon_registration_page')) { // echo event_espresso_coupon_registration_page( $r->use_coupon_code, $r->id, 1 ); } //End coupons display ?> <input type="hidden" name="event_name[<?php echo $r->id; ?> ]" value="<?php echo $r->event_name; ?> " /> </div><!-- / .event-data-display --> </div><!-- / .event-display-boxes --> <?php $counter++; } ?> <div class="event-display-boxes ui-widget"> <div class="mer-event-submit ui-widget-content ui-corner-all"> <input type="hidden" name="event_name[<?php echo $r->id; ?> ]" value="<?php echo stripslashes_deep($r->event_name); ?> " /> <input type="hidden" name="regevent_action" value="load_checkout_page" /> <?php //Coupon code display //Uncomment the following code at your own risk. Just beware that all coupon codes will work for everyting in the cart. ?> <?php /*?><div id="event_espresso_coupon_wrapper" class="clearfix event-data-display"> <label class="coupon-code" for="event_espresso_coupon_code"> <?php _e( 'Enter Coupon Code ', 'event_espresso' ); ?> </label> <input onkeydown="if(event.keyCode==13) {document.getElementById('event_espresso_refresh_total').focus(); return false;}" type="text" name="event_espresso_coupon_code" id ="event_espresso_coupon_code" value="<?php echo $_SESSION['espresso_session']['coupon_code']; ?>"/> </div><?php */ ?> <div id="event_espresso_total_wrapper" class="clearfix event-data-display"> <a href="#" id="event_espresso_refresh_total"><?php _e('Refresh Total', 'event_espresso'); ?> </a> <span class="event_total_price"> <?php _e('Total (' . $org_options['currency_symbol'] . '): <span id="event_total_price">' . $_SESSION['espresso_session']['grand_total'], 'event_espresso') . '</span>'; ?> </span> </div> <input type="submit" class="submit btn_event_form_submit ui-priority-primary ui-state-default ui-state-hover ui-state-focus ui-corner-all" name="Continue" id="event_espresso_continue_registration" value="<?php _e('Finish Registration', 'event_espresso'); ?> " /> </div><!-- / .mer-event-submit --> </div><!-- / .event-display-boxes --> </form> <?php } }
function event_espresso_add_attendees_to_db_multi() { //echo '<h3>'. __CLASS__ . '->' . __FUNCTION__ . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h3>'; do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, ''); global $wpdb, $org_options; if (espresso_verify_recaptcha()) { $primary_registration_id = NULL; $multi_reg = true; $events_in_session = $_SESSION['espresso_session']['events_in_session']; if (event_espresso_invoke_cart_error($events_in_session)) { return false; } $count_of_events = count($events_in_session); $current_session_id = $_SESSION['espresso_session']['id']; $biz_name = $count_of_events . ' ' . $org_options['organization'] . __(' events', 'event_espresso'); $event_cost = $_SESSION['espresso_session']['grand_total']; $event_cost = apply_filters('filter_hook_espresso_cart_grand_total', $event_cost); // If there are events in the session, add them one by one to the attendee table if ($count_of_events > 0) { //first event key will be used to find the first attendee $first_event_id = key($events_in_session); reset($events_in_session); foreach ($events_in_session as $event_id => $event) { $event_meta = event_espresso_get_event_meta($event_id); $session_vars['data'] = $event; if (is_array($event['event_attendees'])) { $counter = 1; //foreach price type in event attendees foreach ($event['event_attendees'] as $price_id => $event_attendees) { $session_vars['data'] = $event; foreach ($event_attendees as $attendee) { $attendee['price_id'] = $price_id; //this has all the attendee information, name, questions.... $session_vars['event_attendees'] = $attendee; $session_vars['data']['price_type'] = $event['price_id'][$price_id]['price_type']; if (isset($event_meta['additional_attendee_reg_info']) && $event_meta['additional_attendee_reg_info'] == 1) { $num_people = (int) $event['price_id'][$price_id]['attendee_quantity']; $session_vars['data']['num_people'] = empty($num_people) || $num_people == 0 ? 1 : $num_people; } // ADD ATTENDEE TO DB $return_data = event_espresso_add_attendees_to_db($event_id, $session_vars, TRUE); $tmp_registration_id = $return_data['registration_id']; $notifications = $return_data['notifications']; if ($primary_registration_id === NULL) { $primary_registration_id = $tmp_registration_id; } $SQL = "SELECT * FROM " . EVENTS_MULTI_EVENT_REGISTRATION_ID_GROUP_TABLE . " "; $SQL .= "WHERE primary_registration_id = %s AND registration_id = %s"; $check = $wpdb->get_row($wpdb->prepare($SQL, $primary_registration_id, $tmp_registration_id)); if ($check === NULL) { $tmp_data = array('primary_registration_id' => $primary_registration_id, 'registration_id' => $tmp_registration_id); $wpdb->insert(EVENTS_MULTI_EVENT_REGISTRATION_ID_GROUP_TABLE, $tmp_data, array('%s', '%s')); } $counter++; } } } } $SQL = "SELECT a.*, ed.id AS event_id, ed.event_name, dc.coupon_code_price, dc.use_percentage "; $SQL .= "FROM " . EVENTS_ATTENDEE_TABLE . " a JOIN " . EVENTS_DETAIL_TABLE . " ed ON a.event_id=ed.id "; $SQL .= "LEFT JOIN " . EVENTS_DISCOUNT_CODES_TABLE . " dc ON a.coupon_code=dc.coupon_code "; $SQL .= "WHERE attendee_session=%s ORDER BY a.id ASC"; $attendees = $wpdb->get_results($wpdb->prepare($SQL, $current_session_id)); //printr( $attendees, '$attendees <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); $quantity = 0; $final_total = 0; $sub_total = 0; $discounted_total = 0; $discount_amount = 0; //$coupon_amount = ! empty($attendees[0]->coupon_code_price) ? $attendees[0]->coupon_code_price : 0; $is_coupon_pct = !empty($attendees[0]->use_percentage) && $attendees[0]->use_percentage == 'Y' ? TRUE : FALSE; //printr( $attendees, '$attendees <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); foreach ($attendees as $attendee) { if ($attendee->is_primary) { $primary_attendee_id = $attendee_id = $attendee->id; $coupon_code = $attendee->coupon_code; $event_id = $attendee->event_id; $fname = $attendee->fname; $lname = $attendee->lname; $address = $attendee->address; $city = $attendee->city; $state = $attendee->state; $zip = $attendee->zip; $attendee_email = $attendee->email; $registration_id = $attendee->registration_id; } $final_total += $attendee->final_price; $sub_total += (int) $attendee->quantity * $attendee->orig_price; $discounted_total += (int) $attendee->quantity * $attendee->final_price; $quantity += (int) $attendee->quantity; //echo '<h2>$attendee->id : ' . $attendee->id . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h2>'; //echo '<h4>$attendee->orig_price : ' . $attendee->orig_price . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>'; //echo '<h4>$attendee->final_price : ' . $attendee->final_price . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>'; //echo '<h4>$attendee->quantity : ' . (int)$attendee->quantity . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>'; //echo '<h4>$sub_total : ' . $sub_total . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>'; //echo '<h4>$discounted_total : ' . $discounted_total . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>'; } $discount_amount = $sub_total - $discounted_total; $total_cost = $discounted_total; //echo '<h4>$discount_amount : ' . $discount_amount . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>'; //echo '<h4>$total_cost : ' . $total_cost . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>'; //echo '<h4>$final_total : ' . $final_total . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4><br/>'; $total_cost = $total_cost < 0 ? 0.0 : (double) $total_cost; if (function_exists('espresso_update_attendee_coupon_info') && $primary_attendee_id && !empty($attendee->coupon_code)) { espresso_update_attendee_coupon_info($primary_attendee_id, $attendee->coupon_code); } if (function_exists('espresso_update_groupon') && $primary_attendee_id && !empty($coupon_code)) { espresso_update_groupon($primary_attendee_id, $coupon_code); } espresso_update_primary_attendee_total_cost($primary_attendee_id, $total_cost, __FILE__); //echo '<h4>$total_cost : ' . $total_cost . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>'; if (!empty($notifications['coupons']) || !empty($notifications['groupons'])) { echo '<div id="event_espresso_notifications" class="clearfix event-data-display no-hide">'; echo $notifications['coupons']; // add space between $coupon_notifications and $groupon_notifications ( if any $groupon_notifications exist ) echo !empty($notifications['coupons']) && !empty($notifications['groupons']) ? '<br/>' : ''; echo $notifications['groupons']; echo '</div>'; } //Post the gateway page with the payment options if ($total_cost > 0) { ?> <div class="espresso_payment_overview event-display-boxes ui-widget" > <h3 class="section-heading ui-widget-header ui-corner-top"> <?php _e('Payment Overview', 'event_espresso'); ?> </h3> <div class="event-data-display ui-widget-content ui-corner-bottom" > <div class="event-messages ui-state-highlight"> <span class="ui-icon ui-icon-alert"></span> <p class="instruct"> <?php _e('Your registration is not complete until payment is received.', 'event_espresso'); ?> </p> </div> <p><?php echo $org_options['email_before_payment'] == 'Y' ? __('A confirmation email has been sent with additional details of your registration.', 'event_espresso') : ''; ?> </p> <table> <?php foreach ($attendees as $attendee) { ?> <tr> <td width="70%"> <?php echo '<strong>' . stripslashes_deep($attendee->event_name) . '</strong>'; ?> - <?php echo stripslashes_deep($attendee->price_option); ?> <?php echo $attendee->final_price < $attendee->orig_price ? '<br /> <span style="font-size:.8em;">' . $org_options['currency_symbol'] . number_format($attendee->orig_price - $attendee->final_price, 2) . __(' discount per registration', 'event_espresso') . '</span>' : ''; ?> <br/> <?php echo __('Attendee:', 'event_espresso') . ' ' . stripslashes_deep($attendee->fname . ' ' . $attendee->lname); ?> </td> <td width="10%"><?php echo $org_options['currency_symbol'] . number_format($attendee->final_price, 2); ?> </td> <td width="10%"><?php echo 'x ' . (int) $attendee->quantity; ?> </td> <td width="10%" style="text-align:right;"><?php echo $org_options['currency_symbol'] . number_format($attendee->final_price * (int) $attendee->quantity, 2); ?> </td> </tr> <?php } ?> <tr> <td colspan="3"><?php _e('Sub-Total:', 'event_espresso'); ?> </td> <td colspan="" style="text-align:right"><?php echo $org_options['currency_symbol'] . number_format($sub_total, 2); ?> </td> </tr> <?php if (!empty($discount_amount)) { ?> <tr> <td colspan="3"><?php _e('Total Discounts:', 'event_espresso'); ?> </td> <td colspan="" style="text-align:right"><?php echo '-' . $org_options['currency_symbol'] . number_format($discount_amount, 2); ?> </td> </tr> <?php } ?> <tr> <td colspan="3"><strong class="event_espresso_name"> <?php _e('Total Amount due: ', 'event_espresso'); ?> </strong></td> <td colspan="" style="text-align:right"><?php echo $org_options['currency_symbol']; echo number_format($total_cost, 2); ?> </td> </tr> </table> <p class="event_espresso_refresh_total"> <a href="?page_id=<?php echo $org_options['event_page_id']; ?> ®event_action=show_shopping_cart"> <?php _e('Edit Cart', 'event_espresso'); ?> </a> <?php _e(' or ', 'event_espresso'); ?> <a href="?page_id=<?php echo $org_options['event_page_id']; ?> ®istration_id=<?php echo $registration_id; ?> &id=<?php echo $attendee_id; ?> ®event_action=edit_attendee&primary=<?php echo $primary_attendee_id; ?> &event_id=<?php echo $event_id; ?> &attendee_num=1"> <?php _e('Edit Registrant Information', 'event_espresso'); ?> </a> </p> </div> </div> <br/><br/> <?php //Show payment options if (file_exists(EVENT_ESPRESSO_GATEWAY_DIR . "gateway_display.php")) { require_once EVENT_ESPRESSO_GATEWAY_DIR . "gateway_display.php"; } else { require_once EVENT_ESPRESSO_PLUGINFULLPATH . "gateways/gateway_display.php"; } //Check to see if the site owner wants to send an confirmation eamil before payment is recieved. if ($org_options['email_before_payment'] == 'Y') { event_espresso_email_confirmations(array('session_id' => $_SESSION['espresso_session']['id'], 'send_admin_email' => 'true', 'send_attendee_email' => 'true', 'multi_reg' => true)); } } elseif ($total_cost == 0.0) { ?> <p> <?php _e('Thank you! Your registration is confirmed for', 'event_espresso'); ?> <strong><?php echo stripslashes_deep($biz_name); ?> </strong></p> <p> <?php _e('A confirmation email has been sent with additional details of your registration.', 'event_espresso'); ?> </p> <?php event_espresso_email_confirmations(array('session_id' => $_SESSION['espresso_session']['id'], 'send_admin_email' => 'true', 'send_attendee_email' => 'true', 'multi_reg' => true)); event_espresso_clear_session(); } } } }
function event_espresso_load_checkout_page() { global $wpdb, $org_options; do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, ''); $events_in_session = isset($_SESSION['espresso_session']['events_in_session']) ? $_SESSION['espresso_session']['events_in_session'] : event_espresso_clear_session(TRUE); // printr( $events_in_session, '$events_in_session <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); $event_count = count($events_in_session); if (event_espresso_invoke_cart_error($events_in_session)) { return false; } //echo "<pre>", print_r( $_SESSION ), "</pre>"; if (file_exists(EVENT_ESPRESSO_TEMPLATE_DIR . "multi_registration_page.php")) { require_once EVENT_ESPRESSO_TEMPLATE_DIR . "multi_registration_page.php"; //This is the path to the template file if available } else { require_once EVENT_ESPRESSO_PLUGINFULLPATH . "templates/multi_registration_page.php"; } $response['html'] = ''; //if the counte of event in the session >0, ok to process if ($event_count > 0) { //for each one of the events in session, grab the event ids, drop into temp array, impode to construct SQL IN clasue (IN(1,5,7)) foreach ($events_in_session as $event) { // echo $event['id']; if (is_numeric($event['id'])) { $events_IN[] = $event['id']; } } $events_IN = implode(',', $events_IN); $sql = "SELECT e.* FROM " . EVENTS_DETAIL_TABLE . " e "; $sql .= " WHERE e.id in ({$events_IN}) "; $sql .= " ORDER BY e.start_date "; $result = $wpdb->get_results($sql); //will hold data to pass to the form builder function $meta = array(); //echo "<pre>", print_r($_POST), "</pre>"; $reg_page_url = add_query_arg('regevent_action', 'post_multi_attendee', get_permalink($org_options['event_page_id'])); ?> <div class = "event_espresso_form_wrapper"> <form id="event_espresso_checkout_form" method="post" action="<?php echo $reg_page_url; ?> "> <?php $err = ''; $cart_page_url = add_query_arg('regevent_action', 'show_shopping_cart', get_permalink($org_options['event_page_id'])); $edit_cart_link = '<a href="' . $cart_page_url . '" rel="nofollow" class="btn_event_form_submit inline-link">' . __('Edit Cart', 'event_espresso') . '</a>'; ob_start(); //will be used if sj is off or they somehow select more than allotted attendees $show_checkout_button = true; $counter = 1; foreach ($result as $r) { $event_id = $r->id; $event_meta = unserialize($r->event_meta); $event_meta['is_active'] = $r->is_active; $event_meta['event_status'] = $r->event_status; $event_meta['start_time'] = empty($r->start_time) ? '' : $r->start_time; $event_meta['start_date'] = $r->start_date; $event_meta['registration_startT'] = $r->registration_startT; $event_meta['registration_start'] = $r->registration_start; $event_meta['registration_endT'] = $r->registration_endT; $event_meta['registration_end'] = $r->registration_end; $r->event_meta = serialize($event_meta); //If the event is still active, then show it. if (event_espresso_get_status($event_id) == 'ACTIVE') { //DEPRECATED //Pull the detail from the event detail row, find out which route to take for additional attendees //Can be 1) no questios asked, just record qty 2) ask for only personal info 3) ask all attendees the full reg questions //#1 is not in use as of ..P35 $meta['additional_attendee_reg_info'] = is_array($event_meta) && array_key_exists('additional_attendee_reg_info', $event_meta) && $event_meta['additional_attendee_reg_info'] > 1 ? $event_meta['additional_attendee_reg_info'] : 2; //In case the js is off, the attendee qty dropdowns will not //function properly, allowing for registering more than allowed limit. //The info from the following 5 lines will determine //if they have surpassed the limit. $available_spaces = get_number_of_attendees_reg_limit($event_id, 'number_available_spaces'); $attendee_limit = $r->additional_limit + 1; if ($available_spaces != 'Unlimited') { $attendee_limit = $attendee_limit <= $available_spaces ? $attendee_limit : $available_spaces; } $total_attendees_per_event = 0; $attendee_overflow = false; //assign variable $meta['additional_attendee'] = 0; $meta['attendee_number'] = 1; //used for "Copy From" dropdown on the reg form $meta['copy_link'] = $counter; //Grab the event price ids from the session. All event must have at least one price id $price_ids = $events_in_session[$event_id]['price_id']; //Just to make sure, check if is array if (is_array($price_ids)) { //for each one of the price ids, load an attendee question section foreach ($price_ids as $_price_id => $val) { if (isset($val['attendee_quantity']) && $val['attendee_quantity'] > 0) { //only show reg form if attendee qty is set $meta['price_id'] = $_price_id; //will be used to keep track of the attendee in the group $meta['price_type'] = $val['price_type']; //will be used to keep track of the attendee in the group $meta['attendee_quantity'] = $val['attendee_quantity']; $total_attendees_per_event += $val['attendee_quantity']; multi_register_attendees(null, $event_id, $meta, $r); $meta['attendee_number'] += $val['attendee_quantity']; } } //If they have selected more than allowed max group registration //display an error instead of the continue button if ($total_attendees_per_event > $attendee_limit || $total_attendees_per_event == 0) { $attendee_overflow = true; $show_checkout_button = false; } } if ($attendee_overflow) { $err .= "<div class='event_espresso_error'><p><em>" . __('Attention', 'event_espresso') . "</em><br /> "; $err .= sprintf(__("For %s, please make sure to select at least one attendee or delete it from your cart.", 'event_espresso'), stripslashes($r->event_name)); $err .= ' <span class="remove-cart-item"><img class="ee_delete_item_from_cart" id="cart_link_' . $event_id . '" alt="Remove this item from your cart" src="' . EVENT_ESPRESSO_PLUGINFULLURL . 'images/icons/remove.gif" /></span> '; $err .= "</p></div>"; } $counter++; } } $output = ob_get_contents(); ob_end_clean(); if ($err != '') { echo $err; } if ($show_checkout_button) { echo $output; //Recaptcha portion if ($org_options['use_captcha'] == 'Y' && !is_user_logged_in()) { // && isset( $_REQUEST['edit_details'] ) && $_REQUEST['edit_details'] != 'true' // this is probably superfluous because it's already being loaded elsewhere...trying to cover all my bases ~c ?> <script type="text/javascript"> var RecaptchaOptions = { theme : '<?php echo $org_options['recaptcha_theme'] == '' ? 'red' : $org_options['recaptcha_theme']; ?> ', lang : '<?php echo $org_options['recaptcha_language'] == '' ? 'en' : $org_options['recaptcha_language']; ?> ' }; </script> <?php if (!function_exists('recaptcha_get_html')) { require_once EVENT_ESPRESSO_PLUGINFULLPATH . 'includes/recaptchalib.php'; } //End require captcha library # the response from reCAPTCHA $resp = true; # the error code from reCAPTCHA, if any $error = null; ?> <p class="event_form_field" id="captcha-<?php echo $event_id; ?> "> <?php _e('Anti-Spam Measure: Please enter the following phrase', 'event_espresso'); ?> <?php echo recaptcha_get_html($org_options['recaptcha_publickey'], $error, is_ssl() ? true : false); ?> </p> <?php } //End use captcha ?> <div class="event-display-boxes ui-widget"> <div class="mer-event-submit ui-widget-content ui-corner-all"> <input type="submit" class="submit btn_event_form_submit ui-priority-primary ui-state-default ui-state-hover ui-state-focus ui-corner-all" name="payment_page" value="<?php _e('Confirm and go to payment page', 'event_espresso'); ?> »" /> </div> </div> <?php } ?> <p id="event_espresso_edit_cart"> <a href="<?php echo $cart_page_url; ?> " class="btn_event_form_submit inline-link"> <?php _e('Edit Cart', 'event_espresso'); ?> </a> </p> </form> </div> <script> jQuery(function(){ //Registration form validation jQuery('#event_espresso_checkout_form').validate(); }); </script> <?php } //echo json_encode( $response ); //die(); }
function event_espresso_shopping_cart() { global $wpdb, $org_options; //session_destroy(); //echo "<pre>", print_r( $_SESSION ), "</pre>"; $events_in_session = isset($_SESSION['espresso_session']['events_in_session']) ? $_SESSION['espresso_session']['events_in_session'] : event_espresso_clear_session(TRUE); if (event_espresso_invoke_cart_error($events_in_session)) { return false; } if (count($events_in_session) > 0) { foreach ($events_in_session as $event) { // echo $event['id']; if (is_numeric($event['id'])) { $events_IN[] = $event['id']; } } $events_IN = implode(',', $events_IN); $sql = "SELECT e.* FROM " . EVENTS_DETAIL_TABLE . " e "; $sql = apply_filters('filter_hook_espresso_shopping_cart_SQL_select', $sql); $sql .= " WHERE e.id in ({$events_IN}) "; $sql .= " AND e.event_status != 'D' "; $sql .= " ORDER BY e.start_date "; //echo '<h4>$sql : ' . $sql . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>'; $result = $wpdb->get_results($sql); ?> <form action='?page_id=<?php echo $org_options['event_page_id']; ?> ®event_action=load_checkout_page' method='post' id="event_espresso_shopping_cart"> <?php $counter = 1; //Counter that will keep track of the first events foreach ($result as $r) { //Check to see if the Members plugin is installed. if (function_exists('espresso_members_installed') && espresso_members_installed() == true && !is_user_logged_in()) { $member_options = get_option('events_member_settings'); if ($r->member_only == 'Y' || $member_options['member_only_all'] == 'Y') { event_espresso_user_login(); return; } } //If the event is still active, then show it. if (event_espresso_get_status($r->id) == 'ACTIVE') { $num_attendees = get_number_of_attendees_reg_limit($r->id, 'num_attendees'); //Get the number of attendees $available_spaces = get_number_of_attendees_reg_limit($r->id, 'available_spaces'); //Gets a count of the available spaces $number_available_spaces = get_number_of_attendees_reg_limit($r->id, 'number_available_spaces'); //Gets the number of available spaces //echo "<pre>$r->id, $num_attendees,$available_spaces,$number_available_spaces</pre>"; ?> <div class="multi_reg_cart_block event-display-boxes ui-widget" id ="multi_reg_cart_block-<?php echo $r->id; ?> "> <h3 class="event_title ui-widget-header ui-corner-top"><?php echo stripslashes_deep($r->event_name); ?> <span class="remove-cart-item"> <img class="ee_delete_item_from_cart" id="cart_link_<?php echo $r->id; ?> " alt="Remove this item from your cart" src="<?php echo EVENT_ESPRESSO_PLUGINFULLURL; ?> images/icons/remove.gif" /> </span> </h3> <div class="event-data-display ui-widget-content ui-corner-bottom"> <table id="cart-reg-details" class="event-display-tables"> <thead> <tr> <th><?php _e('Date', 'event_espresso'); ?> </th> <th><?php _e('Time', 'event_espresso'); ?> </th> </tr> </thead> <tbody> <tr> <td> <?php echo event_date_display($r->start_date, get_option('date_format')); ?> <?php /*_e( ' to ', 'event_espresso' ); ?> <?php echo event_date_display( $r->end_date, get_option( 'date_format' ) )*/ ?> </td> <td> <?php echo event_espresso_time_dropdown($r->id, 0, 1, $_SESSION['espresso_session']['events_in_session'][$r->id]['start_time_id']); ?> </td> </tr> <tr> <td colspan="2"> <?php echo event_espresso_group_price_dropdown($r->id, 0, 1, $_SESSION['espresso_session']['events_in_session'][$r->id]['price_id']); ?> </td> </tr> </tbody> </table> <input type="hidden" name="event_name[<?php echo $r->id; ?> ]" value="<?php echo $r->event_name; ?> " /> <input type="hidden" name="use_coupon[<?php echo $r->id; ?> ]" value="<?php echo $r->use_coupon_code; ?> " /> <input type="hidden" name="use_groupon[<?php echo $r->id; ?> ]" value="<?php echo $r->use_groupon_code; ?> " /> <?php do_action_ref_array('action_hook_espresso_add_to_multi_reg_cart_block', array($r)); ?> </div><!-- / .event-data-display --> </div><!-- / .event-display-boxes --> <?php $counter++; } } //echo $_SESSION['espresso_session']['groupon_used']; // printr( $_SESSION, '$_SESSION <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); ?> <div class="event-display-boxes ui-widget"> <div class="mer-event-submit ui-widget-content ui-corner-all"> <input type="hidden" name="event_name[<?php echo $r->id; ?> ]" value="<?php echo stripslashes_deep($r->event_name); ?> " /> <input type="hidden" name="regevent_action" value="load_checkout_page" /> <?php if (function_exists('event_espresso_coupon_payment_page') && isset($org_options['allow_mer_discounts']) && $org_options['allow_mer_discounts'] == 'Y') { //Discount code display ?> <div id="event_espresso_coupon_wrapper" class="clearfix event-data-display"> <label class="coupon-code" for="event_espresso_coupon_code"><?php _e('Enter Coupon Code ', 'event_espresso'); ?> </label> <input type="text" name="event_espresso_coupon_code" id ="event_espresso_coupon_code" value="<?php echo isset($_SESSION['espresso_session']['event_espresso_coupon_code']) ? $_SESSION['espresso_session']['event_espresso_coupon_code'] : ''; ?> " onkeydown="if(event.keyCode==13) {document.getElementById('event_espresso_refresh_total').focus(); return false;}" /> </div> <?php } ?> <?php if (function_exists('event_espresso_groupon_payment_page') && isset($org_options['allow_mer_vouchers']) && $org_options['allow_mer_vouchers'] == 'Y') { //Voucher code display ?> <div id="event_espresso_coupon_wrapper" class="clearfix event-data-display" > <label class="coupon-code" for="event_espresso_groupon_code"><?php _e('Enter Voucher Code ', 'event_espresso'); ?> </label> <input type="text" name="event_espresso_groupon_code" id ="event_espresso_groupon_code" value="<?php echo isset($_SESSION['espresso_session']['groupon_code']) ? $_SESSION['espresso_session']['groupon_code'] : ''; ?> " onkeydown="if(event.keyCode==13) {document.getElementById('event_espresso_refresh_total').focus(); return false;}" /> </div> <?php } ?> <div id="event_espresso_notifications" class="clearfix event-data-display" style=""></div> <div id="event_espresso_total_wrapper" class="clearfix event-data-display"> <?php do_action('action_hook_espresso_shopping_cart_before_total'); ?> <span class="event_total_price"> <?php _e('Total ', 'event_espresso') . $org_options['currency_symbol']; ?> <span id="event_total_price"><?php echo $_SESSION['espresso_session']['grand_total']; ?> </span> </span> <?php do_action('action_hook_espresso_shopping_cart_after_total'); ?> <p id="event_espresso_refresh_total"> <a id="event_espresso_refresh_total" style="cursor:pointer;"><?php _e('Refresh Total', 'event_espresso'); ?> </a> </p> </div> <p id="event_espresso_submit_cart"> <input type="submit" class="submit btn_event_form_submit ui-priority-primary ui-state-default ui-state-hover ui-state-focus ui-corner-all" name="Continue" id="event_espresso_continue_registration" value="<?php _e('Enter Attendee Information', 'event_espresso'); ?> »" /> </p> </div><!-- / .mer-event-submit --> </div><!-- / .event-display-boxes --> </form> <?php } }
function event_espresso_load_checkout_page() { global $wpdb, $org_options; $events_in_session = $_SESSION['espresso_session']['events_in_session']; if (event_espresso_invoke_cart_error($events_in_session)) { return false; } //echo "<pre>", print_r( $_SESSION ), "</pre>"; if (file_exists(EVENT_ESPRESSO_TEMPLATE_DIR . "multi_registration_page.php")) { require_once EVENT_ESPRESSO_TEMPLATE_DIR . "multi_registration_page.php"; //This is the path to the template file if available } else { require_once EVENT_ESPRESSO_PLUGINFULLPATH . "templates/multi_registration_page.php"; } $response['html'] = ''; //if the counte of event in the session >0, ok to process if (count($events_in_session) > 0) { //for each one of the events in session, grab the event ids, drop into temp array, impode to construct SQL IN clasue (IN(1,5,7)) foreach ($events_in_session as $event) { // echo $event['id']; if (is_numeric($event['id'])) { $events_IN[] = $event['id']; } } $events_IN = implode(',', $events_IN); $sql = "SELECT e.* FROM " . EVENTS_DETAIL_TABLE . " e "; $sql .= " WHERE e.id in ({$events_IN}) "; $sql .= " ORDER BY e.start_date "; $result = $wpdb->get_results($sql); //will hold data to pass to the form builder function $meta = array(); //echo "<pre>", print_r($_POST), "</pre>"; ?> <div class = "event_espresso_form_wrapper"> <form id="event_espresso_checkout_form" method="post" action="?page_id=<?php echo $org_options['event_page_id']; ?> ®event_action=post_multi_attendee"> <?php $err = ''; ob_start(); //will be used if sj is off or they somehow select more than allotted attendees $show_checkout_button = true; $counter = 1; foreach ($result as $r) { $event_id = $r->id; $event_meta = unserialize($r->event_meta); //DEPRECATED //Pull the detail from the event detail row, find out which route to take for additional attendees //Can be 1) no questios asked, just record qty 2) ask for only personal info 3) ask all attendees the full reg questions //#1 is not in use as of ..P35 $meta['additional_attendee_reg_info'] = is_array($event_meta) && array_key_exists('additional_attendee_reg_info', $event_meta) && $event_meta['additional_attendee_reg_info'] > 1 ? $event_meta['additional_attendee_reg_info'] : 2; //In case the js is off, the attendee qty dropdowns will not //function properly, allowing for registering more than allowed limit. //The info from the following 5 lines will determine //if they have surpassed the limit. $available_spaces = get_number_of_attendees_reg_limit($event_id, 'number_available_spaces'); $attendee_limit = $r->additional_limit + 1; if ($available_spaces != 'Unlimited') { $attendee_limit = $attendee_limit <= $available_spaces ? $attendee_limit : $available_spaces; } $total_attendees_per_event = 0; $attendee_overflow = false; //assign variable $meta['additional_attendee'] = 0; $meta['attendee_number'] = 1; //used for "Copy From" dropdown on the reg form $meta['copy_link'] = $counter; //Grab the event price ids from the session. All event must have at least one price id $price_ids = $events_in_session[$event_id]['price_id']; //Just to make sure, check if is array if (is_array($price_ids)) { //for each one of the price ids, load an attendee question section foreach ($price_ids as $_price_id => $val) { if (isset($val['attendee_quantity']) && $val['attendee_quantity'] > 0) { //only show reg form if attendee qty is set $meta['price_id'] = $_price_id; //will be used to keep track of the attendee in the group $meta['price_type'] = $val['price_type']; //will be used to keep track of the attendee in the group $meta['attendee_quantity'] = $val['attendee_quantity']; $total_attendees_per_event += $val['attendee_quantity']; multi_register_attendees(null, $event_id, $meta); $meta['attendee_number'] += $val['attendee_quantity']; } } //If they have selected more than allowed max group registration //Dispaly an error instead of the continue button if ($total_attendees_per_event > $attendee_limit || $total_attendees_per_event == 0) { $attendee_overflow = true; $show_checkout_button = false; } } if ($attendee_overflow) { $err .= "<div class='event_espresso_error'><p><em>Attention</em>"; $err .= sprintf(__("For %s, please make sure to select between 1 and %d attendees or delete it from your cart.", 'event_espresso'), stripslashes($r->event_name), $attendee_limit); $err .= '<span class="remove-cart-item"><img class="ee_delete_item_from_cart" id="cart_link_' . $event_id . '" alt="Remove this item from your cart" src="' . EVENT_ESPRESSO_PLUGINFULLURL . 'images/icons/remove.gif" /></span> '; $err .= "</p></div>"; } $counter++; } $output = ob_get_contents(); ob_end_clean(); if ($err != '') { echo $err; } if ($show_checkout_button) { echo $output; ?> <input type="submit" class="submit btn_event_form_submit" name="payment_page" value="<?php _e('Confirm and go to payment page', 'event_espresso'); ?> " /> <?php _e('<span> - OR - <span>', 'event_espresso'); } ?> <a href="?page_id=<?php echo $org_options['event_page_id']; ?> ®event_action=show_shopping_cart" class="btn_event_form_submit inline-link"> <?php _e('Edit Cart', 'event_espresso'); ?> </a> </form> </div> <script> jQuery(function(){ //Registration form validation jQuery('#event_espresso_checkout_form').validate(); }); </script> <?php } //echo json_encode( $response ); //die(); }