wc block issue

This commit is contained in:
magepeopleteam 2021-10-05 11:30:59 +00:00
parent ea0a6c5db5
commit 608de5e4ee
1 changed files with 95 additions and 93 deletions

View File

@ -625,109 +625,111 @@ function mep_check_attendee_exist_before_create($order_id,$event_id){
} }
add_action('woocommerce_checkout_order_processed', 'mep_event_booking_management', 10); add_action('woocommerce_checkout_order_processed', 'mep_event_booking_management', 90);
if (!function_exists('mep_event_booking_management')) { add_action('__experimental_woocommerce_blocks_checkout_order_processed', 'mep_event_booking_management', 90);
function mep_event_booking_management( $order_id) { // 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) {
$result = !is_numeric($order_id) ? json_decode($order_id) : [0];
if ( ! $order_id ) // $order_id = json_last_error() === JSON_ERROR_NONE ? $result->id : $order_id;
{return;} $order_id = !is_numeric($order_id) ? $result->id : $order_id;
// 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'){
if ( ! $order_id )
{return;}
// Getting an instance of the order object
foreach ( $order->get_items() as $item_id => $item_values ) { $order = wc_get_order( $order_id );
$item_id = $item_id; $order_meta = get_post_meta($order_id);
} $order_status = $order->get_status();
$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);
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)){ if($order_status != 'failed'){
mep_attendee_create('user_form',$order_id,$event_id,$_user_info);
}
} $form_position = mep_get_option( 'mep_user_form_position', 'general_attendee_sec', 'details_page' );
}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)){ if($form_position=='checkout_page'){
mep_attendee_create('billing',$order_id,$event_id,$tinfo);
}
} foreach ( $order->get_items() as $item_id => $item_values ) {
} $item_id = $item_id;
}
}
}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);
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);
}
}
}
}
} // end of check post type
}
} }
do_action('mep_after_event_booking',$order_id,$order->get_status()); $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);
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);
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);
}
}
}
}
} // end of check post type
} }
} }
do_action('mep_after_event_booking',$order_id,$order->get_status());
}
}
}
function mep_delete_attandee_of_an_order($order_id,$event_id){ function mep_delete_attandee_of_an_order($order_id,$event_id){