Magento – Magento 2 – how to redirect to popup login form while add a product to wishlist

magento2wishlist

I add a popup login form in my magento 2 template and when I add a product to the wishlist and I'm not logged in, I want to show the popup for the login and then add to wishlist the product.

Anyone knows how to do it?

Thanks

Best Answer

You can use code:

  1. code html:

you can looking at vendor/magento/module-customer/view/frontend/templates/form/login.phtml

  1. add in your layout

    <referenceContainer name="before.body.end">
        <block class="\Magento\Customer\Block\Form\Login" name="mlx_guestwishlist2_js" template="Magento_Customer::form/login.phtml"/>
    </referenceContainer>
    
  2. add styles

.block-customer-login{display: none;}

  1. add js


jQuery('.towishlist')
    .removeAttr('data-post')
    .click(function(){
        jQuery('.block-customer-login').show();
    });

Related Topic