0){ foreach($mep_event_ticket_type as $_type){ // echo $_type['option_name_t']; $cart_arr = $new[$cnt]; // print_r($cart_arr); $name_key = array_search($_type['option_name_t'],$cart_arr); $qty_key = array_search($_type['option_qty_t'],$cart_arr); if(is_array($name_key)){ $total_found = count($name_key); }else{ $total_found = 0; } if($cart_arr['option_qty'] > 0){ $ticket_type_arr[$cnt]['ticket_name'] = stripslashes( strip_tags( $cart_arr[$name_key] ) ); $ticket_type_arr[$cnt]['ticket_qty'] = stripslashes( strip_tags( $cart_arr['option_qty'] ) ); $ticket_type_arr[$cnt]['ticket_price'] = stripslashes( strip_tags( $cart_arr['option_price'] ) ); $ticket_type_arr[$cnt]['event_date'] = stripslashes( strip_tags( $mep_event_start_date ) ); } $cnt++; } } $mep_events_extra_prices = get_post_meta($product_id, 'mep_events_extra_prices', true) ? get_post_meta($product_id, 'mep_events_extra_prices', true) : array(); $us = 0; foreach($mep_events_extra_prices as $extra_service){ foreach ($new as $key => $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_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_cart_location'] = $event_cart_location; $cart_item_data['event_cart_date'] = $mep_event_start_date; // $cart_item_data['event_cart_date'] = $event_cart_date; } $cart_item_data['event_id'] = $product_id; return $cart_item_data; } add_filter( 'woocommerce_add_cart_item_data', 'mep_add_custom_fields_text_to_cart_item', 90, 3); add_action( 'woocommerce_before_calculate_totals', 'add_custom_price',90,1 ); function add_custom_price( $cart_object ) { foreach ( $cart_object->cart_contents as $key => $value ) { $eid = $value['event_id']; if (get_post_type($eid) == 'mep_events') { $cp = $value['event_tp']; $value['data']->set_price($cp); $value['data']->set_regular_price($cp); $value['data']->set_sale_price($cp); $value['data']->set_sold_individually('yes'); $new_price = $value['data']->get_price(); } } } function mep_display_custom_fields_text_cart( $item_data, $cart_item ) { $mep_events_extra_prices = $cart_item['event_extra_option']; // print_r($cart_item); $eid = $cart_item['event_id']; if (get_post_type($eid) == 'mep_events') { $user_info = $cart_item['event_user_info']; $ticket_type_arr = $cart_item['event_ticket_info']; // echo '
'; // print_r($user_info); echo "