• Resolved davidoso

    (@davidoso)


    How to exclude out of stock products from cache. Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • mukoka

    (@mukoka)

    This would require a certain function, which the LScache plugin does not provide, but which would be technically possible through LSache.

    Plugin Support qtwrk

    (@qtwrk)

    add_action( 'template_redirect', 'check_product_stock_nocache' );
    
    function check_product_stock_nocache() {
        if ( is_product() ) {
            $product = wc_get_product( get_the_ID() );
            if ( defined('LSCWP_V') && ! $product->is_in_stock() ) {
                do_action( 'litespeed_control_set_nocache', 'nocache due to no stock');
            }
        }
    }
    

    please try add this to theme’s functions.php

    Thread Starter davidoso

    (@davidoso)

    It works! Thank you very much.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Exclude out of stock products from cache’ is closed to new replies.