prepare( " SELECT ID FROM $wpdb->posts WHERE post_name = %s AND post_type IN ($post_type_in_string) ", $page_slug ); } else { $sql = $wpdb->prepare( " SELECT ID FROM $wpdb->posts WHERE post_name = %s AND post_type = %s ", $page_slug, $post_type ); } $page = $wpdb->get_var( $sql ); if ( $page ) return get_post( $page, $output ); return null; } function mep_add_event_into_feed_request($qv) { if (isset($qv['feed']) && !isset($qv['post_type'])) $qv['post_type'] = array('mep_events'); return $qv; } add_filter('request', 'mep_add_event_into_feed_request'); if (!function_exists('mepfix_sitemap_exclude_post_type')) { function mepfix_sitemap_exclude_post_type() { return ['auto-draft']; } } if (!function_exists('mep_get_builder_version')) { function mep_get_builder_version() { return '3.8.1'; } } if (!function_exists('mep_check_builder_status')) { function mep_check_builder_status() { $version = '3.2'; return true; } } if (!function_exists('mep_get_all_tax_list')) { 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')); } $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, 'product_id' => $post_object->ID, 'sku' => $post_object->ID, '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. * * @param int $product_id * * @return bool|string * @since 3.0.0 */ 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; } } } } } } add_action('woocommerce_before_checkout_form', 'mep_displays_cart_products_feature_image'); if (!function_exists('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']; } } } if (!function_exists('mep_get_attendee_info_query')) { function mep_get_attendee_info_query($event_id, $order_id) { $_user_set_status = mep_get_option('seat_reserved_order_status', 'general_setting_sec', array('processing','completed')); $_order_status = !empty($_user_set_status) ? $_user_set_status : array('processing','completed'); $order_status = array_values($_order_status); $order_status_filter = array( 'key' => 'ea_order_status', 'value' => $order_status, 'compare' => 'OR' ); $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_order_id', 'value' => $order_id, 'compare' => '=' ) ), $order_status_filter ) ); $loop = new WP_Query($args); return $loop; } } if (!function_exists('mep_email_dynamic_content')) { function mep_email_dynamic_content($email_body, $event_id, $order_id, $__attendee_id = 0) { $event_name = get_the_title($event_id); $attendee_q = mep_get_attendee_info_query($event_id, $order_id); foreach ($attendee_q->posts as $_attendee_q) { $_attendee_id = $_attendee_q->ID; } $attendee_id = $__attendee_id > 0 ? $__attendee_id : $_attendee_id; $attendee_name = get_post_meta($attendee_id, 'ea_name', true) ? get_post_meta($attendee_id, 'ea_name', true) : ''; $email = get_post_meta($attendee_id, 'ea_email', true) ? get_post_meta($attendee_id, 'ea_email', true) : ''; $date_time = get_post_meta($attendee_id, 'ea_event_date', true) ? get_mep_datetime(get_post_meta($attendee_id, 'ea_event_date', true), 'date-time-text') : ''; $date = get_post_meta($attendee_id, 'ea_event_date', true) ? get_mep_datetime(get_post_meta($attendee_id, 'ea_event_date', true), 'date-text') : ''; $time = get_post_meta($attendee_id, 'ea_event_date', true) ? get_mep_datetime(get_post_meta($attendee_id, 'ea_event_date', true), 'time') : ''; $ticket_type = get_post_meta($attendee_id, 'ea_ticket_type', true) ? get_post_meta($attendee_id, 'ea_ticket_type', true) : ''; $email_body = str_replace("{name}", $attendee_name, $email_body); $email_body = str_replace("{email}", $email, $email_body); $email_body = str_replace("{event}", $event_name, $email_body); $email_body = str_replace("{event_date}", $date, $email_body); $email_body = str_replace("{event_time}", $time, $email_body); $email_body = str_replace("{event_datetime}", $date_time, $email_body); $email_body = str_replace("{ticket_type}", $ticket_type, $email_body); return $email_body; } } // Send Confirmation email to customer if (!function_exists('mep_event_confirmation_email_sent')) { function mep_event_confirmation_email_sent($event_id, $sent_email, $order_id, $attendee_id=0) { $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) { $email_body = mep_email_dynamic_content($email_body, $event_id, $order_id, $attendee_id); $confirmation_email_text = apply_filters('mep_event_confirmation_text', $email_body, $event_id, $order_id); wp_mail($sent_email, $email_sub, nl2br($confirmation_email_text), $headers); } } } if (!function_exists('mep_event_get_order_meta')) { function mep_event_get_order_meta($item_id, $key) { global $wpdb; $table_name = $wpdb->prefix . "woocommerce_order_itemmeta"; $results = $wpdb->get_results($wpdb->prepare("SELECT * FROM $table_name WHERE order_item_id = %d AND meta_key = %s", $item_id, $key)); foreach ($results as $result) { $value = $result->meta_value; } $val = isset($value) ? $value : ''; return $val; } } if (!function_exists('mep_event_get_event_city_list')) { function mep_event_get_event_city_list() { global $wpdb; $table_name = $wpdb->prefix . "postmeta"; $sql = "SELECT meta_value FROM $table_name WHERE meta_key ='mep_city' GROUP BY meta_value"; $results = $wpdb->get_results($sql); //or die(mysql_error()); ob_start(); ?>
post_name) { return $page; } } } return false; } } if (!function_exists('mep_page_create')) { function mep_page_create() { if (!mep_get_page_by_slug('event-by-city-name')) { $mep_search_page = array( 'post_type' => 'page', 'post_name' => 'event-by-city-name', 'post_title' => 'Event By City', 'post_content' => '', 'post_status' => 'publish', ); wp_insert_post($mep_search_page); } } } if (!function_exists('mep_city_filter_rewrite_rule')) { function mep_city_filter_rewrite_rule() { add_rewrite_rule( '^event-by-city-name/(.+)/?$', 'index.php?cityname=$matches[1]&pagename=event-by-city-name', 'top' ); } } add_action('init', 'mep_city_filter_rewrite_rule'); if (!function_exists('mep_city_filter_query_var')) { function mep_city_filter_query_var($vars) { $vars[] = 'cityname'; return $vars; } } add_filter('query_vars', 'mep_city_filter_query_var'); if (!function_exists('mep_city_template_chooser')) { function mep_city_template_chooser($template) { if (get_query_var('cityname')) { $template = mep_template_file_path('page-city-filter.php'); } return $template; } } add_filter('template_include', 'mep_city_template_chooser'); if (!function_exists('mep_get_event_ticket_price_by_name')) { function mep_get_event_ticket_price_by_name($event, $type) { $ticket_type = get_post_meta($event, 'mep_event_ticket_type', true); if (sizeof($ticket_type) > 0) { foreach ($ticket_type as $key => $val) { if ($val['option_name_t'] === $type) { return $val['option_price_t']; } } return 0; } } } add_filter( 'archive_template', 'mep_load_default_event_archive_template'); if (!function_exists('mep_load_default_event_archive_template')) { function mep_load_default_event_archive_template($template){ if ( is_post_type_archive ( 'mep_events' ) ) { $template = mep_template_file_path('event-archive.php'); } return $template; } } if (!function_exists('mep_get_ticket_price_by_event')) { function mep_get_ticket_price_by_event($event, $type, $default_price = 0) { $ticket_type = get_post_meta($event, 'mep_event_ticket_type', true); if ($ticket_type) { $all_ticket_tyle = get_post_meta($event, 'mep_event_ticket_type', true); foreach ($all_ticket_tyle as $key => $val) { if ($val['option_name_t'] === $type) { return (int)$val['option_price_t']; } } } else { return $default_price; } } } if (!function_exists('mep_attendee_create')) { function mep_attendee_create($type, $order_id, $event_id, $_user_info = array()) { // 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(); $billing_intotal = isset($order_meta['_billing_address_index'][0]) ? sanitize_text_field($order_meta['_billing_address_index'][0]) : ''; $payment_method = isset($order_meta['_payment_method_title'][0]) ? sanitize_text_field($order_meta['_payment_method_title'][0]) : ''; $user_id = isset($order_meta['_customer_user'][0]) ? sanitize_text_field($order_meta['_customer_user'][0]) : ''; $first_name = isset($order_meta['_billing_first_name'][0]) ? sanitize_text_field($order_meta['_billing_first_name'][0]) : ''; $last_name = isset($order_meta['_billing_last_name'][0]) ? sanitize_text_field($order_meta['_billing_last_name'][0]) : ''; $billing_full_name = $first_name . ' ' . $last_name; if ($type == 'billing') { // Billing Information $company = isset($order_meta['_billing_company'][0]) ? sanitize_text_field($order_meta['_billing_company'][0]) : ''; $address_1 = isset($order_meta['_billing_address_1'][0]) ? sanitize_text_field($order_meta['_billing_address_1'][0]) : ''; $address_2 = isset($order_meta['_billing_address_2'][0]) ? sanitize_text_field($order_meta['_billing_address_2'][0]) : ''; $address = $address_1 . ' ' . $address_2; $gender = ''; $designation = ''; $website = ''; $vegetarian = ''; $tshirtsize = ''; $city = isset($order_meta['_billing_city'][0]) ? sanitize_text_field($order_meta['_billing_city'][0]) : ''; $state = isset($order_meta['_billing_state'][0]) ? sanitize_text_field($order_meta['_billing_state'][0]) : ''; $postcode = isset($order_meta['_billing_postcode'][0]) ? sanitize_text_field($order_meta['_billing_postcode'][0]) : ''; $country = isset($order_meta['_billing_country'][0]) ? sanitize_text_field($order_meta['_billing_country'][0]) : ''; $email = isset($order_meta['_billing_email'][0]) ? sanitize_text_field($order_meta['_billing_email'][0]) : ''; $phone = isset($order_meta['_billing_phone'][0]) ? sanitize_text_field($order_meta['_billing_phone'][0]) : ''; $ticket_type = stripslashes(sanitize_text_field($_user_info['ticket_name'])); $event_date = sanitize_text_field($_user_info['event_date']); $ticket_qty = sanitize_text_field($_user_info['ticket_qty']); } elseif ($type == 'user_form') { $_uname = array_key_exists('user_name',$_user_info) ? sanitize_text_field($_user_info['user_name']) : ""; $email = array_key_exists('user_email',$_user_info) ? sanitize_text_field($_user_info['user_email']) : ""; $phone = array_key_exists('user_phone',$_user_info) ? sanitize_text_field($_user_info['user_phone']) : ""; $address = array_key_exists('user_address',$_user_info) ? sanitize_text_field($_user_info['user_address']) : ""; $gender = array_key_exists('user_gender',$_user_info) ? sanitize_text_field($_user_info['user_gender']) : ""; $company = array_key_exists('user_company',$_user_info) ? sanitize_text_field($_user_info['user_company']) : ""; $designation = array_key_exists('user_designation',$_user_info) ? sanitize_text_field($_user_info['user_designation']) : ""; $website = array_key_exists('user_website',$_user_info) ? sanitize_text_field($_user_info['user_website']) : ""; $vegetarian = array_key_exists('user_vegetarian',$_user_info) ? sanitize_text_field($_user_info['user_vegetarian']) : ""; $tshirtsize = array_key_exists('user_tshirtsize',$_user_info) ? sanitize_text_field($_user_info['user_tshirtsize']) : ""; $ticket_type = array_key_exists('user_ticket_type',$_user_info) ? stripslashes($_user_info['user_ticket_type']) : ""; $ticket_qty = array_key_exists('user_ticket_qty',$_user_info) ? sanitize_text_field($_user_info['user_ticket_qty']) : ""; $event_date = array_key_exists('user_event_date',$_user_info) ? sanitize_text_field($_user_info['user_event_date']) : ""; $event_id = $_user_info['user_event_id'] ? sanitize_text_field($_user_info['user_event_id']) : $event_id; $mep_ucf = isset($_user_info['mep_ucf']) ? sanitize_text_field($_user_info['mep_ucf']) : ""; } $ticket_total_price = (int) (mep_get_event_ticket_price_by_name($event_id, $ticket_type) * (int) $ticket_qty); $uname = isset($_uname) && !empty($_uname) ? $_uname : $billing_full_name; $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_ticket_qty', $ticket_qty); update_post_meta($pid, 'ea_ticket_price', mep_get_ticket_price_by_event($event_id, $ticket_type, 0)); update_post_meta($pid, 'ea_ticket_order_amount', $ticket_total_price); update_post_meta($order_id, 'ea_ticket_qty', $ticket_qty); update_post_meta($order_id, 'ea_ticket_type', $ticket_type); update_post_meta($order_id, 'ea_event_id', $event_id); update_post_meta($pid, 'ea_payment_method', $payment_method); update_post_meta($pid, 'ea_event_name', get_the_title($event_id)); 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, 'mep_checkin', 'No'); update_post_meta($order_id, 'ea_user_id', $user_id); update_post_meta($order_id, 'order_type_name', 'mep_events'); update_post_meta($pid, 'ea_ticket_no', $pin); update_post_meta($pid, 'ea_event_date', $event_date); // update_post_meta($pid, 'ea_order_status', $order_status); update_post_meta($pid, 'ea_flag', 'checkout_processed'); update_post_meta($order_id, 'ea_order_status', $order_status); $hooking_data = apply_filters('mep_event_attendee_dynamic_data', array(), $pid, $type, $order_id, $event_id, $_user_info); if (is_array($hooking_data) && sizeof($hooking_data) > 0) { foreach ($hooking_data as $_data) { update_post_meta($pid, $_data['name'], $_data['value']); } } // Checking if the form builder addon is active and have any custom fields $reg_form_id = mep_fb_get_reg_form_id($event_id); $mep_form_builder_data = get_post_meta($reg_form_id, 'mep_form_builder_data', true) ? get_post_meta($reg_form_id, 'mep_form_builder_data', true) : []; if (sizeof($mep_form_builder_data) > 0) { foreach ($mep_form_builder_data as $_field) { update_post_meta($pid, "ea_" . $_field['mep_fbc_id'], $_user_info[$_field['mep_fbc_id']]); do_action('mep_attendee_upload_file_save',$event_id,$_user_info,$_field); } } // End User Form builder data update loop } } if (!function_exists('mep_attendee_extra_service_create')) { function mep_attendee_extra_service_create($order_id, $event_id, $_event_extra_service) { $order = wc_get_order($order_id); $order_meta = get_post_meta($order_id); $order_status = $order->get_status(); if (is_array($_event_extra_service) && sizeof($_event_extra_service) > 0) { foreach ($_event_extra_service as $extra_serive) { if ($extra_serive['service_name']) { $uname = 'Extra Service for ' . get_the_title($event_id) . ' Order #' . $order_id; $new_post = array( 'post_title' => $uname, 'post_content' => '', 'post_category' => array(), 'tags_input' => array(), 'post_status' => 'publish', 'post_type' => 'mep_extra_service' ); $pid = wp_insert_post($new_post); update_post_meta($pid, 'ea_extra_service_name', $extra_serive['service_name']); update_post_meta($pid, 'ea_extra_service_qty', $extra_serive['service_qty']); update_post_meta($pid, 'ea_extra_service_unit_price', $extra_serive['service_price']); update_post_meta($pid, 'ea_extra_service_total_price', $extra_serive['service_qty'] * (float) $extra_serive['service_price']); update_post_meta($pid, 'ea_extra_service_event', $event_id); update_post_meta($pid, 'ea_extra_service_order', $order_id); update_post_meta($pid, 'ea_extra_service_order_status', $order_status); update_post_meta($pid, 'ea_extra_service_event_date', $extra_serive['event_date']); } } } } } if (!function_exists('mep_check_attendee_exist_before_create')) { function mep_check_attendee_exist_before_create($order_id, $event_id, $date ='') { $date_filter = !empty($date) ? array( 'key' => 'ea_event_date', 'value' => $date, 'compare' => 'LIKE' ) : ''; $pending_status_filter = array( 'key' => 'ea_order_status', 'value' => 'pending', 'compare' => '=' ); $hold_status_filter = array( 'key' => 'ea_order_status', 'value' => 'on-hold', 'compare' => '=' ); $processing_status_filter = array( 'key' => 'ea_order_status', 'value' => 'processing', 'compare' => '=' ); $completed_status_filter = array( 'key' => 'ea_order_status', 'value' => 'completed', 'compare' => '=' ); $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_order_id', 'value' => $order_id, 'compare' => '=' ), $date_filter ), array( 'relation' => 'OR', $pending_status_filter, $hold_status_filter, $processing_status_filter, $completed_status_filter ) ) ); $loop = new WP_Query($args); return $loop->post_count; } } // add_filter('mep_check_product_into_cart', 'mep_beta_disable_add_to_cart_if_product_is_in_cart', 90, 2); function mep_beta_disable_add_to_cart_if_product_is_in_cart($is_purchasable, $product){ $all_multiple_cart = mep_get_option('mep_allow_multiple_add_cart_event', 'general_setting_sec', 'no'); if($all_multiple_cart == 'yes'){ return true; } } add_action('woocommerce_checkout_order_processed', 'mep_event_booking_management', 90); add_action('__experimental_woocommerce_blocks_checkout_order_processed', 'mep_event_booking_management', 90); // add_action('woocommerce_blocks_checkout_order_processed', 'mep_event_booking_management', 90); if (!function_exists('mep_event_booking_management')) { function mep_event_booking_management( $order_id) { global $woocommerce; $result = !is_numeric($order_id) ? json_decode($order_id) : [0]; $order_id = !is_numeric($order_id) ? $result->id : $order_id; 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(); if($order_status != 'failed'){ $form_position = mep_get_option( 'mep_user_form_position', 'general_attendee_sec', 'details_page' ); if($form_position=='checkout_page'){ foreach ( $order->get_items() as $item_id => $item_values ) { $item_id = $item_id; } $event_id = wc_get_order_item_meta($item_id,'event_id',true); 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; $check_before_create = mep_check_attendee_exist_before_create($order_id,$event_id); mep_delete_attandee_of_an_order($order_id, $event_id); foreach ( $event_ticket_info_arr as $field ) { if($field['ticket_qty']>0){ $item_quantity = $item_quantity + $field['ticket_qty']; } } if(is_array($user_info_arr) & sizeof($user_info_arr) > 0){ foreach ($user_info_arr as $_user_info) { // if($check_before_create < count($user_info_arr)){ mep_attendee_create('user_form',$order_id,$event_id,$_user_info); // } } }else{ foreach($event_ticket_info_arr as $tinfo){ for ($x = 1; $x <= $tinfo['ticket_qty']; $x++) { // if($check_before_create < count($event_ticket_info_arr)){ mep_attendee_create('billing',$order_id,$event_id,$tinfo); // } } } } } }else{ foreach ( $order->get_items() as $item_id => $item_values ) { $item_id = $item_id; $event_id = wc_get_order_item_meta($item_id,'event_id',true); 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); $_event_extra_service = wc_get_order_item_meta($item_id,'_event_extra_service',true); $item_quantity = 0; $check_before_create = mep_check_attendee_exist_before_create($order_id,$event_id); mep_attendee_extra_service_create($order_id,$event_id,$_event_extra_service); mep_delete_attandee_of_an_order($order_id, $event_id); foreach ( $event_ticket_info_arr as $field ) { if($field['ticket_qty']>0){ $item_quantity = $item_quantity + $field['ticket_qty']; } } if(is_array($user_info_arr) & sizeof($user_info_arr) > 0){ foreach ($user_info_arr as $_user_info) { $check_before_create_date = mep_check_attendee_exist_before_create($order_id,$event_id, $_user_info['user_event_date']); if(function_exists('mep_re_language_load')){ mep_attendee_create('user_form',$order_id,$event_id,$_user_info); }else{ if($check_before_create < count($user_info_arr)){ if($check_before_create_date == 0){ mep_attendee_create('user_form',$order_id,$event_id,$_user_info); } } } } }else{ foreach($event_ticket_info_arr as $tinfo){ for ($x = 1; $x <= $tinfo['ticket_qty']; $x++) { $check_before_create_date = mep_check_attendee_exist_before_create($order_id,$event_id, $tinfo['event_date']); if(function_exists('mep_re_language_load')){ mep_attendee_create('billing',$order_id,$event_id,$tinfo); }else{ if($check_before_create < count($event_ticket_info_arr)){ if($check_before_create_date == 0){ mep_attendee_create('billing',$order_id,$event_id,$tinfo); } } } } } } $enable_clear_cart = mep_get_option('mep_clear_cart_after_checkout', 'general_setting_sec','enable'); if($enable_clear_cart == 'enable'){ // PayplugWoocommerce if ( ! class_exists( 'Payplug\PayplugWoocommerce' ) ) { if(!class_exists('WC_Xendit_CC')){ if(!class_exists( 'PaysonCheckout_For_WooCommerce' )){ if(!class_exists( 'RP_SUB' )){ if(!class_exists( 'Afterpay_Plugin' )){ if(!class_exists( 'WC_Subscriptions' )){ if ( !is_plugin_active( 'woo-juno/main.php' )){ if ( ! class_exists( 'WC_Saferpay' ) ) { // mep_clear_cart_after_checkout $woocommerce->cart->empty_cart(); } } } } } } } } } } // end of check post type } } do_action('mep_after_event_booking',$order_id,$order->get_status()); } } } if (!function_exists('mep_diff_two_datetime')) { function mep_diff_two_datetime($d1,$d2){ $timeFirst = strtotime($d1); $timeSecond = strtotime($d2); return $differenceInSeconds = $timeSecond - $timeFirst; } } if (!function_exists('mep_delete_attandee_of_an_order')) { function mep_delete_attandee_of_an_order($order_id, $event_id) { $args = array( 'post_type' => array('mep_events_attendees'), 'posts_per_page' => -1, 'meta_query' => array( array( 'key' => 'ea_order_id', 'value' => $order_id, 'compare' => '=' ), array( 'key' => 'ea_event_id', 'value' => $event_id, 'compare' => '=' ), array( 'key' => 'ea_flag', 'value' => 'checkout_processed', 'compare' => '=' ) ) ); $loop = new WP_Query($args); foreach ($loop->posts as $ticket) { $post_id = $ticket->ID; $post_date = get_the_date('Y-m-d H:i:s',$post_id); $time_diff = mep_diff_two_datetime($post_date,current_time('Y-m-d H:i:s')); if($time_diff > 15){ wp_delete_post($post_id, true); } } } } if (!function_exists('change_attandee_order_status')) { function change_attandee_order_status($order_id, $set_status, $post_status, $qr_status = null) { add_filter('wpseo_public_post_statuses', 'mepfix_sitemap_exclude_post_type', 5); $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; update_post_meta($post_id, 'ea_order_status', $qr_status); update_post_meta($post_id, 'ea_flag', $qr_status); $current_post = get_post($post_id, 'ARRAY_A'); $current_post['post_status'] = $set_status; wp_update_post($current_post); } } } if (!function_exists('change_extra_service_status')) { function change_extra_service_status($order_id, $set_status, $post_status, $qr_status = null) { add_filter('wpseo_public_post_statuses', 'mepfix_sitemap_exclude_post_type', 5); $args = array( 'post_type' => array('mep_extra_service'), 'posts_per_page' => -1, 'post_status' => $post_status, 'meta_query' => array( array( 'key' => 'ea_extra_service_order', 'value' => $order_id, 'compare' => '=' ) ) ); $loop = new WP_Query($args); $tid = array(); foreach ($loop->posts as $ticket) { $post_id = $ticket->ID; update_post_meta($post_id, 'ea_extra_service_order_status', $qr_status); $current_post = get_post($post_id, 'ARRAY_A'); $current_post['post_status'] = $set_status; wp_update_post($current_post); } } } if (!function_exists('mep_change_wc_event_product_status')) { function mep_change_wc_event_product_status($order_id, $set_status, $post_status, $qr_status = null) { add_filter('wpseo_public_post_statuses', 'mepfix_sitemap_exclude_post_type', 5); $args = array( 'post_type' => array('product'), 'posts_per_page' => -1, 'post_status' => $post_status, 'meta_query' => array( array( 'key' => 'link_mep_event', '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); if (!function_exists('mep_addendee_trash')) { 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', ''); change_extra_service_status($post_id, 'trash', 'publish', ''); } if ($post_type == 'mep_events') { mep_change_wc_event_product_status($post_id, 'trash', 'publish', ''); } } } add_action('untrash_post', 'mep_addendee_untrash', 90); if (!function_exists('mep_addendee_untrash')) { 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', ''); change_extra_service_status($post_id, 'publish', 'trash', ''); } if ($post_type == 'mep_events') { mep_change_wc_event_product_status($post_id, 'publish', 'trash', ''); } } } add_action('woocommerce_order_status_changed', 'mep_attendee_status_update', 10, 4); if (!function_exists('mep_attendee_status_update')) { function mep_attendee_status_update($order_id, $from_status, $to_status, $order) { // 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(); $email_send_status = mep_get_option('mep_email_sending_order_status', 'email_setting_sec', array('disable_email' => 'disable_email')); $email_send_status = !empty($email_send_status) ? $email_send_status : array('disable_email' => 'disable_email'); $enable_billing_email = mep_get_option('mep_send_confirmation_to_billing_email', 'email_setting_sec','enable'); // mep_email_sending_order_status $order_status = $order->get_status(); $cn = 1; $event_arr = []; foreach ($order->get_items() as $item_id => $item_values) { $item_id = $item_id; $event_id = mep_event_get_order_meta($item_id, 'event_id'); $event_arr[] = $event_id; if (get_post_type($event_id) == 'mep_events') { $event_ticket_info_arr = wc_get_order_item_meta($item_id,'_event_ticket_info',true); $org = get_the_terms($event_id, 'mep_org'); $term_id = $org[0]->term_id; $org_email = get_term_meta( $term_id, 'org_email', true ) ? get_term_meta( $term_id, 'org_email', true ) : ''; if ($order->has_status('processing')) { change_attandee_order_status($order_id, 'publish', 'trash', 'processing'); change_attandee_order_status($order_id, 'publish', 'publish', 'processing'); change_extra_service_status($order_id, 'publish', 'trash', 'processing'); change_extra_service_status($order_id, 'publish', 'publish', 'processing'); do_action('mep_wc_order_status_change', $order_status, $event_id, $order_id); if($enable_billing_email == 'enable'){ if (in_array('processing', $email_send_status)) { mep_event_confirmation_email_sent($event_id, $email, $order_id); if(!empty($org_email)){ // mep_event_confirmation_email_sent($event_id, $org_email, $order_id); } } } } if ($order->has_status('pending')) { change_attandee_order_status($order_id, 'publish', 'trash', 'pending'); change_attandee_order_status($order_id, 'publish', 'publish', 'pending'); change_extra_service_status($order_id, 'publish', 'trash', 'pending'); change_extra_service_status($order_id, 'publish', 'publish', 'pending'); do_action('mep_wc_order_status_change', $order_status, $event_id, $order_id); } 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'); do_action('mep_wc_order_status_change', $order_status, $event_id, $order_id); } if ($order->has_status('completed')) { change_attandee_order_status($order_id, 'publish', 'trash', 'completed'); change_attandee_order_status($order_id, 'publish', 'publish', 'completed'); change_extra_service_status($order_id, 'publish', 'trash', 'completed'); change_extra_service_status($order_id, 'publish', 'publish', 'completed'); do_action('mep_wc_order_status_change', $order_status, $event_id, $order_id); if (in_array('completed', $email_send_status)) { mep_event_confirmation_email_sent($event_id, $email, $order_id); if(!empty($org_email)){ mep_event_confirmation_email_sent($event_id, $org_email, $order_id); } } } if ($order->has_status('cancelled')) { change_attandee_order_status($order_id, 'trash', 'publish', 'cancelled'); change_extra_service_status($order_id, 'trash', 'publish', 'cancelled'); do_action('mep_wc_order_status_change', $order_status, $event_id, $order_id); } if ($order->has_status('refunded')) { change_attandee_order_status($order_id, 'trash', 'publish', 'refunded'); change_extra_service_status($order_id, 'trash', 'publish', 'refunded'); do_action('mep_wc_order_status_change', $order_status, $event_id, $order_id); } if ($order->has_status('failed')) { change_attandee_order_status($order_id, 'trash', 'publish', 'failed'); change_extra_service_status($order_id, 'trash', 'publish', 'failed'); do_action('mep_wc_order_status_change', $order_status, $event_id, $order_id); } mep_update_event_seat_inventory($event_id,$event_ticket_info_arr); } // End of Post Type Check $cn++; } // End order item foreach do_action('mep_wc_order_status_change_single', $order_status, $event_id, $order_id,$cn,$event_arr); } // End Function } function mep_update_ticket_type_seat($event_id,$ticket_type_name,$event_date,$total_quantity,$total_resv_quantity){ $total_sold = (int) mep_ticket_type_sold($event_id, $ticket_type_name, $event_date); // $ticket_type_left = (int) $total_quantity - ((int) $total_sold + (int) $total_resv_quantity); $ticket_type_left = (int) $total_sold; $_date = date('YmdHi',strtotime($event_date)); $ticket_type_meta_name = $ticket_type_name.'_'.$_date; update_post_meta($event_id,$ticket_type_meta_name,$ticket_type_left); return get_post_meta($event_id,$ticket_type_meta_name,true); } function mep_update_event_total_seat($event_id,$date=''){ $seat_left = mep_get_count_total_available_seat($event_id); update_post_meta($event_id,'mep_total_seat_left',$seat_left); if(!empty($date)){ $_date = !empty($date) ? date('YmdHi',strtotime($date)) : 0; $event_name = $event_id.'_'.$_date; $seat_left_date = mep_get_count_total_available_seat($event_id, $date); update_post_meta($event_id,$event_name,$seat_left_date); } $date = !empty($date) ? date('YmdHi',strtotime($date)) : 0; $meta_name = $date > 0 ? $event_id.'_'.$date : 'mep_total_seat_left'; return get_post_meta($event_id,$meta_name,true); } function mep_update_total_seat_on_demand($event_id){ $upcoming_date = !empty(mep_get_event_upcoming_date($event_id)) ? mep_get_event_upcoming_date($event_id) : ''; mep_update_event_total_seat($event_id,$upcoming_date); } function mep_get_event_total_seat_left($event_id,$date=''){ $date = !empty($date) ? date('YmdHi',strtotime($date)) : 0; $meta_name = $date > 0 ? $event_id.'_'.$date : 'mep_total_seat_left'; $availabe_seat = !empty(get_post_meta($event_id,$meta_name,true)) ? get_post_meta($event_id,$meta_name,true) : mep_update_event_total_seat($event_id,$date); return $availabe_seat; } function mep_get_ticket_type_seat_count($event_id,$name,$date,$total,$reserved){ $_date = date('YmdHi',strtotime($date)); $ticket_type_meta_name = $name.'_'.$_date; $availabe_seat = !empty(get_post_meta($event_id,$ticket_type_meta_name,true)) ? get_post_meta($event_id,$ticket_type_meta_name,true) : mep_update_ticket_type_seat($event_id,$name,$date,$total,$reserved); // $availabe_seat = mep_update_ticket_type_seat($event_id,$name,$date,$total,$reserved); return $availabe_seat; } if (!function_exists('mep_get_count_total_available_seat')) { function mep_get_count_total_available_seat($event_id, $date='') { $total_seat = mep_event_total_seat($event_id, 'total'); $total_resv = mep_event_total_seat($event_id, 'resv'); $total_sold = mep_ticket_type_sold($event_id, '', $date); // $total_left = $total_seat - ($total_sold + $total_resv); $total_left = $total_sold; return esc_html($total_left); } } if (!function_exists('mep_reset_event_booking')) { function mep_reset_event_booking($event_id) { add_filter('wpseo_public_post_statuses', 'mepfix_sitemap_exclude_post_type', 5); $mep_event_ticket_type = get_post_meta($event_id, 'mep_event_ticket_type', true); $date = mep_get_event_upcoming_date($event_id); $args_search_qqq = array( 'post_type' => array('mep_events_attendees'), 'posts_per_page' => -1, 'post_status' => 'publish', 'meta_query' => array( array( 'key' => 'ea_event_id', 'value' => $event_id, 'compare' => '=' ) ) ); $loop = new WP_Query($args_search_qqq); while ($loop->have_posts()) { $loop->the_post(); $post_id = get_the_id(); $status = 'trash'; $current_post = get_post($post_id, 'ARRAY_A'); $current_post['post_status'] = $status; wp_update_post($current_post); } if ($mep_event_ticket_type) { foreach ($mep_event_ticket_type as $field) { $name = $field['option_name_t']; mep_update_ticket_type_seat($event_id,$name,$date,0,0); } } mep_update_event_total_seat($event_id,$date); } } function mep_update_event_seat_inventory($event_id,$ticket_array,$type='order'){ $seat_left = mep_get_count_total_available_seat($event_id); foreach($ticket_array as $ticket){ $name = $ticket['ticket_name']; $date = date('Y-m-d H:i',strtotime($ticket['event_date'])); $_date = date('YmdHi',strtotime($date)); $total_quantity = (int) mep_get_ticket_type_info_by_name($name, $event_id); $total_resv_quantity = (int) mep_get_ticket_type_info_by_name($name, $event_id,'option_rsv_t'); $total_sold_type = (int) mep_ticket_type_sold($event_id, $name, $date); $seat_left_date = mep_get_count_total_available_seat($event_id, $date); // $ticket_type_left = (int) $total_quantity - ((int) $total_sold_type + (int) $total_resv_quantity); $ticket_type_left = (int) $total_sold_type; $ticket_type_meta_name = $name.'_'.$_date; $event_name = $event_id.'_'.$_date; // Update Total Seat Count update_post_meta($event_id,'mep_total_seat_left',$seat_left); // Update Ticket Type Seat Count update_post_meta($event_id,$ticket_type_meta_name,$ticket_type_left); // Update Total Event By Date Seat Count update_post_meta($event_id,$event_name,$seat_left_date); // mep_update_ticket_type_seat($event_id,$name,$date,$total_quantity,$total_resv_quantity); } } function mep_get_ticket_type_info_by_name($name, $event_id, $type ='option_qty_t') { $ticket_type_arr = get_post_meta($event_id, 'mep_event_ticket_type', true) ? get_post_meta($event_id, 'mep_event_ticket_type', true) : []; $p = ''; foreach ($ticket_type_arr as $price) { $TicketName = str_replace("'", "", $price['option_name_t']); if ($TicketName === $name) { $p = $price[$type]; } } return $p; } add_action('restrict_manage_posts', 'mep_filter_post_type_by_taxonomy'); if (!function_exists('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]) ? mage_array_strip($_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'); if (!function_exists('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'); if (!function_exists('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']) && mage_array_strip($_GET['post_type']) == $post_type && isset($_GET['meta_value']) && mage_array_strip($_GET['meta_value']) != 0) { $q_vars['meta_key'] = 'ea_event_id'; $q_vars['meta_value'] = mage_array_strip($_GET['meta_value']); } elseif ($pagenow == 'edit.php' && isset($_GET['post_type']) && mage_array_strip($_GET['post_type']) == $post_type && isset($_GET['event_id']) && mage_array_strip($_GET['event_id']) != 0 && !isset($_GET['action'])) { $event_date = date('Y-m-d', strtotime(mage_array_strip($_GET['ea_event_date']))); $meta_query = array([ 'key' => 'ea_event_id', 'value' => mage_array_strip($_GET['event_id']), 'compare' => '=' ], [ 'key' => 'ea_event_date', 'value' => $event_date, 'compare' => 'LIKE' ], [ 'key' => 'ea_order_status', 'value' => 'completed', 'compare' => '=' ]); $query->set('meta_query', $meta_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); if (!function_exists('mep_custom_event_column')) { function mep_custom_event_column($column, $post_id) { mep_update_event_upcoming_date($post_id); $post_id = mep_get_default_lang_event_id($post_id); switch ($column) { case 'mep_status' : $values = get_post_custom($post_id); $recurring = get_post_meta($post_id, 'mep_enable_recurring', true) ? get_post_meta($post_id, 'mep_enable_recurring', true) : 'no'; if ($recurring == 'yes') { $event_more_dates = get_post_meta($post_id, 'mep_event_more_date', true) ? get_post_meta($post_id, 'mep_event_more_date', true) : []; $seat_left = 10; $md = end($event_more_dates); $more_date = $md['event_more_start_date'] . ' ' . $md['event_more_start_time']; $event_date = date('Y-m-d H:i:s', strtotime($more_date)); } else { $event_expire_on_old = mep_get_option('mep_event_expire_on_datetimes', 'general_setting_sec', 'event_start_datetime'); $event_expire_on = $event_expire_on_old == 'event_end_datetime' ? 'event_expire_datetime' : $event_expire_on_old; // $event_date = $values[$event_expire_on][0]; $event_date = !empty(get_post_meta($post_id,$event_expire_on,true)) ? get_post_meta($post_id,$event_expire_on,true) : ''; } echo mep_get_event_status($event_date); break; case 'mep_event_date' : echo "" . get_mep_datetime(get_post_meta($post_id, 'event_upcoming_datetime', true), 'date-time-text') . ""; break; } } } // Getting event exprie date & time if (!function_exists('mep_get_event_status')) { function mep_get_event_status($startdatetime) { $current = current_time('Y-m-d H:i:s'); $newformat = date('Y-m-d H:i:s', strtotime($startdatetime)); $datetime1 = new DateTime($newformat); $datetime2 = new DateTime($current); $interval = date_diff($datetime2, $datetime1); if (current_time('Y-m-d H:i:s') > $newformat) { return __("Expired","mage-eventpress"); } else { $days = $interval->days; $hours = $interval->h; $minutes = $interval->i; if ($days > 0) { $dd = $days . __(" days ","mage-eventpress"); } else { $dd = ""; } if ($hours > 0) { $hh = $hours . __(" hours ","mage-eventpress"); } else { $hh = ""; } if ($minutes > 0) { $mm = $minutes . __(" minutes ","mage-eventpress"); } else { $mm = ""; } return "".esc_html($dd)." ".esc_html($hh)." ".esc_html($mm).""; } } } if (!function_exists('mep_merge_saved_array')) { function mep_merge_saved_array($arr1, $arr2) { $output = []; for ($i = 0; $i < count($arr1); $i++) { $output[$i] = array_merge($arr1[$i], $arr2[$i]); } return $output; } } // Redirect to Checkout after successfuly event registration add_filter('woocommerce_add_to_cart_redirect', 'mep_event_redirect_to_checkout'); if (!function_exists('mep_event_redirect_to_checkout')) { function mep_event_redirect_to_checkout($wc_get_cart_url) { global $woocommerce; $redirect_status = mep_get_option('mep_event_direct_checkout', 'general_setting_sec', 'yes'); if ($redirect_status == 'yes') { $wc_get_cart_url = wc_get_checkout_url(); } return $wc_get_cart_url; } } add_action('init', 'mep_include_template_parts'); if (!function_exists('mep_include_template_parts')) { function mep_include_template_parts() { require_once(dirname(__DIR__) . "/inc/template-prts/templating.php"); } } if (!function_exists('mep_template_file_path')) { function mep_template_file_path($file_name) { $template_path = get_stylesheet_directory() . '/mage-events/'; $default_path = plugin_dir_path(__DIR__) . 'templates/'; $thedir = is_dir($template_path) ? $template_path : $default_path; $themedir = $thedir . $file_name; $the_file_path = locate_template(array('mage-events/' . $file_name)) ? $themedir : $default_path . $file_name; return $the_file_path; } } if (!function_exists('mep_template_part_file_path')) { function mep_template_part_file_path($file_name) { $the_file_path = plugin_dir_path(__DIR__) . 'inc/template-prts/' . $file_name; return $the_file_path; } } if (!function_exists('mep_load_events_templates')) { function mep_load_events_templates($template) { global $post; if ($post->post_type == "mep_events") { $template = mep_template_part_file_path('single-events.php'); return $template; } if ($post->post_type == "mep_event_speaker") { $template = mep_template_file_path('single-speaker.php'); return $template; } if ($post->post_type == "mep_events_attendees") { $template = mep_template_part_file_path('single-mep_events_attendees.php'); return $template; } return $template; } } add_filter('single_template', 'mep_load_events_templates'); add_filter('template_include', 'mep_organizer_set_template'); if (!function_exists('mep_organizer_set_template')) { function mep_organizer_set_template($template) { if (is_tax('mep_org')) { $template = mep_template_file_path('taxonomy-organozer.php'); } if (is_tax('mep_cat')) { $template = mep_template_file_path('taxonomy-category.php'); } return $template; } } if (!function_exists('mep_social_share')) { function mep_social_share() { $event_ss_fb_icon = mep_get_option('mep_event_ss_fb_icon', 'icon_setting_sec', 'fab fa-facebook-f'); $event_ss_twitter_icon = mep_get_option('mep_event_ss_twitter_icon', 'icon_setting_sec', 'fab fa-twitter'); ?> prefix . 'woocommerce_order_itemmeta'; $result = $wpdb->get_results($wpdb->prepare("SELECT * FROM $table_name WHERE order_item_id = %d", $id)); foreach ($result as $page) { if (strpos($page->meta_key, '_') !== 0) { echo mep_get_string_part($page->meta_key, $part) . ''; print_r($loop); echo ''; // // die(); return $loop->post_count; } } if (!function_exists('mep_extra_service_sold')) { function mep_extra_service_sold($event_id, $type, $date) { $type = !empty($type) ? html_entity_decode($type) : ''; $args = array( 'post_type' => 'mep_extra_service', 'posts_per_page' => -1, 'meta_query' => array( 'relation' => 'AND', array( 'relation' => 'AND', array( 'key' => 'ea_extra_service_event', 'value' => $event_id, 'compare' => '=' ), array( 'key' => 'ea_extra_service_name', 'value' => $type, 'compare' => '=' ), array( 'key' => 'ea_extra_service_event_date', 'value' => $date, 'compare' => 'LIKE' ) ), array( 'relation' => 'OR', array( 'key' => 'ea_extra_service_order_status', 'value' => 'processing', 'compare' => '=' ), array( 'key' => 'ea_extra_service_order_status', 'value' => 'completed', 'compare' => '=' ) ) ) ); $loop = new WP_Query($args); $count = 0; foreach ($loop->posts as $sold_service) { $pid = $sold_service->ID; $count = $count + get_post_meta($pid, 'ea_extra_service_qty', true); } return $count; } } if (!function_exists('mep_ticket_sold')) { function mep_ticket_sold($event_id) { $event_start_date = date('Y-m-d', strtotime(get_post_meta($event_id, 'event_start_date', true))); // $get_ticket_type_list = get_post_meta($event_id,'mep_event_ticket_type',true) ? get_post_meta($event_id,'mep_event_ticket_type',true) : array(); $get_ticket_type_list = metadata_exists('post', $event_id, 'mep_event_ticket_type') ? get_post_meta($event_id, 'mep_event_ticket_type', true) : array(); $recurring = get_post_meta($event_id, 'mep_enable_recurring', true) ? get_post_meta($event_id, 'mep_enable_recurring', true) : 'no'; $sold = 0; if (is_array($get_ticket_type_list) && sizeof($get_ticket_type_list) > 0) { foreach ($get_ticket_type_list as $ticket_type) { if(array_key_exists('option_name_t',$ticket_type)){ $sold = $sold + mep_ticket_type_sold($event_id, mep_remove_apostopie($ticket_type['option_name_t']), $event_start_date); } } } if ($recurring == 'yes') { // $mep_event_more_date = get_post_meta($event_id,'mep_event_more_date',true); $mep_event_more_date = metadata_exists('post', $event_id, 'mep_event_more_date') ? get_post_meta($event_id, 'mep_event_more_date', true) : array(); if (is_array($mep_event_more_date) && sizeof($mep_event_more_date) > 0) { foreach ($mep_event_more_date as $md) { if (is_array($get_ticket_type_list) && sizeof($get_ticket_type_list) > 0) { foreach ($get_ticket_type_list as $ticket_type) { if(array_key_exists('option_name_t',$ticket_type)){ $sold = $sold + mep_ticket_type_sold($event_id, mep_remove_apostopie($ticket_type['option_name_t']), $md['event_more_start_date']); } } } } } } return $sold; } } if (!function_exists('mep_event_total_seat')) { 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; if (is_array($mep_event_ticket_type) && sizeof($mep_event_ticket_type) > 0) { foreach ($mep_event_ticket_type as $field) { if ($type == 'total') { $total_name = array_key_exists('option_qty_t', $field) ? (int)$field['option_qty_t'] : 0; } elseif ($type == 'resv') { $total_name = array_key_exists('option_rsv_t', $field) ? (int)$field['option_rsv_t'] : 0; } $total = $total_name + $total; } } return $total; } } if (!function_exists('get_mep_datetime')) { function get_mep_datetime($date, $type) { $event_id = get_the_id() ? get_the_id() : 0; $date_format = mep_get_datetime_format($event_id,'date'); $date_format_timezone = mep_get_datetime_format($event_id,'date_timezone'); $time_format = mep_get_datetime_format($event_id,'time'); $time_format_timezone = mep_get_datetime_format($event_id,'time_timezone'); $wpdatesettings = $date_format . ' ' . $time_format_timezone; $timezone = wp_timezone_string(); $timestamp = strtotime($date . ' ' . $timezone); if ($type == 'date') { return esc_html(wp_date($date_format, $timestamp)); } if ($type == 'date-time') { return esc_html(wp_date($wpdatesettings, $timestamp)); } if ($type == 'date-text') { return esc_html(wp_date($date_format, $timestamp)); } if ($type == 'date-time-text') { return esc_html(wp_date($wpdatesettings, $timestamp, wp_timezone())); } if ($type == 'time') { return esc_html(wp_date($time_format_timezone, $timestamp, wp_timezone())); } if ($type == 'Hour') { return esc_html(wp_date('H', $timestamp, wp_timezone())); } if ($type == 'hour') { return esc_html(wp_date('h', $timestamp, wp_timezone())); } if ($type == 'minute') { return esc_html(wp_date('i', $timestamp, wp_timezone())); } if ($type == 'second') { return esc_html(wp_date('s', $timestamp, wp_timezone())); } if ($type == 'day') { return esc_html(wp_date('d', $timestamp)); } if ($type == 'Dday') { return esc_html(wp_date('D', $timestamp)); } if ($type == 'month') { return esc_html(wp_date('m', $timestamp)); } if ($type == 'month-name') { return esc_html(wp_date('M', $timestamp)); } if ($type == 'year') { return esc_html(wp_date('y', $timestamp)); } if ($type == 'year-full') { return esc_html(wp_date('Y', $timestamp)); } if ($type == 'timezone') { return esc_html(wp_date('T', $timestamp)); } return ''; } } if (!function_exists('mep_get_location')) { function mep_get_location($event_id, $type) { $location_sts = get_post_meta($event_id, 'mep_org_address', true) ? get_post_meta($event_id, 'mep_org_address', true) : ''; if ($location_sts) { $org_arr = get_the_terms($event_id, 'mep_org') ? get_the_terms($event_id, 'mep_org') : []; $org_id = sizeof($org_arr) > 0 ? $org_arr[0]->term_id : ''; $location = !empty($org_id) && get_term_meta($org_id, 'org_location', true) ? get_term_meta($org_id, 'org_location', true) : ''; $street = !empty($org_id) && get_term_meta($org_id, 'org_street', true) ? get_term_meta($org_id, 'org_street', true) : ''; $city = !empty($org_id) && get_term_meta($org_id, 'org_city', true) ? get_term_meta($org_id, 'org_city', true) : ''; $state = !empty($org_id) && get_term_meta($org_id, 'org_state', true) ? get_term_meta($org_id, 'org_state', true) : ''; $zip = !empty($org_id) && get_term_meta($org_id, 'org_postcode', true) ? get_term_meta($org_id, 'org_postcode', true) : ''; $country = !empty($org_id) && get_term_meta($org_id, 'org_country', true) ? get_term_meta($org_id, 'org_country', true) : ''; } else { $location = get_post_meta($event_id, 'mep_location_venue', true) ? get_post_meta($event_id, 'mep_location_venue', true) : ''; $street = get_post_meta($event_id, 'mep_street', true) ? get_post_meta($event_id, 'mep_street', true) : ''; $city = get_post_meta($event_id, 'mep_city', true) ? get_post_meta($event_id, 'mep_city', true) : ''; $state = get_post_meta($event_id, 'mep_state', true) ? get_post_meta($event_id, 'mep_state', true) : ''; $zip = get_post_meta($event_id, 'mep_postcode', true) ? get_post_meta($event_id, 'mep_postcode', true) : ''; $country = get_post_meta($event_id, 'mep_country', true) ? get_post_meta($event_id, 'mep_country', true) : ''; } $location_arr = [$location, $street, $city, $state, $zip, $country]; if ($type == 'full') { echo esc_html(implode(', ', array_filter($location_arr))); } if ($type == 'location') { echo esc_html($location); } if ($type == 'street') { echo esc_html($street); } if ($type == 'state') { echo esc_html($state); } if ($type == 'city') { echo esc_html($city); } if ($type == 'zip') { echo esc_html($zip); } if ($type == 'country') { echo esc_html($country); } } } if (!function_exists('mep_get_event_upcomming_date')) { function mep_get_event_upcomming_date($event_id, $type) { $recurring = get_post_meta($event_id, 'mep_enable_recurring', true) ? get_post_meta($event_id, 'mep_enable_recurring', true) : 'no'; $more_date = get_post_meta($event_id, 'mep_event_more_date', true) ? get_post_meta($event_id, 'mep_event_more_date', true) : array(); $start_datetime = get_post_meta($event_id, 'event_start_datetime', true); $start_date = date('Y-m-d H:i:s', strtotime(get_post_meta($event_id, 'event_start_datetime', true))); $end_date = get_post_meta($event_id, 'event_end_date', true); $end_datetime = get_post_meta($event_id, 'event_end_datetime', true); $show_multidate = mep_get_option('mep_date_list_in_event_listing', 'event_list_setting_sec', 'no'); // if (strtotime(current_time('Y-m-d H:i')) < strtotime($start_datetime)) { $all_datetime = array($start_date); if (sizeof($more_date) > 0) { foreach ($more_date as $mdate) { $all_datetime[] = date('Y-m-d H:i:s', strtotime($mdate['event_more_start_date'] . ' ' . $mdate['event_more_start_time'])); } } $adt = []; foreach ($all_datetime as $ald) { if (strtotime(current_time('Y-m-d H:i')) < strtotime($ald)) { $adt[] = $ald; } } if (sizeof($adt) > 0) { return get_mep_datetime($adt[0], $type); } } } if (!function_exists('mep_on_post_publish')) { function mep_on_post_publish($post_id, $post, $update) { if ($post->post_type == 'mep_events' && $post->post_status == 'publish' && empty(get_post_meta($post_id, 'check_if_run_once'))) { $product_cat_ids = wp_get_post_terms($post_id, 'product_cat', array('fields' => 'ids')); // ADD THE FORM INPUT TO $new_post ARRAY $new_post = array( 'post_title' => $post->post_title, 'post_content' => '', 'post_name' => uniqid(), 'post_category' => array(), // Usable for custom taxonomies too 'tags_input' => array(), 'post_status' => 'publish', // Choose: publish, preview, future, draft, etc. 'post_type' => 'product' //'post',page' or use a custom post type if you want to ); //SAVE THE POST $pid = wp_insert_post($new_post); $product_type = mep_get_option('mep_event_product_type', 'single_event_setting_sec', 'yes'); $_tax_status = 'none'; update_post_meta($pid, '_tax_status', $_tax_status); update_post_meta($post_id, '_tax_status', $_tax_status); update_post_meta($post_id, 'link_wc_product', $pid); update_post_meta($pid, 'link_mep_event', $post_id); update_post_meta($pid, '_price', 0.01); update_post_meta($pid, '_sold_individually', 'yes'); update_post_meta($pid, '_downloadable', $product_type); update_post_meta($pid, '_virtual', $product_type); $terms = array('exclude-from-catalog', 'exclude-from-search'); wp_set_object_terms($pid, $terms, 'product_visibility'); wp_set_post_terms($pid, $product_cat_ids, 'product_cat'); update_post_meta($post_id, 'check_if_run_once', true); } } } add_action('wp_insert_post', 'mep_on_post_publish', 10, 3); if (!function_exists('mep_count_hidden_wc_product')) { function mep_count_hidden_wc_product($event_id) { $args = array( 'post_type' => 'product', 'posts_per_page' => -1, 'meta_query' => array( array( 'key' => 'link_mep_event', 'value' => $event_id, 'compare' => '=' ) ) ); $loop = new WP_Query($args); print_r($loop->posts); return $loop->post_count; } } add_action('save_post', 'mep_wc_link_product_on_save', 99, 1); if (!function_exists('mep_wc_link_product_on_save')) { function mep_wc_link_product_on_save($post_id) { add_filter('wpseo_public_post_statuses', 'mepfix_sitemap_exclude_post_type', 5); if (get_post_type($post_id) == 'mep_events') { if (!isset($_POST['mep_event_reg_btn_nonce']) || !wp_verify_nonce($_POST['mep_event_reg_btn_nonce'], 'mep_event_reg_btn_nonce')) { return; } if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { return; } if (!current_user_can('edit_post', $post_id)) { return; } $event_name = get_the_title($post_id); if (mep_count_hidden_wc_product($post_id) == 0 || empty(get_post_meta($post_id, 'link_wc_product', true))) { mep_create_hidden_event_product($post_id, $event_name); } $product_cat_ids = wp_get_post_terms($post_id, 'product_cat', array('fields' => 'ids')); $product_id = get_post_meta($post_id, 'link_wc_product', true) ? get_post_meta($post_id, 'link_wc_product', true) : $post_id; set_post_thumbnail($product_id, get_post_thumbnail_id($post_id)); wp_publish_post($product_id); $product_type = mep_get_option('mep_event_product_type', 'single_event_setting_sec', 'yes'); $_tax_status = isset($_POST['_tax_status']) ? sanitize_text_field($_POST['_tax_status']) : 'none'; $_tax_class = isset($_POST['_tax_class']) ? sanitize_text_field($_POST['_tax_class']) : ''; $sku = isset($_POST['mep_event_sku']) ? sanitize_text_field($_POST['mep_event_sku']) : $product_id; update_post_meta($product_id, '_sku', $sku); update_post_meta($product_id, '_tax_status', $_tax_status); update_post_meta($product_id, '_tax_class', $_tax_class); update_post_meta($product_id, '_stock_status', 'instock'); update_post_meta($product_id, '_manage_stock', 'no'); update_post_meta($product_id, '_virtual', $product_type); update_post_meta($product_id, '_sold_individually', 'yes'); update_post_meta($product_id, '_downloadable', $product_type); wp_set_post_terms($product_id, $product_cat_ids, 'product_cat'); $terms = array('exclude-from-catalog', 'exclude-from-search'); wp_set_object_terms($product_id, $terms, 'product_visibility'); // Update post $my_post = array( 'ID' => $product_id, 'post_title' => $event_name, // new title 'post_name' => uniqid()// do your thing here ); // unhook this function so it doesn't loop infinitely remove_action('save_post', 'mep_wc_link_product_on_save'); // update the post, which calls save_post again wp_update_post($my_post); // re-hook this function add_action('save_post', 'mep_wc_link_product_on_save'); // Update the post into the database } } } add_action('admin_head', 'mep_hide_date_from_order_page'); if (!function_exists('mep_hide_date_from_order_page')) { function mep_hide_date_from_order_page() { $product_id = []; $hide_wc = mep_get_option('mep_show_hidden_wc_product', 'general_setting_sec', 'no'); $args = array( 'post_type' => 'mep_events', 'posts_per_page' => -1 ); $qr = new WP_Query($args); foreach ($qr->posts as $result) { $post_id = $result->ID; $product_id[] = get_post_meta($post_id, 'link_wc_product', true) ? '.woocommerce-admin-page .post-' . get_post_meta($post_id, 'link_wc_product', true) . '.type-product' : ''; } $product_id = array_filter($product_id); $parr = implode(', ', $product_id); if($hide_wc == 'no'){ echo ''; } } } add_action('init','mep_get_all_hidden_product_id_array'); function mep_get_all_hidden_product_id_array() { $product_id = []; $args = array( 'post_type' => 'mep_events', 'posts_per_page' => -1 ); $qr = new WP_Query($args); foreach ($qr->posts as $result) { $post_id = $result->ID; $product_id[] = get_post_meta($post_id, 'link_wc_product', true) ? get_post_meta($post_id, 'link_wc_product', true) : ''; } $product_id = array_filter($product_id); return $product_id; } add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', 'mep_get_all_hidden_product_id_array' ); // add_action('parse_query', 'mep_product_tags_sorting_query'); if (!function_exists('mep_product_tags_sorting_query')) { function mep_product_tags_sorting_query($query) { global $pagenow; $taxonomy = 'product_visibility'; $q_vars = &$query->query_vars; if ($pagenow == 'edit.php' && isset($q_vars['post_type']) && $q_vars['post_type'] == 'product') { $tax_query = array( [ 'taxonomy' => 'product_visibility', 'field' => 'slug', 'terms' => 'exclude-from-catalog', 'operator' => 'NOT IN', ], [ 'taxonomy' => 'product_cat', 'field' => 'slug', 'terms' => 'uncategorized ', 'operator' => 'NOT IN', ] ); $query->set('tax_query', $tax_query); } } } add_action('wp_head', 'mep_exclude_hidden_product_from_search_engine'); if (!function_exists('mep_exclude_hidden_product_from_search_engine')) { function mep_exclude_hidden_product_from_search_engine() { global $post; if (is_single() && is_product()) { $post_id = $post->ID; $visibility = get_the_terms($post_id, 'product_visibility') ? get_the_terms($post_id, 'product_visibility') : [0]; if (is_object($visibility[0])) { if ($visibility[0]->name == 'exclude-from-catalog') { $check_event_hidden = get_post_meta($post_id, 'link_mep_event', true) ? get_post_meta($post_id, 'link_mep_event', true) : 0; if ($check_event_hidden > 0) { echo ''; } } } } } } add_action('wp', 'mep_hide_hidden_product_from_single', 90); if (!function_exists('mep_hide_hidden_product_from_single')) { function mep_hide_hidden_product_from_single() { global $post, $wp_query; if (is_product()) { $post_id = $post->ID; $visibility = get_the_terms($post_id, 'product_visibility') ? get_the_terms($post_id, 'product_visibility') : [0]; if (is_object($visibility[0])) { if ($visibility[0]->name == 'exclude-from-catalog') { $check_event_hidden = get_post_meta($post_id, 'link_mep_event', true) ? get_post_meta($post_id, 'link_mep_event', true) : 0; if ($check_event_hidden > 0) { $wp_query->set_404(); status_header(404); get_template_part(404); exit(); } } } } } } if (!function_exists('get_event_list_js')) { function get_event_list_js($id, $event_meta, $currency_pos) { ob_start(); ?> &$value) { if (is_array($value)) { $value = mage_array_strip($value); } else { $value = sanitize_text_field(htmlentities(nl2br($value))); } } } return $array_or_string; } } if (!function_exists('mage_array_sanitize')) { function mage_array_sanitize($string, $allowed_tags = null) { if (is_array($string)) { foreach ($string as $k => $v) { $string[$k] = mage_array_sanitize($v, $allowed_tags); } return $string; } return sanitize_text_field($string, $allowed_tags); } } /** * The Giant SEO Plugin Yoast PRO doing some weird thing and that is its auto create a 301 redirect url when delete a post its causing our event some issue Thats why i disable those part for our event post type with the below filter hoook which is provide by Yoast. */ add_filter('wpseo_premium_post_redirect_slug_change', '__return_true'); add_filter('wpseo_premium_term_redirect_slug_change', '__return_true'); add_filter('wpseo_enable_notification_term_slug_change', '__return_false'); if (!function_exists('mep_event_get_the_content')) { function mep_event_get_the_content($post = 0) { $post = get_post($post); return (!empty(apply_filters('the_content', $post->post_content))); } } function mep_string_sanitize($s) { $str = str_replace(array('\'', '"'), '', $s); return $str; } /** * We added event id with every order for using in the attendee & seat inventory calculation, but this info was showing in the thank you page, so i decided to hide this, and here is the fucntion which will hide the event id from the thank you page. */ add_filter('woocommerce_order_item_get_formatted_meta_data', 'mep_hide_event_order_meta_in_emails'); if (!function_exists('mep_hide_event_order_meta_in_emails')) { function mep_hide_event_order_meta_in_emails($meta) { if (!is_admin()) { $criteria = array('key' => 'event_id'); $meta = wp_list_filter($meta, $criteria, 'NOT'); } return $meta; } } add_filter('woocommerce_order_item_get_formatted_meta_data', 'mep_hide_event_order_data_from_thankyou_and_email', 10, 1); if (!function_exists('mep_hide_event_order_data_from_thankyou_and_email')) { function mep_hide_event_order_data_from_thankyou_and_email($formatted_meta) { $hide_location_status = mep_get_option('mep_hide_location_from_order_page', 'general_setting_sec', 'no'); $hide_date_status = mep_get_option('mep_hide_date_from_order_page', 'general_setting_sec', 'no'); $location_text = mep_get_option('mep_location_text', 'label_setting_sec', esc_html__('Location', 'mage-eventpress')); $date_text = mep_get_option('mep_event_date_text', 'label_setting_sec', esc_html__('Date', 'mage-eventpress')); $hide_location = $hide_location_status == 'yes' ? array($location_text) : array(); $hide_date = $hide_date_status == 'yes' ? array($date_text) : array(); $default = array('event_id'); $default = array_merge($default, $hide_date); $hide_them = array_merge($default, $hide_location); $temp_metas = []; foreach ($formatted_meta as $key => $meta) { if (isset($meta->key) && !in_array($meta->key, $hide_them)) { $temp_metas[$key] = $meta; } } return $temp_metas; } } /** * This will create a new section Custom CSS into the Event Settings Page, I write this code here instead of the Admin Settings Class because of YOU! Yes who is reading this comment!! to get the clear idea how you can craete your own settings section and settings fields by using the filter hook from any where or your own plugin. Thanks For reading this comment. Cheers!! */ add_filter('mep_settings_sec_reg', 'mep_custom_css_settings_reg', 90); if (!function_exists('mep_custom_css_settings_reg')) { function mep_custom_css_settings_reg($default_sec) { $sections = array( array( 'id' => 'mep_settings_custom_css', 'title' => ''.__('Custom CSS', 'mage-eventpress') ), array( 'id' => 'mep_settings_licensing', 'title' => __('License', 'mage-eventpress') ) ); return array_merge($default_sec, $sections); } } add_filter('mep_settings_sec_fields', 'mep_custom_css_sectings_fields', 90); if (!function_exists('mep_custom_css_sectings_fields')) { function mep_custom_css_sectings_fields($default_fields) { $settings_fields = array( 'mep_settings_custom_css' => array( array( 'name' => 'mep_custom_css', 'label' => __('Custom CSS', 'mage-eventpress'), 'desc' => __('Please enter your custom CSS code below. Do not include the STYLE tag here.', 'mage-eventpress'), 'type' => 'textarea', ) ) ); return array_merge($default_fields, $settings_fields); } } if (!function_exists('mep_get_ticket_type_price_by_name')) { function mep_get_ticket_type_price_by_name($name, $event_id) { $ticket_type_arr = get_post_meta($event_id, 'mep_event_ticket_type', true) ? get_post_meta($event_id, 'mep_event_ticket_type', true) : []; $p = ''; foreach ($ticket_type_arr as $price) { $TicketName = str_replace("'", "", $price['option_name_t']); if ($TicketName === $name) { $p = $price['option_price_t']; } } return $p; } } if (!function_exists('mep_get_ticket_type_price_arr')) { function mep_get_ticket_type_price_arr($ticket_type, $event_id) { $price = []; foreach ($ticket_type as $ticket) { $price[] = mep_get_ticket_type_price_by_name(stripslashes($ticket), $event_id); } return $price; } } if (!function_exists('mep_get_ticket_name')) { function mep_get_ticket_name($name) { // if (function_exists('mep_sp_not_active_warning')) { // $ticket = explode('_', $name); // return $ticket[0]; // }else{ // return $name; // } $ticket = explode('_', $name); return $ticket[0]; } } if (!function_exists('mep_get_seat_name')) { function mep_get_seat_name($name) { $ticket = explode('_', $name); return $ticket[1]; } } if (!function_exists('mep_get_orginal_ticket_name')) { function mep_get_orginal_ticket_name($names) { $name = []; foreach ($names as $_names) { $name[] = mep_get_ticket_name($_names); } return $name; } } if (!function_exists('mep_cart_ticket_type')) { function mep_cart_ticket_type($type, $total_price, $product_id) { $mep_event_start_date = isset($_POST['mep_event_start_date']) ? mage_array_strip($_POST['mep_event_start_date']) : array(); $names = isset($_POST['option_name']) ? mage_array_strip($_POST['option_name']) : array(); $qty = isset($_POST['option_qty']) ? mage_array_strip($_POST['option_qty']) : array(); $max_qty = isset($_POST['max_qty']) ? mage_array_strip($_POST['max_qty']) : array(); $price = mep_get_ticket_type_price_arr(mep_get_orginal_ticket_name($names), $product_id); $count = count($names); $ticket_type_arr = []; $vald = 0; if (sizeof($names) > 0) { for ($i = 0; $i < $count; $i++) { if ($qty[$i] > 0) { $ticket_type_arr[$i]['ticket_name'] = !empty($names[$i]) ? stripslashes(strip_tags($names[$i])) : ''; $ticket_type_arr[$i]['ticket_price'] = !empty($price[$i]) ? stripslashes(strip_tags($price[$i])) : ''; $ticket_type_arr[$i]['ticket_qty'] = !empty($qty[$i]) ? stripslashes(strip_tags($qty[$i])) : ''; $ticket_type_arr[$i]['max_qty'] = !empty($max_qty[$i]) ? stripslashes(strip_tags($max_qty[$i])) : ''; $ticket_type_arr[$i]['event_date'] = !empty($mep_event_start_date[$i]) ? stripslashes(strip_tags($mep_event_start_date[$i])) : ''; $opttprice = ( (float) $price[$i] * (float) $qty[$i]); $total_price = ( (float) $total_price + (float) $opttprice); $validate[$i]['validation_ticket_qty'] = $vald + stripslashes(strip_tags($qty[$i])); $validate[$i]['event_id'] = stripslashes(strip_tags($product_id)); } } } if ($type == 'ticket_price') { return $total_price; } elseif ($type == 'validation_data') { return $validate; } else { return apply_filters('mep_cart_ticket_type_data_prepare', $ticket_type_arr, $type, $total_price, $product_id); } } } if (!function_exists('mep_get_event_extra_price_by_name')) { function mep_get_event_extra_price_by_name($name, $event_id) { $ticket_type_arr = get_post_meta($event_id, 'mep_events_extra_prices', true) ? get_post_meta($event_id, 'mep_events_extra_prices', true) : []; foreach ($ticket_type_arr as $price) { if ($price['option_name'] === $name) { $p = $price['option_price']; } } return $p; } } if (!function_exists('mep_get_extra_price_arr')) { function mep_get_extra_price_arr($ticket_type, $event_id) { $price = []; foreach ($ticket_type as $ticket) { $price[] = mep_get_event_extra_price_by_name($ticket, $event_id); } return $price; } } if (!function_exists('mep_cart_event_extra_service')) { function mep_cart_event_extra_service($type, $total_price, $product_id) { $mep_event_start_date_es = isset($_POST['mep_event_start_date_es']) ? mage_array_strip($_POST['mep_event_start_date_es']) : array(); $extra_service_name = isset($_POST['event_extra_service_name']) ? mage_array_strip($_POST['event_extra_service_name']) : array(); $extra_service_qty = isset($_POST['event_extra_service_qty']) ? mage_array_strip($_POST['event_extra_service_qty']) : array(); $extra_service_price = isset($_POST['event_extra_service_price']) ? mage_array_strip($_POST['event_extra_service_price']) : array(); $extra_service_price = mep_get_extra_price_arr($extra_service_name, $product_id); $event_extra = []; if ($extra_service_name) { for ($i = 0; $i < count($extra_service_name); $i++) { if ($extra_service_qty[$i] > 0) { $event_extra[$i]['service_name'] = !empty($extra_service_name[$i]) ? stripslashes(strip_tags($extra_service_name[$i])) : ''; $event_extra[$i]['service_price'] = !empty($extra_service_price[$i]) ? stripslashes(strip_tags($extra_service_price[$i])) : ''; $event_extra[$i]['service_qty'] = !empty($extra_service_qty[$i]) ? stripslashes(strip_tags($extra_service_qty[$i])) : ''; $event_extra[$i]['event_date'] = !empty($mep_event_start_date_es[$i]) ? stripslashes(strip_tags($mep_event_start_date_es[$i])) : ''; $extprice = ( (float) $extra_service_price[$i] * (float) $extra_service_qty[$i]); $total_price = ( (float) $total_price + (float) $extprice); } } } if ($type == 'ticket_price') { return $total_price; } else { return $event_extra; } } } if (!function_exists('mep_get_user_custom_field_ids')) { function mep_get_user_custom_field_ids($event_id) { $reg_form_id = mep_fb_get_reg_form_id($event_id); $mep_form_builder_data = get_post_meta($reg_form_id, 'mep_form_builder_data', true) ? get_post_meta($reg_form_id, 'mep_form_builder_data', true) : []; $form_id = []; // print_r($mep_form_builder_data); mep_fbc_label if (sizeof($mep_form_builder_data) > 0) { foreach ($mep_form_builder_data as $_field) { $form_id[$_field['mep_fbc_label']] = $_field['mep_fbc_id']; } } return $form_id; } } if (!function_exists('mep_get_reg_label')) { function mep_get_reg_label($_event_id, $name = '') { $custom_forms_id = mep_get_user_custom_field_ids($_event_id); $event_id = mep_fb_get_reg_form_id( $_event_id ); if ($name == 'Name') { return get_post_meta($event_id, 'mep_name_label', true) ? get_post_meta($event_id, 'mep_name_label', true) : esc_html__('Name', 'mage-eventpress'); } elseif ($name == 'Email') { return get_post_meta($event_id, 'mep_email_label', true) ? get_post_meta($event_id, 'mep_email_label', true) : esc_html__('Email', 'mage-eventpress'); } elseif ($name == 'Phone') { return get_post_meta($event_id, 'mep_phone_label', true) ? get_post_meta($event_id, 'mep_phone_label', true) : esc_html__('Phone', 'mage-eventpress'); } elseif ($name == 'Address') { return get_post_meta($event_id, 'mep_address_label', true) ? get_post_meta($event_id, 'mep_address_label', true) : esc_html__('Address', 'mage-eventpress'); } elseif ($name == 'T-Shirt Size') { return get_post_meta($event_id, 'mep_tshirt_label', true) ? get_post_meta($event_id, 'mep_tshirt_label', true) : esc_html__('T-Shirt Size', 'mage-eventpress'); } elseif ($name == 'Gender') { return get_post_meta($event_id, 'mep_gender_label', true) ? get_post_meta($event_id, 'mep_gender_label', true) : esc_html__('Gender', 'mage-eventpress'); } elseif ($name == 'Company') { return get_post_meta($event_id, 'mep_company_label', true) ? get_post_meta($event_id, 'mep_company_label', true) : esc_html__('Company', 'mage-eventpress'); } elseif ($name == 'Designation') { return get_post_meta($event_id, 'mep_desg_label', true) ? get_post_meta($event_id, 'mep_desg_label', true) : esc_html__('Designation', 'mage-eventpress'); } elseif ($name == 'Website') { return get_post_meta($event_id, 'mep_website_label', true) ? get_post_meta($event_id, 'mep_website_label', true) : esc_html__('Website', 'mage-eventpress'); } elseif ($name == 'Vegetarian') { return get_post_meta($event_id, 'mep_veg_label', true) ? get_post_meta($event_id, 'mep_veg_label', true) : esc_html__('Vegetarian', 'mage-eventpress'); } else { return null; } } } if (!function_exists('mep_cart_display_user_list')) { function mep_cart_display_user_list($user_info, $event_id) { $custom_forms_id = mep_get_user_custom_field_ids($event_id); $form_id = mep_fb_get_reg_form_id( $event_id ); ob_start(); $recurring = get_post_meta($event_id, 'mep_enable_recurring', true) ? get_post_meta($event_id, 'mep_enable_recurring', true) : 'no'; $time_status = get_post_meta($event_id, 'mep_disable_ticket_time', true) ? get_post_meta($event_id, 'mep_disable_ticket_time', true) : 'no'; foreach ($user_info as $userinf) { // array_key_exists( ?>
Add To Cart Form Shortcode','mage-eventpress'); ?>
[event-add-cart-section event=""]