WordPress.org

Forums

WooCommerce - excelling eCommerce
Problem displaying simple products and product variations on sale page! (1 post)

  1. tony123
    Member
    Posted 11 months ago #

    Im nearly finished with the woocommerce development for a site that im working on and I'm stuck on the page that displays the sale posts.

    I would like it to feed out simple products as well as the product variations that its feeding onto the sale page. Is there some type of 'OR' code that can be added to this function?

    Thanks

    add_action('pre_get_posts','sale_items');
    
    // grab sale items
    function sale_items($query) {
    
        if (!is_admin() && ($query->is_post_type_archive( 'product' ) || $query->is_tax( get_object_taxonomies( 'product' ))) && isset($_GET['sale']) && $_GET['sale'] == 1) {
    
             $meta_query = array(
    
                   array(
    
                       'key' => '_min_variation_sale_price',
    
                       'value' => 0,
    
                       'compare' => '>',
    
                       'type' => 'numeric'
    
                   ),
    
             );
    
             $query->set('meta_query',$meta_query);
    
        }
    
    }
    
     // end grab sale items

    https://wordpress.org/plugins/woocommerce/

Reply

You must log in to post.

About this Plugin

  • WooCommerce - excelling eCommerce
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic