• scottking

    (@scottking)


    I would like to display a link to the Wishlist in various places on my site but only if there are items in the Wishlist. Please advise how I can show the Wishlist link conditionally.

    This would be a useful feature addition, a Wishlist menu item built with this logic.

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

Viewing 1 replies (of 1 total)
  • Plugin Author Pablo Pacheco

    (@karzin)

    Hello,
    You could do it like this:

    <?php
    if ( is_user_logged_in() ) {
    	$user             = wp_get_current_user();	
    	$wishlisted_items = Alg_WC_Wish_List::get_wish_list( $user->ID );
    } else {
    	$wishlisted_items = Alg_WC_Wish_List::get_wish_list();
    }
    
    if( is_array ( $wishlisted_items ) && count( $wishlisted_items ) > 0 ){
    	// There are items in the wishlist, do whatever you want
    }
    
Viewing 1 replies (of 1 total)
  • The topic ‘How To Show Wishlist Link Conditionally’ is closed to new replies.