firing woocommerce filter on specific page

Viewed 18

I'm trying to enable backorders for all woocommerce products when the products are viewed through product tables. A plugin called with a shortcode through a wordpress page. i use this code to fire the filters:

add_filter( 'template_include', function( $template ) {
    if (is_page('forma-paraggelias')) {     
        add_filter( 'woocommerce_product_get_backorders', 'filter_get_backorders_callback', 10, 2 );
        add_filter( 'woocommerce_product_variation_get_backorders', 'filter_get_backorders_callback', 10, 2 );
        //return $template;
    }
    return $template;
});
function filter_get_backorders_callback( $backorders_status, $product ){
    error_log( 'filter fired');
    return 'yes';
}

however the filters are not fired. Maybe because of nested filters(add_filter inside add_filter)?

any clues on how to fire the filter inside the specific page?

0 Answers
Related