1

This is a 2 part question:

  1. Currently if a guest customer presses "Add to Wishlist" button they are redirected to the login/register page without any message. How would I go about adding a message such as "The add to wishlist feature is only available to registered users, please login or signup for an account to use it".
  2. Once the customer has logged in after pressing the "Add to Wishlist" button they are redirected to the wishlist page but it does not added the product. How can I get it to add the product after login or alternatively redirect to the product page with a message to say you can now add to wishlist.
1

This is about question number 1.

You can create a script on your list.phtml or any phtml file that has a add to wishlist link.

app/design/vendor_name/theme_name/Magento_Catalog/templates/product/list.phtml

app/design/vendor_name/theme_name/Magento_Wishlist/templates/catalog/product/view/addto/wishlist.phtml

As you can see below just add your add to wishlist link class on the jquery function.

<script>
    require(["jquery"], function($){
        $(".your_add_to_wishlist_class_in_here").click(function()
        {
            alert("You need to Login/Register before you can proceed.");
        });

    });
</script> <!-- Custom Script to inform users that they need to create an account before using this feature. -->

Here's my wishlist.phtml code screenshot enter image description here

I hope this method will help you.

  • using above code i got this error "Uncaught Error: Call to a member function getTypeId() on null" – sudo55 May 3 at 9:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.