NO BUG: Sale products in query Loop

Hi Jolia,
Thanks so much for your report.

  1. this is the purpose of the object cache. If it is not cleared, it shows the cached data. If your products change frequently you should not use this option.

  2. we use a function provided by WooCommerce in the products element. If you use a custom loop, you are responsible for the correct query and due to the complexity of variable products, the simple orderby setting is not sufficient.

a) Add this to the query editor (without any other query settings)

return [
    'post_type' => array('product'),
    'posts_per_page' => -1,
    'orderby' => 'meta_value_num',
    'meta_key' => '_price',
    'order' => 'ASC',
    'post__in' => wc_get_product_ids_on_sale(),
];

We are already working on a simpler solution for the query loop to include on sale and featured products and hide out of stock products.

Best regards,
timmse

2 Likes