Viewing 15 replies - 1 through 15 (of 19 total)
  • Kamlesh

    (@kamleshpawar2006)

    hi sunil,
    i also wants this functionality, have you found any solution on this?

    I’m also looking for a solution to this. Any luck?

    The solution I am using: hide the actual wishlist page for logged-out users. When they click the ‘Wishlist’ page, it will re-direct them to the Register page. If they’re logged in, it will take them to the Wishlist page.

    Add this code to your functions.php file – hope this helps!

    add_action( 'template_redirect', 'redirect_to_specific_page' );
    
    function redirect_to_specific_page() {
    
    if ( is_page('slug') && ! is_user_logged_in() ) {
    
    wp_redirect( 'http://www.example.dev/your-page/', 301 );
      exit;
        }
    }

    hi ghpx
    i am trying to make add to wish list button is available only for logged in users
    I placed your code in functions.php but no luck
    Please any further help would be appreciated.

    Thanks in advance

    Kamlesh

    (@kamleshpawar2006)

    Apply is_user_logged_in() function to the wishlist shortcode.

    if(is_user_logged_in()) {
        echo do_shortcode('[yith_wcwl_add_to_wishlist]' );
     }

    Thank you kamleshpawar for the reply and any idea on how to display the wishlist count in main menu adjacent to the menuitem name or in custom link.

    Thanks in advance.

    Kamlesh

    (@kamleshpawar2006)

    Write this code in your themes functions.php

    add_filter( 'wp_nav_menu_items', 'wishlist_count', 10, 2 );
    function wishlist_count( $items, $args ) {
        if( is_user_logged_in() ) {
                            $current_user = wp_get_current_user();
                            $user_id = $current_user->ID;
        			$sql = "SELECT COUNT(*) as cnt FROM YITH_WCWL_TABLE  WHERE user_id = " . $user_id;
        			$results = $wpdb->get_results( $sql );
        			$count = $results[0]->cnt;
                            $items .= '<li><a href="#">'.$count.'</a></li>
    ';
        }
        return  $items;
    }

    Hello kamleshpawar2006

    I am facing two problems:

    1. When I login and click on an item, it says ‘Product Added. Browse Wishlist.’ But when I click on ‘Browse Wishlist,’ it says, ‘No products were added to the wishlist.’

    2. How can I add Wishlist as a link on a menu so that each user can see her wishlist?

    https://wordpress.org/plugins/yith-woocommerce-wishlist/

    Kamlesh

    (@kamleshpawar2006)

    You need to create a page which will show you users wishlist.Create a page with shortcode [yith_wcwl_wishlist] and add this page on your primary menu .

    Thanks for your reply. I have tried it but I still get the same result: ‘No products were added to the wishlist.’

    Please also tell if all of the above codes (especially the following code) must be added to the functions.php

    if(is_user_logged_in()) {
    echo do_shortcode(‘[yith_wcwl_add_to_wishlist]’ );
    }

    Kamlesh

    (@kamleshpawar2006)

    where did you added the above code?

    I added above codes in functions.php and exchanged my site’s address in the line ‘wp_redirect( ‘http://www.example.dev/your-page/&#8217;, 301 );’

    The wishlist function is still not working. Please help.

    Thanks.

    Kamlesh

    (@kamleshpawar2006)

    The shortcode [yith_wcwl_add_to_wishlist] generates add to wishlist link on products page.
    You need to place this code in single products page simple.php and variable.php located in the plugins folder woocommerce/templates/single-product/add-to-cart/

    Dear kamleshpawar2006

    I am using a child theme and simple.php and variable.php are not accessible from within the child theme.

    I was hoping this would be just a ‘plug-and-play’ plugin but it seems it would require tweaking and coding.

    If you think the problem is getting more complex than being resolved, please feel free to stop. I’ll just remove the plugin and report it as broken.

    Thanks.

Viewing 15 replies - 1 through 15 (of 19 total)
  • The topic ‘how to use add to wish list is availabe for logged users’ is closed to new replies.