function sync_bookings($original_product_id, $product_id, $lang)
 {
     global $wpdb;
     $all_bookings_for_product = WC_Bookings_Controller::get_bookings_for_product($original_product_id, array('in-cart', 'unpaid', 'confirmed', 'paid'));
     foreach ($all_bookings_for_product as $booking) {
         $check_if_exists = $wpdb->get_row($wpdb->prepare("SELECT pm3.* FROM {$wpdb->postmeta} AS pm1\n                                            LEFT JOIN {$wpdb->postmeta} AS pm2 ON pm1.post_id = pm2.post_id\n                                            LEFT JOIN {$wpdb->postmeta} AS pm3 ON pm1.post_id = pm3.post_id\n                                            WHERE pm1.meta_key = '_booking_duplicate_of' AND pm1.meta_value = %s AND pm2.meta_key = '_language_code' AND pm2.meta_value = %s AND pm3.meta_key = '_booking_product_id'", $booking->id, $lang));
         if (is_null($check_if_exists)) {
             $this->duplicate_booking_for_translations($booking->id, $lang);
         } elseif ($check_if_exists->meta_value === '') {
             update_post_meta($check_if_exists->post_id, '_booking_product_id', $this->get_translated_booking_product_id($booking->id, $lang));
             update_post_meta($check_if_exists->post_id, '_booking_resource_id', $this->get_translated_booking_resource_id($booking->id, $lang));
             update_post_meta($check_if_exists->post_id, '_booking_persons', $this->get_translated_booking_persons_ids($booking->id, $lang));
         }
     }
 }
 /**
  * Provides an email notification form
  */
 public function notifications_page()
 {
     global $woocommerce;
     if (!empty($_POST) && check_admin_referer('send_booking_notification')) {
         $notification_product_id = absint($_POST['notification_product_id']);
         $notification_subject = wc_clean(stripslashes($_POST['notification_subject']));
         $notification_message = wp_kses_post(stripslashes($_POST['notification_message']));
         try {
             if (!$notification_product_id) {
                 throw new Exception(__('Please choose a product', 'woocommerce-bookings'));
             }
             if (!$notification_message) {
                 throw new Exception(__('Please enter a message', 'woocommerce-bookings'));
             }
             if (!$notification_subject) {
                 throw new Exception(__('Please enter a subject', 'woocommerce-bookings'));
             }
             $bookings = WC_Bookings_Controller::get_bookings_for_product($notification_product_id);
             $mailer = $woocommerce->mailer();
             $notification = $mailer->emails['WC_Email_Booking_Notification'];
             $attachments = array();
             foreach ($bookings as $booking) {
                 // Add .ics file
                 if (isset($_POST['notification_ics'])) {
                     $generate = new WC_Bookings_ICS_Exporter();
                     $attachments[] = $generate->get_booking_ics($booking);
                 }
                 $notification->trigger($booking->id, $notification_subject, $notification_message, $attachments);
             }
             echo '<div class="updated fade"><p>' . __('Notification sent successfully', 'woocommerce-bookings') . '</p></div>';
         } catch (Exception $e) {
             echo '<div class="error"><p>' . $e->getMessage() . '</p></div>';
         }
     }
     $booking_products = WC_Bookings_Admin::get_booking_products();
     include 'views/html-notifications-page.php';
 }