<?php
function lee_products_shortcode( $atts, $content = null ){
  	extract( shortcode_atts( array(
		'number'=> '-1',
		'icon' => '',
		'el_class' => '',
		'type'=>'',
		'style'=>'grid',
		'columns_number' => '4',
		'columns_number_small' => '1',
		'columns_number_tablet' => '3',
		), $atts ) 
  	);
  	ob_start();
  	if($type=='') return;
  	
	switch ($columns_number) {
		case '5':
			$class_column='large-block-grid-5 small-block-grid-2';
			break;
		case '4':
			$class_column='large-block-grid-4 small-block-grid-2';
			break;
		case '3':
			$class_column='large-block-grid-3 small-block-grid-1';
			break;
		case '2':
			$class_column='large-block-grid-2 small-block-grid-1';
			break;
		default:
			$class_column='large-block-grid-1 small-block-grid-1';
			break;
	}
	
	global $woocommerce;

	$_id = rand();
	$_count = 1;
	$show_rating = $is_deals = false;
	if($type=='top_rate') $show_rating=true;
	if($type=='deals') $is_deals=true;

	$loop = lee_woocommerce_query($type,$number);

	if ( $loop->have_posts() ) : ?>
		<?php $_total = $loop->found_posts; ?>
	    <div class="woocommerce<?php echo (($el_class!='')?' '.$el_class:''); ?>">
			<div class="inner-content">
				<?php wc_get_template(
					'lee-product-layout/'.$style.'.php',
					array( 
						'show_rating' => $show_rating,
						'_id'=>$_id,
						'loop'=>$loop,
						'columns_number'=>$columns_number,
						'columns_number_small'=>$columns_number_small,
						'columns_number_tablet'=>$columns_number_tablet,
						'class_column' => $class_column,
						'_total'=>$_total,
						'number'=>$number,
						'is_deals' => $is_deals
					)
				);?>
			</div>
		</div>
	<?php endif;
	wp_reset_postdata();
	$content = ob_get_contents();
	ob_end_clean();
	return $content;
}
add_shortcode('lee_products', 'lee_products_shortcode');