This topic has 4 replies, 2 voices, and was last updated 7 years, 4 months ago ago by Laranz
Hi,
How can make a shop page which displays only products that are on sale at the moment? I managed to do this by making a category named “SALE”. But it is time consuming to assign many products to a category and after end of sale to delete this assignment. Is it possible to make such page which automatically displays all products on sale?
Thanks in advance
Marcin
Hi Marcin,
Can you try adding this in to your child theme’s functions.php?
add_action( 'woocommerce_product_query', 'theme8_onsale_items' );
function theme8_onsale_items( $q ){
$product_ids_on_sale = wc_get_product_ids_on_sale();
$q->set( 'post__in', $product_ids_on_sale );
}
Let us know,
Thanks,
laranz.
Hi, thank you for the answer. I added the code to functions.php in child theme but what should I do next. I can’t see any changes for now (no new widget for example). I would like to have – apart from existing pages – a standard shop page displaying only products on sale. Could you please give me step-by-step instructions.
Thanks.
Hi,
I thought you want the shop page to include only the sale items, if that is not the case please remove the snippet in the functions.php file, You can do two ways,
1. Use the “Products” widget from the Visual Composer element list,
OR
2. Use the default Woocommerce shortcode, https://docs.woocommerce.com/document/woocommerce-shortcodes/#section-15
Let us know,
Thanks,
laranz.
You must be logged in to reply to this topic.Log in/Sign up