Get product price range in loop
-
By default, woocommerce uses a price range in the default “archive-product.php” file.
I have a custom loop getting products and I want to show the price range. All my products have variations so there’s multiple prices.
I’m currently using
$product->get_price_html()
which just returns a single price. How do I get this price range?<?php $args = array( 'post_type' => 'product', 'posts_per_page' => -1, 'post_status' => 'publish', ); $query = new WP_Query($args); foreach($query->posts as $p): $pid = $p->ID; $product = new WC_Product( $pid ); ?> <div class="product"> <h2><a href="<?php echo get_permalink($pid); ?>"><?php echo $p->post_title; ?></a></h2> <span class="price"><?php echo $product->get_price_html(); ?></span> </div><!-- /item --> <?php endforeach; ?>
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Get product price range in loop’ is closed to new replies.