function query_where($table = '', $limit_to = array()) { global $wpdb; $this->WHERE = ''; $table = epl_suffix('.', $table); $this->daterange_filter(); $filter_params = array('regis_id', 'event_id', 'date_id', 'time_id', 'price_id', 'status'); if (!epl_is_empty_array($limit_to)) { $filter_params = $limit_to; } foreach ($filter_params as $prefix => $filter) { if (isset($_REQUEST[$filter]) && $_REQUEST[$filter] != '') { $this->WHERE .= " AND {$table}{$filter} = '" . esc_sql($_REQUEST[$filter]) . "'"; } } }
function epl_get_currency_symbol($amount = null) { $_amount = $amount; $opt = epl_get_option('epl_general_options'); $symbol = epl_get_element('epl_currency_symbol', $opt, ''); $location = epl_get_element('epl_currency_symbol_location', $opt, 'b'); if ($symbol) { if ($location == 'b') { $amount = epl_prefix($symbol, $amount); } else { $amount = epl_suffix(' ' . $symbol, $amount); } } $amount = apply_filters('epl_get_currency_symbol', $amount, $_amount, $symbol, $location); return $amount; }
function process_discount($totals, $glob_disc = false) { if (epl_is_empty_array($totals)) { return $totals; } static $processed = false; //if ( $processed ) // return $totals; $processed = true; global $event_details, $epl_current_step; $this->discount_config_id = $event_details['ID']; $this->all_discount_configs[$this->discount_config_id] = $event_details; $this->totals = $totals; $this->original_totals = $totals; $this->discount_configs = $event_details; if (epl_sc_is_enabled()) { $this->discount_configs = $this->get_global_discount_configs(true); } $_discount = array(); $_entered_code = strtoupper($this->discount_code_entered($this->totals)); $allow_global_discounts = epl_get_element('_epl_allow_global_discounts', $event_details, 0) == 10; //if discount code entered if ($_entered_code) { //check if the code exists $this->totals['money_totals']['discount_code'] = $_entered_code; if ((!$available_discount_codes || $glob_disc) && $allow_global_discounts) { if (epl_sc_is_enabled()) { $this->all_discount_configs = $this->get_global_discount_configs(); } elseif ($allow_global_discounts) { $this->all_discount_configs += $this->get_global_discount_configs(); } } $this->get_event_discount_codes(); if (!$this->code_discounts) { return $this->totals; } foreach ($this->code_discounts as $discount_source_id => $active_discounts) { $_code_id = array_search(strtolower($_entered_code), (array) $active_discounts); $this->discount_configs = $this->all_discount_configs[$discount_source_id]; if ($_code_id !== false) { $this->discount_source = $this->code_discounts_source[$discount_source_id]; $this->discount_source_id = $discount_source_id; break; } } if ($_code_id !== false) { //if ( !EPL_IS_ADMIN ) { //code expired if ($this->is_code_expired($_code_id)) { $this->totals['money_totals']['discount_code_id'] = ''; $this->totals['money_totals']['discount_code'] = ''; $this->totals['money_totals']['discount_message'] = epl__('The discount code has expired'); return $this->totals; } //code use count exceeded if ($this->is_code_maxed_out($_code_id, $_entered_code)) { $this->totals['money_totals']['discount_code_id'] = ''; $this->totals['money_totals']['discount_code'] = ''; $this->totals['money_totals']['discount_message'] = epl__('The discount code is no longer available'); return $this->totals; } $_categories = epl_get_element($_code_id, epl_get_element('_epl_discount_cat_include', $this->discount_configs), 0); if (!epl_is_empty_array($_categories)) { $this->adjust_discountable_amounts('category', $_categories); } /* TODO removing as of > 2.0.8 $_pay_profiles = epl_get_element( $_code_id, epl_get_element( '_epl_discount_pay_specific', $this->discount_configs ), 0 ); if ( !epl_is_empty_array( $_pay_profiles ) ) { $this->adjust_discountable_amounts( 'pay_profiles', $_pay_profiles ); } */ $is_condition_ok = $this->is_condition_ok($_code_id, $this->totals); if ($is_condition_ok !== true) { $this->totals['money_totals']['discount_code_id'] = ''; $this->totals['money_totals']['discount_code'] = ''; $this->totals['money_totals']['discount_message'] = $is_condition_ok; return $this->totals; } //} $amount_to_discount = epl_get_element($_code_id, epl_get_element('_epl_discount_amount', $this->discount_configs)); $discount_description = epl_get_element($_code_id, epl_get_element('_epl_discount_description', $this->discount_configs)); $discount_type = epl_get_element($_code_id, epl_get_element('_epl_discount_type', $this->discount_configs)); $discounted_amount = $this->calculate_discount($this->totals['money_totals'], $amount_to_discount, $discount_type); if ($discounted_amount >= 0) { $this->totals['money_totals']['pre_discount_total'] = $this->totals['money_totals']['grand_total']; //$this->totals['money_totals']['discount_amount'] = $this->discount_amount; $this->totals['money_totals']['discount_description'] = epl_suffix(', ', $this->totals['money_totals']['discount_description']) . $discount_description; $this->totals['money_totals']['discount_code_id'] = $_code_id; $this->totals['money_totals']['discount_source_id'] = $this->discount_source_id; //$this->totals['money_totals']['grand_total'] = $discounted_amount; } } else { //if ( !$glob_disc ) // $this->process_discount( $totals, true ); //else $this->totals['money_totals']['discount_message'] = epl__('This discount code is invalid'); } } else { //check for automatic discounts //get list of available automatic discounts //$this->get_event_auto_discounts(); if (epl_sc_is_enabled() || (!$available_auto_discounts || $glob_disc) || $allow_global_discounts) { if (epl_sc_is_enabled()) { $this->all_discount_configs = $this->get_global_discount_configs(); } elseif ($allow_global_discounts) { $this->all_discount_configs += $this->get_global_discount_configs(); } } $this->get_event_auto_discounts(); if (epl_is_empty_array($this->auto_discounts)) { return $this->totals; } foreach ($this->auto_discounts as $discount_source_id => $active_discounts) { $this->discount_configs = $this->all_discount_configs[$discount_source_id]; foreach ($active_discounts as $_code_id => $discount_source) { $this->discount_source = $discount_source; $this->discount_source_id = $discount_source_id; //code expired if ($this->is_code_expired($_code_id)) { continue; } //code use count exceeded if ($this->is_code_maxed_out($_code_id, null)) { continue; } /* TODO removing as of > 2.0.8 * $_pay_profiles = epl_get_element( $_code_id, epl_get_element( '_epl_discount_pay_specific', $this->discount_configs ), 0 ); if ( !epl_is_empty_array( $_pay_profiles ) ) { $this->adjust_discountable_amounts( 'pay_profiles', $_pay_profiles ); } */ $_categories = epl_get_element($_code_id, epl_get_element('_epl_discount_cat_include', $this->discount_configs), 0); if (!epl_is_empty_array($_categories)) { $this->adjust_discountable_amounts('category', $_categories); } $is_condition_ok = $this->is_condition_ok($_code_id); if ($is_condition_ok !== true) { $this->totals = $this->original_totals; continue; } $amount_to_discount = epl_get_element($_code_id, epl_get_element('_epl_discount_amount', $this->discount_configs)); $discount_description = epl_get_element($_code_id, epl_get_element('_epl_discount_description', $this->discount_configs)); $discount_type = epl_get_element($_code_id, epl_get_element('_epl_discount_type', $this->discount_configs)); $discounted_amount = $this->calculate_discount($this->totals['money_totals'], $amount_to_discount, $discount_type); if ($discounted_amount > 0) { $this->totals['money_totals']['discount_code_id'] = $_code_id; $this->totals['money_totals']['discount_source_id'] = $discount_source_id; $this->totals['money_totals']['discount_description'] = epl_suffix(', ', epl_get_element('discount_description', $this->totals['money_totals'])) . $discount_description; //only apply the first match break 2; } } } //return $this->totals; } $this->totals = apply_filters('epl__discount_model__processed_totals', $this->totals); return $this->totals; }
function notif_tags($email_body, $data) { global $event_details, $system_email_tags, $email_regis_form; if ($this->regis_id == '') { return null; } $email_body = nl2br(stripslashes_deep(html_entity_decode($email_body, ENT_QUOTES))); $regis_meta = $this->ecm->setup_regis_details($this->regis_id); $reigs_id = $regis_meta['__epl']['_regis_id']; $event_id = key($regis_meta['__epl'][$reigs_id]['_events']); //find the list of all forms $available_forms = $this->ecm->get_list_of_available_forms(); $available_fields = $this->ecm->get_list_of_available_fields(); $attendee_info = $regis_meta['__epl'][$reigs_id]['_attendee_info']; $_attendee_info = array(); foreach ($attendee_info as $_f_id => $_att_data) { if (!isset($available_fields[$_f_id])) { continue; } //$_attendee_info[$_f_id] = epl_get_element( 0, epl_get_element( $event_id, $_att_data ) ); $value = epl_get_element(0, $_att_data, false); if (!$value) { $value = epl_get_element(0, epl_get_element($event_id, $_att_data)); } $input_type = epl_get_element('input_type', $available_fields[$_f_id]); if ($input_type == 'select' || $input_type == 'radio') { $field_choice_text = epl_get_element($value, $available_fields[$_f_id]['epl_field_choice_text'], null); $value = $field_choice_text && $field_choice_text != '' ? $field_choice_text : $value; } elseif ($input_type == 'checkbox') { $value = implode(',', (array) $value); } else { //TODO - eek, find a better way $value = html_entity_decode(htmlspecialchars_decode($value, ENT_QUOTES)); } $_attendee_info[$_f_id] = $value; } $event_ticket_buyer_forms = array_flip((array) $event_details['_epl_primary_regis_forms']); $gateway_info = array(); if (!epl_is_free_event()) { $gw_id = $this->erm->get_payment_profile_id(); $gateway_info = $this->ecm->get_post_meta_all($gw_id); } $data['payment_instructions'] = $this->epl->load_view('front/registration/regis-payment-instr', array('gateway_info' => $gateway_info), true); $data['payment_details'] = $this->epl->load_view('front/registration/regis-payment-details', $data, true); $registration_detail_link = add_query_arg(array('epl_token' => epl_get_token()), get_permalink($this->regis_id)); $_system_email_tags = array('registration_id' => get_the_regis_id(), 'registration_detail_link' => '<a href="' . $registration_detail_link . '" target="_blank" alt="' . epl__('Registration Detail Link') . '">' . epl__('Click here') . '</a>', 'event_name' => get_the_title($event_id), 'registration_details' => str_replace('class="epl_dates_times_prices_table"', 'style="clear:both;width:100%;margin:10px auto;border:1px solid #eee"', get_the_regis_dates_times_prices($data['post_ID'])), 'registration_form_data' => $email_regis_form, 'payment_details' => str_replace('class="epl_payment_details_table"', 'style="clear:both;width:100%;margin:10px auto;border:1px solid #eee"', $data['payment_details']), 'waitlist_approved_link' => epl_anchor(epl_get_waitlist_approved_url(), epl__('Register')), 'waitlist_approved_until' => epl_waitlist_approved_until(), 'event_details_link' => epl_anchor(get_permalink($event_details['ID']), get_the_title($event_details['ID'])), 'location_details' => !epl_is_multi_location() && epl_get_event_property('_epl_event_location', true) > 0 ? epl_suffix(', ', get_the_location_name()) . epl_suffix(', ', get_the_location_address() . ' ' . get_the_location_address2()) . get_the_location_city() . ' ' . get_the_location_state() . ' ' . get_the_location_zip() : '', 'location_map_link' => get_the_location_gmap_icon(epl__('Click here'), true)); $_system_email_tags = apply_filters('epl_system_email_tags', $_system_email_tags); //isolate the forms that are selected inside the event // $ticket_buyer_forms = array_intersect_key( $available_forms, $event_ticket_buyer_forms ); /* $tickey_buyer_fields = array( ); foreach ( $ticket_buyer_forms as $_form_id => $_form_info ) $tickey_buyer_fields += $_form_info['epl_form_fields']; */ preg_match_all('/(?<=\\{)(.*?)(?=\\})/', $email_body, $matches); $_tags_in_body = array_flip(epl_get_element(0, $matches, array())); $_field_input_tags = array(); foreach ($available_fields as $f_id => $f_data) { $_field_input_tags[$f_data['input_slug']] = $f_id; } $tagss = array_intersect_key($_field_input_tags, $_tags_in_body); $final_tags = array(); foreach ($tagss as $k => $v) { $final_tags[$k] = epl_get_element($v, $_attendee_info); } $final_tags += $_system_email_tags; $find = array_keys($final_tags); array_walk($find, create_function('&$val', '$val = "{".$val."}";')); $replace = array_values($final_tags); return str_ireplace($find, $replace, $email_body); }