<?php
if(get_theme_mod('problock2_area_disable') != 'on' ){
	?>
	<!-- problock2 Start -->
	<?php 
		if( get_theme_mod('problock2_areaTpadding',true) ) {
			$problock2_areaTpadding = 'padding-top:'.esc_attr(get_theme_mod('problock2_areaTpadding')).';';
		}
		if( get_theme_mod('problock2_areaBpadding',true) ) {
			$problock2_areaBpadding = 'padding-bottom:'.esc_attr(get_theme_mod('problock2_areaBpadding')).';';
		}
		if( get_theme_mod('problock2_recentprosliderHeight',true) ) {
			$problock2_recentprosliderHeight = 'height:'.esc_attr(get_theme_mod('problock2_recentprosliderHeight')).';';
		}
	?>			
	<div class="problock2-area bg-img-1" id="problock2">  
		<div class="container">
			<div class="row row-eq-height">
		<div class="col-md-3 col-sm-6 col-xs-12">
			<div class="inside-full-height">
				<div class="pro-topcat-area wow zoomIn" >
					<?php
					$showStatic = true;
					for( $i = 1; $i < 4; $i++ ){
						$luzuk_featuredpro_page_id = get_theme_mod('luzuk_featuredpro_page'.$i); 
						if(!empty($luzuk_featuredpro_page_id)){
							$showStatic = false;
							break;
						}
					}
					$protopcat_title = get_theme_mod('protopcat_title', 'TOP CATEGORY PRODUCT ');	
					
					?>
					<div class="row">
						<div class="section-title pd-0">
							<h2><?php echo ($protopcat_title);  ?></h2>

						</div>
					</div>
					 <div class="responsive-tabs s-border">			
		                <?php
		                $categories = get_theme_mod('topcatproduct_categories');
		                $args = array(
		                    'number' => 4,
		                    'orderby' => 'name',
		                    'order' => 'asc',
		                    'hide_empty' => false,
		                    'include' => $categories
		                );
		                $product_categories = get_terms('product_cat', $args);
		                $i = 0;
		                if(function_exists('get_woocommerce_term_meta')){
		                    foreach ($product_categories as $cat) {
		                        if(!empty($cat)){
		                            ?>
                            <!-- <h2><?php //echo !empty($cat->name)?$cat->name:''; ?></h2> -->
                            <div id="<?php echo $cat->slug;?>">
                                <?php
                                $i = 0;
                                $args = array( 'post_type' => 'product', 'posts_per_page' => 2,  'orderby' =>'date','order' => 'DESC' );
                                if(!empty($cat->slug)){
                                    $args['product_cat']= $cat->slug;
                                }
                                $product = new stdClass();
                                $loop = new WP_Query( $args );
                                while ( $loop->have_posts() ) : $loop->the_post();
                                    global $product; ?>		
                                    <div class="wow zoomIn" > 
                                        <div id="recent-porduct">
                                    	<div class="col-md-4 col-sm-6 col-xs-6 pd-0">
                                    		 <div class="imgeffect">
                                            <a id="id-<?php the_id(); ?>" href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
                                                <?php
                                                if (has_post_thumbnail( $loop->post->ID )) 
                                                    echo get_the_post_thumbnail($loop->post->ID, 'shop_catalog'); 
                                                else
                                                    echo '<img src="'.get_template_directory_uri().'/images/default.png" alt="Placeholder" width="100%" height="200px" />'; ?>
                                                <div class="ht-protopcat-social-id"> 
		    											<?php
		    											$product->is_icon = true;
		    											woocommerce_template_loop_add_to_cart( $product ); ?>
		    									</div>
                                            </a>

                                            </div>
                                    	</div>
                                    	<div class="col-md-8 col-sm-6 col-xs-6">
                                    		 <div class="content-part">		
                                    		 	<?php
				    									$taxonomyName = "product_cat";
				    									$terms = wp_get_post_terms( get_the_id(), 'product_cat' );
														 $term  = reset($terms);
														foreach ($terms as $term) {
															if( isset( $term->name ) ){
															$img_ll = get_term_link($term->name, $taxonomyName);
															if ( is_wp_error( $img_ll ) ) {
															continue;
															}

														echo '<a class="pro-cat" href="' . $img_ll . '"> ' . $term->name . '</a>';
														}
													}
													?>								
                                                <a id="id-<?php the_id(); ?>" href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
                                                    <!-- <h6><?php //the_title(); ?></h6>   -->
                                                    <h6><?php echo wp_trim_words( get_the_title(), 5 ); ?></h6>
                                                </a>
                                                <?php
                                                if(method_exists($product, 'get_price_html')){
                                                    ?>
                                                    <span class="price"><?php echo $product->get_price_html(); ?></span>
                                                    <?php
                                                }
                                                ?>
												<div class="clearfix"></div>
                                            </div>
                                        		
                                        	</div>
                                        	<div class="clearfix"></div>
                                        </div>
                                    </div><!-- /span3 -->


                                <?php endwhile; 
                                wp_reset_query(); 
                                ?>
                                <div class="clearfix"></div>    
                            </div>
                            <?php
		                        }
		                    }
		                }else{?>
		                <div class="alert alert-warning text-center">
		                    Kindly Install or Activate the WooCommerce plugin.
		                </div>
		                <?php
		            }
		            ?>  
		            <div class="clearfix"></div>
		        </div>
					<div class="clearfix"></div>
				</div>
				<div class="clearfix"></div>
				
					</div>
				</div>
				<div class="col-md-9 col-sm-6 col-xs-12">
					<div class="inside-full-height">
						<div class="row row-eq-height">
						<div class="col-md-5 pd-0">
							<?php
								$problock2_box_page_id = get_theme_mod('problock2_box1_page');
								$problock2box1sell = get_theme_mod('problock2_box1_sell', 'Sell');
								$problock2box1title = get_theme_mod('problock2_box1_title', 'New Fashion 2020');
								$problock2box1offert = get_theme_mod('problock2_box1_offert', 'Get Extra<span>30% OFF</span>');
								$problock2box1price = get_theme_mod('problock2_box1_price', 'From: <span>$99.00</span>');
								?>

							
								<div class="pro-box1-area wow zoomIn">
									<div class="inside-full-height">
									<div class="col-md-6 col-sm-6 col-xs-6">
										<div class="pro-b-img">
										<?php
					                    $static=true;
					                    for($i=1;$i<2;$i++){
					                        $link = get_theme_mod('proboxblock21_link'.$i);
					                        $img = get_theme_mod('proboxblock21_image'.$i);
					                        if (!empty($img) || !empty($link)){
					                            $static=false;
					                        }
					                    }

					                    if(function_exists('get_woocommerce_term_meta')){
					                        for($i=1;$i<2;$i++){

					                            if($static==false){
					                                $link = get_theme_mod('proboxblock21_link'.$i);
					                                $img = get_theme_mod('proboxblock21_image'.$i);
					                                $url = get_theme_mod('proboxblock21_url_'.$i, '#');
					                                $category = get_term_by( 'id', $link, 'product_cat' );

					                                $img = !empty($img)?$img:get_template_directory_uri().'/images/probox1.png';

					                                if( !empty($url) || !empty($category) ){
					                                    //echo $term->name;
					                                    ?>
					                                        <a href="<?php echo esc_url(!empty($url)?$url:'#');?>">
					                                            <img src="<?php echo esc_url($img);?>" alt="">
					                                        </a>
					                                    <?php
					                                }
					                            }
					                        }
					                    }else{ ?>
					                    <div class="alert alert-warning">
					                        Kindly Install or Activate the WooCommerce plugin.
					                    </div>
					                    <?php }

					                    if($static==true){
					                        ?>
					                            <a href="#">
					                                <img class="img-responsive" src="<?php echo get_template_directory_uri(); ?>/images/probox1.png" alt="">
					                            </a>
					                        <?php
					                    }?>
									</div>
									</div>
									<div class="col-md-6 col-sm-6 col-xs-6">
										<?php if($problock2box1sell){ ?>	
										<div class="sale"><?php echo ($problock2box1sell);  ?></div>
										<?php }?>
										<h4><?php echo ($problock2box1title);  ?></h4>
										<div class="prob2offer"><?php echo ($problock2box1offert);  ?></div>
										<div class="pro-box-price"><?php echo ($problock2box1price);  ?></div>
									</div>
									<div class="clearfix"></div>
								</div>
							</div>
						</div>
						<div class="col-md-7 pd-0">
							
								<?php
								$problock2_box2_page_id = get_theme_mod('problock2_box2_page');
								$problock2box2sell = get_theme_mod('problock2_box2_sell', 'Available Now');
								$problock2box2title = get_theme_mod('problock2_box2_title', 'iPhone Pro 9+ Black Headphone');
								$problock2box2price = get_theme_mod('problock2_box2_price', 'Intro Price: <span>$190.00</span>');
								?>

							
								<div class="pro-box2-area wow zoomIn">
									<div class="inside-full-height">
									<div class="col-md-6 col-sm-6 col-xs-6">
											<div class="pro-b-img">
										<?php
					                    $static=true;
					                    for($i=1;$i<2;$i++){
					                        $link = get_theme_mod('proboxblock22_link'.$i);
					                        $img = get_theme_mod('proboxblock22_image'.$i);
					                        if (!empty($img) || !empty($link)){
					                            $static=false;
					                        }
					                    }

					                    if(function_exists('get_woocommerce_term_meta')){
					                        for($i=1;$i<2;$i++){

					                            if($static==false){
					                                $link = get_theme_mod('proboxblock22_link'.$i);
					                                $img = get_theme_mod('proboxblock22_image'.$i);
					                                $url = get_theme_mod('proboxblock22_url_'.$i, '#');
					                                $category = get_term_by( 'id', $link, 'product_cat' );

					                                $img = !empty($img)?$img:get_template_directory_uri().'/images/probox2.png';

					                                if( !empty($url) || !empty($category) ){
					                                    //echo $term->name;
					                                    ?>
					                                        <a href="<?php echo esc_url(!empty($url)?$url:'#');?>">
					                                            <img src="<?php echo esc_url($img);?>" alt="">
					                                        </a>
					                                    <?php
					                                }
					                            }
					                        }
					                    }else{ ?>
					                    <div class="alert alert-warning">
					                        Kindly Install or Activate the WooCommerce plugin.
					                    </div>
					                    <?php }

					                    if($static==true){
					                        ?>
					                            <a href="#">
					                                <img class="img-responsive" src="<?php echo get_template_directory_uri(); ?>/images/probox2.png" alt="">
					                            </a>
					                        <?php
					                    }?>
									</div>
									</div>
									<div class="col-md-5 col-md-offset-1 col-md-6 col-sm-6 col-xs-6">
										<div class="sale"><?php echo ($problock2box2sell);  ?></div>
										<h4><?php echo ($problock2box2title);  ?></h4>
										<div class="pro-box-price"><?php echo ($problock2box2price);  ?></div>
									</div>
									<div class="clearfix"></div>
								</div>
							</div>
						</div>
							<div class="clearfix"></div>
						</div>
						<div class="clearfix"></div>
						<div class="pro-recentpro-area">
							<?php
							$showStatic = true;
							for( $i = 1; $i < 4; $i++ ){
								$luzuk_featuredpro_page_id = get_theme_mod('luzuk_featuredpro_page'.$i); 
								if(!empty($luzuk_featuredpro_page_id)){
									$showStatic = false;
									break;
								}
							}
							$recentpro_title = get_theme_mod('recentpro_title', 'RECENT PRODUCTS');	
							
							?>
							<div class="row">
								<div class="section-title pd-0">
									<h2><?php echo ($recentpro_title);  ?></h2>

								</div>
							</div>
							<div class="row s-border">
								<button class="slide-prev ctrl-btn pro-prev fa fa-chevron-left"></button>
								<button class="ctrl-btn pro-next fa fa-chevron-right slide-next"></button>
								<!-- Wrapper for slides -->
								<div class="slider" id="slider">
									<div class="slides" id="slide">
							    <!-- <div class="row-fluid">
							    	<div class="recent-box">-->
							    		<?php
					    		if(function_exists('woocommerce_template_loop_add_to_cart') && function_exists('WC')){
					    			$args = array( 'post_type' => 'product', 'stock' => 1, 'posts_per_page' => 4, 'orderby' =>'date','order' => 'DESC' );
					    			$meta_query   = WC()->query->get_meta_query();
					    			$tax_query   = WC()->query->get_tax_query();
					    			
					    			$args = array(
					    				'post_type'   =>  'product',
					    				'stock'       =>  1,
					    				'posts_per_page' => -1, 
					    				'orderby'     =>  'date',
					    				'order'       =>  'DESC',
					    				'meta_query'  =>  $meta_query,
					    				'tax_query'   => $tax_query,
					    			);
					    			$loop = new WP_Query( $args );
					    			if($loop->post_count > 0){
					    				while ( $loop->have_posts() ) : $loop->the_post(); global $product; ?>
					    					<div class="col-md-3 slide-item pd-0"> 
					    						<div id="recent-porduct" class="wow zoomIn">
					    							<div class="pro-img text-center">
					    								<a id="id-<?php the_id(); ?>" href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" class="img">
					    									<div class="pro-img-b">
					    									<?php if (has_post_thumbnail( $loop->post->ID )) 
					    									echo get_the_post_thumbnail($loop->post->ID, 'shop_catalog');
					    									else
					    										echo '<img src="'.get_template_directory_uri().'/images/default.png" alt="Placeholder" width="100%" height="200px" />'; ?>	
					    									</div>
					    								</a>
					    								<div class="recent-social-id"> 
					    									<ul>
					    										<li>
					    											<?php
					    											$product->is_icon = true;
					    											woocommerce_template_loop_add_to_cart( $product ); ?>
					    										</li>
					    										<li>
					    											<a id="id-<?php the_id(); ?>" href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><i class="fa fa-eye"></i></a>
					    										</li>
					    									</ul>
					    								</div>
					    							</div>
					    							
					    							<div class="total-product-title-wrap">
					    								<?php
				    									$taxonomyName = "product_cat";
				    									$terms = wp_get_post_terms( get_the_id(), 'product_cat' );
														 $term  = reset($terms);
														foreach ($terms as $term) {
															if( isset( $term->name ) ){
															$img_ll = get_term_link($term->name, $taxonomyName);
															if ( is_wp_error( $img_ll ) ) {
															continue;
															}

														echo '<a class="pro-cat" href="' . $img_ll . '"> ' . $term->name . '</a>';
														}
													}
													?>
					    								<a id="id-<?php the_id(); ?>" href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">	
					    									<h6><?php the_title(); ?></h6></a>
					    									<span class="price"><?php echo $product->get_price_html(); ?></span>
					    								</div>
					    								
					    							</div>
					    						</div><!-- /span3 -->
					    						<?php
					    					endwhile; 
					    				}else{ ?>
					    					<div class="alert alert-warning text-center">
					    						<strong>Sorry, no recent products to show.</strong>
					    					</div>
					    					<?php
					    				}
					    				?>
					    				<!-- </div>-->
					    				<!-- </div>-->
					    				<?php
					    				wp_reset_query(); 
					    			}else{ ?>
					    				<div class="alert alert-warning text-center">
					    					Kindly Install or Activate the WooCommerce plugin.
					    				</div>
					    				<?php
					    			}?>
							    		</div>
							    	</div><!-- /row-fluid -->
							    </div>

						</div>
						<div class="clearfix"></div>
						<div class="pro-popularpro-area">
							<?php
							$showStatic = true;
							for( $i = 1; $i < 4; $i++ ){
								$luzuk_featuredpro_page_id = get_theme_mod('luzuk_featuredpro_page'.$i); 
								if(!empty($luzuk_featuredpro_page_id)){
									$showStatic = false;
									break;
								}
							}
							$popularpro_title = get_theme_mod('popularpro_title', 'POPULAR PRODUCTS');	
							
							?>
							<div class="row">
								<div class="section-title pd-0">
									<h2><?php echo ($popularpro_title);  ?></h2>

								</div>
							</div>
							<div class="row s-border">
								<button class="slide-prev ctrl-btn pro-prev fa fa-chevron-left"></button>
								<button class="ctrl-btn pro-next fa fa-chevron-right slide-next"></button>
								<!-- Wrapper for slides -->
								<div class="slider" id="slider">
									<div class="slides" id="slide">
							    <!-- <div class="row-fluid">
							    	<div class="popular-box">-->
							    		<?php
					    		if(function_exists('woocommerce_template_loop_add_to_cart') && function_exists('WC')){
					    			$args = array( 'post_type' => 'product', 'stock' => 1, 'posts_per_page' => 4, 'orderby' =>'date','order' => 'DESC' );
					    			$meta_query   = WC()->query->get_meta_query();
					    			$tax_query   = WC()->query->get_tax_query();
					    			
					    			$args = array(
					    				'post_type' => 'product',
									    'meta_key' => 'total_sales',
									    'orderby' => 'meta_value_num',
									    'posts_per_page' => -1,
					    			);

					    			$loop = new WP_Query( $args );
					    			if($loop->post_count > 0){
					    				while ( $loop->have_posts() ) : $loop->the_post(); global $product; ?>
					    					<div class="col-md-3 slide-item pd-0"> 
					    						<div id="popular-porduct" class="wow zoomIn">
					    							<div class="pro-img text-center">
					    								<a id="id-<?php the_id(); ?>" href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" class="img">
					    									<div class="pro-img-b">
					    									<?php if (has_post_thumbnail( $loop->post->ID )) 
					    									echo get_the_post_thumbnail($loop->post->ID, 'shop_catalog');
					    									else
					    										echo '<img src="'.get_template_directory_uri().'/images/default.png" alt="Placeholder" width="100%" height="200px" />'; ?>	
					    									</div>
					    								</a>
					    								<div class="popular-social-id"> 
					    									<ul>
					    										<li>
					    											<?php
					    											$product->is_icon = true;
					    											woocommerce_template_loop_add_to_cart( $product ); ?>
					    										</li>
					    										<li>
					    											<a id="id-<?php the_id(); ?>" href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><i class="fa fa-eye"></i></a>
					    										</li>
					    									</ul>
					    								</div>
					    							</div>
					    							
					    							<div class="total-product-title-wrap">
					    								<?php
				    									$taxonomyName = "product_cat";
				    									$terms = wp_get_post_terms( get_the_id(), 'product_cat' );
														 $term  = reset($terms);
														foreach ($terms as $term) {
															if( isset( $term->name ) ){
															$img_ll = get_term_link($term->name, $taxonomyName);
															if ( is_wp_error( $img_ll ) ) {
															continue;
															}

														echo '<a class="pro-cat" href="' . $img_ll . '"> ' . $term->name . '</a>';
														}
													}
													?>
					    								<a id="id-<?php the_id(); ?>" href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">	
					    								<h6><?php the_title(); ?></h6></a>
														
					    									<span class="price"><?php echo $product->get_price_html(); ?></span>
					    								</div>
					    								
					    							</div>
					    						</div><!-- /span3 -->
					    						<?php
					    					endwhile; 
					    				}else{ ?>
					    					<div class="alert alert-warning text-center">
					    						<strong>Sorry, no popular products to show.</strong>
					    					</div>
					    					<?php
					    				}
					    				?>
					    				<!-- </div>-->
					    				<!-- </div>-->
					    				<?php
					    				wp_reset_query(); 
					    			}else{ ?>
					    				<div class="alert alert-warning text-center">
					    					Kindly Install or Activate the WooCommerce plugin.
					    				</div>
					    				<?php
					    			}?>
							    		</div>
							    	</div><!-- /row-fluid -->
							    </div>

						</div>
						<div class="clearfix"></div>
					
					</div>
				</div>
			</div>
		<div class="clearfix"></div>
		</div>
	</div>

	
	<!-- problock2 Area End -->
<?php }  