'grid', 'tab_title' => 'default', 'tab_style' => 'normal', 'grid_style' => 'normal', 'tab_title_text'=> '', 'adv_grid' => '', 'icon_cat' => '', 'position' => '2', 'number' => '8', 'cats' => '', 'order_by' => 'date', 'order' => 'DESC', 'product_type' => 'latest', 'show_meta' => 'no', ),$attr)); $custom_list = array(); $args = array( 'post_type' => 'product', 'posts_per_page' => $number, 'orderby' => $order_by, 'order' => $order, ); if($product_type == 'toprate'){ add_filter( 'posts_clauses', array( WC()->query, 'order_by_rating_post_clauses' ) ); $args['no_found_rows'] = 1; $args['meta_query'] = WC()->query->get_meta_query(); } if($product_type == 'mostview'){ $args['meta_key'] = 'post_views'; $args['orderby'] = 'meta_value_num'; } if($product_type == 'bestsell'){ $args['meta_key'] = 'total_sales'; $args['orderby'] = 'meta_value_num'; } if($product_type=='onsale'){ $args['meta_query'][]=array( 'key' => '_sale_price', 'value' => 0, 'compare' => '>', 'type' => 'numeric' ); } if($product_type == 'featured'){ $args['meta_key'] = '_featured'; $args['meta_value'] = 'yes'; } if(!empty($cats)) { $custom_list = explode(",",$cats); $args['tax_query'][]=array( 'taxonomy'=>'product_cat', 'field'=>'slug', 'terms'=> $custom_list ); } $product_query = new WP_Query($args); $count_query = $product_query->post_count; switch ($style) { case 'featured-product': $html .= ''; break; case 'grid': $html .= '
'; if($grid_style == 'slider'){ $html .= '
'; } else $html .= '
'; } else $html .= ''; $html .= '
'; break; case 'grid-2': if($grid_style == 'slider'){ $html .= '
'; } else $html .= '
'; } else $html .= ''; break; case 'hot-deal': $html .= ''; break; case 'tab-cate-grid': if(!empty($cats)){ $pre = rand(0,1000); $cats = explode(',', $cats); $tab_title_html = ''; $tab_title_html .= ''; if($tab_title == 'style-2'){ $html .= '

'.$tab_title_text.'

'.$tab_title_html.'
'; } else{ $html .= ''; } $html .= '
'; $ccount = 1; foreach ($cats as $cat_id) { $f_class = ''; if($ccount == 1) $f_class = 'active'; $term = get_term_by( 'slug',$cat_id, 'product_cat' ); $args['tax_query'] = array(); $args['tax_query'][]=array( 'taxonomy'=>'product_cat', 'field'=>'slug', 'terms'=> $cat_id ); $product_query = new WP_Query($args); $count_query = $product_query->post_count; $html .= '
'; $html .= '
'; if($tab_style == 'slider') $html .= '
'; else $html .= '
    '; $count = 1; if($product_query->have_posts()) { while($product_query->have_posts()) { $product_query->the_post(); global $product,$post; if(has_post_thumbnail(get_the_ID())) $thumb_html = get_the_post_thumbnail(get_the_ID(),array(370,370),array('class'=>'img-responsive')); else $thumb_html = ''; if($tab_style == 'slider' && $count % 6 == 1){ $html .= '
      '; } $html .= '
    • '.$thumb_html.' '.sv_product_box_hover().' '.sv_get_meta_product($show_meta).'

      '.get_the_title().'

      '.$product->get_price_html().'
    • '; if($tab_style == 'slider' && ($count % 6 == 0 || $count == $count_query)){ $html .= '
    '; } $count++; } } if($tab_style == 'slider') $html .= '
'; else $html .= ''; $html .= '
'; $html .= '
'; $ccount++; } $html .= '
'; } break; default: if(!empty($cats)){ $pre = rand(0,1000); $cats = explode(',', $cats); $tab_title_html = $icon_html = ''; $tab_title_html .= ''; $el_slider = 'nav-default'; switch ($tab_title) { case 'style-2': $html .= '

'.$tab_title_text.'

'.$tab_title_html.'
'; break; case 'style-3': $el_slider = 'home-directnav'; $html .= ''; break; default: $html .= ''; break; } $html .= '
'; $ccount = 1;$position = (int)$position; parse_str( urldecode( $adv_grid ), $data); if(is_array($data)){ $new_data = array(); $k = 1; foreach ($data as $value) { $new_data[$k] = $value; $k++; } $data = $new_data; } foreach ($cats as $cat_id) { $f_class = ''; if($ccount == 1) $f_class = 'active'; $term = get_term_by( 'slug',$cat_id, 'product_cat' ); $args['tax_query'] = array(); $args['tax_query'][]=array( 'taxonomy'=>'product_cat', 'field'=>'slug', 'terms'=> $cat_id ); $product_query = new WP_Query($args); $count_query = $product_query->post_count; $html .= '
'; if($tab_style == 'slider') $html .= '
'; else $html .= '
    '; $count = 1;$first_slider = true;$item_slider = 6; if($product_query->have_posts()) { while($product_query->have_posts()) { $product_query->the_post(); global $product,$post; $thumb_html = $count_down_html = ''; if(!isset($data[$ccount]['image'])) $item_slider = 7; if($position < 1) $item_slider = 8; if(!$first_slider) $item_slider = 8; if($tab_style == 'slider' && $count % $item_slider == 1 && $count == 9 && $position < 1){ $html .= '
      '; } if($tab_style == 'slider' && $count % $item_slider == 1 && $count != 9){ $html .= '
        '; if($count > $item_slider){ $item_slider = 8; $first_slider = false; } } if($count == $position){ if(isset($data[$ccount]['image'])){ $thumb_html = wp_get_attachment_image($data[$ccount]['image'],array(570,334),0,array('class'=>'img-responsive')); $s_price = '
        '.$data[$ccount]['price'].'
        '; $s_link = $data[$ccount]['link']; $s_title = $data[$ccount]['title']; $s_label = $data[$ccount]['label']; if(!empty($data[$ccount]['time'])){ $s_price = '
        '.$data[$ccount]['price'].'
        '; $count_down_html = '
        '; } } else{ if(has_post_thumbnail(get_the_ID())) $thumb_html = get_the_post_thumbnail(get_the_ID(),array(570,334),array('class'=>'img-responsive')); $s_price = '
        '.$product->get_price_html().'
        '; $s_link = get_the_permalink(); $s_title = get_the_title(); $s_label = esc_html__("Shop Now","bigc"); } $html .= '
      • '.$thumb_html.' '; if(isset($data[$ccount]['image'])){ // $html .= '
        // //
        '; } else{ $html .= sv_product_box_hover(); } $html .= '
        '.$s_price.'

        '.$s_title.'

        '; $html .= $count_down_html; if(!empty($s_label)) $html .= ''.$s_label.''; $html .= '
      • '; if(isset($data[$ccount]['image'])){ if(has_post_thumbnail(get_the_ID())) $thumb_html = get_the_post_thumbnail(get_the_ID(),array(270,270),array('class'=>'img-responsive')); $html .= '
      • '.$thumb_html.' '.sv_product_box_hover().' '.sv_get_meta_product($show_meta).'

        '.get_the_title().'

        '.$product->get_price_html().'
      • '; } } else{ if(has_post_thumbnail(get_the_ID())) $thumb_html = get_the_post_thumbnail(get_the_ID(),array(270,270),array('class'=>'img-responsive')); $html .= '
      • '.$thumb_html.' '.sv_product_box_hover().' '.sv_get_meta_product($show_meta).'

        '.get_the_title().'

        '.$product->get_price_html().'
      • '; } if($tab_style == 'slider' && ($count % $item_slider == 0 || $count == $count_query) && $count != 8 ){ $html .= '
      '; } if($tab_style == 'slider' && $count == 8 && $position < 1 ){ $html .= '
    '; } $count++; } } if($tab_style == 'slider') $html .= '
'; else $html .= ''; $html .= '
'; $ccount++; } $html .= '
'; } break; } wp_reset_postdata(); return $html; } } stp_reg_shortcode('sv_product_list','sv_vc_product_list'); add_action( 'vc_build_admin_page','sv_add_list_product',10,100 ); if ( ! function_exists( 'sv_add_list_product' ) ) { function sv_add_list_product(){ vc_map( array( "name" => esc_html__("SV Product list", 'bigc'), "base" => "sv_product_list", "icon" => "icon-st", "category" => '7Up-theme', "params" => array( array( 'heading' => esc_html__( 'Style', 'bigc' ), 'type' => 'dropdown', 'description' => esc_html__( 'Choose style to display.', 'bigc' ), 'param_name' => 'style', 'value' => array( esc_html__('Grid','bigc') => 'grid', esc_html__('Grid 2','bigc') => 'grid-2', esc_html__('Tab Category','bigc') => 'tab-cate-grid', esc_html__('Tab Category 2','bigc') => 'tab-cate-grid-2', esc_html__('Hot deal','bigc') => 'hot-deal', esc_html__('Featured Style','bigc') => 'featured-product', ) ), array( 'heading' => esc_html__( 'Tab title', 'bigc' ), 'type' => 'dropdown', 'description' => esc_html__( 'Choose style to display.', 'bigc' ), 'param_name' => 'tab_title', 'value' => array( esc_html__('Default','bigc') => 'default', esc_html__('Style 2','bigc') => 'style-2', esc_html__('Style 3','bigc') => 'style-3', ), 'edit_field_class'=>'vc_col-sm-6 vc_column', 'dependency' => array( 'element' => 'style', 'value' => array('tab-cate-grid','tab-cate-grid-2'), ) ), array( 'heading' => esc_html__( 'Tab style', 'bigc' ), 'type' => 'dropdown', 'description' => esc_html__( 'Choose style to display.', 'bigc' ), 'param_name' => 'tab_style', 'value' => array( esc_html__('Normal','bigc') => 'normal', esc_html__('Slider','bigc') => 'slider', ), 'edit_field_class'=>'vc_col-sm-6 vc_column', 'dependency' => array( 'element' => 'style', 'value' => array('tab-cate-grid','tab-cate-grid-2'), ) ), array( 'heading' => esc_html__( 'Tab block text', 'bigc' ), 'type' => 'textfield', 'param_name' => 'tab_title_text', 'dependency' => array( 'element' => 'tab_title', 'value' => 'style-2', ) ), array( 'heading' => esc_html__( 'Grid style', 'bigc' ), 'type' => 'dropdown', 'description' => esc_html__( 'Choose style to display.', 'bigc' ), 'param_name' => 'grid_style', 'value' => array( esc_html__('Normal','bigc') => 'normal', esc_html__('Slider','bigc') => 'slider', ), 'dependency' => array( 'element' => 'style', 'value' => array('grid','grid-2'), ) ), array( 'heading' => esc_html__( 'Position', 'bigc' ), 'type' => 'textfield', 'description' => esc_html__( 'Set position for advantage in grid(enter number). Only Grid 2 and Tab Category 2. Default is 2.', 'bigc' ), 'param_name' => 'position', 'group' => esc_html__( 'Advanced', 'bigc' ), 'dependency' => array( 'element' => 'style', 'value' => array('grid-2','tab-cate-grid-2'), ) ), array( 'heading' => esc_html__( 'Grid Advantage', 'bigc' ), 'type' => 'add_image_adv', 'param_name' => 'adv_grid', 'description' => esc_html__( 'Only Grid 2 and Tab Category 2.', 'bigc' ), 'group' => esc_html__( 'Advanced', 'bigc' ), 'dependency' => array( 'element' => 'style', 'value' => array('grid-2','tab-cate-grid-2'), ) ), array( 'heading' => esc_html__( 'Tab Icon', 'bigc' ), 'type' => 'add_icon_cat', 'param_name' => 'icon_cat', 'description' => esc_html__( 'Only Tab Category 2.', 'bigc' ), 'group' => esc_html__( 'Icon', 'bigc' ), 'dependency' => array( 'element' => 'tab_title', 'value' => array('style-3'), ) ), array( 'heading' => esc_html__( 'Number', 'bigc' ), 'type' => 'textfield', 'description' => esc_html__( 'Enter number of product. Default is 8.', 'bigc' ), 'param_name' => 'number', ), array( 'heading' => esc_html__( 'Product Type', 'bigc' ), 'type' => 'dropdown', 'param_name' => 'product_type', 'value' => array( esc_html__('Latest Products','bigc') => 'latest', esc_html__('Featured Products','bigc') => 'featured', esc_html__('Best Sellers','bigc') => 'bestsell', esc_html__('On Sale','bigc') => 'onsale', esc_html__('Top rate','bigc') => 'toprate', esc_html__('Most view','bigc') => 'mostview', ), 'description' => esc_html__( 'Select Product View Type', 'bigc' ), ), array( 'holder' => 'div', 'heading' => esc_html__( 'Product Categories', 'bigc' ), 'type' => 'checkbox', 'param_name' => 'cats', 'value' => sv_list_taxonomy('product_cat',false) ), array( 'type' => 'dropdown', 'heading' => esc_html__( 'Order By', 'bigc' ), 'value' => array( esc_html__('Date','bigc') => 'date', esc_html__('Rand','bigc') => 'rand', esc_html__('Name','bigc') => 'title', esc_html__('Price','bigc') => 'price', ), 'param_name' => 'orderby', 'description' => esc_html__( 'Select Orderby Type ', 'bigc' ), 'edit_field_class'=>'vc_col-sm-6 vc_column', ), array( 'heading' => esc_html__( 'Order', 'bigc' ), 'type' => 'dropdown', 'param_name' => 'order', 'value' => array( esc_html__('Desc','bigc') => 'DESC', esc_html__('Asc','bigc') => 'ASC', ), 'description' => esc_html__( 'Select Order Type ', 'bigc' ), 'edit_field_class'=>'vc_col-sm-6 vc_column', ), array( 'heading' => esc_html__( 'Show Meta Product', 'bigc' ), 'type' => 'dropdown', 'param_name' => 'show_meta', 'value' => array( esc_html__('No','bigc') => 'no', esc_html__('Yes','bigc') => 'yes', ), 'description' => esc_html__( 'Show meta product. Contain new and sale box. Choose Yes to show.', 'bigc' ), ) ) )); } }