wc block issue
This commit is contained in:
parent
ea0a6c5db5
commit
608de5e4ee
|
@ -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);
|
||||
if (!function_exists('mep_event_booking_management')) {
|
||||
function mep_event_booking_management( $order_id) {
|
||||
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) {
|
||||
|
||||
|
||||
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'){
|
||||
$result = !is_numeric($order_id) ? json_decode($order_id) : [0];
|
||||
// $order_id = json_last_error() === JSON_ERROR_NONE ? $result->id : $order_id;
|
||||
$order_id = !is_numeric($order_id) ? $result->id : $order_id;
|
||||
|
||||
if ( ! $order_id )
|
||||
{return;}
|
||||
|
||||
|
||||
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);
|
||||
|
||||
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) {
|
||||
// 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($check_before_create < count($user_info_arr)){
|
||||
mep_attendee_create('user_form',$order_id,$event_id,$_user_info);
|
||||
}
|
||||
if($order_status != 'failed'){
|
||||
|
||||
}
|
||||
}else{
|
||||
foreach($event_ticket_info_arr as $tinfo){
|
||||
for ($x = 1; $x <= $tinfo['ticket_qty']; $x++) {
|
||||
$form_position = mep_get_option( 'mep_user_form_position', 'general_attendee_sec', 'details_page' );
|
||||
|
||||
if($check_before_create < count($event_ticket_info_arr)){
|
||||
mep_attendee_create('billing',$order_id,$event_id,$tinfo);
|
||||
}
|
||||
if($form_position=='checkout_page'){
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}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
|
||||
}
|
||||
foreach ( $order->get_items() as $item_id => $item_values ) {
|
||||
$item_id = $item_id;
|
||||
}
|
||||
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){
|
||||
|
||||
|
|
Loading…
Reference in New Issue