LATEST >>

Welcome Here And Thanks For Visiting. Like Us On Facebook...

EXEIdeas – Let's Your Mind Rock » WordPress / WordPress ECommerce / WordPress Snippets » Display WooCommerce On-Sale Products From All Products

Display WooCommerce On-Sale Products From All Products

Display-WooCommerce-On-Sale-Products-From-All-Products
Woocommerce is a free Ecommerce plugin for WordPress blog that will change over your WordPress blog into a web shopping store page. Without a moment’s hesitation there are different point open by Woocommerce staff or untouchables to make your store sweet however if you need to make your particular then it is more remarkable.

So for them, who are organizing their particular Woocommerce point oblige some distinctive kind of codes to make there subject extraordinary. Immediately you comprehend that Woocommerce have its particular subject pages yet on the off chance that you need to show there things on your interestingly made pages with some exceptional eccentricities then you can additionally do it. Woocommerce things fills in as WordPress and additional all information as WordPress posts do so its question is pretty much in like way same that will make Woocommerce thing round with all exceptional information. It will pick Woocommerce just onsale items included things in same style as indicating on Shop page.

You can show new things on your any custom pages. You can fuse some just at a bargain things on your rule page to attract guests that you have such splendid things so to see more things , you need to view our shop page. In this demand that limit as WordPress round, you can also control that what number of things you need to show too. So now without any more prelude, starting late push forward to the piece and duplicate it.

How To Display WooCommerce On-Sale Products From All Products?

<ul class="products">
 <?php
 $args = array(
 'post_type' => 'product',
 'posts_per_page' =&gt 4,
 'meta_query' => array(
 'relation' => 'OR',
 array( // Simple products type
 'key' => '_sale_price',
 'value' => 0,
 'compare' => '>',
 'type' => 'numeric'
 ),
 array( // Variable products type
 'key' => '_min_variation_sale_price',
 'value' => 0,
 'compare' => '>',
 'type' => 'numeric'
 )
 )
 );
 $loop = new WP_Query( $args );
 if ( $loop->have_posts() ) {
 while ( $loop->have_posts() ) : $loop->the_post();
 woocommerce_get_template_part( 'content', 'product' );
 endwhile;
 } else {
 echo __( 'No products found' );
 }
 wp_reset_postdata();
 ?>
</ul>
<ul class="products">
 <?php
 $args = array(
 'post_type' => 'product',
 'posts_per_page' =&gt 4,
 'meta_query' => array(
 'relation' => 'OR',
 array( // Simple products type
 'key' => '_sale_price',
 'value' => 0,
 'compare' => '>',
 'type' => 'numeric'
 ),
 array( // Variable products type
 'key' => '_min_variation_sale_price',
 'value' => 0,
 'compare' => '>',
 'type' => 'numeric'
 )
 )
 );
 $loop = new WP_Query( $args );
 while ( $loop->have_posts() ) : $loop->the_post(); global $product; ?>
 <li class="product"> 
 <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); ?>">
 <?php woocommerce_show_product_sale_flash( $post, $product ); ?>
 <?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" width="300px" height="300px" />'; ?>
 <h3><?php the_title(); ?></h3>
 <span class="price"><?php echo $product->get_price_html(); ?></span> 
 </a>
 <?php woocommerce_template_loop_add_to_cart( $loop->post, $product ); ?>
 </li>
 <?php endwhile; ?>
 <?php wp_reset_query(); ?>
</ul>

Customization:

You can control that how many On-Sale products you want to show through this snippet in upper code. YOu can also pick random products from On-Sale too.

Last Words:

This is what we have and shared in easy steps for newbies so that they can easily know how it works. Stay with us because we are going to share a whole guide step by step about WordPress and make it easy for you. If you liked it then share it and be with us to get next tutorial. If you have any problem then feel free to ask us. We will help you with what we can or have.

You Like It, Please Share This Recipe With Your Friends Using...

Be the first to write a comment.

Leave a Reply

Your email address will not be published. Required fields are marked *