• 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://www.ads-software.com/plugins/woocommerce/

  • The topic ‘Problem displaying simple products and product variations on sale page!’ is closed to new replies.