示例#1
0
 function event_espresso_run()
 {
     global $wpdb, $org_options, $load_espresso_scripts;
     do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, '');
     $load_espresso_scripts = true;
     //This tells the plugin to load the required scripts
     ob_start();
     //Make sure scripts are loading
     echo espresso_check_scripts();
     // Get action type
     $regevent_action = isset($_REQUEST['regevent_action']) ? $_REQUEST['regevent_action'] : '';
     if (isset($_REQUEST['ee'])) {
         $regevent_action = "register";
         $_REQUEST['event_id'] = $_REQUEST['ee'];
     }
     if (isset($_REQUEST['form_action']) && $_REQUEST['form_action'] == 'edit_attendee' || isset($_REQUEST['edit_attendee']) && $_REQUEST['edit_attendee'] == 'true') {
         $regevent_action = "edit_attendee";
     }
     switch ($regevent_action) {
         case "register":
             register_attendees();
             break;
         case "post_attendee":
             event_espresso_add_attendees_to_db(NULL, NULL, FALSE);
             break;
         case "show_shopping_cart":
             // MER ONLY - This is the form page for registering the attendee
             event_espresso_require_template('shopping_cart.php');
             event_espresso_shopping_cart();
             break;
         case "load_checkout_page":
             // MER ONLY
             if ($_POST) {
                 event_espresso_update_item_in_session('details');
             }
             event_espresso_load_checkout_page();
             break;
         case "post_multi_attendee":
             // MER ONLY
             event_espresso_update_item_in_session('attendees');
             event_espresso_add_attendees_to_db_multi();
             break;
         case "confirm_registration":
             espresso_confirm_registration();
             break;
         case "edit_attendee":
             require_once EVENT_ESPRESSO_PLUGINFULLPATH . 'includes/process-registration/attendee_edit_record.php';
             attendee_edit_record();
             break;
         default:
             display_all_events();
     }
     $content = ob_get_contents();
     ob_end_clean();
     return $content;
 }
 function event_espresso_run()
 {
     global $wpdb, $org_options, $load_espresso_scripts, $espresso_content;
     do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, '');
     $load_espresso_scripts = true;
     //This tells the plugin to load the required scripts
     ob_start();
     //Make sure scripts are loading
     echo espresso_check_scripts();
     // Get action type
     $regevent_action = isset($_REQUEST['regevent_action']) ? $_REQUEST['regevent_action'] : '';
     if (isset($_REQUEST['event_id']) && !empty($_REQUEST['event_id'])) {
         $_REQUEST['event_id'] = wp_strip_all_tags(absint($_REQUEST['event_id']));
     }
     if (isset($_REQUEST['form_action']) && !empty($_REQUEST['form_action'])) {
         if (isset($_REQUEST['form_action']) && !$_REQUEST['form_action'] == 'edit_attendee') {
             $_REQUEST['primary'] = wp_strip_all_tags(absint($_REQUEST['primary']));
         }
     }
     if (isset($_REQUEST['ee']) && !empty($_REQUEST['ee'])) {
         $regevent_action = "register";
         $_REQUEST['ee'] = wp_strip_all_tags(absint($_REQUEST['ee']));
         $_REQUEST['event_id'] = $_REQUEST['ee'];
     }
     if (isset($_REQUEST['form_action']) && $_REQUEST['form_action'] == 'edit_attendee' || isset($_REQUEST['edit_attendee']) && $_REQUEST['edit_attendee'] == 'true') {
         $regevent_action = "edit_attendee";
     }
     switch ($regevent_action) {
         case "register":
             register_attendees();
             break;
         case "post_attendee":
             //Various attendee functions
             require_once "includes/functions/attendee_functions.php";
             //Add attendees to the database
             require_once "includes/process-registration/add_attendees_to_db.php";
             //Payment/Registration Processing - Used to display the payment options and the payment link in the email. Used with the [ESPRESSO_PAYMENTS] tag
             require_once "includes/process-registration/payment_page.php";
             event_espresso_add_attendees_to_db(NULL, NULL, FALSE);
             break;
         case "show_shopping_cart":
             // MER ONLY - This is the form page for registering the attendee
             event_espresso_require_template('shopping_cart.php');
             event_espresso_shopping_cart();
             break;
         case "load_checkout_page":
             // MER ONLY
             if ($_POST) {
                 event_espresso_update_item_in_session('details');
             }
             event_espresso_load_checkout_page();
             break;
         case "post_multi_attendee":
             // MER ONLY
             //Various attendee functions
             require_once "includes/functions/attendee_functions.php";
             //Add attendees to the database
             require_once "includes/process-registration/add_attendees_to_db.php";
             event_espresso_update_item_in_session('attendees');
             event_espresso_add_attendees_to_db_multi();
             break;
         case "confirm_registration":
             //Various attendee functions
             require_once "includes/functions/attendee_functions.php";
             //Payment/Registration Processing - Used to display the payment options and the payment link in the email. Used with the [ESPRESSO_PAYMENTS] tag
             require_once "includes/process-registration/payment_page.php";
             espresso_confirm_registration();
             break;
         case "edit_attendee":
             //Various attendee functions
             require_once "includes/functions/attendee_functions.php";
             //Payment/Registration Processing - Used to display the payment options and the payment link in the email. Used with the [ESPRESSO_PAYMENTS] tag
             require_once "includes/process-registration/payment_page.php";
             require_once EVENT_ESPRESSO_PLUGINFULLPATH . 'includes/process-registration/attendee_edit_record.php';
             attendee_edit_record();
             break;
         default:
             display_all_events();
     }
     $content = ob_get_contents();
     ob_end_clean();
     $espresso_content = $content;
     add_shortcode('ESPRESSO_EVENTS', 'espresso_return_espresso_content');
 }
示例#3
0
 function event_espresso_calculate_total($update_section = null)
 {
     //print_r($_POST);
     global $wpdb;
     $events_in_session = $_SESSION['espresso_session']['events_in_session'];
     if (is_array($events_in_session)) {
         $event_total_cost = 0;
         foreach ($events_in_session as $k => $v) {
             $event_cost = 0;
             $event_id = $k;
             $event_individual_cost[$event_id] = 0;
             $start_time_id = '';
             if (array_key_exists('start_time_id', $_POST) && array_key_exists($event_id, $_POST['start_time_id'])) {
                 $start_time_id = $_POST['start_time_id'][$event_id];
             }
             /*
              * two ways the price id comes this way
              * - from a dropdown >> price_id[event_id][price_id]
              * - from a radio >> price_id[event_id] with a value of price_id
              */
             $price_id = $_POST['price_id'][$event_id];
             if (is_array($price_id)) {
                 foreach ($price_id as $_price_id => $val) {
                     $attendee_quantitiy = $wpdb->escape($val);
                     if ($attendee_quantitiy > 0) {
                         $event_cost = event_espresso_get_final_price($_price_id, $event_id);
                         $event_individual_cost[$event_id] += number_format($event_cost * $attendee_quantitiy, 2, '.', '');
                     }
                 }
             } else {
                 $attendee_quantitiy = 1;
                 $event_cost = event_espresso_get_final_price($price_id, $event_id);
                 $event_individual_cost[$event_id] = number_format($event_cost * $attendee_quantitiy, 2, '.', '');
             }
             $_SESSION['espresso_session']['events_in_session'][$event_id]['cost'] = $event_individual_cost[$event_id];
             $event_total_cost += $event_individual_cost[$event_id];
         }
         $_SESSION['espresso_session']['pre_discount_total'] = number_format($event_total_cost, 2, '.', '');
         if (function_exists('event_espresso_coupon_payment_page') && isset($_POST['event_espresso_coupon_code'])) {
             if (isset($_POST['event_espresso_coupon_code'])) {
                 $event_total_cost = event_espresso_coupon_payment_page('Y', NULL, $event_total_cost, NULL);
             }
         }
         $grand_total = number_format($event_total_cost, 2, '.', '');
         $_SESSION['espresso_session']['grand_total'] = $grand_total;
         event_espresso_update_item_in_session($update_section);
     }
     //}
     if ($update_section == null) {
         echo event_espresso_json_response(array('grand_total' => $grand_total));
         die;
     }
 }
 function event_espresso_calculate_total($update_section = FALSE, $mer = TRUE)
 {
     do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, '');
     //print_r($_POST);
     $events_in_session = isset($_SESSION['espresso_session']['events_in_session']) ? $_SESSION['espresso_session']['events_in_session'] : event_espresso_clear_session(TRUE);
     $grand_total = 0.0;
     $coupon_events = array();
     $coupon_notifications = '';
     $coupon_errors = '';
     $groupon_events = array();
     $groupon_notifications = '';
     $groupon_errors = '';
     $notifications = '';
     if (is_array($events_in_session)) {
         $event_total_cost = 0;
         foreach ($events_in_session as $event_id => $event) {
             $event_id = absint($event_id);
             if ($event_id) {
                 $event_cost = 0;
                 $event_individual_cost[$event_id] = 0;
                 $attendee_quantity = 0;
                 $coupon_results = array('event_cost' => 0, 'valid' => FALSE, 'error' => '', 'msg' => '');
                 $groupon_results = array('event_cost' => 0, 'valid' => FALSE, 'error' => '', 'msg' => '');
                 $use_coupon_code = isset($_POST['use_coupon'][$event_id]) ? $_POST['use_coupon'][$event_id] : 'N';
                 //only bother processing coupon codes if G (only globals), Y (gloabl and specific ones), or A (absolutely all)
                 if ($use_coupon_code != 'N') {
                     add_filter('filter_hook_espresso_coupon_results', 'espresso_filter_coupon_results', 10, 3);
                 }
                 $use_groupon_code = isset($_POST['use_groupon'][$event_id]) ? $_POST['use_groupon'][$event_id] : 'N';
                 if ($use_groupon_code == 'Y') {
                     add_filter('filter_hook_espresso_groupon_results', 'espresso_filter_groupon_results', 10, 3);
                 }
                 $start_time_id = '';
                 if (array_key_exists('start_time_id', $_POST) && array_key_exists($event_id, $_POST['start_time_id'])) {
                     $start_time_id = $_POST['start_time_id'][$event_id];
                 }
                 /*
                  * two ways the price id comes this way
                  * - from a dropdown >> price_id[event_id][price_id]
                  * - from a radio >> price_id[event_id] with a value of price_id
                  */
                 if (isset($_POST['price_id'][$event_id])) {
                     $event_price = $_POST['price_id'][$event_id];
                 } else {
                     $event_price = FALSE;
                     $notifications = __('An error occured, a valid price is required.', 'event_espresso');
                 }
                 //echo '<h4>event_cost : ' . $event_individual_cost[$event_id] . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
                 if (is_array($event_price)) {
                     foreach ($event_price as $_price_id => $qty) {
                         $attendee_quantity = absint($qty);
                         if ($attendee_quantity > 0) {
                             // Process coupons
                             $coupon_results['event_cost'] = event_espresso_get_final_price($_price_id, $event_id);
                             $coupon_results = apply_filters('filter_hook_espresso_coupon_results', $coupon_results, $event_id, $mer);
                             $coupon_notifications = apply_filters('filter_hook_espresso_cart_modifier_strings', $coupon_notifications, $coupon_results['msg']);
                             $coupon_errors = apply_filters('filter_hook_espresso_cart_modifier_strings', $coupon_errors, $coupon_results['error']);
                             if ($coupon_results['valid']) {
                                 $coupon_events = apply_filters('filter_hook_espresso_cart_coupon_events_array', $coupon_events, $event['event_name']);
                             }
                             $event_cost = $coupon_results['event_cost'];
                             if (function_exists('event_espresso_groupon_payment_page') && isset($_POST['event_espresso_groupon_code'])) {
                                 // Process Groupons
                                 $groupon_results['event_cost'] = $event_cost;
                                 $groupon_results = apply_filters('filter_hook_espresso_groupon_results', $groupon_results, $event_id, $mer);
                                 $groupon_notifications = apply_filters('filter_hook_espresso_cart_modifier_strings', $groupon_notifications, $groupon_results['msg']);
                                 $groupon_errors = apply_filters('filter_hook_espresso_cart_modifier_strings', $groupon_errors, $groupon_results['error']);
                                 if ($groupon_results['valid']) {
                                     $groupon_events = apply_filters('filter_hook_espresso_cart_groupon_events_array', $groupon_events, $event['event_name']);
                                 }
                                 //printr( $groupon_results, '$groupon_results  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
                                 $event_cost = $groupon_results['event_cost'];
                             }
                             // now sum up costs so far
                             $event_individual_cost[$event_id] += number_format($event_cost * $attendee_quantity, 2, '.', '');
                             do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, 'line ' . __LINE__ . ': event_cost=' . $event_cost);
                         }
                     }
                 } else {
                     if ($event_price !== FALSE) {
                         // Process coupons
                         $coupon_results['event_cost'] = event_espresso_get_final_price($event_price, $event_id);
                         $coupon_results = apply_filters('filter_hook_espresso_coupon_results', $coupon_results, $event_id, $mer);
                         $coupon_notifications = apply_filters('filter_hook_espresso_cart_modifier_strings', $coupon_notifications, $coupon_results['msg']);
                         $coupon_errors = apply_filters('filter_hook_espresso_cart_modifier_strings', $coupon_errors, $coupon_results['error']);
                         if ($coupon_results['valid']) {
                             $coupon_events = apply_filters('filter_hook_espresso_cart_coupon_events_array', $coupon_events, $event['event_name']);
                         }
                         $event_cost = $coupon_results['event_cost'];
                         if (function_exists('event_espresso_groupon_payment_page') && isset($_POST['event_espresso_groupon_code'])) {
                             // Process groupons
                             $groupon_results['event_cost'] = $event_cost;
                             $groupon_results = apply_filters('filter_hook_espresso_groupon_results', $groupon_results, $event_id, $mer);
                             $groupon_notifications = apply_filters('filter_hook_espresso_cart_modifier_strings', $groupon_notifications, $groupon_results['msg']);
                             $groupon_errors = apply_filters('filter_hook_espresso_cart_modifier_strings', $groupon_errors, $groupon_results['error']);
                             if ($groupon_results['valid']) {
                                 $groupon_events = apply_filters('filter_hook_espresso_cart_groupon_events_array', $groupon_events, $event['event_name']);
                             }
                             //printr( $groupon_results, '$groupon_results  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
                             $event_cost = $groupon_results['event_cost'];
                         }
                         // now sum up costs so far
                         $event_individual_cost[$event_id] += number_format($event_cost, 2, '.', '');
                         //echo '<h4>event_cost : ' . $event_individual_cost[$event_id] . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
                         do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, 'line ' . __LINE__ . ': event_cost=' . $event_cost);
                     }
                 }
                 $_SESSION['espresso_session']['events_in_session'][$event_id]['cost'] = $event_individual_cost[$event_id];
                 //echo '<h4>event_cost : ' . $event_individual_cost[$event_id] . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
                 $event_total_cost += $event_individual_cost[$event_id];
             }
         }
         $grand_total = number_format($event_total_cost, 2, '.', '');
         //echo '<h4>$grand_total : ' . $grand_total . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
         $_SESSION['espresso_session']['pre_discount_total'] = $grand_total;
         $_SESSION['espresso_session']['grand_total'] = $grand_total;
         event_espresso_update_item_in_session('details');
     }
     //		echo '$coupon_notifications = ' . $coupon_notifications . '<br/>';
     //		echo '$coupon_errors = ' . $coupon_errors . '<br/>';
     //		echo '$groupon_notifications = ' . $groupon_notifications . '<br/>';
     //		echo '$groupon_errors = ' . $groupon_errors . '<br/>';
     $coupon_events = array_unique($coupon_events);
     $coupon_count = count($coupon_events);
     if (!strpos($coupon_notifications, 'event_espresso_invalid_coupon') && $coupon_count > 0) {
         $events = implode($coupon_events, '<br/>&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;');
         $coupon_notifications .= '&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;' . $events . '</p>';
         $coupon_errors = FALSE;
     }
     $groupon_events = array_unique($groupon_events);
     $groupon_count = count($groupon_events);
     if (!strpos($groupon_notifications, 'event_espresso_invalid_groupon') && $groupon_count > 0) {
         $events = implode($groupon_events, '<br/>&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;');
         $groupon_notifications .= '&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;' . $events . '</p>';
         $groupon_errors = FALSE;
     }
     //		echo '$coupon_notifications = ' . $coupon_notifications . '<br/>';
     //		echo '$coupon_errors = ' . $coupon_errors . '<br/>';
     //		echo '$groupon_notifications = ' . $groupon_notifications . '<br/>';
     //		echo '$groupon_errors = ' . $groupon_errors . '<br/>';
     // add space between $coupon_notifications and  $coupon_errors ( if any $coupon_errors exist )
     $coupon_notifications = $coupon_count && $coupon_errors ? $coupon_notifications . '<br/>' : $coupon_notifications;
     // combine $coupon_notifications & $coupon_errors
     $coupon_notifications .= $coupon_errors;
     // add space between $coupon_notifications and $groupon_notifications ( if any $groupon_notifications exist )
     $coupon_notifications = ($coupon_count || $coupon_errors) && ($groupon_count || $groupon_errors) ? $coupon_notifications . '<br/>' : $coupon_notifications;
     // add space between $groupon_notifications and  $groupon_errors ( if any $groupon_errors exist )
     $groupon_notifications = $groupon_count && $groupon_errors ? $groupon_notifications . '<br/>' : $groupon_notifications;
     // ALL together now!!!
     $notifications .= $coupon_notifications . $groupon_notifications . $groupon_errors;
     if (!$update_section) {
         echo event_espresso_json_response(array('grand_total' => number_format($grand_total, 2, '.', ''), 'msg' => $notifications));
         die;
     }
 }
示例#5
0
 function event_espresso_run()
 {
     global $wpdb, $org_options, $load_espresso_scripts;
     $load_espresso_scripts = true;
     //This tells the plugin to load the required scripts
     ob_start();
     //Make sure scripts are loading
     echo espresso_check_scripts();
     // Get action type
     $regevent_action = isset($_REQUEST['regevent_action']) ? $_REQUEST['regevent_action'] : '';
     if (isset($_REQUEST['ee'])) {
         $regevent_action = "register";
         $_REQUEST['event_id'] = $_REQUEST['ee'];
     }
     if (isset($_REQUEST['edit_attendee'])) {
         $regevent_action = "register";
     }
     switch ($regevent_action) {
         case "post_attendee":
             event_espresso_add_attendees_to_db();
             break;
         case "register":
             register_attendees();
             break;
         case "add_to_session":
             break;
         case "show_shopping_cart":
             //This is the form page for registering the attendee
             event_espresso_require_template('shopping_cart.php');
             event_espresso_shopping_cart();
             break;
         case "load_checkout_page":
             if ($_POST) {
                 event_espresso_calculate_total('details');
             }
             event_espresso_load_checkout_page();
             break;
         case "post_multi_attendee":
             //echo " YESssss";
             event_espresso_update_item_in_session('attendees');
             event_espresso_add_attendees_to_db_multi();
             break;
         default:
             display_all_events();
     }
     $content = ob_get_contents();
     ob_end_clean();
     return $content;
 }