deepankar Posted April 30, 2015 Share Posted April 30, 2015 Hello there, I want to change some functionality of cart as following: (1) user need to be logged in for adding product in cart . (2)If user who is not logged in whether they are guest or visitor , if they click add to cart button they will first have to login/register themselves then product will be added in their cart . I need help in this topic. How can I do this ?? :( though I am also aware of this topic: [ https://www.prestashop.com/forums/topic/81810-disable-add-to-cart-button-for-unregistered-visitors/ ] but I don't want to achieve this thing . I want to make condition here so that if guest or visitor click add to cart button firstly they will redirect to login page and then they will be able to add product in cart . Link to comment Share on other sites More sharing options...
tuk66 Posted May 5, 2015 Share Posted May 5, 2015 I think I saw a module for this - users who are not logged see just the catalog (not shop). Link to comment Share on other sites More sharing options...
deepankar Posted May 5, 2015 Author Share Posted May 5, 2015 thanks for your reply...yeah exactly I want to do same thing. I found the solution for it . Just use following code in override/controllers/front directory in your prestashop dir. <?php /* Copyright (C) 2015 by Iriemo Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ class CartController extends CartControllerCore { public function init() { parent::init(); if (!self::$cookie->isLogged(false)) { // not logged in if (Tools::getValue('ajax') === 'true' && Tools::getValue('add') === '1') // ajax cart die('{"hasError" : true, "errors" : ["' . Tools::displayError('Please login first.', false) . '"]}'); else $this->errors[] = Tools::displayError('Please login first.'); } } } ?> But I want More functionality like if user is not logged in and he/she is clicking ADD TO CART button, they need to be redirected in login page like following snapshot : For New Account : For Login : it should be directly prompted login or sign up (toggle tab) hover page . How can I create a module for this kind of functionality? Link to comment Share on other sites More sharing options...
ABANGWEB Posted July 4, 2015 Share Posted July 4, 2015 Any update.. Please someone answer this, i need costumer register or login if click checkout button in cart on top or if they go to order page. Link to comment Share on other sites More sharing options...
ABANGWEB Posted July 4, 2015 Share Posted July 4, 2015 Ah got it just use one page checkout and maintenance with some subject to hidden with {if $logged} .. {/if} cek gudangimpor.com/quick-order or add some product to cart for test. Link to comment Share on other sites More sharing options...
musicmaster Posted July 5, 2015 Share Posted July 5, 2015 {if $logged} add to cart button {else} add to cart button as image - and link code around it that leads to login page {/if} 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