SHARE
TWEET

Get Multiple Bookings Checkout Form Fields

eventsmanager Feb 1st, 2019 (edited) 174 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  * Get multiple bookings checkout pages booking form fields using placeholder #_BOOKINGFORMCUSTOM{field_id}
  3.  */
  4. if ( is_admin() )add_filter('em_booking_output_placeholder','my_bookings_placeholder',1,3);
  5. function my_bookings_placeholder($replace, $EM_Booking, $full_result){
  6.     global $wpdb;
  7.    
  8.     $main_booking_id= $wpdb->get_var($wpdb->prepare('SELECT booking_main_id FROM '.EM_BOOKINGS_RELATIONSHIPS_TABLE.' WHERE booking_id=%d', $EM_Booking->booking_id));
  9.     $booking_meta   = $wpdb->get_var($wpdb->prepare('SELECT booking_meta FROM '.EM_BOOKINGS_TABLE.' WHERE booking_id=%d', $main_booking_id));
  10.     $booking_meta   = unserialize($booking_meta);
  11.  
  12.     $replace = '';
  13.  
  14.     foreach($booking_meta['booking'] as $key => $value){
  15.         if ( '#_BOOKINGFORMCUSTOM{'.$key.'}' == $full_result){
  16.                 $replace = $booking_meta['booking'][$key];
  17.                 break;
  18.         }
  19.     }
  20.    
  21.     foreach($booking_meta['registration'] as $key => $value){
  22.         if ( '#_BOOKINGFORMCUSTOM{'.$key.'}' == $full_result){
  23.                 $replace = $booking_meta['booking'][$key];
  24.                 break;
  25.         }
  26.     }
  27.    
  28.     return $replace;
  29. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top