From eaeb45859c0f74e75eef2531aef36bbd80abff8c Mon Sep 17 00:00:00 2001 From: magepeopleteam Date: Thu, 26 Nov 2020 04:53:40 +0000 Subject: [PATCH] file update --- inc/mep_extra_price.php | 20 +++++++-------- inc/mep_functions.php | 57 +++++++++++++++++++++++++++++++++++------ 2 files changed, 58 insertions(+), 19 deletions(-) diff --git a/inc/mep_extra_price.php b/inc/mep_extra_price.php index 4d6954b..d02f8d3 100644 --- a/inc/mep_extra_price.php +++ b/inc/mep_extra_price.php @@ -30,18 +30,16 @@ function mep_add_custom_fields_text_to_cart_item($cart_item_data, $product_id, $ $recurring_event_date = $recurring == 'yes' && isset($_POST['recurring_event_date']) ? $_POST['recurring_event_date'] : array(); $ticket_type_arr = mep_cart_ticket_type('ticket_type', $total_price,$product_id); $total_price = mep_cart_ticket_type('ticket_price', $total_price,$product_id); - $event_extra = mep_cart_event_extra_service('event_extra_service', $total_price); - $total_price = mep_cart_event_extra_service('ticket_price', $total_price); + $event_extra = mep_cart_event_extra_service('event_extra_service', $total_price,$product_id); + $total_price = mep_cart_event_extra_service('ticket_price', $total_price,$product_id); $user = $form_position == 'details_page' ? mep_save_attendee_info_into_cart($product_id) : array(); $validate = mep_cart_ticket_type('validation_data', $total_price,$product_id); - - -// echo '
';
-// // print_r($user);
-// print_r($ticket_type_arr);
-// echo '
'; -// die(); + // echo '
';
+    // // print_r($user);
+    // print_r($ticket_type_arr);
+    // echo '
'; + // die(); /** * Now Store the datas into Cart Session @@ -105,8 +103,8 @@ function mep_display_custom_fields_text_cart($item_data, $cart_item) $eid = array_key_exists('event_id', $cart_item) ? $cart_item['event_id'] : 0; //$cart_item['event_id']; if (get_post_type($eid) == 'mep_events') { -$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'); + $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'); $user_info = $cart_item['event_user_info']; $ticket_type_arr = $cart_item['event_ticket_info']; $event_extra_service = $cart_item['event_extra_service']; diff --git a/inc/mep_functions.php b/inc/mep_functions.php index 0937afc..a3c9b3e 100755 --- a/inc/mep_functions.php +++ b/inc/mep_functions.php @@ -2790,21 +2790,38 @@ function mep_apply_custom_css(){ } +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) : []; +foreach($ticket_type_arr as $price){ + if($price['option_name_t'] === $name){ + $p = $price['option_price_t']; + } +} +return $p; +} + + +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($ticket,$event_id); + } + return $price; +} + + + 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']) ? $_POST['mep_event_start_date'] : array(); $names = isset($_POST['option_name']) ? $_POST['option_name'] : array(); $qty = isset($_POST['option_qty']) ? $_POST['option_qty'] : array(); - $max_qty = isset($_POST['max_qty']) ? $_POST['max_qty'] : array(); - $price = isset($_POST['option_price']) ? $_POST['option_price'] : array(); + $max_qty = isset($_POST['max_qty']) ? $_POST['max_qty'] : array(); + $price = mep_get_ticket_type_price_arr($names,$product_id); $count = count( $names ); $ticket_type_arr = []; -// echo '
';
-// print_r($names);
-// // print_r($mep_event_start_date);
-// // print_r($qty);
-// echo '
'; + $vald = 0; if(sizeof($names) > 0){ for ( $i = 0; $i < $count; $i++ ) { @@ -2832,12 +2849,36 @@ function mep_cart_ticket_type($type,$total_price,$product_id){ } } + + + +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; +} + +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){ +function mep_cart_event_extra_service($type,$total_price,$product_id){ $mep_event_start_date_es = isset($_POST['mep_event_start_date_es']) ? $_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){