Page 1 of 1

[SOLVED]Add to cart Login pop up

Posted: Tue Oct 11, 2011 9:56 pm
by Wardy_118
Hi,

I am currently using opencart v1.5.0 for my website. I have set the pricing to only be displayed once a customer has logged in to their account. However, I notice that without being logged in you can still add products to your shopping cart. They just show without the price being displayed in the cart.

I was wondering if it would be possible that if someone is not logged in and they click "Add to cart" that a pop up message would come up on the screen saying "To add products to your shopping cart please login". As well as this pop up the product itself would not be added to the shopping cart like it currently is. So you are only able to see products in the cart once you have logged in.

Can anybody help with this.

Thanks in advance.

Re: Add to cart Login pop up

Posted: Wed Oct 12, 2011 6:49 pm
by uksitebuilder
OK big edit

for each of the following files
Untitled-1.png

Untitled-1.png (3.41 KiB) Viewed 8952 times

find

Code: Select all

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

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 }else{ ?><a onclick="alert('Please Login to View Prices and Add to Cart!');" class="button"><span><?php echo $button_cart; ?></span></a><?php } ?>
and also

open: catalog/view/theme/default/template/product/product.tpl

find

Code: Select all

<a id="button-cart" class="button"><span><?php echo $button_cart; ?></span></a>
change to

Code: Select all

<?php if($this->customer->isLogged()){ ?><a id="button-cart" class="button"><span><?php echo $button_cart; ?></span></a><?php }else{ ?><a onclick="alert('Please Login to View Prices and Add to Cart!');" class="button"><span><?php echo $button_cart; ?></span></a><?php } ?>

[SOLVED]Re: Add to cart Login pop up

Posted: Wed Oct 12, 2011 8:18 pm
by Wardy_118
Hi Simon,

It is now working great.

Thanks so much for all of your help.

Re: [SOLVED]Add to cart Login pop up

Posted: Sun Feb 12, 2012 2:14 am
by VAHID
hi simon
i need this for addition image popup in product page
What do I need to change?
thanks

Re: [SOLVED]Add to cart Login pop up

Posted: Fri Mar 30, 2012 9:29 pm
by spitos
Vqmod here to help anyone out too.

Re: [SOLVED]Add to cart Login pop up

Posted: Tue Apr 24, 2012 7:11 am
by variuxdavid
I've updated the vqmod for Add To Cart Login Aleart for OpenCart Version 1.5.2.1

I removed the wishlist.tpl, because it seems you can't view a wishlist unless you are logged in anyway.

Enjoy,

Re: [SOLVED]Add to cart Login pop up

Posted: Thu May 10, 2012 10:13 pm
by halena
Hi.

If I need this popup message regardless if customer logged in or not ..What do I need to change?

thanks in advance.

Re: [SOLVED]Add to cart Login pop up

Posted: Thu Nov 28, 2013 8:23 pm
by mojkan
Hi!

I know I'm reviving an old thread. However, I have the exact same issue! BUT, finding the lines needed to alter they don't exist.

For instance, if I open a specified file and search for "<a onclick="addToCart" it doesn't exist. Therefore, I'm afraid of editing it since Idon't know if 1.5.6 is different.

Anyone care to give me a nudge in the right direction so that I can apply these changes in version 1.5.6

Thanks!

/H