• Resolved kookaburrainternational

    (@kookaburrainternational)


    Hi Support,

    Using Version 1.0.4, after I created the gifts in the product list with $0 price. How can I hide these gifts in the shop?

    Thanks and Best Regards,
    Thomas

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Plugin Author DecomTeam

    (@decomteam)

    Hi @kookaburrainternational you can create category then exclude that category using a action woocommerce_product_query inside your functions.php file.
    Here is a gist link and here is a code:

    add_action( 'woocommerce_product_query', 'giftable_custom_pre_get_posts_query' );
    function giftable_custom_pre_get_posts_query( $exclude_query ) {
    	if( is_shop() || is_page('or-some-special-page') ) { // set conditions here
    	    $tax_query = (array) $exclude_query->get( 'tax_query' );
    	    $tax_query[] = array(
    	           'taxonomy' => 'product_cat',
    	           'field'    => 'slug',
    	           'terms'    => array( 'exclude', 'gifts' ), // excluded categories
    	           'operator' => 'NOT IN'
    	    );
    	
    	    $exclude_query->set( 'tax_query', $tax_query );
    	}
    }
    • This reply was modified 5 years, 3 months ago by DecomTeam.
Viewing 1 replies (of 1 total)
  • The topic ‘Don’t want to show the gifts on shop.’ is closed to new replies.