WordPress.org

Forums

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

  1. tony123
    Member
    Posted 1 year 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/

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WooCommerce
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic