WordPress.org

Ready to get started?Download WordPress

Forums

YITH WooCommerce Wishlist
how to use add to wish list is availabe for logged users (20 posts)

  1. sunil ch
    Member
    Posted 6 months ago #

    Hi
    i am trying to make add to wish list button is available only for logged in users

    if the user is not logged in the it will ask for login

    any suggestions

    Thanks in advance

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

  2. kamleshpawar2006
    Member
    Posted 4 months ago #

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

  3. gphx
    Member
    Posted 2 months ago #

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

  4. gphx
    Member
    Posted 2 months ago #

    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;
        }
    }
  5. rms9886
    Member
    Posted 1 month ago #

    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

  6. kamleshpawar2006
    Member
    Posted 1 month ago #

    Apply is_user_logged_in() function to the wishlist shortcode.

    if(is_user_logged_in()) {
        echo do_shortcode('[yith_wcwl_add_to_wishlist]' );
     }
  7. rms9886
    Member
    Posted 1 month ago #

    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.

  8. kamleshpawar2006
    Member
    Posted 1 month ago #

    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;
    }
  9. John Doe
    Member
    Posted 1 month ago #

    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/

  10. kamleshpawar2006
    Member
    Posted 1 month ago #

    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 .

  11. John Doe
    Member
    Posted 1 month ago #

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

  12. John Doe
    Member
    Posted 1 month ago #

    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]' );
    }

  13. kamleshpawar2006
    Member
    Posted 1 month ago #

    where did you added the above code?

  14. John Doe
    Member
    Posted 1 month ago #

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

    The wishlist function is still not working. Please help.

    Thanks.

  15. kamleshpawar2006
    Member
    Posted 1 month ago #

    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/

  16. John Doe
    Member
    Posted 1 month ago #

    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.

  17. John Doe
    Member
    Posted 1 month ago #

    An addition to my above reply: The button already appears on the product page.

  18. kamleshpawar2006
    Member
    Posted 1 month ago #

    This plugin(https://wordpress.org/plugins/yith-woocommerce-wishlist/) is an extenstion to woocommerce plugin.

  19. kamleshpawar2006
    Member
    Posted 1 month ago #

    You should create a new post and discuss the topic there

  20. John Doe
    Member
    Posted 1 month ago #

    Ok. Thanks a lot for your patience and help.

Reply

You must log in to post.

About this Plugin

About this Topic

Tags