diff --git a/inc/mep_event_meta.php b/inc/mep_event_meta.php
index bc25c20..bc2124f 100644
--- a/inc/mep_event_meta.php
+++ b/inc/mep_event_meta.php
@@ -836,13 +836,13 @@ $more_date = get_post_meta($post->ID, 'mep_event_more_date', true);
diff --git a/inc/mep_extra_price.php b/inc/mep_extra_price.php
index e2512f2..e016802 100644
--- a/inc/mep_extra_price.php
+++ b/inc/mep_extra_price.php
@@ -104,7 +104,8 @@ if (get_post_type($eid) == 'mep_events') {
function mep_display_custom_fields_text_cart( $item_data, $cart_item ) {
$mep_events_extra_prices = $cart_item['event_extra_option'];
// print_r($cart_item);
-
+$eid = $cart_item['event_id'];
+if (get_post_type($eid) == 'mep_events') {
echo "";
?>
:
@@ -124,6 +125,7 @@ if(array_key_exists('event_ticket_type', $cart_item)){
echo " Ticket: ".$cart_item['event_ticket_type']." x ".$cart_item['event_ticket_qty'].": ".get_woocommerce_currency_symbol().$cart_item['event_ticket_price']." ";
}
echo " ";
+ }
return $item_data;
}
@@ -136,9 +138,21 @@ function mep_add_custom_fields_text_to_order_items( $item, $cart_item_key, $valu
$eid = $values['event_id'];
if (get_post_type($eid) == 'mep_events') {
$mep_events_extra_prices = $values['event_extra_option'];
+if(isset($values['event_ticket_type'])){
$event_ticket_type = $values['event_ticket_type'];
+}else{
+$event_ticket_type = " ";
+}
+if(isset($values['event_ticket_price'])){
$event_ticket_price = $values['event_ticket_price'];
+}else{
+$event_ticket_price = " ";
+}
+if(isset($values['event_ticket_qty'])){
$event_ticket_qty = $values['event_ticket_qty'];
+}else{
+$event_ticket_qty = " ";
+}
$product_id = $values['product_id'];
$cart_location = $values['event_cart_location'];
$cart_date = $values['event_cart_date'];
@@ -181,8 +195,9 @@ update_post_meta( $product_id, "mep_xtra_$opt_name",$ntes);
if($event_ticket_type){
-$event_ticket_type = "Ticket:".$event_ticket_type;
-$item->add_meta_data( $event_ticket_type." x ".$event_ticket_qty,get_woocommerce_currency_symbol().$event_ticket_price);
+// $event_ticket_type = "Ticket:".$event_ticket_type;
+
+// $item->add_meta_data( $event_ticket_type." x ".$event_ticket_qty,get_woocommerce_currency_symbol().$event_ticket_price);
$tck_name = $product_id.str_replace(' ', '', $event_ticket_type);
$tesqt = get_post_meta($product_id,"mep_xtra_$tck_name",true);
$ntesqt = ($tesqt+$event_ticket_qty);
diff --git a/woocommerce-event-press.php b/woocommerce-event-press.php
index 21e4430..2504032 100644
--- a/woocommerce-event-press.php
+++ b/woocommerce-event-press.php
@@ -1,1213 +1,1213 @@
-set_defaults();
-
- if ( ! $product->get_id() || ! ( $post_object = get_post( $product->get_id() ) ) || ! in_array( $post_object->post_type, array( 'mep_events', 'product' ) ) ) { // change birds with your post type
- throw new Exception( __( 'Invalid product.', 'woocommerce' ) );
- }
-
- $id = $product->get_id();
-
- $product->set_props( array(
- 'name' => $post_object->post_title,
- 'slug' => $post_object->post_name,
- 'date_created' => 0 < $post_object->post_date_gmt ? wc_string_to_timestamp( $post_object->post_date_gmt ) : null,
- 'date_modified' => 0 < $post_object->post_modified_gmt ? wc_string_to_timestamp( $post_object->post_modified_gmt ) : null,
- 'status' => $post_object->post_status,
- 'description' => $post_object->post_content,
- 'short_description' => $post_object->post_excerpt,
- 'parent_id' => $post_object->post_parent,
- 'menu_order' => $post_object->menu_order,
- 'reviews_allowed' => 'open' === $post_object->comment_status,
- ) );
-
- $this->read_attributes( $product );
- $this->read_downloads( $product );
- $this->read_visibility( $product );
- $this->read_product_data( $product );
- $this->read_extra_data( $product );
- $product->set_object_read( true );
- }
-
- /**
- * Get the product type based on product ID.
- *
- * @since 3.0.0
- * @param int $product_id
- * @return bool|string
- */
- public function get_product_type( $product_id ) {
- $post_type = get_post_type( $product_id );
- if ( 'product_variation' === $post_type ) {
- return 'variation';
- } elseif ( in_array( $post_type, array( 'mep_events', 'product' ) ) ) { // change birds with your post type
- $terms = get_the_terms( $product_id, 'product_type' );
- return ! empty( $terms ) ? sanitize_title( current( $terms )->name ) : 'simple';
- } else {
- return false;
- }
- }
-}
-
-
-
-function mep_get_order_info($info,$id){
- if($info){
- $stock_msg = $info;
- $koba = explode("_", $stock_msg);
- return $koba[$id];
-}else{
- return null;
-}
-}
-
-
-
-add_filter( 'woocommerce_data_stores', 'mep_woocommerce_data_stores' );
-function mep_woocommerce_data_stores ( $stores ) {
- $stores['product'] = 'MEP_Product_Data_Store_CPT';
- return $stores;
- }
-
- } else {
-
- add_action('admin_notices', 'wc_not_loaded');
- }
-
-function wc_not_loaded() {
- printf(
- '',
- __('You Must Install WooCommerce Plugin before activating WooCommerce Event Manager, Becuase It is dependent on Woocommerce Plugin')
- );
-}
-
-add_action('woocommerce_before_checkout_form', 'mep_displays_cart_products_feature_image');
-
-function mep_displays_cart_products_feature_image() {
- foreach ( WC()->cart->get_cart() as $cart_item ) {
- $item = $cart_item['data'];
- }
-}
-
-
-// Send Confirmation email to customer
-function mep_event_confirmation_email_sent($event_id,$sent_email){
-$values = get_post_custom($event_id);
-
-$global_email_text = mep_get_option( 'mep_confirmation_email_text', 'email_setting_sec', '');
-$global_email_form_email = mep_get_option( 'mep_email_form_email', 'email_setting_sec', '');
-$global_email_form = mep_get_option( 'mep_email_form_name', 'email_setting_sec', '');
-$global_email_sub = mep_get_option( 'mep_email_subject', 'email_setting_sec', '');
-$event_email_text = $values['mep_event_cc_email_text'][0];
-$admin_email = get_option( 'admin_email' );
-$site_name = get_option( 'blogname' );
-
-
- if($global_email_sub){
- $email_sub = $global_email_sub;
- }else{
- $email_sub = 'Confirmation Email';
- }
-
- if($global_email_form){
- $form_name = $global_email_form;
- }else{
- $form_name = $site_name;
- }
-
- if($global_email_form_email){
- $form_email = $global_email_form_email;
- }else{
- $form_email = $admin_email;
- }
-
- if($event_email_text){
- $email_body = $event_email_text;
- }else{
- $email_body = $global_email_text;
- }
-
- $headers[] = "From: $form_name <$form_email>";
-
- if($email_body){
- $sent = wp_mail( $sent_email, $email_sub, $email_body, $headers );
- }
-}
-
-}
-
-function mep_event_get_order_meta($item_id,$key){
-global $wpdb;
- $table_name = $wpdb->prefix."woocommerce_order_itemmeta";
- $sql = 'SELECT meta_value FROM '.$table_name.' WHERE order_item_id ='.$item_id.' AND meta_key="'.$key.'"';
- $results = $wpdb->get_results($sql); //or die(mysql_error());
- foreach( $results as $result ) {
- $value = $result->meta_value;
- }
- return $value;
-}
-
-
-
-
-
-add_action( 'woocommerce_thankyou','mep_set_first_order_sts');
-function mep_set_first_order_sts($order_id ){
-
- // Getting an instance of the order object
- $order = wc_get_order( $order_id );
- $order_meta = get_post_meta($order_id);
-
- # Iterating through each order items (WC_Order_Item_Product objects in WC 3+)
- foreach ( $order->get_items() as $item_id => $item_values ) {
- $item_id = $item_id;
- }
-$event_id = mep_event_get_order_meta($item_id,'event_id');
-$mep_atnd = "_mep_atnd_".$order_id;
-update_post_meta( $event_id, $mep_atnd, "a1");
-}
-
-
-
-
-
-
-
-
-
-add_action('woocommerce_order_status_changed', 'mep_event_seat_management', 10, 4);
-function mep_event_seat_management( $order_id, $from_status, $to_status, $order ) {
-global $wpdb;
-
-
- // Getting an instance of the order object
- $order = wc_get_order( $order_id );
- $order_meta = get_post_meta($order_id);
-
- $c = 1;
- # Iterating through each order items (WC_Order_Item_Product objects in WC 3+)
- foreach ( $order->get_items() as $item_id => $item_values ) {
- $item_quantity = $item_values->get_quantity();
- $item_id = $item_id;
- }
-
-$event_id = mep_event_get_order_meta($item_id,'event_id');
-$table_name = $wpdb->prefix . 'woocommerce_order_itemmeta';
-$result = $wpdb->get_results( "SELECT * FROM $table_name WHERE order_item_id=$item_id" );
-
-
- $mep_total = get_post_meta($event_id,'total_booking', true);
- if($mep_total){
- $mep_total_booking = $mep_total;
- }else{
- $mep_total_booking =0;
- }
-
-
- $email = $order_meta['_billing_email'][0];
- $order_meta_text = "_stock_msg_".$order_id;
- $order_processing = "processing_".$order_id;
- $order_completed = "completed_".$order_id;
- $order_cancelled = "cancelled_".$order_id;
- $mep_atnd = "_mep_atnd_".$order_id;
-
-
-// if($order->has_status( 'processing' ) || $order->has_status( 'pending' )) {
-if($order->has_status( 'processing' ) || $order->has_status( 'pending' )) {
-// update_post_meta( $event_id, $mep_atnd, "a2");
-
-$mep_stock_msgc = mep_get_order_info(get_post_meta($event_id,$order_meta_text, true),0);
-$mep_stock_orderc = mep_get_order_info(get_post_meta($event_id,$order_meta_text, true),1);
-
-if($mep_stock_orderc==$order_id){
- if($mep_stock_msgc=='cancelled'){
-
- foreach ( $result as $page ){
- if (strpos($page->meta_key, '_') !== 0) {
-
- $order_option_name = $event_id.str_replace(' ', '', mep_get_string_part($page->meta_key,0));
-
- $order_option_qty = mep_get_string_part($page->meta_key,1);
- $tes = get_post_meta($event_id,"mep_xtra_$order_option_name",true);
- $ntes = ($tes+$order_option_qty);
- update_post_meta( $event_id, "mep_xtra_$order_option_name",$ntes);
- }
- }
- }
- }
-
- update_post_meta( $event_id, $order_meta_text, $order_processing);
-
- $mep_stock_msg = mep_get_order_info(get_post_meta($event_id,$order_meta_text, true),0);
- $mep_stock_order = mep_get_order_info(get_post_meta($event_id,$order_meta_text, true),1);
-
-
-if($mep_stock_order==$order_id){
- if($mep_stock_msg=='completed'){
- update_post_meta( $event_id, $order_meta_text, $order_processing);
- }
- else{
- update_post_meta( $event_id, 'total_booking', ($mep_total_booking+$item_quantity));
- update_post_meta( $event_id, $order_meta_text, $order_processing);
-
- }
- }
-}
-
-
-
-
-
-if($order->has_status( 'cancelled' )) {
- update_post_meta( $event_id,$mep_atnd, "a2");
- update_post_meta( $event_id, $order_meta_text, $order_cancelled);
- $mep_stock_msg = mep_get_order_info(get_post_meta($event_id,$order_meta_text, true),0);
- $mep_stock_order = mep_get_order_info(get_post_meta($event_id,$order_meta_text, true),1);
-
-
- if($mep_stock_order==$order_id){
- $update_total_booking = update_post_meta( $event_id, 'total_booking', ($mep_total_booking-$item_quantity));
-
- foreach ( $result as $page ){
- if (strpos($page->meta_key, '_') !== 0) {
- $order_option_name = $event_id.str_replace(' ', '', mep_get_string_part($page->meta_key,0));
- $order_option_qty = mep_get_string_part($page->meta_key,1);
- $tes = get_post_meta($event_id,"mep_xtra_$order_option_name",true);
- $ntes = ($tes-$order_option_qty);
- if($tes>0){
- update_post_meta( $event_id, "mep_xtra_$order_option_name",$ntes);
- }
- }
- }
- }
-
-}
-
-
-
-
-
-
-
-if( $order->has_status( 'completed' )) {
-update_post_meta( $event_id, $mep_atnd, "a2");
- // update_post_meta( $event_id, $order_meta_text, $order_completed);
- $mep_stock_msg = mep_get_order_info(get_post_meta($event_id,$order_meta_text, true),0);
- $mep_stock_order = mep_get_order_info(get_post_meta($event_id,$order_meta_text, true),1);
- mep_event_confirmation_email_sent($event_id,$email);
-
- if($mep_stock_order==$order_id){
-
- if($mep_stock_msg=='processing'){
- update_post_meta( $event_id, $order_meta_text, $order_completed);
- }
- else{
- // update_post_meta( $event_id, 'total_booking', ($mep_total_booking+$item_quantity));
- update_post_meta( $event_id, $order_meta_text, $order_completed);
-
- foreach ( $result as $page ){
- if (strpos($page->meta_key, '_') !== 0) {
- $order_option_name = $event_id.str_replace(' ', '', mep_get_string_part($page->meta_key,0));
- $order_option_qty = mep_get_string_part($page->meta_key,1);
- $tes = get_post_meta($event_id,"mep_xtra_$order_option_name",true);
- $ntes = ($tes+$order_option_qty);
- update_post_meta( $event_id, "mep_xtra_$order_option_name",$ntes);
- }
- }
- }
-
- }
-
-
- }
-
-}
-
-
-
-add_action('restrict_manage_posts', 'mep_filter_post_type_by_taxonomy');
-function mep_filter_post_type_by_taxonomy() {
- global $typenow;
- $post_type = 'mep_events'; // change to your post type
- $taxonomy = 'mep_cat'; // change to your taxonomy
- if ($typenow == $post_type) {
- $selected = isset($_GET[$taxonomy]) ? $_GET[$taxonomy] : '';
- $info_taxonomy = get_taxonomy($taxonomy);
- wp_dropdown_categories(array(
- 'show_option_all' => __("Show All {$info_taxonomy->label}"),
- 'taxonomy' => $taxonomy,
- 'name' => $taxonomy,
- 'orderby' => 'name',
- 'selected' => $selected,
- 'show_count' => true,
- 'hide_empty' => true,
- ));
- };
-}
-
-
-
-
-add_filter('parse_query', 'mep_convert_id_to_term_in_query');
-function mep_convert_id_to_term_in_query($query) {
- global $pagenow;
- $post_type = 'mep_events'; // change to your post type
- $taxonomy = 'mep_cat'; // change to your taxonomy
- $q_vars = &$query->query_vars;
-
- if ( $pagenow == 'edit.php' && isset($q_vars['post_type']) && $q_vars['post_type'] == $post_type && isset($q_vars[$taxonomy]) && is_numeric($q_vars[$taxonomy]) && $q_vars[$taxonomy] != 0 ) {
- $term = get_term_by('id', $q_vars[$taxonomy], $taxonomy);
- $q_vars[$taxonomy] = $term->slug;
- }
-
-}
-
-
-
-add_filter('parse_query', 'mep_attendee_filter_query');
-function mep_attendee_filter_query($query) {
- global $pagenow;
- $post_type = 'mep_events_attendees';
- $q_vars = &$query->query_vars;
-
- if ( $pagenow == 'edit.php' && isset($_GET['post_type']) && $_GET['post_type'] == $post_type && isset($_GET['meta_value']) && $_GET['meta_value'] != 0) {
-
- $q_vars['meta_key'] = 'ea_event_id';
- $q_vars['meta_value'] = $_GET['meta_value'];
-
- }
-}
-
-
-
-
-
-
-
-
-
-
-// Add the data to the custom columns for the book post type:
-add_action( 'manage_mep_events_posts_custom_column' , 'mep_custom_event_column', 10, 2 );
-function mep_custom_event_column( $column, $post_id ) {
-switch ( $column ) {
-case 'mep_status' :
-$values = get_post_custom( $post_id );
-echo mep_get_event_status($values['mep_event_start_date'][0]);
- break;
-
- case 'mep_atten' :
- echo 'Attendees List ';
- break;
- }
-}
-
-
-// Getting event exprie date & time
-function mep_get_event_status($startdatetime){
-
- $time = strtotime($startdatetime);
- $newformat = date('Y-m-d H:i:s',$time);
- $datetime1 = new DateTime();
- $datetime2 = new DateTime($newformat);
- $interval = $datetime1->diff($datetime2);
-// print_r($newformat);
- if(time() > strtotime($newformat)){
- return "Expired ";
- }
- else{
- $days = $interval->days;
- $hours = $interval->h;
- $minutes = $interval->i;
- if($days>0){ $dd = $days." days "; }else{ $dd=""; }
- if($hours>0){ $hh = $hours." hours "; }else{ $hh=""; }
- if($minutes>0){ $mm = $minutes." minutes "; }else{ $mm=""; }
- return "$dd $hh $mm ";
- }
-}
-
-
-
-
-
-// Redirect to Checkout after successfuly event registration
-add_filter ('woocommerce_add_to_cart_redirect', 'mep_event_redirect_to_checkout');
-function mep_event_redirect_to_checkout() {
- global $woocommerce;
- $redirect_status = mep_get_option( 'mep_event_direct_checkout', 'general_setting_sec', 'yes' );
- if($redirect_status=='yes'){
- $checkout_url = wc_get_checkout_url();
- return $checkout_url;
- }
-}
-
-
-
-
-function mep_load_events_templates($template) {
- global $post;
- if ($post->post_type == "mep_events"){
- $template_name = 'single-events.php';
- $template_path = 'mage-events/';
- $default_path = plugin_dir_path( __FILE__ ) . 'templates/';
- $template = locate_template( array($template_path . $template_name) );
- if ( ! $template ) :
- $template = $default_path . $template_name;
- endif;
- return $template;
- }
-
- if ($post->post_type == "mep_events_attendees"){
- $plugin_path = plugin_dir_path( __FILE__ );
- $template_name = 'templates/single-mep_events_attendees.php';
- if($template === get_stylesheet_directory() . '/' . $template_name
- || !file_exists($plugin_path . $template_name)) {
- return $template;
- }
- return $plugin_path . $template_name;
- }
-
- return $template;
-}
-add_filter('single_template', 'mep_load_events_templates');
-
-
-
-
-
-add_filter('template_include', 'mep_organizer_set_template');
-function mep_organizer_set_template( $template ){
-
- if( is_tax('mep_org')){
- $template = plugin_dir_path( __FILE__ ).'templates/taxonomy-organozer.php';
- }
-
- if( is_tax('mep_cat')){
- $template = plugin_dir_path( __FILE__ ).'templates/taxonomy-category.php';
- }
-
- return $template;
-}
-
-
-
-function mep_social_share(){
-?>
-
-
-
-prefix . 'woocommerce_order_itemmeta';
-$result = $wpdb->get_results( "SELECT * FROM $table_name WHERE order_item_id=$id" );
-
-foreach ( $result as $page )
-{
- if (strpos($page->meta_key, '_') !== 0) {
- echo mep_get_string_part($page->meta_key,$part).' ';
- }
-}
-
-}
-
-add_action('woocommerce_account_dashboard','mep_ticket_lits_users');
-function mep_ticket_lits_users(){
-ob_start();
-?>
-
-
-
-
-
-
-
-
- array( 'mep_events_attendees' ),
- 'posts_per_page' => -1,
- 'meta_query' => array(
- array(
- 'key' => 'ea_user_id',
- 'value' => get_current_user_id()
- )
- )
- );
- $loop = new WP_Query( $args_search_qqq );
- while ($loop->have_posts()) {
- $loop->the_post();
-$event_id = get_post_meta( get_the_id(), 'ea_event_id', true );
- $event_meta = get_post_custom($event_id);
-
- $time = strtotime($event_meta['mep_event_start_date'][0]);
- $newformat = date('Y-m-d H:i:s',$time);
-
-
- if(time() < strtotime($newformat)){
-?>
-
-
-
-
-
-
-
-
-
-","",strip_tags(file_get_contents($filename, FALSE, NULL, 24, 14)));
- }
- $theme[$file] = $naame;
-}
-return $theme;
-}
-
-
-
-function event_single_template_list($current_theme){
-$themes = event_template_name();
- $buffer = '';
- foreach ($themes as $num=>$desc){
- if($current_theme==$num){ $cc = 'selected'; }else{ $cc = ''; }
- $buffer .= "$desc ";
- }//end foreach
- $buffer .= ' ';
- echo $buffer;
-}
-
-function mep_title_cutoff_words($text, $length){
- if(strlen($text) > $length) {
- $text = substr($text, 0, strpos($text, ' ', $length));
- }
-
- return $text;
-}
-
-function mep_get_tshirts_sizes($event_id){
- $event_meta = get_post_custom($event_id);
- $tee_sizes = $event_meta['mep_reg_tshirtsize_list'][0];
- $tszrray = explode(',', $tee_sizes);
-$ts = "";
- foreach ($tszrray as $value) {
- $ts .= "$value ";
- }
-return $ts;
-}
-
-
-function my_function_meta_deta() {
- global $order;
-
-$order_id = $_GET['post'];
- // Getting an instance of the order object
- $order = wc_get_order( $order_id );
- $order_meta = get_post_meta($order_id);
-
- # Iterating through each order items (WC_Order_Item_Product objects in WC 3+)
- foreach ( $order->get_items() as $item_id => $item_values ) {
- $product_id = $item_values->get_product_id();
- $item_data = $item_values->get_data();
- $product_id = $item_data['product_id'];
- $item_quantity = $item_values->get_quantity();
- $product = get_page_by_title( $item_data['name'], OBJECT, 'mep_events' );
- $event_name = $item_data['name'];
- $event_id = $product->ID;
- $item_id = $item_id;
- }
-
-$user_info_arr = wc_get_order_item_meta($item_id,'_event_user_info',true);
-
-// print_r($user_info_arr);
-
- ob_start();
-?>
-
-
-
- Name
- City
-
-
-
-
-
-
-id );
-
-
-
-// add_action( 'woocommerce_thankyou', 'woocommerce_thankyou_change_order_status', 10, 1 );
-function woocommerce_thankyou_change_order_status( $order_id ){
- if( ! $order_id ) return;
-
- $order = wc_get_order( $order_id );
-
- if( $order->get_status() == 'processing' )
- $order->update_status( 'completed' );
-}
-
-
-
-
-function mep_event_list_price($pid){
-global $post;
- $cur = get_woocommerce_currency_symbol();
- $mep_event_ticket_type = get_post_meta($pid, 'mep_event_ticket_type', true);
- $mep_events_extra_prices = get_post_meta($pid, 'mep_events_extra_prices', true);
- $n_price = get_post_meta($pid, '_price', true);
-
- if($n_price==0){
- $gn_price = "Free";
- }else{
- $gn_price = wc_price($n_price);
- }
-
- // if($mep_events_extra_prices){
- // $gn_price = $cur.$mep_events_extra_prices[0]['option_price'];
- // }
-
- if($mep_event_ticket_type){
- $gn_price = $cur.$mep_event_ticket_type[0]['option_price_t'];
- }
-
-return $gn_price;
-}
-
-function mep_get_label($pid,$label_id,$default_text){
- return mep_get_option( $label_id, 'label_setting_sec', $default_text);
-}
-
-// Add the custom columns to the book post type:
-add_filter( 'manage_mep_events_posts_columns', 'mep_set_custom_edit_event_columns' );
-function mep_set_custom_edit_event_columns($columns) {
-
- unset( $columns['date'] );
-
- $columns['mep_status'] = __( 'Status', 'mage-eventpress' );
-
- return $columns;
-}
-
-
-function mep_get_full_time_and_date($datetime){
- $user_set_format = mep_get_option( 'mep_event_time_format','general_setting_sec',12);
-
- if($user_set_format==12){
- echo date_i18n('D, d M Y h:i A', strtotime($datetime));
- }
- if($user_set_format==24){
- echo date_i18n('D, d M Y H:i', strtotime($datetime));
- }
-}
-
-
-function mep_get_only_time($datetime){
- $user_set_format = mep_get_option( 'mep_event_time_format','general_setting_sec',12);
-
- if($user_set_format==12){
- echo date_i18n('h:i A', strtotime($datetime));
- }
- if($user_set_format==24){
- echo date_i18n('H:i', strtotime($datetime));
- }
-}
-
-
-
-function mep_get_event_city($id){
-$location_sts = get_post_meta($id,'mep_org_address',true);
-$event_meta = get_post_custom($id);
-if($location_sts){
-$org_arr = get_the_terms( $id, 'mep_org' );
-$org_id = $org_arr[0]->term_id;
- echo "".get_term_meta( $org_id, 'org_city', true )." ";
-}else{
-
- echo "".$event_meta['mep_city'][0]." ";
-
-}
-}
-
-
-
-function mep_get_total_available_seat($event_id, $event_meta){
-$book_count = get_post_meta(get_the_id(),'total_booking', true);
-if($book_count){ $total_book = $book_count; }else{ $total_book = 0; }
-$simple_rsv = $event_meta['mep_rsv_seat'][0];
-if($simple_rsv){
- $simple_rsv = $simple_rsv;
-}else{
- $simple_rsv = 0;
-}
-$total_book = ($total_book + $simple_rsv);
-$mep_event_ticket_type = get_post_meta(get_the_id(), 'mep_event_ticket_type', true);
-if($mep_event_ticket_type){
-$stc = 0;
-$leftt = 0;
-$res = 0;
-foreach ( $mep_event_ticket_type as $field ) {
-$qm = $field['option_name_t'];
-$tesqn = get_the_id().str_replace(' ', '', $qm);
-$tesq = get_post_meta(get_the_id(),"mep_xtra_$tesqn",true);
-$stc = $stc+$field['option_qty_t'];
-$res = $res + (int)$field['option_rsv_t'];
-$res = (int)$res;
-$llft = ($field['option_qty_t'] - (int)$tesq);
-$leftt = ($leftt+$llft);
-}
- $leftt = $leftt-$res;
-}else{
- $leftt = (int) $event_meta['mep_total_seat'][0]- (int) $total_book;
-}
-return $leftt;
-}
-
-
-
-
-function mep_event_location_item($event_id,$item_name){
- return get_post_meta($event_id,$item_name,true);
-}
-
-function mep_event_org_location_item($event_id,$item_name){
- $location_sts = get_post_meta($event_id,'mep_org_address',true);
-
- $org_arr = get_the_terms( $event_id, 'mep_org' );
- if($org_arr){
- $org_id = $org_arr[0]->term_id;
- return get_term_meta( $org_id, $item_name, true );
-}
-}
-
-
-
-
-
-function mep_get_event_locaion_item($event_id,$item_name){
- if($event_id){
-$location_sts = get_post_meta($event_id,'mep_org_address',true);
-
-
-if($item_name=='mep_location_venue'){
- if($location_sts){
- $org_arr = get_the_terms( $event_id, 'mep_org' );
- $org_id = $org_arr[0]->term_id;
- return get_term_meta( $org_id, 'org_location', true );
- }else{
- return get_post_meta($event_id,'mep_location_venue',true);
- }
-}
-
-
-if($item_name=='mep_location_venue'){
- if($location_sts){
- $org_arr = get_the_terms( $event_id, 'mep_org' );
- $org_id = $org_arr[0]->term_id;
- return get_term_meta( $org_id, 'org_location', true );
- }else{
- return get_post_meta($event_id,'mep_location_venue',true);
- }
-}
-
-
-if($item_name=='mep_street'){
- if($location_sts){
- $org_arr = get_the_terms( $event_id, 'mep_org' );
- $org_id = $org_arr[0]->term_id;
- return get_term_meta( $org_id, 'org_street', true );
- }else{
- return get_post_meta($event_id,'mep_street',true);
- }
-}
-
-
-if($item_name=='mep_city'){
- if($location_sts){
- $org_arr = get_the_terms( $event_id, 'mep_org' );
- $org_id = $org_arr[0]->term_id;
- return get_term_meta( $org_id, 'org_city', true );
- }else{
- return get_post_meta($event_id,'mep_city',true);
- }
-}
-
-
-if($item_name=='mep_state'){
- if($location_sts){
- $org_arr = get_the_terms( $event_id, 'mep_org' );
- $org_id = $org_arr[0]->term_id;
- return get_term_meta( $org_id, 'org_state', true );
- }else{
- return get_post_meta($event_id,'mep_state',true);
- }
-}
-
-
-
-if($item_name=='mep_postcode'){
- if($location_sts){
- $org_arr = get_the_terms( $event_id, 'mep_org' );
- $org_id = $org_arr[0]->term_id;
- return get_term_meta( $org_id, 'org_postcode', true );
- }else{
- return get_post_meta($event_id,'mep_postcode',true);
- }
-}
-
-
-if($item_name=='mep_country'){
- if($location_sts){
- $org_arr = get_the_terms( $event_id, 'mep_org' );
- $org_id = $org_arr[0]->term_id;
- return get_term_meta( $org_id, 'org_country', true );
- }else{
- return get_post_meta($event_id,'mep_country',true);
- }
-}
-
-
-}
-
-}
-
-function mep_save_attendee_info_into_cart($product_id){
-
- $user = array();
-
- if(isset($_POST['user_name'])){
- $mep_user_name = $_POST['user_name'];
- }else{ $mep_user_name=""; }
-
- if(isset($_POST['user_email'])){
- $mep_user_email = $_POST['user_email'];
- }else{ $mep_user_email=""; }
-
- if(isset($_POST['user_phone'])){
- $mep_user_phone = $_POST['user_phone'];
- }else{ $mep_user_phone=""; }
-
- if(isset($_POST['user_address'])){
- $mep_user_address = $_POST['user_address'];
- }else{ $mep_user_address=""; }
-
- if(isset($_POST['gender'])){
- $mep_user_gender = $_POST['gender'];
- }else{ $mep_user_gender=""; }
-
- if(isset($_POST['tshirtsize'])){
- $mep_user_tshirtsize = $_POST['tshirtsize'];
- }else{ $mep_user_tshirtsize=""; }
-
- if(isset($_POST['user_company'])){
- $mep_user_company = $_POST['user_company'];
- }else{ $mep_user_company=""; }
-
- if(isset($_POST['user_designation'])){
- $mep_user_desg = $_POST['user_designation'];
- }else{ $mep_user_desg=""; }
-
- if(isset($_POST['user_website'])){
- $mep_user_website = $_POST['user_website'];
- }else{ $mep_user_website=""; }
-
- if(isset($_POST['vegetarian'])){
- $mep_user_vegetarian = $_POST['vegetarian'];
- }else{ $mep_user_vegetarian=""; }
-
- if(isset($_POST['ticket_type'])){
- $mep_user_ticket_type = $_POST['ticket_type'];
- }else{ $mep_user_ticket_type=""; }
-
- if(isset($_POST['mep_ucf'])){
- $mep_user_cfd = $_POST['mep_ucf'];
- }else{
- $mep_user_cfd = "";
- }
-
- $count_user = count($mep_user_name);
-
- for ( $iu = 0; $iu < $count_user; $iu++ ) {
-
- if ( $mep_user_name[$iu] != '' ) :
- $user[$iu]['user_name'] = stripslashes( strip_tags( $mep_user_name[$iu] ) );
- endif;
-
- if ( $mep_user_email[$iu] != '' ) :
- $user[$iu]['user_email'] = stripslashes( strip_tags( $mep_user_email[$iu] ) );
- endif;
-
- if ( $mep_user_phone[$iu] != '' ) :
- $user[$iu]['user_phone'] = stripslashes( strip_tags( $mep_user_phone[$iu] ) );
- endif;
-
- if ( $mep_user_address[$iu] != '' ) :
- $user[$iu]['user_address'] = stripslashes( strip_tags( $mep_user_address[$iu] ) );
- endif;
-
- if ( $mep_user_gender[$iu] != '' ) :
- $user[$iu]['user_gender'] = stripslashes( strip_tags( $mep_user_gender[$iu] ) );
- endif;
-
- if ( $mep_user_tshirtsize[$iu] != '' ) :
- $user[$iu]['user_tshirtsize'] = stripslashes( strip_tags( $mep_user_tshirtsize[$iu] ) );
- endif;
-
- if ( $mep_user_company[$iu] != '' ) :
- $user[$iu]['user_company'] = stripslashes( strip_tags( $mep_user_company[$iu] ) );
- endif;
-
- if ( $mep_user_desg[$iu] != '' ) :
- $user[$iu]['user_designation'] = stripslashes( strip_tags( $mep_user_desg[$iu] ) );
- endif;
-
- if ( $mep_user_website[$iu] != '' ) :
- $user[$iu]['user_website'] = stripslashes( strip_tags( $mep_user_website[$iu] ) );
- endif;
-
- if ( $mep_user_vegetarian[$iu] != '' ) :
- $user[$iu]['user_vegetarian'] = stripslashes( strip_tags( $mep_user_vegetarian[$iu] ) );
- endif;
-
- if ( $mep_user_ticket_type[$iu] != '' ) :
- $user[$iu]['user_ticket_type'] = stripslashes( strip_tags( $mep_user_ticket_type[$iu] ) );
- endif;
-
- $mep_form_builder_data = get_post_meta($product_id, 'mep_form_builder_data', true);
- if ( $mep_form_builder_data ) {
- foreach ( $mep_form_builder_data as $_field ) {
- $user[$iu][$_field['mep_fbc_id']] = stripslashes( strip_tags( $_POST[$_field['mep_fbc_id']][$iu] ) );
- }
- }
- }
- return $user;
-}
-
-
-
-function mep_wc_price( $price, $args = array() ) {
- $args = apply_filters(
- 'wc_price_args', wp_parse_args(
- $args, array(
- 'ex_tax_label' => false,
- 'currency' => '',
- 'decimal_separator' => wc_get_price_decimal_separator(),
- 'thousand_separator' => wc_get_price_thousand_separator(),
- 'decimals' => wc_get_price_decimals(),
- 'price_format' => get_woocommerce_price_format(),
- )
- )
- );
-
- $unformatted_price = $price;
- $negative = $price < 0;
- $price = apply_filters( 'raw_woocommerce_price', floatval( $negative ? $price * -1 : $price ) );
- $price = apply_filters( 'formatted_woocommerce_price', number_format( $price, $args['decimals'], $args['decimal_separator'], $args['thousand_separator'] ), $price, $args['decimals'], $args['decimal_separator'], $args['thousand_separator'] );
-
- if ( apply_filters( 'woocommerce_price_trim_zeros', false ) && $args['decimals'] > 0 ) {
- $price = wc_trim_zeros( $price );
- }
-
- $formatted_price = ( $negative ? '-' : '' ) . sprintf( $args['price_format'], '' . '' . '', $price );
- $return = '' . $formatted_price . '';
-
- if ( $args['ex_tax_label'] && wc_tax_enabled() ) {
- $return .= '' . WC()->countries->ex_tax_or_vat() . '';
- }
-
- /**
- * Filters the string of price markup.
- *
- * @param string $return Price HTML markup.
- * @param string $price Formatted price.
- * @param array $args Pass on the args.
- * @param float $unformatted_price Price as float to allow plugins custom formatting. Since 3.2.0.
- */
- return apply_filters( 'mep_wc_price', $return, $price, $args, $unformatted_price );
-}
-
-
-
-
-
-
-
-
-}else{
-function mep_admin_notice_wc_not_active() {
- $class = 'notice notice-error';
- printf(
- '',
- __('You Must Install WooCommerce Plugin before activating WooCommerce Event Manager, Becuase It is dependent on Woocommerce Plugin')
- );
-}
-add_action( 'admin_notices', 'mep_admin_notice_wc_not_active' );
+set_defaults();
+
+ if ( ! $product->get_id() || ! ( $post_object = get_post( $product->get_id() ) ) || ! in_array( $post_object->post_type, array( 'mep_events', 'product' ) ) ) { // change birds with your post type
+ throw new Exception( __( 'Invalid product.', 'woocommerce' ) );
+ }
+
+ $id = $product->get_id();
+
+ $product->set_props( array(
+ 'name' => $post_object->post_title,
+ 'slug' => $post_object->post_name,
+ 'date_created' => 0 < $post_object->post_date_gmt ? wc_string_to_timestamp( $post_object->post_date_gmt ) : null,
+ 'date_modified' => 0 < $post_object->post_modified_gmt ? wc_string_to_timestamp( $post_object->post_modified_gmt ) : null,
+ 'status' => $post_object->post_status,
+ 'description' => $post_object->post_content,
+ 'short_description' => $post_object->post_excerpt,
+ 'parent_id' => $post_object->post_parent,
+ 'menu_order' => $post_object->menu_order,
+ 'reviews_allowed' => 'open' === $post_object->comment_status,
+ ) );
+
+ $this->read_attributes( $product );
+ $this->read_downloads( $product );
+ $this->read_visibility( $product );
+ $this->read_product_data( $product );
+ $this->read_extra_data( $product );
+ $product->set_object_read( true );
+ }
+
+ /**
+ * Get the product type based on product ID.
+ *
+ * @since 3.0.0
+ * @param int $product_id
+ * @return bool|string
+ */
+ public function get_product_type( $product_id ) {
+ $post_type = get_post_type( $product_id );
+ if ( 'product_variation' === $post_type ) {
+ return 'variation';
+ } elseif ( in_array( $post_type, array( 'mep_events', 'product' ) ) ) { // change birds with your post type
+ $terms = get_the_terms( $product_id, 'product_type' );
+ return ! empty( $terms ) ? sanitize_title( current( $terms )->name ) : 'simple';
+ } else {
+ return false;
+ }
+ }
+}
+
+
+
+function mep_get_order_info($info,$id){
+ if($info){
+ $stock_msg = $info;
+ $koba = explode("_", $stock_msg);
+ return $koba[$id];
+}else{
+ return null;
+}
+}
+
+
+
+add_filter( 'woocommerce_data_stores', 'mep_woocommerce_data_stores' );
+function mep_woocommerce_data_stores ( $stores ) {
+ $stores['product'] = 'MEP_Product_Data_Store_CPT';
+ return $stores;
+ }
+
+ } else {
+
+ add_action('admin_notices', 'wc_not_loaded');
+ }
+
+function wc_not_loaded() {
+ printf(
+ '',
+ __('You Must Install WooCommerce Plugin before activating WooCommerce Event Manager, Becuase It is dependent on Woocommerce Plugin')
+ );
+}
+
+add_action('woocommerce_before_checkout_form', 'mep_displays_cart_products_feature_image');
+
+function mep_displays_cart_products_feature_image() {
+ foreach ( WC()->cart->get_cart() as $cart_item ) {
+ $item = $cart_item['data'];
+ }
+}
+
+
+// Send Confirmation email to customer
+function mep_event_confirmation_email_sent($event_id,$sent_email){
+$values = get_post_custom($event_id);
+
+$global_email_text = mep_get_option( 'mep_confirmation_email_text', 'email_setting_sec', '');
+$global_email_form_email = mep_get_option( 'mep_email_form_email', 'email_setting_sec', '');
+$global_email_form = mep_get_option( 'mep_email_form_name', 'email_setting_sec', '');
+$global_email_sub = mep_get_option( 'mep_email_subject', 'email_setting_sec', '');
+$event_email_text = $values['mep_event_cc_email_text'][0];
+$admin_email = get_option( 'admin_email' );
+$site_name = get_option( 'blogname' );
+
+
+ if($global_email_sub){
+ $email_sub = $global_email_sub;
+ }else{
+ $email_sub = 'Confirmation Email';
+ }
+
+ if($global_email_form){
+ $form_name = $global_email_form;
+ }else{
+ $form_name = $site_name;
+ }
+
+ if($global_email_form_email){
+ $form_email = $global_email_form_email;
+ }else{
+ $form_email = $admin_email;
+ }
+
+ if($event_email_text){
+ $email_body = $event_email_text;
+ }else{
+ $email_body = $global_email_text;
+ }
+
+ $headers[] = "From: $form_name <$form_email>";
+
+ if($email_body){
+ $sent = wp_mail( $sent_email, $email_sub, $email_body, $headers );
+ }
+}
+
+}
+
+function mep_event_get_order_meta($item_id,$key){
+global $wpdb;
+ $table_name = $wpdb->prefix."woocommerce_order_itemmeta";
+ $sql = 'SELECT meta_value FROM '.$table_name.' WHERE order_item_id ='.$item_id.' AND meta_key="'.$key.'"';
+ $results = $wpdb->get_results($sql); //or die(mysql_error());
+ foreach( $results as $result ) {
+ $value = $result->meta_value;
+ }
+ return $value;
+}
+
+
+
+
+
+add_action( 'woocommerce_thankyou','mep_set_first_order_sts');
+function mep_set_first_order_sts($order_id ){
+
+ // Getting an instance of the order object
+ $order = wc_get_order( $order_id );
+ $order_meta = get_post_meta($order_id);
+
+ # Iterating through each order items (WC_Order_Item_Product objects in WC 3+)
+ foreach ( $order->get_items() as $item_id => $item_values ) {
+ $item_id = $item_id;
+ }
+$event_id = mep_event_get_order_meta($item_id,'event_id');
+$mep_atnd = "_mep_atnd_".$order_id;
+update_post_meta( $event_id, $mep_atnd, "a1");
+}
+
+
+
+
+
+
+
+
+
+add_action('woocommerce_order_status_changed', 'mep_event_seat_management', 10, 4);
+function mep_event_seat_management( $order_id, $from_status, $to_status, $order ) {
+global $wpdb;
+
+
+ // Getting an instance of the order object
+ $order = wc_get_order( $order_id );
+ $order_meta = get_post_meta($order_id);
+
+ $c = 1;
+ # Iterating through each order items (WC_Order_Item_Product objects in WC 3+)
+ foreach ( $order->get_items() as $item_id => $item_values ) {
+ $item_quantity = $item_values->get_quantity();
+ $item_id = $item_id;
+ }
+
+$event_id = mep_event_get_order_meta($item_id,'event_id');
+$table_name = $wpdb->prefix . 'woocommerce_order_itemmeta';
+$result = $wpdb->get_results( "SELECT * FROM $table_name WHERE order_item_id=$item_id" );
+
+
+ $mep_total = get_post_meta($event_id,'total_booking', true);
+ if($mep_total){
+ $mep_total_booking = $mep_total;
+ }else{
+ $mep_total_booking =0;
+ }
+
+
+ $email = $order_meta['_billing_email'][0];
+ $order_meta_text = "_stock_msg_".$order_id;
+ $order_processing = "processing_".$order_id;
+ $order_completed = "completed_".$order_id;
+ $order_cancelled = "cancelled_".$order_id;
+ $mep_atnd = "_mep_atnd_".$order_id;
+
+
+// if($order->has_status( 'processing' ) || $order->has_status( 'pending' )) {
+if($order->has_status( 'processing' ) || $order->has_status( 'pending' )) {
+// update_post_meta( $event_id, $mep_atnd, "a2");
+
+$mep_stock_msgc = mep_get_order_info(get_post_meta($event_id,$order_meta_text, true),0);
+$mep_stock_orderc = mep_get_order_info(get_post_meta($event_id,$order_meta_text, true),1);
+
+if($mep_stock_orderc==$order_id){
+ if($mep_stock_msgc=='cancelled'){
+
+ foreach ( $result as $page ){
+ if (strpos($page->meta_key, '_') !== 0) {
+
+ $order_option_name = $event_id.str_replace(' ', '', mep_get_string_part($page->meta_key,0));
+
+ $order_option_qty = mep_get_string_part($page->meta_key,1);
+ $tes = get_post_meta($event_id,"mep_xtra_$order_option_name",true);
+ $ntes = ($tes+$order_option_qty);
+ update_post_meta( $event_id, "mep_xtra_$order_option_name",$ntes);
+ }
+ }
+ }
+ }
+
+ update_post_meta( $event_id, $order_meta_text, $order_processing);
+
+ $mep_stock_msg = mep_get_order_info(get_post_meta($event_id,$order_meta_text, true),0);
+ $mep_stock_order = mep_get_order_info(get_post_meta($event_id,$order_meta_text, true),1);
+
+
+if($mep_stock_order==$order_id){
+ if($mep_stock_msg=='completed'){
+ update_post_meta( $event_id, $order_meta_text, $order_processing);
+ }
+ else{
+ update_post_meta( $event_id, 'total_booking', ($mep_total_booking+$item_quantity));
+ update_post_meta( $event_id, $order_meta_text, $order_processing);
+
+ }
+ }
+}
+
+
+
+
+
+if($order->has_status( 'cancelled' )) {
+ update_post_meta( $event_id,$mep_atnd, "a2");
+ update_post_meta( $event_id, $order_meta_text, $order_cancelled);
+ $mep_stock_msg = mep_get_order_info(get_post_meta($event_id,$order_meta_text, true),0);
+ $mep_stock_order = mep_get_order_info(get_post_meta($event_id,$order_meta_text, true),1);
+
+
+ if($mep_stock_order==$order_id){
+ $update_total_booking = update_post_meta( $event_id, 'total_booking', ($mep_total_booking-$item_quantity));
+
+ foreach ( $result as $page ){
+ if (strpos($page->meta_key, '_') !== 0) {
+ $order_option_name = $event_id.str_replace(' ', '', mep_get_string_part($page->meta_key,0));
+ $order_option_qty = mep_get_string_part($page->meta_key,1);
+ $tes = get_post_meta($event_id,"mep_xtra_$order_option_name",true);
+ $ntes = ($tes-$order_option_qty);
+ if($tes>0){
+ update_post_meta( $event_id, "mep_xtra_$order_option_name",$ntes);
+ }
+ }
+ }
+ }
+
+}
+
+
+
+
+
+
+
+if( $order->has_status( 'completed' )) {
+update_post_meta( $event_id, $mep_atnd, "a2");
+ // update_post_meta( $event_id, $order_meta_text, $order_completed);
+ $mep_stock_msg = mep_get_order_info(get_post_meta($event_id,$order_meta_text, true),0);
+ $mep_stock_order = mep_get_order_info(get_post_meta($event_id,$order_meta_text, true),1);
+ mep_event_confirmation_email_sent($event_id,$email);
+
+ if($mep_stock_order==$order_id){
+
+ if($mep_stock_msg=='processing'){
+ update_post_meta( $event_id, $order_meta_text, $order_completed);
+ }
+ else{
+ // update_post_meta( $event_id, 'total_booking', ($mep_total_booking+$item_quantity));
+ update_post_meta( $event_id, $order_meta_text, $order_completed);
+
+ foreach ( $result as $page ){
+ if (strpos($page->meta_key, '_') !== 0) {
+ $order_option_name = $event_id.str_replace(' ', '', mep_get_string_part($page->meta_key,0));
+ $order_option_qty = mep_get_string_part($page->meta_key,1);
+ $tes = get_post_meta($event_id,"mep_xtra_$order_option_name",true);
+ $ntes = ($tes+$order_option_qty);
+ update_post_meta( $event_id, "mep_xtra_$order_option_name",$ntes);
+ }
+ }
+ }
+
+ }
+
+
+ }
+
+}
+
+
+
+add_action('restrict_manage_posts', 'mep_filter_post_type_by_taxonomy');
+function mep_filter_post_type_by_taxonomy() {
+ global $typenow;
+ $post_type = 'mep_events'; // change to your post type
+ $taxonomy = 'mep_cat'; // change to your taxonomy
+ if ($typenow == $post_type) {
+ $selected = isset($_GET[$taxonomy]) ? $_GET[$taxonomy] : '';
+ $info_taxonomy = get_taxonomy($taxonomy);
+ wp_dropdown_categories(array(
+ 'show_option_all' => __("Show All {$info_taxonomy->label}"),
+ 'taxonomy' => $taxonomy,
+ 'name' => $taxonomy,
+ 'orderby' => 'name',
+ 'selected' => $selected,
+ 'show_count' => true,
+ 'hide_empty' => true,
+ ));
+ };
+}
+
+
+
+
+add_filter('parse_query', 'mep_convert_id_to_term_in_query');
+function mep_convert_id_to_term_in_query($query) {
+ global $pagenow;
+ $post_type = 'mep_events'; // change to your post type
+ $taxonomy = 'mep_cat'; // change to your taxonomy
+ $q_vars = &$query->query_vars;
+
+ if ( $pagenow == 'edit.php' && isset($q_vars['post_type']) && $q_vars['post_type'] == $post_type && isset($q_vars[$taxonomy]) && is_numeric($q_vars[$taxonomy]) && $q_vars[$taxonomy] != 0 ) {
+ $term = get_term_by('id', $q_vars[$taxonomy], $taxonomy);
+ $q_vars[$taxonomy] = $term->slug;
+ }
+
+}
+
+
+
+add_filter('parse_query', 'mep_attendee_filter_query');
+function mep_attendee_filter_query($query) {
+ global $pagenow;
+ $post_type = 'mep_events_attendees';
+ $q_vars = &$query->query_vars;
+
+ if ( $pagenow == 'edit.php' && isset($_GET['post_type']) && $_GET['post_type'] == $post_type && isset($_GET['meta_value']) && $_GET['meta_value'] != 0) {
+
+ $q_vars['meta_key'] = 'ea_event_id';
+ $q_vars['meta_value'] = $_GET['meta_value'];
+
+ }
+}
+
+
+
+
+
+
+
+
+
+
+// Add the data to the custom columns for the book post type:
+add_action( 'manage_mep_events_posts_custom_column' , 'mep_custom_event_column', 10, 2 );
+function mep_custom_event_column( $column, $post_id ) {
+switch ( $column ) {
+case 'mep_status' :
+$values = get_post_custom( $post_id );
+echo mep_get_event_status($values['mep_event_start_date'][0]);
+ break;
+
+ case 'mep_atten' :
+ echo 'Attendees List ';
+ break;
+ }
+}
+
+
+// Getting event exprie date & time
+function mep_get_event_status($startdatetime){
+
+ $time = strtotime($startdatetime);
+ $newformat = date('Y-m-d H:i:s',$time);
+ $datetime1 = new DateTime();
+ $datetime2 = new DateTime($newformat);
+ $interval = $datetime1->diff($datetime2);
+// print_r($newformat);
+ if(time() > strtotime($newformat)){
+ return "Expired ";
+ }
+ else{
+ $days = $interval->days;
+ $hours = $interval->h;
+ $minutes = $interval->i;
+ if($days>0){ $dd = $days." days "; }else{ $dd=""; }
+ if($hours>0){ $hh = $hours." hours "; }else{ $hh=""; }
+ if($minutes>0){ $mm = $minutes." minutes "; }else{ $mm=""; }
+ return "$dd $hh $mm ";
+ }
+}
+
+
+
+
+
+// Redirect to Checkout after successfuly event registration
+add_filter ('woocommerce_add_to_cart_redirect', 'mep_event_redirect_to_checkout');
+function mep_event_redirect_to_checkout() {
+ global $woocommerce;
+ $redirect_status = mep_get_option( 'mep_event_direct_checkout', 'general_setting_sec', 'yes' );
+ if($redirect_status=='yes'){
+ $checkout_url = wc_get_checkout_url();
+ return $checkout_url;
+ }
+}
+
+
+
+
+function mep_load_events_templates($template) {
+ global $post;
+ if ($post->post_type == "mep_events"){
+ $template_name = 'single-events.php';
+ $template_path = 'mage-events/';
+ $default_path = plugin_dir_path( __FILE__ ) . 'templates/';
+ $template = locate_template( array($template_path . $template_name) );
+ if ( ! $template ) :
+ $template = $default_path . $template_name;
+ endif;
+ return $template;
+ }
+
+ if ($post->post_type == "mep_events_attendees"){
+ $plugin_path = plugin_dir_path( __FILE__ );
+ $template_name = 'templates/single-mep_events_attendees.php';
+ if($template === get_stylesheet_directory() . '/' . $template_name
+ || !file_exists($plugin_path . $template_name)) {
+ return $template;
+ }
+ return $plugin_path . $template_name;
+ }
+
+ return $template;
+}
+add_filter('single_template', 'mep_load_events_templates');
+
+
+
+
+
+add_filter('template_include', 'mep_organizer_set_template');
+function mep_organizer_set_template( $template ){
+
+ if( is_tax('mep_org')){
+ $template = plugin_dir_path( __FILE__ ).'templates/taxonomy-organozer.php';
+ }
+
+ if( is_tax('mep_cat')){
+ $template = plugin_dir_path( __FILE__ ).'templates/taxonomy-category.php';
+ }
+
+ return $template;
+}
+
+
+
+function mep_social_share(){
+?>
+
+
+
+prefix . 'woocommerce_order_itemmeta';
+$result = $wpdb->get_results( "SELECT * FROM $table_name WHERE order_item_id=$id" );
+
+foreach ( $result as $page )
+{
+ if (strpos($page->meta_key, '_') !== 0) {
+ echo mep_get_string_part($page->meta_key,$part).' ';
+ }
+}
+
+}
+
+add_action('woocommerce_account_dashboard','mep_ticket_lits_users');
+function mep_ticket_lits_users(){
+ob_start();
+?>
+
+
+
+
+
+
+
+
+ array( 'mep_events_attendees' ),
+ 'posts_per_page' => -1,
+ 'meta_query' => array(
+ array(
+ 'key' => 'ea_user_id',
+ 'value' => get_current_user_id()
+ )
+ )
+ );
+ $loop = new WP_Query( $args_search_qqq );
+ while ($loop->have_posts()) {
+ $loop->the_post();
+$event_id = get_post_meta( get_the_id(), 'ea_event_id', true );
+ $event_meta = get_post_custom($event_id);
+
+ $time = strtotime($event_meta['mep_event_start_date'][0]);
+ $newformat = date('Y-m-d H:i:s',$time);
+
+
+ if(time() < strtotime($newformat)){
+?>
+
+
+
+
+
+
+
+
+
+","",strip_tags(file_get_contents($filename, FALSE, NULL, 24, 14)));
+ }
+ $theme[$file] = $naame;
+}
+return $theme;
+}
+
+
+
+function event_single_template_list($current_theme){
+$themes = event_template_name();
+ $buffer = '';
+ foreach ($themes as $num=>$desc){
+ if($current_theme==$num){ $cc = 'selected'; }else{ $cc = ''; }
+ $buffer .= "$desc ";
+ }//end foreach
+ $buffer .= ' ';
+ echo $buffer;
+}
+
+function mep_title_cutoff_words($text, $length){
+ if(strlen($text) > $length) {
+ $text = substr($text, 0, strpos($text, ' ', $length));
+ }
+
+ return $text;
+}
+
+function mep_get_tshirts_sizes($event_id){
+ $event_meta = get_post_custom($event_id);
+ $tee_sizes = $event_meta['mep_reg_tshirtsize_list'][0];
+ $tszrray = explode(',', $tee_sizes);
+$ts = "";
+ foreach ($tszrray as $value) {
+ $ts .= "$value ";
+ }
+return $ts;
+}
+
+
+function my_function_meta_deta() {
+ global $order;
+
+$order_id = $_GET['post'];
+ // Getting an instance of the order object
+ $order = wc_get_order( $order_id );
+ $order_meta = get_post_meta($order_id);
+
+ # Iterating through each order items (WC_Order_Item_Product objects in WC 3+)
+ foreach ( $order->get_items() as $item_id => $item_values ) {
+ $product_id = $item_values->get_product_id();
+ $item_data = $item_values->get_data();
+ $product_id = $item_data['product_id'];
+ $item_quantity = $item_values->get_quantity();
+ $product = get_page_by_title( $item_data['name'], OBJECT, 'mep_events' );
+ $event_name = $item_data['name'];
+ $event_id = $product->ID;
+ $item_id = $item_id;
+ }
+
+$user_info_arr = wc_get_order_item_meta($item_id,'_event_user_info',true);
+
+// print_r($user_info_arr);
+
+ ob_start();
+?>
+
+
+
+ Name
+ City
+
+
+
+
+
+
+id );
+
+
+
+// add_action( 'woocommerce_thankyou', 'woocommerce_thankyou_change_order_status', 10, 1 );
+function woocommerce_thankyou_change_order_status( $order_id ){
+ if( ! $order_id ) return;
+
+ $order = wc_get_order( $order_id );
+
+ if( $order->get_status() == 'processing' )
+ $order->update_status( 'completed' );
+}
+
+
+
+
+function mep_event_list_price($pid){
+global $post;
+ $cur = get_woocommerce_currency_symbol();
+ $mep_event_ticket_type = get_post_meta($pid, 'mep_event_ticket_type', true);
+ $mep_events_extra_prices = get_post_meta($pid, 'mep_events_extra_prices', true);
+ $n_price = get_post_meta($pid, '_price', true);
+
+ if($n_price==0){
+ $gn_price = "Free";
+ }else{
+ $gn_price = wc_price($n_price);
+ }
+
+ // if($mep_events_extra_prices){
+ // $gn_price = $cur.$mep_events_extra_prices[0]['option_price'];
+ // }
+
+ if($mep_event_ticket_type){
+ $gn_price = $cur.$mep_event_ticket_type[0]['option_price_t'];
+ }
+
+return $gn_price;
+}
+
+function mep_get_label($pid,$label_id,$default_text){
+ return mep_get_option( $label_id, 'label_setting_sec', $default_text);
+}
+
+// Add the custom columns to the book post type:
+add_filter( 'manage_mep_events_posts_columns', 'mep_set_custom_edit_event_columns' );
+function mep_set_custom_edit_event_columns($columns) {
+
+ unset( $columns['date'] );
+
+ $columns['mep_status'] = __( 'Status', 'mage-eventpress' );
+
+ return $columns;
+}
+
+
+function mep_get_full_time_and_date($datetime){
+ $user_set_format = mep_get_option( 'mep_event_time_format','general_setting_sec',12);
+
+ if($user_set_format==12){
+ echo date_i18n('D, d M Y h:i A', strtotime($datetime));
+ }
+ if($user_set_format==24){
+ echo date_i18n('D, d M Y H:i', strtotime($datetime));
+ }
+}
+
+
+function mep_get_only_time($datetime){
+ $user_set_format = mep_get_option( 'mep_event_time_format','general_setting_sec',12);
+
+ if($user_set_format==12){
+ echo date_i18n('h:i A', strtotime($datetime));
+ }
+ if($user_set_format==24){
+ echo date_i18n('H:i', strtotime($datetime));
+ }
+}
+
+
+
+function mep_get_event_city($id){
+$location_sts = get_post_meta($id,'mep_org_address',true);
+$event_meta = get_post_custom($id);
+if($location_sts){
+$org_arr = get_the_terms( $id, 'mep_org' );
+$org_id = $org_arr[0]->term_id;
+ echo "".get_term_meta( $org_id, 'org_city', true )." ";
+}else{
+
+ echo "".$event_meta['mep_city'][0]." ";
+
+}
+}
+
+
+
+function mep_get_total_available_seat($event_id, $event_meta){
+$book_count = get_post_meta(get_the_id(),'total_booking', true);
+if($book_count){ $total_book = $book_count; }else{ $total_book = 0; }
+$simple_rsv = $event_meta['mep_rsv_seat'][0];
+if($simple_rsv){
+ $simple_rsv = $simple_rsv;
+}else{
+ $simple_rsv = 0;
+}
+$total_book = ($total_book + $simple_rsv);
+$mep_event_ticket_type = get_post_meta(get_the_id(), 'mep_event_ticket_type', true);
+if($mep_event_ticket_type){
+$stc = 0;
+$leftt = 0;
+$res = 0;
+foreach ( $mep_event_ticket_type as $field ) {
+$qm = $field['option_name_t'];
+$tesqn = get_the_id().str_replace(' ', '', $qm);
+$tesq = get_post_meta(get_the_id(),"mep_xtra_$tesqn",true);
+$stc = $stc+$field['option_qty_t'];
+$res = $res + (int)$field['option_rsv_t'];
+$res = (int)$res;
+$llft = ($field['option_qty_t'] - (int)$tesq);
+$leftt = ($leftt+$llft);
+}
+ $leftt = $leftt-$res;
+}else{
+ $leftt = (int) $event_meta['mep_total_seat'][0]- (int) $total_book;
+}
+return $leftt;
+}
+
+
+
+
+function mep_event_location_item($event_id,$item_name){
+ return get_post_meta($event_id,$item_name,true);
+}
+
+function mep_event_org_location_item($event_id,$item_name){
+ $location_sts = get_post_meta($event_id,'mep_org_address',true);
+
+ $org_arr = get_the_terms( $event_id, 'mep_org' );
+ if($org_arr){
+ $org_id = $org_arr[0]->term_id;
+ return get_term_meta( $org_id, $item_name, true );
+}
+}
+
+
+
+
+
+function mep_get_event_locaion_item($event_id,$item_name){
+ if($event_id){
+$location_sts = get_post_meta($event_id,'mep_org_address',true);
+
+
+if($item_name=='mep_location_venue'){
+ if($location_sts){
+ $org_arr = get_the_terms( $event_id, 'mep_org' );
+ $org_id = $org_arr[0]->term_id;
+ return get_term_meta( $org_id, 'org_location', true );
+ }else{
+ return get_post_meta($event_id,'mep_location_venue',true);
+ }
+}
+
+
+if($item_name=='mep_location_venue'){
+ if($location_sts){
+ $org_arr = get_the_terms( $event_id, 'mep_org' );
+ $org_id = $org_arr[0]->term_id;
+ return get_term_meta( $org_id, 'org_location', true );
+ }else{
+ return get_post_meta($event_id,'mep_location_venue',true);
+ }
+}
+
+
+if($item_name=='mep_street'){
+ if($location_sts){
+ $org_arr = get_the_terms( $event_id, 'mep_org' );
+ $org_id = $org_arr[0]->term_id;
+ return get_term_meta( $org_id, 'org_street', true );
+ }else{
+ return get_post_meta($event_id,'mep_street',true);
+ }
+}
+
+
+if($item_name=='mep_city'){
+ if($location_sts){
+ $org_arr = get_the_terms( $event_id, 'mep_org' );
+ $org_id = $org_arr[0]->term_id;
+ return get_term_meta( $org_id, 'org_city', true );
+ }else{
+ return get_post_meta($event_id,'mep_city',true);
+ }
+}
+
+
+if($item_name=='mep_state'){
+ if($location_sts){
+ $org_arr = get_the_terms( $event_id, 'mep_org' );
+ $org_id = $org_arr[0]->term_id;
+ return get_term_meta( $org_id, 'org_state', true );
+ }else{
+ return get_post_meta($event_id,'mep_state',true);
+ }
+}
+
+
+
+if($item_name=='mep_postcode'){
+ if($location_sts){
+ $org_arr = get_the_terms( $event_id, 'mep_org' );
+ $org_id = $org_arr[0]->term_id;
+ return get_term_meta( $org_id, 'org_postcode', true );
+ }else{
+ return get_post_meta($event_id,'mep_postcode',true);
+ }
+}
+
+
+if($item_name=='mep_country'){
+ if($location_sts){
+ $org_arr = get_the_terms( $event_id, 'mep_org' );
+ $org_id = $org_arr[0]->term_id;
+ return get_term_meta( $org_id, 'org_country', true );
+ }else{
+ return get_post_meta($event_id,'mep_country',true);
+ }
+}
+
+
+}
+
+}
+
+function mep_save_attendee_info_into_cart($product_id){
+
+ $user = array();
+
+ if(isset($_POST['user_name'])){
+ $mep_user_name = $_POST['user_name'];
+ }else{ $mep_user_name=""; }
+
+ if(isset($_POST['user_email'])){
+ $mep_user_email = $_POST['user_email'];
+ }else{ $mep_user_email=""; }
+
+ if(isset($_POST['user_phone'])){
+ $mep_user_phone = $_POST['user_phone'];
+ }else{ $mep_user_phone=""; }
+
+ if(isset($_POST['user_address'])){
+ $mep_user_address = $_POST['user_address'];
+ }else{ $mep_user_address=""; }
+
+ if(isset($_POST['gender'])){
+ $mep_user_gender = $_POST['gender'];
+ }else{ $mep_user_gender=""; }
+
+ if(isset($_POST['tshirtsize'])){
+ $mep_user_tshirtsize = $_POST['tshirtsize'];
+ }else{ $mep_user_tshirtsize=""; }
+
+ if(isset($_POST['user_company'])){
+ $mep_user_company = $_POST['user_company'];
+ }else{ $mep_user_company=""; }
+
+ if(isset($_POST['user_designation'])){
+ $mep_user_desg = $_POST['user_designation'];
+ }else{ $mep_user_desg=""; }
+
+ if(isset($_POST['user_website'])){
+ $mep_user_website = $_POST['user_website'];
+ }else{ $mep_user_website=""; }
+
+ if(isset($_POST['vegetarian'])){
+ $mep_user_vegetarian = $_POST['vegetarian'];
+ }else{ $mep_user_vegetarian=""; }
+
+ if(isset($_POST['ticket_type'])){
+ $mep_user_ticket_type = $_POST['ticket_type'];
+ }else{ $mep_user_ticket_type=""; }
+
+ if(isset($_POST['mep_ucf'])){
+ $mep_user_cfd = $_POST['mep_ucf'];
+ }else{
+ $mep_user_cfd = "";
+ }
+
+ $count_user = count($mep_user_name);
+
+ for ( $iu = 0; $iu < $count_user; $iu++ ) {
+
+ if (isset($mep_user_name[$iu])):
+ $user[$iu]['user_name'] = stripslashes( strip_tags( $mep_user_name[$iu] ) );
+ endif;
+
+ if (isset($mep_user_email[$iu])) :
+ $user[$iu]['user_email'] = stripslashes( strip_tags( $mep_user_email[$iu] ) );
+ endif;
+
+ if (isset($mep_user_phone[$iu])) :
+ $user[$iu]['user_phone'] = stripslashes( strip_tags( $mep_user_phone[$iu] ) );
+ endif;
+
+ if (isset($mep_user_address[$iu])) :
+ $user[$iu]['user_address'] = stripslashes( strip_tags( $mep_user_address[$iu] ) );
+ endif;
+
+ if (isset($mep_user_gender[$iu])) :
+ $user[$iu]['user_gender'] = stripslashes( strip_tags( $mep_user_gender[$iu] ) );
+ endif;
+
+ if (isset($mep_user_tshirtsize[$iu])) :
+ $user[$iu]['user_tshirtsize'] = stripslashes( strip_tags( $mep_user_tshirtsize[$iu] ) );
+ endif;
+
+ if (isset($mep_user_company[$iu])) :
+ $user[$iu]['user_company'] = stripslashes( strip_tags( $mep_user_company[$iu] ) );
+ endif;
+
+ if (isset($mep_user_desg[$iu])) :
+ $user[$iu]['user_designation'] = stripslashes( strip_tags( $mep_user_desg[$iu] ) );
+ endif;
+
+ if (isset($mep_user_website[$iu])) :
+ $user[$iu]['user_website'] = stripslashes( strip_tags( $mep_user_website[$iu] ) );
+ endif;
+
+ if (isset($mep_user_vegetarian[$iu])) :
+ $user[$iu]['user_vegetarian'] = stripslashes( strip_tags( $mep_user_vegetarian[$iu] ) );
+ endif;
+
+ if (isset($mep_user_ticket_type[$iu])) :
+ $user[$iu]['user_ticket_type'] = stripslashes( strip_tags( $mep_user_ticket_type[$iu] ) );
+ endif;
+
+ $mep_form_builder_data = get_post_meta($product_id, 'mep_form_builder_data', true);
+ if ( $mep_form_builder_data ) {
+ foreach ( $mep_form_builder_data as $_field ) {
+ $user[$iu][$_field['mep_fbc_id']] = stripslashes( strip_tags( $_POST[$_field['mep_fbc_id']][$iu] ) );
+ }
+ }
+ }
+ return $user;
+}
+
+
+
+function mep_wc_price( $price, $args = array() ) {
+ $args = apply_filters(
+ 'wc_price_args', wp_parse_args(
+ $args, array(
+ 'ex_tax_label' => false,
+ 'currency' => '',
+ 'decimal_separator' => wc_get_price_decimal_separator(),
+ 'thousand_separator' => wc_get_price_thousand_separator(),
+ 'decimals' => wc_get_price_decimals(),
+ 'price_format' => get_woocommerce_price_format(),
+ )
+ )
+ );
+
+ $unformatted_price = $price;
+ $negative = $price < 0;
+ $price = apply_filters( 'raw_woocommerce_price', floatval( $negative ? $price * -1 : $price ) );
+ $price = apply_filters( 'formatted_woocommerce_price', number_format( $price, $args['decimals'], $args['decimal_separator'], $args['thousand_separator'] ), $price, $args['decimals'], $args['decimal_separator'], $args['thousand_separator'] );
+
+ if ( apply_filters( 'woocommerce_price_trim_zeros', false ) && $args['decimals'] > 0 ) {
+ $price = wc_trim_zeros( $price );
+ }
+
+ $formatted_price = ( $negative ? '-' : '' ) . sprintf( $args['price_format'], '' . '' . '', $price );
+ $return = '' . $formatted_price . '';
+
+ if ( $args['ex_tax_label'] && wc_tax_enabled() ) {
+ $return .= '' . WC()->countries->ex_tax_or_vat() . '';
+ }
+
+ /**
+ * Filters the string of price markup.
+ *
+ * @param string $return Price HTML markup.
+ * @param string $price Formatted price.
+ * @param array $args Pass on the args.
+ * @param float $unformatted_price Price as float to allow plugins custom formatting. Since 3.2.0.
+ */
+ return apply_filters( 'mep_wc_price', $return, $price, $args, $unformatted_price );
+}
+
+
+
+
+
+
+
+
+}else{
+function mep_admin_notice_wc_not_active() {
+ $class = 'notice notice-error';
+ printf(
+ '',
+ __('You Must Install WooCommerce Plugin before activating WooCommerce Event Manager, Becuase It is dependent on Woocommerce Plugin')
+ );
+}
+add_action( 'admin_notices', 'mep_admin_notice_wc_not_active' );
}
\ No newline at end of file