Home Forums WoodMart support forum Excluding products in shop by meta data

Excluding products in shop by meta data

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #314062

    skyescott
    Participant

    Hello.

    We have some discontinued products which have a meta tag of “_discontinued-product”. When these values are set (to anything), we want to exclude it from the shop loop.

    We have tried this by modifying our functions.php file with variations of this entry:

    function remove_discontinued_4(){
        
        if( ! is_shop() ) return $meta_query;
    
        $meta_query[] = array(
             'key' => '_discontinue_product',
             'compare' => 'NOT EXISTS' 
            );
    
        return $meta_query;
    }
    
    add_filter( 'woocommerce_product_query_meta_query', 'remove_discontinued_4', 10, 2 );

    This WORKS, but we have alot of products (around 2000) plus variations – so this becomes VERY VERY slow, adding about 30 full seconds to the page load time, which is unacceptable for the user experience.

    Is there a way to do this through woodmart that I’ve missed? Or perhaps you have a suggestion on how to achieve this without such a huge lag?

    Thanks in advance!
    ~S

    #314178

    Hello,

    Woocommerce customization is not covered by our support. Please try to find a plugin that would ensure you what you need.

    If you have any questions please feel free to contact us.

    Best Regards

Viewing 2 posts - 1 through 2 (of 2 total)