
<?php
/**
 * The template for displaying all pages.
 *
 * This is the template that displays all pages by default.
 * Please note that this is the WordPress construct of pages
 * and that other 'pages' on your WordPress site may use a
 * different template.
 *
 * @link https://codex.wordpress.org/Template_Hierarchy
 *
 * @package luzuk
 */
get_header(); ?>
<div class="clearfix"></div>
<?php $image = wp_get_attachment_url( get_post_thumbnail_id($post->ID));?>

<header class="page-main-header"  >
    <div class="container">
        <!-- </?php the_title( '<h1 class="ht-main-title wow zoomIn">', '</h1>' ); ?> -->
        <?php if( get_theme_mod('breadcrumb_button_display','show' ) == 'show') : ?>
        <div class="breadcrumbbox wow bounceInLeft">
            <div class='button'>
             <?php luzuk_lite_the_breadcrumb(); ?> </div>
            <div class="clearfix"></div>
        </div>
        <?php endif ?>
        <div class="clearfix"></div>
    </div>
    <div class="clearfix"></div>
</header>


<!-- </?php //do_action('woocommerce_before_main_content'); ?>
	</?php //if ( apply_filters( 'woocommerce_show_page_title', true ) ) : ?>
		<h1 class="page-title wow zoomIn"></?php //woocommerce_page_title(); ?></h1>
	</?php //endif; ?>						
	</?php //do_action( 'woocommerce_archive_description' ); ?> -->

<div class="single-productpage"> 
	<main id="innerpage-box">
		<div id="page" class="container" >
			<div class="inner_contentbox" >		
				<article id="content" class="article single_inner">
					<?php do_action('woocommerce_before_main_content'); ?>
						<?php while ( have_posts() ) : the_post(); ?>
							<?php wc_get_template_part( 'content', 'single-product' ); ?>
							<div class="featuredproducts-area " id="featuredproducts">		  
								<div class="container">
									<?php
										$showStatic = true;
										for( $i = 1; $i < 11; $i++ ){
											$featuredproductsus_page_id = get_theme_mod('featuredproductsus_page_icon'.$i); 
											if(!empty($featuredproductsus_page_id)){
												$showStatic = false;
												break;
											}
										}
										$feature_title = get_theme_mod('feature_title', 'Featured Products');
									?>
									<div class="row justify-content-center">
								        <div class="section-title">
								            <h2><?php echo ($feature_title);  ?></h2>
								        </div>    
								    </div> 
									<div class="featuredproductsus-post-wrap">
										<div class="featuredproductsus-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' => 9, 'orderby' =>'date','order' => 'DESC' );
										    			$meta_query   = WC()->query->get_meta_query();
										    			$tax_query   = WC()->query->get_tax_query();
										    			$tax_query[] = array(
										    				'taxonomy' => 'product_visibility',
										    				'field'    => 'name',
										    				'terms'    => 'featured',
										    				'operator' => 'IN',
										    			);
										    			$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;
										    					$product_id = $product->get_id();
																	//$wishlist_url = esc_url(add_query_arg('add_to_wishlist', $product_id));
													        $sale_text = get_post_meta(get_the_ID(), '_custom_product_salenew_field', true);
													        $discount_text = get_post_meta(get_the_ID(), '_custom_product_discount_field', true);
												?>
												<div class="item featuredproductsbx wow zoomIn" data-wow-duration="1s">
													<div class="featuredproductsus-single" >
														<div class="featuredproducts-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>
															</div>
															<div class="product_label">
										              			<?php  if (!empty($sale_text)) : ?>
											                		<div class="product-discount-data">
																		<span class="product-discount"><?php echo ($sale_text);  ?></span>
																	</div>
																<?php endif ?>
																<?php  if (!empty($discount_text)) : ?>
													          		<div class="product-discount-data">
																		<span class="product-discount"><?php echo ($discount_text);  ?></span>
																	</div>
																<?php endif ?>
															</div>
															<div class="featured-icons">
																<div class="featured-list tooltip-container">
																	<?php 
																		$user_id = get_current_user_id();
																		$product_id = $product->get_id();
																		$wishlist = get_user_meta($user_id, 'wishlist', true);
																		$button_class = in_array($product_id, (array)$wishlist) ? 'added' : '';
																		$nonce = wp_create_nonce('update_wishlist_' . $product_id);

																		$wishlist_url = esc_url(add_query_arg(
																		    array(
																		        'update_wishlist' => $product_id,
																		        '_wpnonce' => $nonce
																		    )
																		));

																		echo '<a href="' . $wishlist_url . '" class="add-to-wishlist-button ' . $button_class . '">
																		    <span class="spinner"></span>
																		    <i class="fa fa-heart' . ($button_class ? '' : '-o') . '" aria-hidden="true"></i>
																		    <span class="tooltip-text">' . ($button_class ? 'Added to Wishlist' : 'Add to Wishlist') . '</span>
																		</a>'; 
																	?>
																</div>
																<div class="featured-list tooltip-container">
															        <a href="<?php echo esc_url( $product->add_to_cart_url() ); ?>" data-quantity="1" class="button product_type_<?php echo esc_attr( $product->get_type() ); ?> add_to_cart_button">
															            <span class="spinner"></span>
															            <i class="fa fa-shopping-cart"></i>
															            <span class="tooltip-text">Add to Cart</span>
															        </a>
																</div>
																<div class="featured-list tooltip-container">
																    <a href="#quick-view-<?php the_id(); ?>" class="quick-view" data-product-id="<?php echo esc_attr( $product->get_id() ); ?>">
																        <span class="spinner"></span>
																        <i class="fa fa-eye"></i>
																        <span class="tooltip-text">Quick View</span>
																    </a>
																</div>
															</div>
															<div id="quick-view-<?php the_id(); ?>" class="quick-view-popup">
														    	<div class="quick-view-content">
														          <button class="close-quick-view">
														        	<svg viewBox="0 0 28 28" fill="none" >
														        		<g id="SVGRepo_bgCarrier" stroke-width="0"></g>
														        		<g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g>
														        		<g id="SVGRepo_iconCarrier"> <path fill-rule="evenodd" clip-rule="evenodd" d="M5.46967 5.46967C5.76256 5.17678 6.23744 5.17678 6.53033 5.46967L18.5303 17.4697C18.8232 17.7626 18.8232 18.2374 18.5303 18.5303C18.2374 18.8232 17.7626 18.8232 17.4697 18.5303L5.46967 6.53033C5.17678 6.23744 5.17678 5.76256 5.46967 5.46967Z" fill="#000000"></path> 
														        			<path fill-rule="evenodd" clip-rule="evenodd" d="M18.5303 5.46967C18.8232 5.76256 18.8232 6.23744 18.5303 6.53033L6.53035 18.5303C6.23745 18.8232 5.76258 18.8232 5.46969 18.5303C5.17679 18.2374 5.17679 17.7626 5.46968 17.4697L17.4697 5.46967C17.7626 5.17678 18.2374 5.17678 18.5303 5.46967Z" fill="#000000"></path> 
														        		</g>
														        	</svg>
														        </button>
														        <div class="product-details">
														        	<div class="row">
														        		<div class="col-lg-4">
														        			<div class="product-image">
																                <?php
																                if (has_post_thumbnail($loop->post->ID)) {
																                    echo get_the_post_thumbnail($loop->post->ID, 'shop_single');
																                } else {
																                    echo '<img src="' . get_template_directory_uri() . '/images/default.png" alt="featured products" />';
																                }
																                ?>
																            </div>
														        		</div>
														        		<div class="col-lg-8">
														        			<h2><?php the_title(); ?></h2>
														        			<div class="product-price">
																                <?php echo $product->get_price_html(); ?>
																            </div>
														        			<div class="product-description">
																                <?php the_content(); ?>
																            </div>
																            <div class="product-button">
																		        <div class="product-add-to-cart">
																		            <a href="<?php echo esc_url( $product->add_to_cart_url() ); ?>" data-quantity="1" class="button product_type_<?php echo esc_attr( $product->get_type() ); ?> add_to_cart_button">
																					    <i class="fa fa-shopping-cart"></i><span class="tooltip-text">Add to Cart</span>
																					    </a>
																		        </div>
																		        <div class="product-wishlist">
																		            <a href="<?php echo $wishlist_url; ?>" class="add-to-wishlist-button <?php echo $button_class; ?>">		        
																					<i class="fa fa-heart<?php echo $button_class ? '' : '-o'; ?>" aria-hidden="true"></i>
																					<span class="tooltip-text"><?php echo $button_class ? 'Added To Wishlist' : 'Add To Wishlist'; ?></span>
																					</a>
																		        </div>
																		    </div>
														        		</div>
														        	</div>
														        </div>
														    </div>
														</div>
													</div> 
													<div class="featuredproducts-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">
															<?php echo $product->get_price_html(); ?>
														</div>
													</div>				 
												</div>
											</div>
									<?php					
									endwhile; 
										}else{
									?>
									<div class="item  featuredproductsbx wow zoomIn" data-wow-duration="1s">
										<div class="featuredproductsus-single" >
											<div class="featuredproducts-box"> 
												<div class="hi-icon">
													<a href="#">
														<img class="img-responsive" src="<?php echo esc_url(get_template_directory_uri().'/images/feature.png');?>" alt="featured products" />
														<div class="skewd"></div>	
													</a>
												</div>
												<div id="quick-view-<?php the_id(); ?>" class="quick-view-popup">
												    <div class="quick-view-content">
												        <button class="close-quick-view">
												        	<svg viewBox="0 0 28 28" fill="none" >
												        		<g id="SVGRepo_bgCarrier" stroke-width="0"></g>
												        		<g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g>
												        		<g id="SVGRepo_iconCarrier"> <path fill-rule="evenodd" clip-rule="evenodd" d="M5.46967 5.46967C5.76256 5.17678 6.23744 5.17678 6.53033 5.46967L18.5303 17.4697C18.8232 17.7626 18.8232 18.2374 18.5303 18.5303C18.2374 18.8232 17.7626 18.8232 17.4697 18.5303L5.46967 6.53033C5.17678 6.23744 5.17678 5.76256 5.46967 5.46967Z" fill="#000000"></path> 
												        			<path fill-rule="evenodd" clip-rule="evenodd" d="M18.5303 5.46967C18.8232 5.76256 18.8232 6.23744 18.5303 6.53033L6.53035 18.5303C6.23745 18.8232 5.76258 18.8232 5.46969 18.5303C5.17679 18.2374 5.17679 17.7626 5.46968 17.4697L17.4697 5.46967C17.7626 5.17678 18.2374 5.17678 18.5303 5.46967Z" fill="#000000"></path> 
												        		</g>
												        	</svg>
												        </button>
												        <div class="product-details">
												        	<div class="row">
												        		<div class="col-lg-4 col-md-5">
												        			<div class="product-image">
														                <?php
														                if (has_post_thumbnail($loop->post->ID)) {
														                    echo get_the_post_thumbnail($loop->post->ID, 'shop_single');
														                } else {
														                    echo '<img src="' . get_template_directory_uri() . '/images/default.png" alt="featured products" />';
														                }
														                ?>
														            </div>
												        		</div>
												        		<div class="col-lg-8 col-md-7">
												        			<h2><?php the_title(); ?></h2>
												        			<div class="product-price">
														                <?php echo $product->get_price_html(); ?>
														            </div>
												        			 <div class="product-description">
														                <?php the_content(); ?>
														            </div>
														            <div class="product-button">
																        <div class="product-add-to-cart">
																            <a href="<?php echo esc_url( $product->add_to_cart_url() ); ?>" data-quantity="1" class="button product_type_<?php echo esc_attr( $product->get_type() ); ?> add_to_cart_button">
																			    <i class="fa fa-shopping-cart"></i><span class="tooltip-text">Add to Cart</span>
																			        </a>
																        </div>
																        <div class="product-wishlist">
																            <a href="<?php echo $wishlist_url; ?>" class="add-to-wishlist-button <?php echo $button_class; ?>">
																			<i class="fa fa-heart<?php echo $button_class ? '' : '-o'; ?>" aria-hidden="true"></i>
																			<span class="tooltip-text"><?php echo $button_class ? 'Added To Wishlist' : 'Add To Wishlist'; ?></span>
																			</a>
																        </div>
																    </div>
												        		</div>
												        	</div>
												        </div>
												    </div>
												</div>
											</div> 
											<div class="featuredproducts-area-data">
												<a href="#"><h4 class="inner-area-title">Wooden Mirror</h4></a>
												<div class="price">$159.00</div>
												<div class="fea-btn">
													<a href="#">
														<span>Add To Cart</span>
														<span><i class="fa fa-shopping-cart" aria-hidden="true"></i></span>
													</a>
												</div>
											</div>				 
										</div>
									</div>
								<?php }
									//wp_reset_query(); 
								}
							?>
							</div>	
						</div>
					</div>
				</div>
			</div>
			<?php endwhile; // end of the loop. ?>
		</article>
	<div class="clearfix"></div>
	</div>
	<div class="clearfix"></div>
</div>
	</main><!-- #primary -->	
</div>
<div class="clearfix"></div>
<?php get_footer(); ?>
<!-- </?php do_action('woocommerce_before_main_content'); ?>
	</?php if ( apply_filters( 'woocommerce_show_page_title', true ) ) : ?>
		<h1 class="page-title wow zoomIn"></?php woocommerce_page_title(); ?></h1>
	</?php endif; ?>						
	</?php do_action( 'woocommerce_archive_description' ); ?>
<div class="single-productpage">
	<main id="innerpage-box">
		<div id="page" class="container" >
			<div class="inner_contentbox" >		
				<article id="content" class="article single_inner">
					</?php do_action('woocommerce_before_main_content'); ?>
						</?php while ( have_posts() ) : the_post(); ?>
							</?php wc_get_template_part( 'content', 'single-product' ); ?>
						</?php endwhile; // end of the loop. ?>
				</article>
				<div class="clearfix"></div>
			</div>
			<div class="clearfix"></div>
		</div>
	</main>
</div>
<div class="clearfix"></div> -->
<!-- <//?php get_footer(); ?> -->
