widget_cssclass = 'woocommerce best_shop_product_attribute_widget'; $this->widget_description = __( 'Display Product by Attribute.', 'best-shop' ); $this->widget_id = 'best_shop_product_attribute_widget'; $this->widget_name = __( '+ Product by Attribute Grid', 'best-shop' ); parent::__construct(); } public function widget( $args, $instance ) { $max_items = ( ! empty( $instance['max_items'] ) ) ? absint( $instance['max_items'] ) : 10; $category = ( ! empty( $instance['category'] ) ) ? wp_strip_all_tags( $instance['category'] ) : -1; $colums = (!empty($instance['colums'])) ? absint($instance['colums']) : 5; $pagination = ( ! empty( $instance['pagination'] ) ) ? true : false; $product_shortcode = ''; if($category == 'on_sale'){ $product_shortcode = "[products limit='".absint($max_items)."' columns='".absint($colums)."' on_sale='true' orderby='id' order='DESC' paginate=true ]"; } if($category == 'best_selling'){ $product_shortcode = "[products limit='".absint($max_items)."' columns='".absint($colums)."' best_selling='true' orderby='id' order='DESC' paginate=true ]"; } if($category == 'featured'){ $product_shortcode = "[products limit='".absint($max_items)."' columns='".absint($colums)."' visibility='featured' orderby='id' order='DESC' paginate=true ]"; } if($category == 'top_rated'){ $product_shortcode = "[products limit='".absint($max_items)."' columns='".absint($colums)."' visibility='top_rated' orderby='id' order='DESC' paginate=true ]"; } if($category == 'newest'){ $product_shortcode = "[products limit='".absint($max_items)."' columns='".absint($colums)."' orderby='id' order='DESC' visibility='visible' paginate=true ]"; } if(!$pagination) { $product_shortcode = str_replace("paginate=true", " paginate=false", $product_shortcode); } //echo $product_shortcode; ?>
esc_html__('On Sale','best-shop') , 'best_selling'=>esc_html__('Best Selling','best-shop'), 'top_rated'=>esc_html__('Top Rated','best-shop') , 'featured'=> esc_html__('Featured','best-shop'), 'newest'=> esc_html__('Newest','best-shop'), ); $category_list = ''; if(0 == $category){ $category_list = $category_list.''; } else{ $category_list = $category_list.''; } foreach ( $categories as $cat=>$value ) { $selected =''; if(($cat)==$category){ $selected ='Selected=selected'; } $category_list = $category_list.''; } ?>
id="get_field_id( 'pagination' )); ?>" name="get_field_name( 'pagination' )); ?>" />