esc_html__('This Widget show product category On Tab', 'buzstores') ) ); } /** * Helper function that holds widget fields * Array is used in update and form functions */ private function widget_fields() { $bs_woo_pro_categories = array(); $bs_woo_pro_categories_obj = get_categories(array( 'taxonomy' => 'product_cat', 'orderby' => 'name', 'pad_counts' => 0, 'show_count' => 0,'title_li' => '','hierarchical' => 1,'hide_empty' => 1)); foreach ($bs_woo_pro_categories_obj as $bs_woo_pro_category) { $bs_woo_pro_categories[$bs_woo_pro_category->term_id] = $bs_woo_pro_category->name; } $fields = array( 'tab_title' => array( 'buzstores_widgets_name' => 'tab_title', 'buzstores_widgets_title' => esc_html__('Section Title', 'buzstores'), 'buzstores_widgets_field_type' => 'text', ), 'tab_product_category' => array( 'buzstores_widgets_name' => 'tab_product_category', 'buzstores_widgets_title' => esc_html__('Select Products Categorys', 'buzstores'), 'buzstores_widgets_field_type' => 'multicheckboxes', 'buzstores_widgets_field_options' => $bs_woo_pro_categories ), ); return $fields; } /** * Front-end display of widget. * * @see WP_Widget::widget() * * @param array $args Widget arguments. * @param array $instance Saved values from database. */ public function widget($args, $instance) { extract($args); $title_widget = apply_filters( 'widget_title', empty( $instance['tab_title'] ) ? '' : $instance['tab_title'], $instance, $this->id_base ); $product_categories = isset( $instance['tab_product_category'] ) ? $instance['tab_product_category'] : '' ; echo $before_widget; ?>
$tab_product_category){ $term_count_get = get_term_by( 'id', $term_id, 'product_cat'); ?> name); ?>
$tab_product_category){ ?>
'product', 'tax_query' => array(array('taxonomy' => 'product_cat', 'field' => 'term_id', 'terms' => $term_id )), 'posts_per_page' => '6' ) ); if($product_query->have_posts()): ?>
    have_posts()){ $product_query->the_post(); global $product; wc_get_template_part( 'content', 'product' ); } ?>
widget_fields(); foreach ($widget_fields as $widget_field) { extract($widget_field); $instance[$buzstores_widgets_name] = buzstores_widgets_updated_field_value($widget_field, $new_instance[$buzstores_widgets_name]); } return $instance; } public function form($instance) { $widget_fields = $this->widget_fields(); foreach ($widget_fields as $widget_field) { extract($widget_field); $buzstores_widgets_field_value = !empty($instance[$buzstores_widgets_name]) ? $instance[$buzstores_widgets_name] : ''; buzstores_widgets_show_widget_field($this, $widget_field, $buzstores_widgets_field_value); } } }