function update

This commit is contained in:
magepeopleteam 2021-01-26 06:04:24 +00:00
parent d6769b5f2d
commit b1dee3a551
3 changed files with 46 additions and 53 deletions

View File

@ -167,6 +167,17 @@ if (!class_exists('MAGE_Events_Setting_Controls')) :
'no' => 'No'
)
),
array(
'name' => 'mep_show_product_cat_in_event',
'label' => __('Show Product Category in Event?', 'mage-eventpress'),
'desc' => __('Want to show Product Category in Event Edit Page? If you want set product category based coupon code you need to assign event into Product category, Please set yes only when you need it', 'mage-eventpress'),
'type' => 'select',
'default' => 'no',
'options' => array(
'yes' => 'Yes',
'no' => 'No'
)
),
array(
'name' => 'mep_global_single_template',
'label' => __('Event Details Template', 'mage-eventpress'),

View File

@ -371,8 +371,6 @@ class MP_Event_All_Info_In_One
jQuery('#show_gmap').html('<iframe id="gmap_canvas" src="https://maps.google.com/maps?q=' + location + '&t=&z=19&ie=UTF8&iwloc=&output=embed" frameborder="0" scrolling="no" marginheight="0" marginwidth="0"></iframe>')
}
})
jQuery('[name="mep_location_venue"]').keypress(function() {
let location = jQuery(this).val();
if (location === '') {
@ -1044,7 +1042,6 @@ function mep_events_ticket_type_save($post_id)
$new[$i]['option_qty_t'] = stripslashes(strip_tags($qty[$i]));
endif;
if ($rsv[$i] != '') :
$new[$i]['option_rsv_t'] = stripslashes(strip_tags($rsv[$i]));
endif;
@ -1065,7 +1062,6 @@ function mep_events_ticket_type_save($post_id)
$ticket_type_list = apply_filters('mep_ticket_type_arr_save', $new);
if (!empty($ticket_type_list) && $ticket_type_list != $old) {
update_post_meta($post_id, 'mep_event_ticket_type', $ticket_type_list);
} elseif (empty($ticket_type_list) && $old) {
@ -1107,7 +1103,6 @@ function mep_events_repeatable_meta_box_save($post_id)
$count = count($names);
for ($i = 0; $i < $count; $i++) {
if ($names[$i] != '') :
$new[$i]['option_name'] = stripslashes(strip_tags($names[$i]));
endif;
@ -1154,7 +1149,6 @@ function mep_event_meta_save($post_id)
return;
}
/**
* If the saving post is event then go on
*/

View File

@ -2235,7 +2235,7 @@ if (!function_exists('mep_get_event_upcomming_date')) {
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,
@ -2256,6 +2256,7 @@ if (!function_exists('mep_on_post_publish')) {
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 );
}
}
@ -2301,6 +2302,7 @@ if (!function_exists('mep_on_post_publish')) {
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) );
@ -2318,8 +2320,9 @@ if (!function_exists('mep_on_post_publish')) {
$update__tax_class = update_post_meta( $product_id, '_virtual', $product_type);
$update__tax_class = update_post_meta( $product_id, '_sold_individually', 'yes');
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,
@ -3508,29 +3511,14 @@ function mep_fb_get_reg_form_id($event_id){
return $event_reg_form_id;
}
// function mep_get_event_upcomming_date($event_id){
// $date = [];
// $event_start_datetime = get_post_meta($event_id,'event_start_datetime',true);
// $event_end_datetime = get_post_meta($event_id,'event_end_datetime',true);
// $event_multidate = get_post_meta($event_id,'mep_event_more_date',true);
// $event_std[] = array(
// 'event_std' => $event_start_datetime,
// 'event_etd' => $event_end_datetime
// );
// $a = 1;
// foreach($event_multidate as $event_mdt){
// $event_std[$a]['event_std'] = $event_mdt['event_more_start_date'].' '.$event_mdt['event_more_start_time'];
// $event_std[$a]['event_etd'] = $event_mdt['event_more_end_date'].' '.$event_mdt['event_more_end_time'];
// $a++;
// }
// $cn = 0;
// foreach($event_std as $_event_std){
// $std = $_event_std['event_std'];
// $start_date = date('Y-m-d H:i:s',strtotime($_event_std['event_std']));
// $end_date = date('Y-m-d',strtotime($_event_std['event_etd']));
// if (strtotime(current_time('Y-m-d H:i')) < strtotime($std) && $cn == 0) {
// $date = $start_date;
// $cn++;
// }
// }
// }
add_action( 'init', 'mep_show_product_cat_in_event' );
function mep_show_product_cat_in_event() {
$pro_cat_status = mep_get_option( 'mep_show_product_cat_in_event', 'general_setting_sec', 'no');
if($pro_cat_status == 'yes'){
register_taxonomy_for_object_type( 'product_cat', 'mep_events' );
}else{
return null;
}
}