/**
  * widget function.
  *
  * @see WP_Widget
  * @access public
  * @param array $args
  * @param array $instance
  * @return void
  */
 function widget($args, $instance)
 {
     if ($this->get_cached_widget($args)) {
         return;
     }
     global $job_manager, $post;
     extract($args);
     $wpjmp = WPJMP();
     remove_action('single_job_listing_end', array($wpjmp->products, 'listing_display_products'));
     ob_start();
     $wpjmp->products->listing_display_products();
     wp_reset_query();
     $content = ob_get_clean();
     echo $content;
     $this->cache_widget($args, $content);
 }
 /**
  * widget function.
  *
  * @see WP_Widget
  * @access public
  * @param array $args
  * @param array $instance
  * @return void
  */
 function widget($args, $instance)
 {
     if ($this->get_cached_widget($args)) {
         return;
     }
     extract($args);
     $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
     $icon = isset($instance['icon']) ? $instance['icon'] : null;
     if ($icon) {
         $before_title = sprintf($before_title, 'ion-' . $icon);
     }
     ob_start();
     global $post, $product;
     $products = get_post_meta($post->ID, '_products', true);
     if (!$products) {
         return;
     }
     if (count($products) > 1) {
         return;
     }
     $product = current($products);
     $product = get_product($product);
     if ('booking' != $product->product_type) {
         return;
     }
     $wpjmp = WPJMP();
     remove_action('single_job_listing_end', array($wpjmp->products, 'listing_display_products'));
     echo $before_widget;
     if ($title) {
         echo $before_title . $title . $after_title;
     }
     // Prepare form
     $booking_form = new WC_Booking_Form($product);
     // Get template
     woocommerce_get_template('single-product/add-to-cart/booking.php', array('booking_form' => $booking_form), 'woocommerce-bookings', WC_BOOKINGS_TEMPLATE_PATH);
     echo $after_widget;
     $content = ob_get_clean();
     echo apply_filters($this->widget_id, $content);
     $this->cache_widget($args, $content);
 }
 /**
  * widget function.
  *
  * @see WP_Widget
  * @access public
  * @param array $args
  * @param array $instance
  * @return void
  */
 function widget($args, $instance)
 {
     if ($this->get_cached_widget($args)) {
         return;
     }
     extract($args);
     $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
     $icon = isset($instance['icon']) ? $instance['icon'] : null;
     if ($icon) {
         $before_title = sprintf($before_title, 'ion-' . $icon);
     }
     ob_start();
     global $post, $product, $listify_woocommerce_bookings;
     $products = $listify_woocommerce_bookings->get_bookable_products($post->ID);
     if (!$products) {
         return;
     }
     $wpjmp = WPJMP();
     remove_action('single_job_listing_end', array($wpjmp->products, 'listing_display_products'));
     echo $before_widget;
     if ($title) {
         echo $before_title . $title . $after_title;
     }
     do_action('listify_widget_job_listing_bookings_before');
     foreach ($products as $product) {
         // Prepare form
         $booking_form = new WC_Booking_Form($product);
         echo '<h3 class="booking-form-title">' . $product->post->post_title . ':</h3>';
         // Get template
         woocommerce_get_template('single-product/add-to-cart/booking.php', array('booking_form' => $booking_form), 'woocommerce-bookings', WC_BOOKINGS_TEMPLATE_PATH);
     }
     do_action('listify_widget_job_listing_bookings_after');
     echo $after_widget;
     $content = ob_get_clean();
     echo apply_filters($this->widget_id, $content);
     $this->cache_widget($args, $content);
 }
 public function setup_actions()
 {
     add_action('widgets_init', array($this, 'widgets_init'));
     $wpjmp = WPJMP();
     remove_action('single_job_listing_end', array($wpjmp->products, 'listing_display_products'));
 }