<?php

	$user_id = get_current_user_id();
    $current_user= wp_get_current_user();
    $customer_email = $current_user->email;

    $args = array( 'post_type' => 'product', 'stock' => 1, 'posts_per_page' => 3, 'orderby' =>'date','order' => 'DESC' );
    $loop = new WP_Query( $args );

    if ( $loop->have_posts() ) :
	    while ( $loop->have_posts() ) : $loop->the_post(); global $product; 

	    	if (!wc_customer_bought_product($customer_email, $user_id,$product->id)) :

	    		$add_to_cart = do_shortcode('[add_to_cart_url id="' . $post->ID . '"]'); 

	    	?>

			<div class="product_container">

				<a id="id-<?php the_id(); ?>" href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" class="product_thumb">
					  <?php if (has_post_thumbnail( $loop->post->ID )) echo get_the_post_thumbnail($loop->post->ID, 'shop_catalog'); else echo '<img src="'.woocommerce_placeholder_img_src().'" alt="Placeholder"  />'; ?>
				</a>

				<div class="product_content">

					<h3>
						<a id="id-<?php the_id(); ?>" href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
							<?php the_title(); ?>
							<span>
								<?php echo $product->get_price_html(); ?>
							</span>
						</a>
					</h3>

					<a href="<?=$add_to_cart;?>" data-color-override="false" class="nectar-button accent-color medium">Buy Now</a>

				</div>

			</div>	
			<?php endif; ?>
		<?php endwhile; ?>
	<?php endif; ?>

<?php wp_reset_query(); ?>