Page 1 of 1

[SOLVED] remove add to cart until person has loged in

Posted: Thu Nov 24, 2011 7:22 pm
by davidbni
I need to be able to disable the add to cart only when a person is not loged in kinda like the way hide prices until log in works where is the code for this can i hide the add to cart button same way ?

I am using opencart version 1.5.1 also is their a relleax payment module for this version

Re: remove add to cart until person has loged in

Posted: Thu Nov 24, 2011 7:37 pm
by fido-x
In the template files for some of your modules (latest, featured, special) and some of the product related files (category, manufacturer, special, search, compare), you will find the following (somewhere within each file):

Code: Select all

<a onclick="addToCart('<?php echo $product['product_id']; ?>');" class="button"><span><?php echo $button_cart; ?></span></a>
Replace with:

Code: Select all

<?php if ($this->customer->isLogged()) { ?><a onclick="addToCart('<?php echo $product['product_id']; ?>');" class="button"><span><?php echo $button_cart; ?></span></a><?php } ?>
And, in the product template file, find:

Code: Select all

<a id="button-cart" class="button"><span><?php echo $button_cart; ?></span></a>
and replace with:

Code: Select all

<?php if ($this->customer->isLogged()) { ?><a id="button-cart" class="button"><span><?php echo $button_cart; ?></span></a><?php } ?>

Re: remove add to cart until person has loged in

Posted: Thu Nov 24, 2011 8:16 pm
by davidbni
thanks

Re: remove add to cart until person has loged in

Posted: Sun Jan 29, 2012 1:02 am
by santana
fido-x wrote:In the template files for some of your modules (latest, featured, special) and some of the product related files (category, manufacturer, special, search, compare), you will find the following (somewhere within each file):

Code: Select all

<a onclick="addToCart('<?php echo $product['product_id']; ?>');" class="button"><span><?php echo $button_cart; ?></span></a>
Replace with:

Code: Select all

<?php if ($this->customer->isLogged()) { ?><a onclick="addToCart('<?php echo $product['product_id']; ?>');" class="button"><span><?php echo $button_cart; ?></span></a><?php } ?>
And, in the product template file, find:

Code: Select all

<a id="button-cart" class="button"><span><?php echo $button_cart; ?></span></a>
and replace with:

Code: Select all

<?php if ($this->customer->isLogged()) { ?><a id="button-cart" class="button"><span><?php echo $button_cart; ?></span></a><?php } ?>
hi guys
thank you Fido-x, i used it and it was great
one thing more i like to add to help
because this changes used for guests of the website, which in my case (resellers only website)
another thing must be done
removing add to wishlist, because simply its not useful (guest must login to see it)
with help fido-x code above, i make add to wishlist become Request quote, that direct guest to contact form
lets start .....
first
replace:

Code: Select all

<a onclick="addToWishList('<?php echo $product['product_id']; ?>');"><?php echo $button_wishlist; ?></a>
in most pages fido-x mentioned above with:

Code: Select all

<?php if (!$this->customer->isLogged()) { ?>
  <a href="<?php echo $contact; ?>">request quote</a>
       <?php } else { ?>
   <a onclick="addToWishList('<?php echo $product['product_id']; ?>');"><?php echo $button_wishlist; ?></a>
    <?php } ?>
then you have to go to controllers/product and add this to all .php anywhere:

Code: Select all

$this->data['contact'] = $this->url->link('information/contact');
you should do more changes if your website is multilanguage

again I'm not coder ore in IT business at all, but guys here are so great, and make it easy for people like me ;D