Page 1 of 2

Remove + sign & price if the customer is not logged in?

Posted: Fri Jun 11, 2010 8:11 am
by bcfl
Just updated to 1.4.8 on my test box, if I check System Settings, Login Display prices = yes (like I do)
The prices disappear on the home page, (as they should) but the little + signs stay, If I click the +(Add to Cart)
the customer is taken to the cart screen and the prices are displayed.

Can we get the + sign removed along with the price if the customer is not logged in??

Thanks, and Great Work!
bob

Re: Post any OpenCart 1.4.8 Bugs here!

Posted: Fri Jun 11, 2010 8:13 am
by Qphoria
its not a + sign.. its the add to cart button.

Re: Post any OpenCart 1.4.8 Bugs here!

Posted: Fri Jun 11, 2010 8:18 am
by bcfl
OK My error but same question, can we remove the add to cart button if the user is not logged in?
Thank You

Re: Post any OpenCart 1.4.8 Bugs here!

Posted: Fri Jun 11, 2010 8:28 am
by Qphoria
Sure

1. EDIT:
catalog/view/theme/default/template/module/latest_home.tpl
catalog/view/theme/default/template/module/featured_home.tpl
catalog/view/theme/default/template/module/special_home.tpl
catalog/view/theme/default/template/module/bestseller_home.tpl
catalog/view/theme/default/template/product/special.tpl
catalog/view/theme/default/template/product/category.tpl
catalog/view/theme/default/template/product/manufacturer.tpl
catalog/view/theme/default/template/product/search.tpl
catalog/view/theme/default/template/product/product.tpl


2. IN ALL FILES CHANGE:

Code: Select all

<?php } ?>
<?php } ?>
<a class="button_add_small" href="<?php echo $products[$j]['add']; ?>" title="<?php echo $button_add_to_cart; ?>" >&nbsp;</a>
3. TO:

Code: Select all

<?php } ?>
<a class="button_add_small" href="<?php echo $products[$j]['add']; ?>" title="<?php echo $button_add_to_cart; ?>" >&nbsp;</a>
<?php } ?>

Re: Post any OpenCart 1.4.8 Bugs here!

Posted: Fri Jun 11, 2010 8:44 am
by bcfl
Works like a charm, Thank YOU

Re: Post any OpenCart 1.4.8 Bugs here!

Posted: Thu Jun 24, 2010 6:08 pm
by felizone
Qphoria wrote:Sure

1. EDIT:
catalog/view/theme/default/template/module/latest_home.tpl
catalog/view/theme/default/template/module/featured_home.tpl
catalog/view/theme/default/template/module/special_home.tpl
catalog/view/theme/default/template/module/bestseller_home.tpl
catalog/view/theme/default/template/product/special.tpl
catalog/view/theme/default/template/product/category.tpl
catalog/view/theme/default/template/product/manufacturer.tpl
catalog/view/theme/default/template/product/search.tpl

2. IN ALL FILES CHANGE:

Code: Select all

<?php } ?>
<?php } ?>
<a class="button_add_small" href="<?php echo $products[$j]['add']; ?>" title="<?php echo $button_add_to_cart; ?>" >&nbsp;</a>
3. TO:

Code: Select all

<?php } ?>
<a class="button_add_small" href="<?php echo $products[$j]['add']; ?>" title="<?php echo $button_add_to_cart; ?>" >&nbsp;</a>
<?php } ?>
After i did, i still can see the small cross icon in the related product section.
MAy i know which file can i edit it?
Thanks

Re: Remove + sign & price if the customer is not logged in?

Posted: Thu Jun 24, 2010 6:15 pm
by felizone
My fault , sorry.
It works perfectly

Thank you guys. O0

Re: Remove + sign & price if the customer is not logged in?

Posted: Sun Aug 22, 2010 4:22 am
by krollster
Hi,

I've just come across this in the 1.4.8b install, and moving the add to cart button obviously fixes the
problem of stopping people from adding things to the cart and seeing prices when 'display prices to logged in users only' is set however. The actual cart controller and template do not seem to check for this setting at all.

What this means is that people that know open cart, or have ever seen an openCart site can easily modify the url
and find out pricing that is supposed to be hidden from them if they're not logged in.

If you're not logged in and prices are set to be hidden from guest users, simply going to

http://<my_site>/index.php?route=checkout/cart&product_id=30
http://<my_site>/index.php?route=checkout/cart&product_id=42
etc ...

or another product ID will add an item to the cart and show you the item pricing and total on the cart page.
To fix this issue for my current project I've added taken the following code from the category controller:

Code: Select all

if (!$this->config->get('config_customer_price')) {
	$this->data['display_price'] = TRUE;
} elseif ($this->customer->isLogged()) {
	$this->data['display_price'] = TRUE;
} else {
	$this->data['display_price'] = FALSE;
}
I added that code to the very beginning of the index() method and wrapped a conditional around $_GET and $_POST incoming product check like so :

Code: Select all

if ( $this->data['display_price'] )
{
    if ($this->request->server['REQUEST_METHOD'] == 'GET' && isset($this->request->get['product_id'])) {
    
        ...
        
    } elseif ($this->request->server['REQUEST_METHOD'] == 'POST') {
    
        ...
    }
} // END 'display price' fix
It is pretty plain, but I think if you're locking your store down to registered users only (like in my case) and want to hide pricing from everyone else, the cart really shouldn't be handling any incoming product actions either.

In addition to that I've wrapped the form on the cart.tpl in a conditional too:

Code: Select all

<?php if ($display_price) { ?>
    <form action="<?php echo str_replace('&', '&', $action); ?>" method="post" enctype="multipart/form-data" id="cart">
      ...
   </form>
<?php } ?>
So the fix is quite simple (in my case) I'm sure the check for the display price setting will be added to the cart and other areas of openCart in future versions. If it has been fixed in a patch already, I do apologise for the double post.

If not maybe this will help someone else out there in the meantime.

Re: Remove + sign & price if the customer is not logged in?

Posted: Sun Aug 22, 2010 11:30 pm
by Qphoria
krollster wrote: What this means is that people that know open cart, or have ever seen an openCart site can easily modify the url
and find out pricing that is supposed to be hidden from them if they're not logged in.

If you're not logged in and prices are set to be hidden from guest users, simply going to

http://<my_site>/index.php?route=checkout/cart&product_id=30
http://<my_site>/index.php?route=checkout/cart&product_id=42
etc ...
Good find!. fixed in 1.4.9 RC2

Re: Remove + sign & price if the customer is not logged in?

Posted: Wed Oct 13, 2010 7:29 pm
by robster
@krollster

I have done the fix originally described in this post but I agree with your observations about adding items to cart if you know your way around an OpenCart site.

However I am not sure which file or files I should make your suggested changes to - can you give more information please?

Thank you

robster

Re: Remove + sign & price if the customer is not logged in?

Posted: Tue Nov 02, 2010 7:28 pm
by robster
OK so I have removed every + sign so that they don't show when not logged in. However when the customer logs in they are ALL there again. Now I am sure that this is how the script is meant to function, however the annoying thing is that adding items to cart using the + sign works completely differently to adding items to cart using the 'add to cart' button.

Clicking the + sign adds items to the cart and shows the cart page (very slow method for shopping), whilst clicking the 'add to cart' button uses the nice ajax feature but remains on the same page. Why offer two add to cart methods that do different things??

How do I either, a) remove all + signs EVEN when logged in OR, b) get them to add the items to cart the same ajax way.

Sorry about the perhaps longwinded way of explaining but hopefully somebody will have the solution.

Cheers

Rob

Re: Remove + sign & price if the customer is not logged in?

Posted: Tue Nov 02, 2010 9:09 pm
by robster
Also I notice that despite the fix posted here for not showing the + sign when not logged in - they still show when viewing 'related products'. Can somebody show me where to remove these + signs please also.

Q, did you update 1.4.9.2 to fix krollster's points?

Cheers

robster

Re: Remove + sign & price if the customer is not logged in?

Posted: Tue Nov 02, 2010 9:36 pm
by Qphoria
robster wrote: Q, did you update 1.4.9.2 to fix krollster's points?

Qphoria wrote:Good find!. fixed in 1.4.9 RC2
But i may have missed the related products.

Re: Remove + sign & price if the customer is not logged in?

Posted: Tue Nov 02, 2010 9:46 pm
by robster
Hi Q

I didn't see this listed in features of 1.4.9.2 patch hence reason for asking.

Yeah I missed them too until now - where would I look to remove them please?

robster

Re: Remove + sign & price if the customer is not logged in?

Posted: Tue Nov 02, 2010 10:11 pm
by Qphoria
robster wrote:Hi Q

I didn't see this listed in features of 1.4.9.2 patch hence reason for asking.

Yeah I missed them too until now - where would I look to remove them please?

robster
That is because it was fixed in 1.4.9.0

Re: Remove + sign & price if the customer is not logged in?

Posted: Tue Nov 02, 2010 10:13 pm
by Qphoria
Qphoria wrote: But i may have missed the related products.
I just took a look and no i didn't miss it in related products. It should be fixed everywhere as of 1.4.9.0 Final

Re: Remove + sign & price if the customer is not logged in?

Posted: Tue Nov 02, 2010 10:39 pm
by robster
Hmm weird as I am using fresh install of 1.4.9.1 just installed today and they are there.....

Any way I would still be grateful if you could tell me which file i edit to remove them - everywhere else is indeed fine.

robster

Re: Remove + sign & price if the customer is not logged in?

Posted: Wed Nov 03, 2010 7:29 pm
by robster
So is it a secret then Q?

Re: Remove + sign & price if the customer is not logged in?

Posted: Thu Nov 04, 2010 10:26 pm
by Qphoria
I assume you are just using a 1.4.8 theme as that is where this was fixed.

Re: Remove + sign & price if the customer is not logged in?

Posted: Thu Nov 04, 2010 10:48 pm
by robster
in my particular case - yep