Post by davidbni » Thu Nov 24, 2011 7:22 pm

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

Newbie

Posts

Joined
Thu Nov 24, 2011 7:19 pm

Post by fido-x » Thu Nov 24, 2011 7:37 pm

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 } ?>

Image
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool

If you're not living on the edge ... you're taking up too much space!


User avatar
Expert Member

Posts

Joined
Sat Jun 28, 2008 1:09 am
Location - Tasmania, Australia

Post by davidbni » Thu Nov 24, 2011 8:16 pm

thanks

Newbie

Posts

Joined
Thu Nov 24, 2011 7:19 pm

Post by santana » Sun Jan 29, 2012 1:02 am

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

Newbie

Posts

Joined
Fri Jan 27, 2012 12:19 am
Who is online

Users browsing this forum: No registered users and 19 guests