Sale products
For displaying on sale products with WooCommere the [products on_sale="true"]
or [sale_products]
shortcodes can be used. If your WooCommerce version is lower than 3.2 then you can only use the latter since the [products]
shortcode did not support the on_sale
attribute in the earlier versions.
The appearance of the displayed products depends on your active theme, the following examples are using Chap theme, but the shortcodes work with any theme as long as you’re using WooCommerce.
<products limit="8" columns="4" on_sale="true" />
<sale_products columns="3" per_page="3">
On sale shortcode displaying products that are not on sale
In some circumstances the shortcode is known to not work properly and display products that are not currently on sale.
When this happens you can try the following:
If all else fails and it’s critical to not display non-sale products you could use JavaScript as a temporary fix:
jQuery(function($){
$('.woocommerce[class*="columns-"] .product:not(.sale)').hide();
});