<?php
if(get_theme_mod('newarrival_area_disable') != 'on' ){
	?>
	<?php 
		if( get_theme_mod('newarrival_areaTpadding',true) ) {
			$newarrival_areaTpadding = 'padding-top:'.esc_attr(get_theme_mod('newarrival_areaTpadding')).';';
		}
		if( get_theme_mod('newarrival_areaBpadding',true) ) {
			$newarrival_areaBpadding = 'padding-bottom:'.esc_attr(get_theme_mod('newarrival_areaBpadding')).';';
		}
	?>			
	<div class="newarrival-area " id="newarrival">		  
		<div class="container">
			<?php
				$showStatic = true;
				for( $i = 1; $i < 11; $i++ ){
					$newarrivalus_page_id = get_theme_mod('newarrivalus_page_icon'.$i); 
					if(!empty($newarrivalus_page_id)){
						$showStatic = false;
						break;
					}
				}
				$newarrival_title = get_theme_mod('newarrival_title', 'New Arrival');
				$newarrivalubtitle = get_theme_mod('newarrivalubtitle', 'Find Gorgeous Dress For Any Occasion');
				$newarrivalbtntxt = get_theme_mod('newarrival_prdctbtntxt', 'Rent A Dress');
				$newarrbtntxt = get_theme_mod('newarrbtntxt', 'View More'); 
				$newarrbtnlink = get_theme_mod('newarrbtnlink', 'add link here');
			?>
			<div class="row justify-content-center">
          <div class="section-title">
	          	<?php if( $newarrival_title){ ?>
		          		<div class="heading-brd"></div>
		              <h2><?php echo ($newarrival_title);  ?></h2>
		           <?php } ?>
              <?php if( $newarrivalubtitle){ ?>
                  <p class="section-text">
                      <?php echo ($newarrivalubtitle);  ?>
                  </p>
              <?php } ?>
          </div>    
      </div> 
			<div class="newarrivalus-post-wrap">
				<div class="newarrivalus-post-boxes row">
					<div class="owl-carousel owl-theme"> 
						<?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' => 'ASC' );
				    			$meta_query   = WC()->query->get_meta_query();
				    			$tax_query   = WC()->query->get_tax_query();
				    			
				    			$args = array(
				    				'post_type'   =>  'product',
				    				'stock'       =>  1,
				    				'posts_per_page' => 10, 
				    				'orderby'     =>  'date',
				    				'order'       =>  'ASC',
				    				'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;

								global $woo_options;
						        global $post;

						        // $terms = get_the_terms( $post->ID, 'product_cat' );
						        // foreach ($terms as $term) {
						        //     $product_cat = $term->name;
						        //     break;
       							// }
						?>
						<div class="item newarrivalbx wow zoomIn" data-wow-duration="1s">
							<div class="newarrivalus-single" >
								<div class="newarrival-box"> 
									<div class="hi-icon">
											<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="featured products" />'; 
				    							?>
											</a>
											<?php 
													if($newarrivalbtntxt){
											?>
													<div class="fea-btn">
															<a href="<?php echo esc_url(get_permalink()); ?>">
																<span><?php echo $newarrivalbtntxt; ?></span>
															</a>
													</div>
											<?php } ?>
											<div class="newarr-icn">
													<a href="<?php echo esc_url(get_permalink()); ?>">
															<i class="fa fa-link" aria-hidden="true"></i>
													</a>
											</div>
									</div>
								</div> 
								<div class="newarrival-area-data">
										<a id="id-<?php the_id(); ?>" href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
											<h4 class="inner-area-title"><?php the_title();?></h4>
										</a>
										<div class="price">
												from <?php echo $product->get_price_html(); ?>
										</div>
									</div>				 
								</div>
							</div>
						<?php					
						endwhile; 
							}else{
						?>
						<div class="item  newarrivalbx wow zoomIn" data-wow-duration="1s">
							<div class="newarrivalus-single" >
								<div class="newarrival-box"> 
									<div class="hi-icon">
										<a href="#">
											<img class="img-responsive" src="<?php echo esc_url(get_template_directory_uri().'/images/feaproducts.jpg');?>" alt="featured products" />
										</a>
										<div class="fea-btn">
											<a href="#">
												<span>Rent A Dress</span>
											</a>
										</div>
										<div class="newarr-icn">
													<a href="#">
															<i class="fa fa-link" aria-hidden="true"></i>
													</a>
											</div>
									</div>
								</div> 
								<div class="newarrival-area-data">
									<a href="#"><h4 class="inner-area-title">Sheath Dress </h4></a>
									<div class="price">from $120</div>
								</div>				 
							</div>
						</div>
						<?php }
							//wp_reset_query(); 
						}
							?>
						</div>	
				</div>
				<div class="newarrival-btmbtn">
						<?php if(!empty($newarrbtntxt)){ ?>
							<a href="<?php echo $newarrbtnlink ?>">
								<span><?php echo ($newarrbtntxt);  ?></span>
							</a>
						<?php }?> 
				</div>
			</div>
		</div>
	</div>
    <script>
        $(document).ready(function() {
          $('#newarrival .owl-carousel').owlCarousel({
            nav: false,
            loop: true,
            margin: 30,
            dots: true,
            autoplay: false,
            autoplaySpeed: 7000,
            autoplayTimeout: 5000,
            autoplayHoverPause: true,
            slideTransition: 'linear',
            navText: [
                '<i class="fa fa-caret-left" aria-hidden="true"></i>',
                '<i class="fa fa-caret-right" aria-hidden="true"></i>'
            ],
            responsive: {
              0: {
                items: 1,
                nav: true,
                margin: 15
              },
              550: {
                items: 2,
                nav: true,
                margin: 15
              },
              768: {
                items:3,
                nav: true,
                margin: 15
              },
              1000: {
                items:4,
                nav: true,
                loop: true,
                margin: 20
              }
            }
          })
        })
    </script>
<?php }  