diff --git a/css/style.css b/css/style.css index 29f4aea..c59cc56 100644 --- a/css/style.css +++ b/css/style.css @@ -1479,6 +1479,16 @@ h4.mep-cart-table-title { padding: 0 0 0 25px; } +p#mep_btn_notice { + text-align: center; + width: 300px; + float: none; + margin: 0; +} + + + + /* Responsive CSS =====================================================================*/ @media only screen and (min-width: 768px) and (max-width: 990px) { diff --git a/inc/mep_event_meta.php b/inc/mep_event_meta.php index 8c21f3b..928c9f0 100644 --- a/inc/mep_event_meta.php +++ b/inc/mep_event_meta.php @@ -7,10 +7,10 @@ function mep_event_meta_box_add(){ add_meta_box( 'mep-event-price', __('Event Price (Event Base price, It will not work if you add Event Ticket type Price)','mage-eventpress'), 'mep_event_price_meta_box_cb', 'mep_events', 'normal', 'high' ); - add_meta_box( 'mep-event-extra-price', __('Event Extra Service (Extra Service as Product that you can sell and it is not included on event package)','mage-eventpress'), 'mep_event_extra_price_option', 'mep_events', 'normal', 'high' ); - add_meta_box( 'mep-event-ticket-type', __('Event Ticket Type and Pricing','mage-eventpress'), 'mep_event_ticket_type', 'mep_events', 'normal', 'high' ); + add_meta_box( 'mep-event-extra-price', __('Event Extra Service (Extra Service as Product that you can sell and it is not included on event package)','mage-eventpress'), 'mep_event_extra_price_option', 'mep_events', 'normal', 'high' ); + add_meta_box( 'mep-event-date', __('Event Date & Time','mage-eventpress'), 'mep_event_date_meta_box_cb', 'mep_events', 'normal', 'high' ); add_meta_box( 'mep-event-emails', __('Event Email text','mage-eventpress'), 'mep_event_email_meta_box_cb', 'mep_events', 'normal', 'high' ); @@ -111,16 +111,7 @@ if(array_key_exists('_tax_class', $values)){ $tx_class = $values['_tax_class'][0 diff --git a/inc/mep_extra_price.php b/inc/mep_extra_price.php index b1e24b6..f8dca91 100644 --- a/inc/mep_extra_price.php +++ b/inc/mep_extra_price.php @@ -1,6 +1,6 @@ $val) { + if ($val['option_name'] === $extra_service['option_name']) { + if($val['option_qty'] > 0){ + $event_extra[$us]['service_name'] = stripslashes( strip_tags($val['option_name']) ); + + $event_extra[$us]['service_qty'] = stripslashes(strip_tags($val['option_qty'])); + $event_extra[$us]['service_price'] = stripslashes(strip_tags($val['option_price'])); + } + }else{ + $event_extra = array(); + } + } + + $us++; +} + - $cart_item_data['event_ticket_info'] = $ticket_type_arr; - - - + $cart_item_data['event_ticket_info'] = $ticket_type_arr; $cart_item_data['event_extra_option'] = $new; $cart_item_data['event_user_info'] = $user; $cart_item_data['event_tp'] = $tp; $cart_item_data['line_total'] = $tp; $cart_item_data['line_subtotal'] = $tp; - $cart_item_data['event_id'] = $product_id; + $cart_item_data['event_cart_location'] = $event_cart_location; $cart_item_data['event_cart_date'] = $event_cart_date; - - +} + $cart_item_data['event_id'] = $product_id; return $cart_item_data; } diff --git a/inc/mep_upgrade.php b/inc/mep_upgrade.php new file mode 100644 index 0000000..507f771 --- /dev/null +++ b/inc/mep_upgrade.php @@ -0,0 +1,154 @@ + 'mep_events_attendees', + 'posts_per_page' => -1, + + 'meta_query' => array( + + + array( + 'key' => 'ea_event_id', + 'value' => $event_id, + 'compare' => '=' + ), + array( + 'key' => 'ea_order_id', + 'value' => $order_id, + 'compare' => '=' + ), + array( + 'key' => 'ea_ticket_type', + 'value' => $type, + 'compare' => '=' + ), + array( + 'key' => 'ea_name', + 'value' => $name, + 'compare' => '=' + ), + array( + 'key' => 'ea_email', + 'value' => $email, + 'compare' => '=' + ), + array( + 'key' => 'ea_phone', + 'value' => $phone, + 'compare' => '=' + ) + ) + ); + + + $loop = new WP_Query($args); + return $loop->post_count; +} + + + +add_action('admin_init','mep_get_all_order_data_and_create_attendee'); + +function mep_get_all_order_data_and_create_attendee(){ + +if ( get_option( 'mep_event_magor_update_3' ) != 'completed' ) { + +global $wpdb; +$args = array( + 'limit' => -1, + 'return' => 'ids', +); +$query = new WC_Order_Query( $args ); +$orders = $query->get_orders(); +$c = 1; + +foreach($orders as $order_id){ + $order = wc_get_order( $order_id ); + $order_meta = get_post_meta($order_id); + + foreach ( $order->get_items() as $item_id => $item_values ) { + $item_id = $item_id; + } + + $event_info = maybe_unserialize(mep_event_get_order_meta($item_id,'_event_user_info')); + + $event_id = mep_event_get_order_meta($item_id,'event_id') ? mep_event_get_order_meta($item_id,'event_id') : 0; + + if(is_array($event_info) && sizeof($event_info) > 0 && $event_id > 0){ + // echo '
';
+    // print_r(array_merge($event_info,$event_id));  
+
+        foreach($event_info as $_event_info){
+
+          $user_name = isset($_event_info['user_name']) ? $_event_info['user_name'] : '';
+          $user_email = isset($_event_info['user_email']) ? $_event_info['user_email'] : '';
+          $user_phone = isset($_event_info['user_phone']) ? $_event_info['user_phone'] : '';
+          $user_address = isset($_event_info['user_address']) ? $_event_info['user_address'] : '';
+          $user_gender = isset($_event_info['user_gender']) ? $_event_info['user_gender'] : '';
+          $user_tshirtsize = isset($_event_info['user_tshirtsize']) ? $_event_info['user_tshirtsize'] : '';
+          $user_company = isset($_event_info['user_company']) ? $_event_info['user_company'] : '';
+           
+          $user_designation = isset($_event_info['user_designation']) ? $_event_info['user_designation'] : '';
+          
+          $user_website = isset($_event_info['user_website']) ? $_event_info['user_website'] : '';
+          $user_vegetarian = isset($_event_info['user_vegetarian']) ? $_event_info['user_vegetarian'] : '';
+          $user_ticket_type = isset($_event_info['user_ticket_type']) ? $_event_info['user_ticket_type'] : '';
+            
+            
+           $check = mep_check_attendee_exists($event_id,$order_id,$user_name,$user_email,$user_phone,$user_address,$user_gender,$user_company,$user_designation,$user_website,$user_vegetarian,$user_tshirtsize,$user_ticket_type);
+           
+           if($check == 0){
+               
+            $first_name       = isset($order_meta['_billing_first_name'][0]) ? $order_meta['_billing_first_name'][0] : '';
+            $last_name        = isset($order_meta['_billing_last_name'][0]) ? $order_meta['_billing_last_name'][0] : '';         
+            $uname            = $first_name.' '.$last_name;
+            $payment_method   = isset($order_meta['_payment_method_title'][0]) ? $order_meta['_payment_method_title'][0] : array();
+            $user_id          = isset($order_meta['_customer_user'][0]) ? $order_meta['_customer_user'][0] : array();
+            $event_name       = get_the_title($event_id);
+            $order_status     = $order->get_status();
+
+          $new_post = array(
+              'post_title'    =>   $uname,
+              'post_content'  =>   '',
+              'post_category' =>   array(),  // Usable for custom taxonomies too
+              'tags_input'    =>   array(),
+              'post_status'   =>   'publish', // Choose: publish, preview, future, draft, etc.
+              'post_type'     =>   'mep_events_attendees'  //'post',page' or use a custom post type if you want to
+            );
+
+              //SAVE THE POST
+                $pid                = wp_insert_post($new_post);
+                $pin = $user_id.$order_id.$event_id.$pid;  
+                update_post_meta( $pid, 'ea_name', $user_name);
+                update_post_meta( $pid, 'ea_address_1', $user_address);
+                update_post_meta( $pid, 'ea_email', $user_email);
+                update_post_meta( $pid, 'ea_phone', $user_phone);
+                update_post_meta( $pid, 'ea_gender', $user_gender);
+                update_post_meta( $pid, 'ea_company', $user_company);
+                update_post_meta( $pid, 'ea_desg', $user_designation);
+                update_post_meta( $pid, 'ea_website', $user_website);
+                update_post_meta( $pid, 'ea_vegetarian', $user_vegetarian);
+                update_post_meta( $pid, 'ea_tshirtsize', $user_tshirtsize);
+                update_post_meta( $pid, 'ea_ticket_type', $user_ticket_type);
+                update_post_meta( $pid, 'ea_payment_method', $payment_method);
+                update_post_meta( $pid, 'ea_event_name', $event_name);
+                update_post_meta( $pid, 'ea_event_id', $event_id);
+                update_post_meta( $pid, 'ea_order_id', $order_id);
+                update_post_meta( $pid, 'ea_user_id', $user_id);
+                update_post_meta( $pid, 'ea_ticket_no', $pin);
+                update_post_meta( $pid, 'ea_order_status', $order_status);
+        
+           }
+           
+        }
+    
+    }
+    
+}    
+update_option( 'mep_event_magor_update_3', 'completed' );
+}
+
+
+// die();
+}
\ No newline at end of file
diff --git a/readme.txt b/readme.txt
index 194625e..7815766 100644
--- a/readme.txt
+++ b/readme.txt
@@ -149,14 +149,14 @@ our support team will back to you shortly.
 
 
 
-### How to Add New Event 
-https://www.youtube.com/watch?v=2VLWSUS6GPI
+### How to install Woo Commerce Event Manager Plugin in 3 Minutes
+https://www.youtube.com/watch?v=_CRPyKHPhTU
 
-### How to Add Ticket Base Event 
-https://www.youtube.com/watch?v=2VLWSUS6GPI
+### WooCommerce Event Manager Pro Addons Setup And Full Functionality Explained
+https://www.youtube.com/watch?v=LZj6oUavTQg
 
-### How to Buy/Purchase/Booking an Event 
-https://www.youtube.com/watch?v=IyUCCIeS6P8
+### How to Configure Event Manager Attendee Registration Form 
+https://www.youtube.com/watch?v=F9wnlUjXa6I
 
 
 **CHECKOUT OUR OTHER PRODUCTS**
@@ -403,4 +403,17 @@ A. you can create support ticket here with problem details with possible screens
 *= 2.7.2 =
 * Update Release:
 ==> Bug Fixed
-15 Sep 2019*
\ No newline at end of file
+15 Sep 2019*
+
+
+*= 2.7.3 =
+* Update Release:
+==> Bug Fixed
+*
+
+
+*= 2.8.0 =
+* Update Release:
+==> Bug Fixed
+==> Event seating issue fixed while order status chganged
+04 Nov 2019*
\ No newline at end of file
diff --git a/templates/template-prts/event_add_cart.php b/templates/template-prts/event_add_cart.php
index 3cc1396..9a76223 100644
--- a/templates/template-prts/event_add_cart.php
+++ b/templates/template-prts/event_add_cart.php
@@ -42,24 +42,23 @@ $simple_rsv = '';
     $interval   = $datetime1->diff($datetime2);
     $mep_event_ticket_type = get_post_meta($post_id, 'mep_event_ticket_type', true);
 
-    $stc        = 0;
-    $leftt      = 0;
+		$total_seat = mep_event_total_seat(get_the_id(),'total');
+		$total_resv = mep_event_total_seat(get_the_id(),'resv');
+		$total_sold = mep_ticket_sold(get_the_id());
+		$total_left = $total_seat - ($total_sold + $total_resv);
+
+
+
 if (is_array($mep_event_ticket_type) || is_object($mep_event_ticket_type)){
 foreach ($mep_event_ticket_type as $field ) {
   $qm = $field['option_name_t'];
-  $opt_qty = isset($field['option_qty_t']) ? $field['option_qty_t'] : 0;
-// $opt_rst_qty = $field['option_rsv_t'] ? $field['option_rsv_t'] : 0;
-  $tesqn = $post_id.str_replace(' ', '', $qm);
-  $tesq = get_post_meta($post_id,"mep_xtra_$tesqn",true);
-  $stc = $stc+$opt_qty;
-  $llft = ($opt_qty - (int)$tesq);
-  $leftt = $leftt+$llft;
 }
 }else{$qm='';}
+
 if($mep_event_ticket_type){
-  $seat_left = $leftt;
+  $seat_left = $total_left;
 }else{
-  $seat_left = $seat_left;
+  $seat_left = $total_left;
 }
 
 
@@ -122,29 +121,7 @@ if(array_key_exists('mep_rsv_seat', $event_meta)){
     $mep_available_seat = 'on';
   }
 
-if($mep_event_ticket_type){
-
-  $stc    = 0;
-  $leftt  = 0;
-  $res    = 0;
-
-foreach ( $mep_event_ticket_type as $field ) {
-    $qm = $field['option_name_t'];
-      $opt_qty = isset($field['option_qty_t']) ? $field['option_qty_t'] : 0;
-$opt_rst_qty = isset($field['option_rsv_t']) ? $field['option_rsv_t'] : 0;
-    $tesqn = $post->ID.str_replace(' ', '', $qm);
-    $tesq = get_post_meta($post->ID,"mep_xtra_$tesqn",true);
-    $stc = $stc+$opt_qty;
-    $res = $res + (int)$opt_rst_qty;
-    $res = (int)$res;
-    $llft = ($opt_qty - (int)$tesq);
-    $leftt = ($leftt+$llft);
-  }
-  $leftt = $leftt-$res;
-}else{
-  $leftt = $event_meta['mep_total_seat'][0]- $total_book;
-}
-
+  $leftt = $total_left;
   $days = $interval->d;
   $hours = $interval->h;
   $minutes = $interval->i;
@@ -168,7 +145,8 @@ if($reg_status!='off'){
 
0){ + +if($leftt>0){ ?> "/> @@ -176,12 +154,12 @@ if($reg_status!='off'){
- + - + - + +$total_quantity = isset($field['option_qty_t']) ? $field['option_qty_t'] : 0; +$total_resv_quantity = isset($field['option_rsv_t']) ? $field['option_rsv_t'] : 0; +$total_sold = (int) mep_ticket_type_sold(get_the_id(),$field['option_name_t']); +$total_left = (int) $total_quantity - ((int) $total_sold + (int) $total_resv_quantity); +?>
-
+
@@ -42,23 +38,22 @@ $qty_t_type = $field['option_qty_t_type']; 0){ -//echo $llft; +if($total_left>0){ if($qty_t_type=='dropdown'){ ?> - style='display: none!important;' class='extra-qty-box etp'> + - size="4" pattern="[0-9]*" inputmode="numeric" type="number" class='extra-qty-box etp' name='option_qty[]' data-price='' value='0' min="0" max=""> + size="4" pattern="[0-9]*" inputmode="numeric" type="number" class='extra-qty-box etp' name='option_qty[]' data-price='' value='0' min="0" max=""> -0){ ?> +0){ ?> '> '> diff --git a/templates/template-prts/total_seat.php b/templates/template-prts/total_seat.php index c55fd6e..5a97f45 100644 --- a/templates/template-prts/total_seat.php +++ b/templates/template-prts/total_seat.php @@ -1,56 +1,21 @@ ID, 'mep_event_ticket_type', true); - - -if(array_key_exists('mep_available_seat', $event_meta)){ - $mep_available_seat = $event_meta['mep_available_seat'][0]; -}else{ - $mep_available_seat = 'on'; -} - -if($mep_event_ticket_type){ -$stc = 0; -$leftt = 0; -$res = 0; -foreach ( $mep_event_ticket_type as $field ) { -$qm = $field['option_name_t']; - $opt_qty = isset($field['option_qty_t']) ? $field['option_qty_t'] : 0; -$opt_rst_qty = isset($field['option_rsv_t']) ? $field['option_rsv_t'] : 0; -$tesqn = $post->ID.str_replace(' ', '', $qm); -$tesq = get_post_meta($post->ID,"mep_xtra_$tesqn",true); -$stc = $stc+$opt_qty; -$res = $res + (int)$opt_rst_qty; -$res = (int)$res; -$llft = ($opt_qty - (int)$tesq); -$leftt = ($leftt+$llft); -} -$leftt = $leftt-$res; -?> -
( )
- -
( )
- +
( )
+ = $version ) { + return true; + }elseif ( is_plugin_active( 'woocommerce-event-manager-addon-form-builder/addon-builder.php' ) && $data['Version'] < $version ) { + return false; + }else{ + return true; + } + }else{ + return true; + } +} + + +function mep_get_all_tax_list($current_tax=null){ + global $wpdb; + $table_name = $wpdb->prefix . 'wc_tax_rate_classes'; + $result = $wpdb->get_results( "SELECT * FROM $table_name" ); + + foreach ( $result as $tax ){ + ?> + + 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' ) ); } @@ -129,8 +159,6 @@ function mep_woocommerce_data_stores ( $stores ) { return $stores; } - - } else { add_action('admin_notices', 'wc_not_loaded'); @@ -206,37 +234,172 @@ global $wpdb; foreach( $results as $result ) { $value = $result->meta_value; } - return $value; + $val = isset($value) ? $value : ''; + return $val; } +add_action('woocommerce_checkout_order_processed', 'mep_event_booking_management', 10); + +function mep_event_booking_management( $order_id) { +if(mep_check_builder_status()){ + +if ( ! $order_id ) + return; + +// Getting an instance of the order object +$order = wc_get_order( $order_id ); +$order_meta = get_post_meta($order_id); +$order_status = $order->get_status(); -add_action( 'woocommerce_thankyou','mep_set_first_order_sts'); -function mep_set_first_order_sts($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; - // Getting an instance of the order object - $order = wc_get_order( $order_id ); - $order_meta = get_post_meta($order_id); + $event_id = wc_get_order_item_meta($item_id,'event_id',true); - # 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; - } - - $product_id = mep_event_get_order_meta($item_id,'_product_id'); - - if($product_id==0){ - $event_id = mep_event_get_order_meta($item_id,'event_id'); - if (get_post_type($event_id) == 'mep_events') { - $mep_atnd = "_mep_atnd_".$order_id; - update_post_meta( $event_id, $mep_atnd, "a1"); + if (get_post_type($event_id) == 'mep_events') { + $event_name = get_the_title($event_id); + $user_info_arr = wc_get_order_item_meta($item_id,'_event_user_info',true); + $service_info_arr = wc_get_order_item_meta($item_id,'_event_service_info',true); + $event_ticket_info_arr = wc_get_order_item_meta($item_id,'_event_ticket_info',true); + + $item_quantity = 0; + + foreach ( $event_ticket_info_arr as $field ) { + if($field['ticket_qty']>0){ + $item_quantity = $item_quantity + $field['ticket_qty']; + } + } + + $first_name = isset($order_meta['_billing_first_name'][0]) ? $order_meta['_billing_first_name'][0] : ''; + $last_name = isset($order_meta['_billing_last_name'][0]) ? $order_meta['_billing_last_name'][0] : ''; + $company_name = isset($order_meta['_billing_company'][0]) ? $order_meta['_billing_company'][0] : ''; + $address_1 = isset($order_meta['_billing_address_1'][0]) ? $order_meta['_billing_address_1'][0] : ''; + $address_2 = isset($order_meta['_billing_address_2'][0]) ? $order_meta['_billing_address_2'][0] : ''; + $city = isset($order_meta['_billing_city'][0]) ? $order_meta['_billing_city'][0] : ''; + $state = isset($order_meta['_billing_state'][0]) ? $order_meta['_billing_state'][0] : ''; + $postcode = isset($order_meta['_billing_postcode'][0]) ? $order_meta['_billing_postcode'][0] : ''; + $country = isset($order_meta['_billing_country'][0]) ? $order_meta['_billing_country'][0] : ''; + $email = isset($order_meta['_billing_email'][0]) ? $order_meta['_billing_email'][0] : ''; + $phone = isset($order_meta['_billing_phone'][0]) ? $order_meta['_billing_phone'][0] : ''; + $billing_intotal = isset($order_meta['_billing_address_index'][0]) ? $order_meta['_billing_address_index'][0] : ''; + $payment_method = isset($order_meta['_payment_method_title'][0]) ? $order_meta['_payment_method_title'][0] : ''; + $user_id = isset($order_meta['_customer_user'][0]) ? $order_meta['_customer_user'][0] : ''; + + if(is_array($user_info_arr) & sizeof($user_info_arr) > 0){ + + foreach ($user_info_arr as $_user_info) { + $uname = $_user_info['user_name']; + $email = $_user_info['user_email']; + $phone = $_user_info['user_phone']; + $address = $_user_info['user_address']; + $gender = $_user_info['user_gender']; + $company = $_user_info['user_company']; + $designation = $_user_info['user_designation']; + $website = $_user_info['user_website']; + $vegetarian = $_user_info['user_vegetarian']; + $tshirtsize = $_user_info['user_tshirtsize']; + $ticket_type = $_user_info['user_ticket_type']; + $mep_ucf = isset($_user_info['mep_ucf']) ? $_user_info['mep_ucf'] : ""; + + // ADD THE FORM INPUT TO $new_post ARRAY + $new_post = array( + 'post_title' => $uname, + 'post_content' => '', + 'post_category' => array(), // Usable for custom taxonomies too + 'tags_input' => array(), + 'post_status' => 'publish', // Choose: publish, preview, future, draft, etc. + 'post_type' => 'mep_events_attendees' //'post',page' or use a custom post type if you want to + ); + + //SAVE THE POST + $pid = wp_insert_post($new_post); + $pin = $user_id.$order_id.$event_id.$pid; + update_post_meta( $pid, 'ea_name', $uname); + update_post_meta( $pid, 'ea_address_1', $address); + update_post_meta( $pid, 'ea_email', $email); + update_post_meta( $pid, 'ea_phone', $phone); + update_post_meta( $pid, 'ea_gender', $gender); + update_post_meta( $pid, 'ea_company', $company); + update_post_meta( $pid, 'ea_desg', $designation); + update_post_meta( $pid, 'ea_website', $website); + update_post_meta( $pid, 'ea_vegetarian', $vegetarian); + update_post_meta( $pid, 'ea_tshirtsize', $tshirtsize); + update_post_meta( $pid, 'ea_ticket_type', $ticket_type); + update_post_meta( $pid, 'ea_payment_method', $payment_method); + update_post_meta( $pid, 'ea_event_name', $event_name); + update_post_meta( $pid, 'ea_event_id', $event_id); + update_post_meta( $pid, 'ea_order_id', $order_id); + update_post_meta( $pid, 'ea_user_id', $user_id); + update_post_meta( $pid, 'ea_ticket_no', $pin); + update_post_meta( $pid, 'ea_order_status', $order_status); + + // Checking if the form builder addon is active and have any custom fields + $mep_form_builder_data = get_post_meta($event_id, 'mep_form_builder_data', true); + if ( $mep_form_builder_data ) { + foreach ( $mep_form_builder_data as $_field ) { + update_post_meta( $pid, "ea_".$_field['mep_fbc_id'], $_user_info[$_field['mep_fbc_id']]); } - } + } // End User Form builder data update loop + + } // End User Array Foreach Loop + + }else{ + + //for ($x = 1; $x <= count($event_ticket_info_arr); $x++) { + foreach($event_ticket_info_arr as $tinfo){ + $uname = $first_name.' '.$last_name; + + // ADD THE FORM INPUT TO $new_post ARRAY + +for ($x = 1; $x <= $tinfo['ticket_qty']; $x++) { + $new_post = array( + 'post_title' => $uname, + 'post_content' => '', + 'post_category' => array(), // Usable for custom taxonomies too + 'tags_input' => array(), + 'post_status' => 'publish', // Choose: publish, preview, future, draft, etc. + 'post_type' => 'mep_events_attendees' //'post',page' or use a custom post type if you want to + ); + + //SAVE THE POST + $pid = wp_insert_post($new_post); + $count = ($x -1); + $pin = $user_id.$order_id.$event_id.$pid; + $ticket_type = $tinfo['ticket_name']; + // $ticket_type = $event_ticket_info_arr[$count]['ticket_name']; + + update_post_meta( $pid, 'ea_name', $uname); + update_post_meta( $pid, 'ea_address_1', $address_1); + update_post_meta( $pid, 'ea_email', $email); + update_post_meta( $pid, 'ea_phone', $phone); + update_post_meta( $pid, 'ea_gender', ''); + update_post_meta( $pid, 'ea_company', $company_name); + update_post_meta( $pid, 'ea_desg', ''); + update_post_meta( $pid, 'ea_website', ''); + update_post_meta( $pid, 'ea_vegetarian', ''); + update_post_meta( $pid, 'ea_tshirtsize', ''); + update_post_meta( $pid, 'ea_ticket_type', $ticket_type); + update_post_meta( $pid, 'ea_payment_method', $payment_method); + update_post_meta( $pid, 'ea_event_name', $event_name); + update_post_meta( $pid, 'ea_event_id', $event_id); + update_post_meta( $pid, 'ea_order_id', $order_id); + update_post_meta( $pid, 'ea_user_id', $user_id); + update_post_meta( $pid, 'ea_ticket_no', $pin); + update_post_meta( $pid, 'ea_order_status', $order_status); + } + } + + } + } // end of check post type +} +do_action('mep_after_event_booking',$order_id,$order->get_status()); +} + } - - add_action('woocommerce_checkout_order_processed', 'mep_event_order_status_make_pending', 10, 1); @@ -257,6 +420,8 @@ $product_id = mep_event_get_order_meta($item_id,'_product_id'); if($product_id==0){ $event_id = mep_event_get_order_meta($item_id,'event_id'); if (get_post_type($event_id) == 'mep_events') { + $mep_atnd = "_mep_atnd_".$order_id; + update_post_meta( $event_id, $mep_atnd, "a1"); $order_meta_text = "_stock_msg_".$order_id; $order_processing = "pending_".$order_id; update_post_meta( $event_id, $order_meta_text, $order_processing); @@ -265,8 +430,110 @@ if($product_id==0){ } +function change_attandee_order_status($order_id,$set_status,$post_status,$qr_status=null){ + + $args = array ( + 'post_type' => array( 'mep_events_attendees' ), + 'posts_per_page' => -1, + 'post_status' => $post_status, + 'meta_query' => array( + array( + 'key' => 'ea_order_id', + 'value' => $order_id, + 'compare' => '=' + ) + ) + ); + $loop = new WP_Query($args); + $tid = array(); + foreach ($loop->posts as $ticket) { + $post_id = $ticket->ID; + if(!empty($qr_status)){ + update_post_meta($post_id, 'ea_order_status', $qr_status); + } + $current_post = get_post( $post_id, 'ARRAY_A' ); + $current_post['post_status'] = $set_status; + wp_update_post($current_post); + } +} + + + + + +add_action('wp_trash_post','mep_addendee_trash',90); +function mep_addendee_trash( $post_id ) { + $post_type = get_post_type( $post_id ); + $post_status = get_post_status( $post_id ); + if ( $post_type == 'shop_order' ) { + + change_attandee_order_status( $post_id, 'trash', 'publish', '' ); + } +} + + +add_action('untrash_post','mep_addendee_untrash',90); +function mep_addendee_untrash( $post_id ) { + $post_type = get_post_type( $post_id ); + $post_status = get_post_status( $post_id ); + if ( $post_type == 'shop_order' ) { + $order = wc_get_order( $post_id ); + $order_status = $order->get_status(); + change_attandee_order_status( $post_id, 'publish', 'trash', '' ); + } +} + + +add_action('woocommerce_order_status_changed', 'mep_attendee_status_update', 10, 4); +function mep_attendee_status_update($order_id, $from_status, $to_status, $order ){ + if(mep_check_builder_status()){ + global $wpdb,$wotm; + // Getting an instance of the order object + $order = wc_get_order( $order_id ); + $order_meta = get_post_meta($order_id); + $email = isset($order_meta['_billing_email'][0]) ? $order_meta['_billing_email'][0] : array(); + + + + foreach ( $order->get_items() as $item_id => $item_values ) { + $item_id = $item_id; + $event_id = mep_event_get_order_meta($item_id,'event_id'); + + if (get_post_type($event_id) == 'mep_events') { + + + if($order->has_status( 'processing' ) ) { + change_attandee_order_status($order_id,'publish','trash','processing'); + change_attandee_order_status($order_id,'publish','publish','processing'); + } + if($order->has_status( 'pending' )) { + change_attandee_order_status($order_id,'publish','trash','pending'); + change_attandee_order_status($order_id,'publish','publish','pending'); + } + if($order->has_status( 'on-hold' )) { + change_attandee_order_status($order_id,'publish','trash','on-hold'); + change_attandee_order_status($order_id,'publish','publish','on-hold'); + } + if($order->has_status( 'completed' ) ) { + mep_event_confirmation_email_sent($event_id,$email); + change_attandee_order_status($order_id,'publish','trash','completed'); + change_attandee_order_status($order_id,'publish','publish','completed'); + } + if($order->has_status( 'cancelled' ) ) { + change_attandee_order_status($order_id,'trash','publish','cancelled'); + } + if($order->has_status( 'refunded' ) ) { + change_attandee_order_status($order_id,'trash','publish','refunded'); + } + if($order->has_status( 'failed' ) ) { + change_attandee_order_status($order_id,'trash','publish','failed'); + } + } // End of Post Type Check + } // End order item foreach + } // End builder version check +} // End Function + -// add_action('woocommerce_order_status_changed', 'your_function', 10, 4); 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; @@ -379,17 +646,12 @@ if($order->has_status( 'cancelled' ) || $order->has_status( 'refunded' ) || $ord } - - - - - 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); + // mep_event_confirmation_email_sent($event_id,$email); if($ordr_total==0){ update_post_meta( $event_id, 'total_booking', ($mep_total_booking+$item_quantity)); } @@ -493,14 +755,6 @@ function mep_attendee_filter_query($query) { } - - - - - - - - // 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 ) { @@ -562,6 +816,7 @@ function mep_event_redirect_to_checkout() { } } + add_action('init','mep_include_template_parts'); function mep_include_template_parts(){ $template_name = 'templating.php'; @@ -666,12 +921,7 @@ function mep_add_to_google_calender_link($pid){ $event_end = $event_meta['mep_event_end_date'][0]; $location = $event_meta['mep_location_venue'][0]." ".$event_meta['mep_street'][0]." ".$event_meta['mep_city'][0]." ".$event_meta['mep_state'][0]." ".$event_meta['mep_postcode'][0]." ".$event_meta['mep_country'][0]; - - - ob_start(); - - - +ob_start(); ?>
@@ -1046,37 +1296,11 @@ $org_id = $org_arr[0]->term_id; 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); - $opt_qty = isset($field['option_qty_t']) ? $field['option_qty_t'] : 0; -$opt_rst_qty = isset($field['option_rsv_t']) ? $field['option_rsv_t'] : 0; -$stc = $stc+$opt_qty; -$res = $res + (int)$opt_rst_qty; -$res = (int)$res; -$llft = ($opt_qty - (int)$tesq); -$leftt = ($leftt+$llft); -} - $leftt = $leftt-$res; -}else{ - $leftt = (int) $event_meta['mep_total_seat'][0]- (int) $total_book; -} -return $leftt; +$total_seat = mep_event_total_seat($event_id,'total'); +$total_resv = mep_event_total_seat($event_id,'resv'); +$total_sold = mep_ticket_sold($event_id); +$total_left = $total_seat - ($total_sold + $total_resv); +return $total_left; } @@ -1155,7 +1379,6 @@ if($item_name=='mep_location_venue'){ return null; } - if($item_name=='mep_location_venue'){ if($location_sts){ $org_arr = get_the_terms( $event_id, 'mep_org' ); @@ -1398,48 +1621,13 @@ function mep_wc_price( $price, $args = array() ) { function mep_get_event_total_seat($event_id){ - $event_meta = get_post_custom($event_id); - $book_count = get_post_meta($event_id,'total_booking', true); - if($book_count){ $total_book = $book_count; }else{ $total_book = 0; } - if(array_key_exists('mep_rsv_seat', $event_meta)){ - $simple_rsv = $event_meta['mep_rsv_seat'][0]; - }else{ - $simple_rsv = ''; - } - if($simple_rsv){ - $simple_rsv = $simple_rsv; - }else{ - $simple_rsv = 0; - } - $total_book = ($total_book + $simple_rsv); - $mep_event_ticket_type = get_post_meta($event_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 = $event_id.str_replace(' ', '', $qm); - $tesq = get_post_meta($event_id,"mep_xtra_$tesqn",true); - $opt_qty = isset($field['option_qty_t']) ? $field['option_qty_t'] : 0; -$opt_rst_qty = isset($field['option_rsv_t']) ? $field['option_rsv_t'] : 0; - $stc = $stc+$opt_qty; - $res = $res + (int)$opt_rst_qty; - $res = (int)$res; - $llft = ($opt_qty - (int)$tesq); - $leftt = ($leftt+$llft); - } - $leftt = $leftt-$res; +$total_seat = mep_event_total_seat($event_id,'total'); +$total_resv = mep_event_total_seat($event_id,'resv'); +$total_sold = mep_ticket_sold($event_id); +$total_left = $total_seat - ($total_sold + $total_resv); ?> - / + / - / - have_posts()) { $loop->the_post(); - $post_id = get_the_id(); // change this to your post ID + $post_id = get_the_id(); $status = 'trash'; $current_post = get_post( $post_id, 'ARRAY_A' ); $current_post['post_status'] = $status; @@ -1520,6 +1708,96 @@ function mep_get_term_as_class($post_id,$taxonomy){ } +function mep_ticket_type_sold($event_id,$type){ + + $args = array( + 'post_type' => 'mep_events_attendees', + 'posts_per_page' => -1, + + 'meta_query' => array( + 'relation' => 'AND', + array( + 'relation' => 'AND', + array( + 'key' => 'ea_event_id', + 'value' => $event_id, + 'compare' => '=' + ), + array( + 'key' => 'ea_ticket_type', + 'value' => $type, + 'compare' => '=' + ) + ),array( + 'relation' => 'OR', + array( + 'key' => 'ea_order_status', + 'value' => 'processing', + 'compare' => '=' + ), + array( + 'key' => 'ea_order_status', + 'value' => 'completed', + 'compare' => '=' + ) + ) + ) + ); + $loop = new WP_Query($args); + return $loop->post_count; +} + + +function mep_ticket_sold($event_id){ + + $args = array( + 'post_type' => 'mep_events_attendees', + 'posts_per_page' => -1, + + 'meta_query' => array( + 'relation' => 'AND', + array( + 'relation' => 'AND', + array( + 'key' => 'ea_event_id', + 'value' => $event_id, + 'compare' => '=' + ) + ),array( + 'relation' => 'OR', + array( + 'key' => 'ea_order_status', + 'value' => 'processing', + 'compare' => '=' + ), + array( + 'key' => 'ea_order_status', + 'value' => 'completed', + 'compare' => '=' + ) + ) + ) + ); + $loop = new WP_Query($args); + return $loop->post_count; +} + + + +function mep_event_total_seat($event_id,$type){ + $mep_event_ticket_type = get_post_meta($event_id, 'mep_event_ticket_type', true); + // print_r($mep_event_ticket_type); + $total = 0; + foreach ( $mep_event_ticket_type as $field ) { + if($type == 'total'){ + $total_name = (int) $field['option_qty_t']; + }elseif($type == 'resv'){ + $total_name = (int) $field['option_rsv_t']; + } + $total = $total_name + $total; + } + return $total; +} }else{ function mep_admin_notice_wc_not_active() {