'',
'style' => 'tab-list',
'number' => '8',
'tab_is' => 'product_tag',
'cats' => '',
'tags' => '',
'tab_special' => '',
'tab_special_style' => 'style1',
'order_by' => 'date',
'order' => 'DESC',
'product_type' => 'latest',
),$attr));
$args = array(
'post_type' => 'product',
'posts_per_page' => $number,
'orderby' => $order_by,
'order' => $order,
);
if($style == 'tab-list'){
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 == 'featured'){
$args['meta_key'] = '_featured';
$args['meta_value'] = 'yes';
}
}
$product_query = new WP_Query($args);
$count_query = $product_query->post_count;
switch ($style) {
case 'tab-list':
$pre = rand(0,1000);
$tab_cat = false;
$tabs_list = explode(',', $cats);
if($tab_is == 'product_tag'){
$tab_cat = true;
$tabs_list = explode(',', $tags);
}
if(!empty($tabs_list)){
$tab_title_html = '
';
}
else{
$html .= '
';
}
$html .= '
'.sv_product_filter_attr().'
';
$html .= '
';
foreach ($tabs_list as $key => $item_slug) {
$f_class = '';
if($key == 0) $f_class = 'active';
$args['paged'] = 1;
unset($args['meta_key']);
unset($args['orderby']);
unset($args['meta_query']);
unset($args['meta_value']);
if($item_slug == "bestseller"){
$args['meta_key'] = 'total_sales';
$args['orderby'] = 'meta_value_num';
}
if($item_slug == "onsale"){
$args['meta_query'][]=array(
'key' => '_sale_price',
'value' => 0,
'compare' => '>',
'type' => 'numeric'
);
}
if($item_slug == "featured"){
$args['meta_key'] = '_featured';
$args['meta_value'] = 'yes';
}
// var_dump($args);
$args2 = $args;
$args2['posts_per_page'] = 4;
$product_query2 = new WP_Query($args2);
$max_page_ajax = $product_query2->max_num_pages;
$product_query = new WP_Query($args);
$count_query = $product_query->post_count;
$max_page = $product_query->max_num_pages;
$html .= '
';
if($product_query->have_posts()) {
while($product_query->have_posts()) {
$product_query->the_post();
global $product,$post;
$thumb_html = '';
if(has_post_thumbnail(get_the_ID())) $thumb_html = get_the_post_thumbnail(get_the_ID(),array(270,270),array('class'=>'img-responsive'));'';
$html .= '-
';
if($tab_special_style == 'style2'){
$html .= '
'.$product->get_price_html().'
'.sv_product_link_filter($tab_special_style);
}
else{
$html .= '
'.$product->get_price_html().'
'.substr(get_the_excerpt(),0,70).'..
'.sv_get_rating_html().'
'.sv_product_link_filter($tab_special_style);
}
$html .= '
';
}
}
$html .= '
';
if($max_page > 1){
$html .= '
';
}
$html .= '
';
}
$html .= '
';
$html .= '
';
break;
default:
# code...
break;
}
wp_reset_postdata();
return $html;
}
}
stp_reg_shortcode('sv_product_filter','sv_vc_product_filter');
add_action( 'vc_build_admin_page','sv_add_list_product_filter' );
if ( ! function_exists( 'sv_add_list_product_filter' ) ) {
function sv_add_list_product_filter(){
vc_map( array(
"name" => esc_html__("SV Product Filter", 'bigc'),
"base" => "sv_product_filter",
"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__('Tabs List','bigc') => 'tab-list',
esc_html__('Tabs Special','bigc') => 'tab-special',
)
),
array(
'heading' => esc_html__( 'Tab Style', 'bigc' ),
'type' => 'dropdown',
'description' => esc_html__( 'Choose style to display.', 'bigc' ),
'param_name' => 'tab_special_style',
'value' => array(
esc_html__('Style 1','bigc') => 'style1',
esc_html__('Style 2','bigc') => 'style2',
),
'dependency' => array(
'element' => 'style',
'value' => 'tab-special',
)
),
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__('Most view','bigc') => 'mostview',
),
'description' => esc_html__( 'Select Product View Type', 'bigc' ),
'dependency' => array(
'element' => 'style',
'value' => 'tab-list',
)
),
array(
'heading' => esc_html__( 'Tab Is', 'bigc' ),
'type' => 'dropdown',
'description' => esc_html__( 'Choose style to display.', 'bigc' ),
'param_name' => 'tab_is',
'value' => array(
esc_html__('Tags Cloud','bigc') => 'product_tag',
esc_html__('Category','bigc') => 'product_cat',
)
),
array(
'holder' => 'div',
'heading' => esc_html__( 'Product Categories', 'bigc' ),
'type' => 'checkbox',
'param_name' => 'cats',
'value' => sv_list_taxonomy('product_cat',false),
'dependency' => array(
'element' => 'tab_is',
'value' => 'product_cat',
)
),
array(
'holder' => 'div',
'heading' => esc_html__( 'Product Tags', 'bigc' ),
'type' => 'checkbox',
'param_name' => 'tags',
'value' => sv_list_tag_product(),
'dependency' => array(
'element' => 'tab_is',
'value' => 'product_tag',
)
),
array(
'holder' => 'div',
'heading' => esc_html__( 'Tab Special', 'bigc' ),
'type' => 'checkbox',
'param_name' => 'tab_special',
'value' => array(
esc_html__( 'New Arrivals', 'bigc' ) => 'newarrival',
esc_html__( 'Best Sellers', 'bigc' ) => 'bestseller',
esc_html__( 'On Sale', 'bigc' ) => 'onsale',
esc_html__( 'Featured', 'bigc' ) => 'featured',
),
// 'dependency' => array(
// 'element' => 'tab_is',
// 'value' => 'product_tag',
// )
),
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',
),
)
));
}
}