• Hi,
    First of all I want to congratulate with the developer group for having done a very good job with this plugin. I want to know if is possible to disable the “Add to Wishlist” c.t.a. in products that refer to a specific category.
    Thanks

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

    (@yithemes)

    Hi there

    Thank you, we appreciate your support ??
    Yes, you can disable wishlist for specific product categories, but you’ll need some custom coding

    Try to add the following snippet of code at the end of functions.php file of your theme or child theme

    if ( ! function_exists( 'yith_wcwl_show_add_to_wishlist_button' ) ) {
    	function yith_wcwl_show_add_to_wishlist_button( $show ) {
    		global $product;
    
    		$excluded_categories = array(
    			'category-1',
    			'category-2',
    		);
    		$product_categories = wp_get_post_terms( $product->get_id(), 'product_cat' );
    		$product_categories = $product_categories ? wp_list_pluck( $product_categories, 'slug' ) : array();
    
    		if ( array_intersect( $excluded_categories, $product_categories ) ) {
    			return false;
    		}
    
    		return $show;
    	}
    	add_filter( 'yith_wcwl_show_add_to_wishlist', 'yith_wcwl_show_add_to_wishlist_button', 10, 1 );
    }
    

    Of course you should change the list of exclued cateories as it is relevant for you

Viewing 1 replies (of 1 total)
  • The topic ‘Disable wishlist button for some categories’ is closed to new replies.