I want to create a page in WooCommerce that shows only product untilspecific price. For example I want to show all products that whose prices not big than 50$.
How i can do this? Thanks :)
I want to create a page in WooCommerce that shows only product untilspecific price. For example I want to show all products that whose prices not big than 50$.
How i can do this? Thanks :)
This can be achieved using the following code, by writing custom query:
$paged = (get_query_var('paged'))? get_query_var('paged') : 1;
$price_limit = 50;
$args = array('paged' => $paged,
'post_type' => array('product','product_variation')
'post-status' =>'publish',
'meta_key' => '_price',
'meta_query' => array(
array(
'key' => '_price',
'value' => $price_limit
'compare' => '<=',
)
)
);
$wp_query = new WP_Query( $args );
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php //code to represent product list ?>
<?php endwhile; ?>
<?php wp_reset_postdata(); ?>
<?php else : ?>
<?php echo "Data not found"; ?>
<?php endif; ?>
Here, change $price_limit
value to as per the requirement.