loisetornadozzx Posted December 13, 2023 Share Posted December 13, 2023 Hi, I'm building a module for my client. This is my client's requirement. How to force user login when trying to add product to cart and after login the product should be in the cart and also redirect the user to the product page. do anyone has any opinion or suggestions? Link to comment Share on other sites More sharing options...
ps8modules Posted December 13, 2023 Share Posted December 13, 2023 Hi It is better to change the behavior of the add to cart button in TPL than to make such confusion and redirection (you will lose the customer). Add a condition, if the user is not logged in, display a modal window for login or registration. But even this does not ensure that the customer buys the product and does not leave. Link to comment Share on other sites More sharing options...
SorelRouge Posted February 9 Share Posted February 9 Hi, I have the same question. I would like to open a login form (like you suggest by displaying a modal window for login or registration) from the "add to cart" button but I'm a bit confused on how to do that. I'm currently trying things in product-add-to-cart.tpl, for exemple by adding behavious from ps_customersignin.tpl when user is not logged but that doesn't semm to work. <div class="add col-auto"> {if !$logged} //open login form {/if} <button class="btn btn-blue add-to-cart btn-lg btn-block btn-add-to-cart js-add-to-cart" data-button-action="add-to-cart" type="submit" {if !$product.add_to_cart_url} disabled {/if} > <span class="btn-add-to-cart__spinner" role="status" aria-hidden="true"></span> {l s='Add to cart' d='Shop.Theme.Actions'} </button> </div> Any idea on how to do that ? Like @loisetornadozzx, I would like the customer, once logged in, to be redirected in the product page with the product in the cart. Thank you in advance for your time and your help ;) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now