Exclude Out of Stock Products from a sale

This requires the PW On Sale! Pro version.

1. Download the free Code Snippets plugin: https://wordpress.org/plugins/code-snippets/
2. Create a Snippet with the following code:

(You can optionally add this to your functions.php if you’re more familiar with that process instead.)

function custom_pwos_product_include_in_sale( $product_included, $product, $sale ) {
    if ( is_a( $product, 'WC_Product' ) && ! $product->is_in_stock() ) {
        $product_included = false;

    return $product_included;
add_action( 'pwos_product_include_in_sale', 'custom_pwos_product_include_in_sale', 10, 3 );
Skip to content