I am wanting to display each WooCommerce product in a loop while ( $loop -> have_posts() ) : $loop -> the_post(); whilst being displayed in a list view by using the following:
do_action( 'woocommerce_single_product_summary');
Could anyone please provide me with a method of how I could achieve this?
This is the following code I have in place:
<ul class="products">
<?php
$args = array( 'post_type' => 'product', 'posts_per_page' => 3 );
$loop = new WP_Query( $args );
$interval = 1;
while ( $loop -> have_posts() ) : $loop -> the_post();
$productId = get_the_ID();
$product = get_product( $productId );
?>
<?php if ($interval % 2 != 0): ?>
<img class="arch" src="/wp-content/uploads/2019/02/main-pages-blue-background-arch-top.png">
<?php endif; ?>
<li class="product" style="<?php echo ($interval % 2 != 0 ? "background-color: #f2fafd" : ""); ?>">
<div class="content">
<a href="<?php echo get_permalink( $loop -> post -> ID ) ?>" title="<?php echo esc_attr($loop -> post -> post_title ? $loop -> post -> post_title : $loop -> post -> ID); ?>">
do_action( 'woocommerce_before_single_product' );
</a>
</div>
<!-- <?php woocommerce_template_loop_add_to_cart( $loop-> post, $product ); ?> -->
</li>
<?php if ($interval % 2 != 0): ?>
<img class="arch arch-bottom" src="/wp-content/uploads/2019/02/main-pages-white-background-arch-top.png">
<?php endif; ?>
<?php $interval += 1; ?>
<?php endwhile; ?>
<?php wp_reset_query(); ?>
</ul>
Essentially I'm trying to place single products in a list view that will then loop through each product for a certain category.
Thanks.