eCommerce - Possible to hide price from unregistered users?

Permalink
Does anyone know if it is possible to only show price in the eCommerce product block to registered logged in users? Assume I can do this with a duplicate block for price only with permissions set, however, do not want to rebuild the already existing product pages. Possibly this is a simple task and there is something I am missing, or there is some simple editing I can do. Thanks in advance for any input.

MrGrowBizz
 
ronyDdeveloper replied on at Permalink Reply
ronyDdeveloper
I've done this previously. You just need to write down some custom php code in the product list blocks. It will put a condition to the price to show only for registered users.

Rony
blokeybloke replied on at Permalink Reply
Hi

if I understand your question correctly, I have a section on my company website (www.akhter.co.uk under Akhter Group drop down menu) where users have to login (after registering and being validated)

Once logged in they can see products and prices specific to them. I have 2 login sections one for NHS and another for GPS but they cannot see each others products due to the permissions I have set on the appropriate web pages.

Hope this is useful to you

Regards

Steve
MrGrowBizz replied on at Permalink Reply
MrGrowBizz
Wow! Thanks guys for jumping in so quickly.

Rony, do you remember the code and placement?

Steve, What I am trying to accomplish is allowing guests to see the item but not the price until registered and logged in. An example of this is used by 1stdibs.com My site is AlphaHD.com, currently I have shut the prices off, as well as ordering, within the block.
ronyDdeveloper replied on at Permalink Reply
ronyDdeveloper
I can tell you the code. But I can't remember the place exactly. It is in my laptop, but I'm in my desktop now. But it should be under packages->core_commerce->blocks->product_list (or something like that, not sure)
the you need to find out the place from where the price is displaying.

<?php
$u = new User();
if ($u->isRegistered()) { 
?>
<!--  Put the Price code here inside the if condition  -->
<?php
}//end if 
?>
MrGrowBizz replied on at Permalink Reply
MrGrowBizz
Rony thanks a bunch! Will give it a whirl in the morning. mkly also sent a different coding approach from the support side. Will see how many times I can redo before getting it right!
laaaamb replied on at Permalink Reply
laaaamb
Thanks a lot for this. It works perfectly.
dilio replied on at Permalink Reply
dilio
It would be wonderful if you could tell us where you exactly put the code! I am looking for the same solution.
enlil replied on at Permalink Reply
enlil
I believe you want to make the modifications in packages/core_commerce/elements/product/price.php
dilio replied on at Permalink Reply
dilio
Thank you, enlil. I followed your suggestion and it made the price disappear! However, it still shows the 'Add to cart' button, and the following pop-up cart item list window displays the prices. In addition I then placed the same code in packages/core_commerce/elements/cart_item_list.php
and it leads to a blank pop up window - which is okay - but it would be better to make the 'Add to cart' button disappear, so the pop-up window can't be triggered. Would you have a suggestion? Thanks in advance.
MrGrowBizz replied on at Permalink Reply
MrGrowBizz
Dilio, I last worked on this doing the following suggested by Mkly, unfortunately worked great on product pages, but price still showed on product lists for users not logged in. Did not get to the cart issue as I had to let it go. The complexity was going beyond my capability to figure out and was not confident it could be achieved at the time based on input from others. Certainly would be interested if you find a full solution. Thx


/core_commerce/blocks/product/view.php
<?php defined('C5_EXECUTE') or die(_("Access Denied.")); ?>
<?php
if (isset($product) && is_object($product)) {
$args = array();
foreach($this->controller->getSets() as $key => $value) {
$args[$key] = $value;
}
$args['id'] = $b->getBlockID();
if ($controller->hideSoldOut && $product->isSoldOut()) {
// show nothing
} else {
// If not logged in we set the display
// price to 0 to hide it
$u = new User;
if (!$u->isLoggedIn()) {
dilio replied on at Permalink Reply
dilio
Thanks, MrGrowBizz. As stated before, it works sufficiently for me (thanks enlil) and by putting the same code around cart_item_list. It would be ideal though if the 'Add to cart' button disappeared. Feel free to see the current result here:http://designedinitaly.com.au
enlil replied on at Permalink Reply
enlil
you should be able to add similar code to the elements/product/display.php file to hide the add to cart button. You could probably use some css to hide it as well. Haven't tested either method.
dilio replied on at Permalink Reply
dilio
Thanks, enlil. I placed the code around parts of display.php and it makes the Add to cart button unclickable. That's better than to have a blank window pop up. The unclickable button may inspire more visitors to register, rather than to have no Add to cart button at all.

<?php
$u = new User();
if ($u->isRegistered()) {
?>
<!-- Put the Price code here inside the if condition -->

<div class="ccm-core-commerce-add-to-cart">
<form method="post" id="ccm-core-commerce-add-to-cart-form-<?php echo $id?>" action="<?php echo $this->url('/cart', 'update')?>">
<input type="hidden" name="rcID" value="<?php echo $c->getCollectionID()?>" />

<!-- Put the Price code here inside the if condition -->
<?php
}//end if
?>