No prices displayed until member registered

  • Posts: 206
  • Thank you received: 26
11 years 9 months ago #88406

I have a site where i want to have the products showing, however no prices displayed until they're registered, Is there a way that can do this?


I'm not an expert at this, if i post on your thread i'm doing so with the best of my knowledge and just trying to help :)

Please Log in or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2322
11 years 9 months ago #88552

I think that you will have to edit the views "product / listing_price" and add a check on the user to display or not the price.

The check should be something like:

if(hikashop_loadUser() != null){ ... }

Please Log in or Create an account to join the conversation.

  • Posts: 206
  • Thank you received: 26
11 years 9 months ago #88592

Xavier wrote: I think that you will have to edit the views "product / listing_price" and add a check on the user to display or not the price.

The check should be something like:

if(hikashop_loadUser() != null){ ... }

Code of the view "product | listing_price"

That's the code that comes up, where would i add it?

Also once they're registered (and i put them in a specific user group) how would i do this? (with the prices then being displayed)


I'm not an expert at this, if i post on your thread i'm doing so with the best of my knowledge and just trying to help :)
Last edit: 11 years 9 months ago by Jerome.

Please Log in or Create an account to join the conversation.

  • Posts: 26152
  • Thank you received: 4027
  • MODERATOR
11 years 9 months ago #88636

Hi,

You can use replace

	<span class="hikashop_product_price_full<?php echo $class; ?>">
	<?php
	if(empty($this->row->prices)){
		echo JText::_('FREE_PRICE');
	}else{
By
	<span class="hikashop_product_price_full<?php echo $class; ?>">
	<?php
	if(empty($this->row->prices)){
		echo JText::_('FREE_PRICE');
	} else if(hikashop_loadUser() == null){
		echo JText::_('PLEASE_LOGIN'); // Or any other text
	} else {

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

  • Posts: 206
  • Thank you received: 26
11 years 9 months ago #88641

Hi Jerome,

I tried this and it didn't work, tradelights.co.uk/index.php/product/35-p...w-e27-40w-equivalent


Thanks

Tom


I'm not an expert at this, if i post on your thread i'm doing so with the best of my knowledge and just trying to help :)

Please Log in or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2322
11 years 9 months ago #88760

Hi,

That's because in the code previously given, if the price is free it's displayed if the user is registered or not.
To hide it too when the price is free, you can use this code:

if(hikashop_loadUser() == null){
		echo JText::_('PLEASE_LOGIN'); // Or any other text
	} else {

Please Log in or Create an account to join the conversation.

  • Posts: 206
  • Thank you received: 26
11 years 9 months ago #88761

Xavier wrote: Hi,

That's because in the code previously given, if the price is free it's displayed if the user is registered or not.
To hide it too when the price is free, you can use this code:

if(hikashop_loadUser() == null){
		echo JText::_('PLEASE_LOGIN'); // Or any other text
	} else {


This code is in the modification which Jerome gave to me:

Jerome wrote: Hi,

You can use replace

	<span class="hikashop_product_price_full<?php echo $class; ?>">
	<?php
	if(empty($this->row->prices)){
		echo JText::_('FREE_PRICE');
	}else{
By
	<span class="hikashop_product_price_full<?php echo $class; ?>">
	<?php
	if(empty($this->row->prices)){
		echo JText::_('FREE_PRICE');
	} else if(hikashop_loadUser() == null){
		echo JText::_('PLEASE_LOGIN'); // Or any other text
	} else {

Regards,

However it's still not working :/


I'm not an expert at this, if i post on your thread i'm doing so with the best of my knowledge and just trying to help :)
Last edit: 11 years 9 months ago by tjharvey.

Please Log in or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2322
11 years 9 months ago #88770

You have to place the loadUser check before the check for the empty price.

<span class="hikashop_product_price_full<?php echo $class; ?>">
	<?php
	if(hikashop_loadUser() == null){
		echo JText::_('PLEASE_LOGIN'); // Or any other text
                continue;
	} else {
            if(empty($this->row->prices)){
		echo JText::_('FREE_PRICE');
	    }else{

Last edit: 11 years 9 months ago by Xavier.

Please Log in or Create an account to join the conversation.

  • Posts: 206
  • Thank you received: 26
11 years 9 months ago #88771

Xavier wrote: You have to place the loadUser check before the check for the empty price.

<span class="hikashop_product_price_full<?php echo $class; ?>">
	<?php
	if(hikashop_loadUser() == null){
		echo JText::_('PLEASE_LOGIN'); // Or any other text
                continue;
	} else {
            if(empty($this->row->prices)){
		echo JText::_('FREE_PRICE');
	    }else{


Still not working :/
tradelights.co.uk/index.php/product/35-p...w-e27-40w-equivalent


Here's the code:
<?php
/**
 * @package  HikaShop for Joomla!
 * @version  2.0.0
 * @author  hikashop.com
 * @copyright  (C) 2010-2012 HIKARI SOFTWARE. All rights reserved.
 * @license  GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */
defined('_JEXEC') or die('Restricted access');
?><span class="hikashop_product_price_full<?php echo $class; ?>">
  <?php
  if(hikashop_loadUser() == null){
    echo JText::_('PLEASE_LOGIN'); // Or any other text
                continue;
  } else {
            if(empty($this->row->prices)){
    echo JText::_('FREE_PRICE');
      }else{
 
     $first=true;
    echo JText::_('PRICE_BEGINNING');
    foreach($this->row->prices as $price){
      if($first)$first=false;
      else echo JText::_('PRICE_SEPARATOR');
      if(!empty($this->unit) && isset($price->unit_price)){
        $price =& $price->unit_price;
      }
      if(!isset($price->price_currency_id))$price->price_currency_id = hikashop_getCurrency();
      echo '<span class="hikashop_product_price">';
      if($this->params->get('price_with_tax')){
        echo $this->currencyHelper->format($price->price_value_with_tax,$price->price_currency_id);
      }
      if($this->params->get('price_with_tax')==2){
        echo JText::_('PRICE_BEFORE_TAX');
      }
      if($this->params->get('price_with_tax')==2||!$this->params->get('price_with_tax')){
        echo $this->currencyHelper->format($price->price_value,$price->price_currency_id);
      }
      if($this->params->get('price_with_tax')==2){
        echo JText::_('PRICE_AFTER_TAX');
      }
      if($this->params->get('show_original_price','-1')=='-1'){
        $config =& hikashop_config();
        $defaultParams = $config->get('default_params');
        $this->params->set('show_original_price',$defaultParams['show_original_price']);
      }
      if($this->params->get('show_original_price') && !empty($price->price_orig_value)){
        echo JText::_('PRICE_BEFORE_ORIG');
        if($this->params->get('price_with_tax')){
          echo $this->currencyHelper->format($price->price_orig_value_with_tax,$price->price_orig_currency_id);
        }
        if($this->params->get('price_with_tax')==2){
          echo JText::_('PRICE_BEFORE_TAX');
        }
        if($this->params->get('price_with_tax')==2||!$this->params->get('price_with_tax')){
          echo $this->currencyHelper->format($price->price_orig_value,$price->price_orig_currency_id);
        }
        if($this->params->get('price_with_tax')==2){
          echo JText::_('PRICE_AFTER_TAX');
        }
        echo JText::_('PRICE_AFTER_ORIG');
      }
      echo '</span> ';
      if(!empty($this->row->discount)){
        if($this->params->get('show_discount',3)==3){
          $config =& hikashop_config();
          $defaultParams = $config->get('default_params');
          $this->params->set('show_discount',$defaultParams['show_discount']);
        }
        if($this->params->get('show_discount')==1){
          echo '<span class="hikashop_product_discount">'.JText::_('PRICE_DISCOUNT_START');
          if(bccomp($this->row->discount->discount_flat_amount,0,5)!==0){
            echo $this->currencyHelper->format(-1*$this->row->discount->discount_flat_amount,$price->price_currency_id);
          }else{
            echo -1*$this->row->discount->discount_percent_amount.'%';
          }
          echo JText::_('PRICE_DISCOUNT_END').'</span>';
        }elseif($this->params->get('show_discount')==2){
          echo '<span class="hikashop_product_price_before_discount">'.JText::_('PRICE_DISCOUNT_START');
          if($this->params->get('price_with_tax')){
            echo $this->currencyHelper->format($price->price_value_without_discount_with_tax,$price->price_currency_id);
          }
          if($this->params->get('price_with_tax')==2){
            echo JText::_('PRICE_BEFORE_TAX');
          }
          if($this->params->get('price_with_tax')==2||!$this->params->get('price_with_tax')){
            echo $this->currencyHelper->format($price->price_value_without_discount,$price->price_currency_id);
          }
          if($this->params->get('price_with_tax')==2){
            echo JText::_('PRICE_AFTER_TAX');
          }
          if($this->params->get('show_original_price') && !empty($price->price_orig_value_without_discount_with_tax)){
            echo JText::_('PRICE_BEFORE_ORIG');
            if($this->params->get('price_with_tax')){
              echo $this->currencyHelper->format($price->price_orig_value_without_discount_with_tax,$price->price_orig_currency_id);
            }
            if($this->params->get('price_with_tax')==2){
              echo JText::_('PRICE_BEFORE_TAX');
            }
            if($this->params->get('price_with_tax')==2||!$this->params->get('price_with_tax')){
              echo $this->currencyHelper->format($price->price_orig_value_without_discount,$price->price_orig_currency_id);
            }
            if($this->params->get('price_with_tax')==2){
              echo JText::_('PRICE_AFTER_TAX');
            }
            echo JText::_('PRICE_AFTER_ORIG');
          }
          echo JText::_('PRICE_DISCOUNT_END').'</span>';
        }
      }
    }
    echo JText::_('PRICE_END');
  }
  ?></span>


I'm not an expert at this, if i post on your thread i'm doing so with the best of my knowledge and just trying to help :)

Please Log in or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2322
11 years 9 months ago #88841

Sorry, I gave you a wrong code, thanks to use this one:

<?php
/**
 * @package  HikaShop for Joomla!
 * @version  2.0.0
 * @author  hikashop.com
 * @copyright  (C) 2010-2012 HIKARI SOFTWARE. All rights reserved.
 * @license  GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */
defined('_JEXEC') or die('Restricted access');
?><span class="hikashop_product_price_full<?php echo $class; ?>">
  <?php
	if(hikashop_loadUser() == null){
		echo JText::_('PLEASE_LOGIN'); // Or any other text
	} else if(empty($this->row->prices)) {
		echo JText::_('FREE_PRICE');
	}else{
 
     $first=true;
    echo JText::_('PRICE_BEGINNING');
    foreach($this->row->prices as $price){
      if($first)$first=false;
      else echo JText::_('PRICE_SEPARATOR');
      if(!empty($this->unit) && isset($price->unit_price)){
        $price =& $price->unit_price;
      }
      if(!isset($price->price_currency_id))$price->price_currency_id = hikashop_getCurrency();
      echo '<span class="hikashop_product_price">';
      if($this->params->get('price_with_tax')){
        echo $this->currencyHelper->format($price->price_value_with_tax,$price->price_currency_id);
      }
      if($this->params->get('price_with_tax')==2){
        echo JText::_('PRICE_BEFORE_TAX');
      }
      if($this->params->get('price_with_tax')==2||!$this->params->get('price_with_tax')){
        echo $this->currencyHelper->format($price->price_value,$price->price_currency_id);
      }
      if($this->params->get('price_with_tax')==2){
        echo JText::_('PRICE_AFTER_TAX');
      }
      if($this->params->get('show_original_price','-1')=='-1'){
        $config =& hikashop_config();
        $defaultParams = $config->get('default_params');
        $this->params->set('show_original_price',$defaultParams['show_original_price']);
      }
      if($this->params->get('show_original_price') && !empty($price->price_orig_value)){
        echo JText::_('PRICE_BEFORE_ORIG');
        if($this->params->get('price_with_tax')){
          echo $this->currencyHelper->format($price->price_orig_value_with_tax,$price->price_orig_currency_id);
        }
        if($this->params->get('price_with_tax')==2){
          echo JText::_('PRICE_BEFORE_TAX');
        }
        if($this->params->get('price_with_tax')==2||!$this->params->get('price_with_tax')){
          echo $this->currencyHelper->format($price->price_orig_value,$price->price_orig_currency_id);
        }
        if($this->params->get('price_with_tax')==2){
          echo JText::_('PRICE_AFTER_TAX');
        }
        echo JText::_('PRICE_AFTER_ORIG');
      }
      echo '</span> ';
      if(!empty($this->row->discount)){
        if($this->params->get('show_discount',3)==3){
          $config =& hikashop_config();
          $defaultParams = $config->get('default_params');
          $this->params->set('show_discount',$defaultParams['show_discount']);
        }
        if($this->params->get('show_discount')==1){
          echo '<span class="hikashop_product_discount">'.JText::_('PRICE_DISCOUNT_START');
          if(bccomp($this->row->discount->discount_flat_amount,0,5)!==0){
            echo $this->currencyHelper->format(-1*$this->row->discount->discount_flat_amount,$price->price_currency_id);
          }else{
            echo -1*$this->row->discount->discount_percent_amount.'%';
          }
          echo JText::_('PRICE_DISCOUNT_END').'</span>';
        }elseif($this->params->get('show_discount')==2){
          echo '<span class="hikashop_product_price_before_discount">'.JText::_('PRICE_DISCOUNT_START');
          if($this->params->get('price_with_tax')){
            echo $this->currencyHelper->format($price->price_value_without_discount_with_tax,$price->price_currency_id);
          }
          if($this->params->get('price_with_tax')==2){
            echo JText::_('PRICE_BEFORE_TAX');
          }
          if($this->params->get('price_with_tax')==2||!$this->params->get('price_with_tax')){
            echo $this->currencyHelper->format($price->price_value_without_discount,$price->price_currency_id);
          }
          if($this->params->get('price_with_tax')==2){
            echo JText::_('PRICE_AFTER_TAX');
          }
          if($this->params->get('show_original_price') && !empty($price->price_orig_value_without_discount_with_tax)){
            echo JText::_('PRICE_BEFORE_ORIG');
            if($this->params->get('price_with_tax')){
              echo $this->currencyHelper->format($price->price_orig_value_without_discount_with_tax,$price->price_orig_currency_id);
            }
            if($this->params->get('price_with_tax')==2){
              echo JText::_('PRICE_BEFORE_TAX');
            }
            if($this->params->get('price_with_tax')==2||!$this->params->get('price_with_tax')){
              echo $this->currencyHelper->format($price->price_orig_value_without_discount,$price->price_orig_currency_id);
            }
            if($this->params->get('price_with_tax')==2){
              echo JText::_('PRICE_AFTER_TAX');
            }
            echo JText::_('PRICE_AFTER_ORIG');
          }
          echo JText::_('PRICE_DISCOUNT_END').'</span>';
        }
      }
    }
    echo JText::_('PRICE_END');
  }
  ?></span>

The following user(s) said Thank You: tjharvey

Please Log in or Create an account to join the conversation.

  • Posts: 206
  • Thank you received: 26
11 years 9 months ago #88845

Hi Xavier,

Here's what i'm getting:
tradelights.co.uk/product/122-pharox-200...-20w-equivalent.html


If you wish to login and try you've got an account with:
HikaShop
WY0P7B5Z

(user/pw)


Also, i can see all the displayed prices now (for different user groups, even though they're set at different levels)
Also Xavier, congratulations on 500 "Thank You"'s


I'm not an expert at this, if i post on your thread i'm doing so with the best of my knowledge and just trying to help :)
Last edit: 11 years 9 months ago by tjharvey.

Please Log in or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2322
11 years 9 months ago #88925

Hi,

Thanks :)
Concerning the logs they don't work. Could you check that ?

Just to be sure of what you are needing, you want to hide the price and the add to cart button to all the not registered customers but display it for the registered ?

Please Log in or Create an account to join the conversation.

  • Posts: 206
  • Thank you received: 26
11 years 9 months ago #88926

Logs being login?

Yeah that's all right except its not when they register, when they are approved (and put into a custom user group) then I'd like the price displayed.


I'm not an expert at this, if i post on your thread i'm doing so with the best of my knowledge and just trying to help :)

Please Log in or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2322
11 years 9 months ago #88963

Yes I mean login. I can't login with the username and password given.

To restrict to a certain group, you will have to check on the user group so use something like:
$regUser = hikashop_loadUser()
if($regUser == null || !in_array('theGroupID',$regUser->group_id){

Please Log in or Create an account to join the conversation.

  • Posts: 206
  • Thank you received: 26
11 years 9 months ago #88979

The id is 9, so would it be:

$regUser = hikashop_loadUser()
if($regUser == null || !in_array('9',$regUser->group_id){

try:

HikaShop
hikashop

as the user/pw


I'm not an expert at this, if i post on your thread i'm doing so with the best of my knowledge and just trying to help :)

Please Log in or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2322
11 years 9 months ago #89010

You will need something like:

<?php 
$regUser = hikashop_loadUser(true); 
if($regUser != null){
	$db = JFactory::getDBO();
	$query = 'SELECT group_id FROM '.hikashop_table('user_usergroup_map',false).'  WHERE user_id ='.$regUser->user_cms_id;
	$db->setQuery($query);
	$regUser = $db->loadResultArray();
}else{
	$regUser = array();
}
if(!in_array('9',$regUser)){
	echo "Hide the price";
}
?>

Please Log in or Create an account to join the conversation.

  • Posts: 206
  • Thank you received: 26
11 years 9 months ago #89012

Xavier wrote: You will need something like:

<?php 
$regUser = hikashop_loadUser(true); 
if($regUser != null){
	$db = JFactory::getDBO();
	$query = 'SELECT group_id FROM '.hikashop_table('user_usergroup_map',false).'  WHERE user_id ='.$regUser->user_cms_id;
	$db->setQuery($query);
	$regUser = $db->loadResultArray();
}else{
	$regUser = array();
}
if(!in_array('9',$regUser)){
	echo "Hide the price";
}
?>



So that would become:
<?php
/**
 * @package  HikaShop for Joomla!
 * @version  2.0.0
 * @author  hikashop.com
 * @copyright  (C) 2010-2012 HIKARI SOFTWARE. All rights reserved.
 * @license  GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */
defined('_JEXEC') or die('Restricted access');
?><span class="hikashop_product_price_full<?php echo $class; ?>">
  <?php 
$regUser = hikashop_loadUser(true); 
if($regUser != null){
	$db = JFactory::getDBO();
	$query = 'SELECT group_id FROM '.hikashop_table('user_usergroup_map',false).'  WHERE user_id ='.$regUser->user_cms_id;
	$db->setQuery($query);
	$regUser = $db->loadResultArray();
}else{
	$regUser = array();
}
if(!in_array('9',$regUser)){
	echo "Hide the price";
}
?>
 
     $first=true;
    echo JText::_('PRICE_BEGINNING');
    foreach($this->row->prices as $price){
      if($first)$first=false;
      else echo JText::_('PRICE_SEPARATOR');
      if(!empty($this->unit) && isset($price->unit_price)){
        $price =& $price->unit_price;
      }
      if(!isset($price->price_currency_id))$price->price_currency_id = hikashop_getCurrency();
      echo '<span class="hikashop_product_price">';
      if($this->params->get('price_with_tax')){
        echo $this->currencyHelper->format($price->price_value_with_tax,$price->price_currency_id);
      }
      if($this->params->get('price_with_tax')==2){
        echo JText::_('PRICE_BEFORE_TAX');
      }
      if($this->params->get('price_with_tax')==2||!$this->params->get('price_with_tax')){
        echo $this->currencyHelper->format($price->price_value,$price->price_currency_id);
      }
      if($this->params->get('price_with_tax')==2){
        echo JText::_('PRICE_AFTER_TAX');
      }
      if($this->params->get('show_original_price','-1')=='-1'){
        $config =& hikashop_config();
        $defaultParams = $config->get('default_params');
        $this->params->set('show_original_price',$defaultParams['show_original_price']);
      }
      if($this->params->get('show_original_price') && !empty($price->price_orig_value)){
        echo JText::_('PRICE_BEFORE_ORIG');
        if($this->params->get('price_with_tax')){
          echo $this->currencyHelper->format($price->price_orig_value_with_tax,$price->price_orig_currency_id);
        }
        if($this->params->get('price_with_tax')==2){
          echo JText::_('PRICE_BEFORE_TAX');
        }
        if($this->params->get('price_with_tax')==2||!$this->params->get('price_with_tax')){
          echo $this->currencyHelper->format($price->price_orig_value,$price->price_orig_currency_id);
        }
        if($this->params->get('price_with_tax')==2){
          echo JText::_('PRICE_AFTER_TAX');
        }
        echo JText::_('PRICE_AFTER_ORIG');
      }
      echo '</span> ';
      if(!empty($this->row->discount)){
        if($this->params->get('show_discount',3)==3){
          $config =& hikashop_config();
          $defaultParams = $config->get('default_params');
          $this->params->set('show_discount',$defaultParams['show_discount']);
        }
        if($this->params->get('show_discount')==1){
          echo '<span class="hikashop_product_discount">'.JText::_('PRICE_DISCOUNT_START');
          if(bccomp($this->row->discount->discount_flat_amount,0,5)!==0){
            echo $this->currencyHelper->format(-1*$this->row->discount->discount_flat_amount,$price->price_currency_id);
          }else{
            echo -1*$this->row->discount->discount_percent_amount.'%';
          }
          echo JText::_('PRICE_DISCOUNT_END').'</span>';
        }elseif($this->params->get('show_discount')==2){
          echo '<span class="hikashop_product_price_before_discount">'.JText::_('PRICE_DISCOUNT_START');
          if($this->params->get('price_with_tax')){
            echo $this->currencyHelper->format($price->price_value_without_discount_with_tax,$price->price_currency_id);
          }
          if($this->params->get('price_with_tax')==2){
            echo JText::_('PRICE_BEFORE_TAX');
          }
          if($this->params->get('price_with_tax')==2||!$this->params->get('price_with_tax')){
            echo $this->currencyHelper->format($price->price_value_without_discount,$price->price_currency_id);
          }
          if($this->params->get('price_with_tax')==2){
            echo JText::_('PRICE_AFTER_TAX');
          }
          if($this->params->get('show_original_price') && !empty($price->price_orig_value_without_discount_with_tax)){
            echo JText::_('PRICE_BEFORE_ORIG');
            if($this->params->get('price_with_tax')){
              echo $this->currencyHelper->format($price->price_orig_value_without_discount_with_tax,$price->price_orig_currency_id);
            }
            if($this->params->get('price_with_tax')==2){
              echo JText::_('PRICE_BEFORE_TAX');
            }
            if($this->params->get('price_with_tax')==2||!$this->params->get('price_with_tax')){
              echo $this->currencyHelper->format($price->price_orig_value_without_discount,$price->price_orig_currency_id);
            }
            if($this->params->get('price_with_tax')==2){
              echo JText::_('PRICE_AFTER_TAX');
            }
            echo JText::_('PRICE_AFTER_ORIG');
          }
          echo JText::_('PRICE_DISCOUNT_END').'</span>';
        }
      }
    }
    echo JText::_('PRICE_END');
  }
  ?></span>
Right?


I'm not an expert at this, if i post on your thread i'm doing so with the best of my knowledge and just trying to help :)

Please Log in or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2322
11 years 9 months ago #89114

<?php
/**
 * @package  HikaShop for Joomla!
 * @version  2.0.0
 * @author  hikashop.com
 * @copyright  (C) 2010-2012 HIKARI SOFTWARE. All rights reserved.
 * @license  GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */
defined('_JEXEC') or die('Restricted access');
?><span class="hikashop_product_price_full<?php echo $class; ?>">
  <?php
$regUser = hikashop_loadUser(true); 
if($regUser != null){
	$db = JFactory::getDBO();
	$query = 'SELECT group_id FROM '.hikashop_table('user_usergroup_map',false).'  WHERE user_id ='.$regUser->user_cms_id;
	$db->setQuery($query);
	$regUser = $db->loadResultArray();
}else{
	$regUser = array();
}
if(!in_array('9',$regUser)){
		echo JText::_('PLEASE_LOGIN'); // Or any other text
	} else if(empty($this->row->prices)) {
		echo JText::_('FREE_PRICE');
	}else{
 
     $first=true;
    echo JText::_('PRICE_BEGINNING');
    foreach($this->row->prices as $price){
      if($first)$first=false;
      else echo JText::_('PRICE_SEPARATOR');
      if(!empty($this->unit) && isset($price->unit_price)){
        $price =& $price->unit_price;
      }
      if(!isset($price->price_currency_id))$price->price_currency_id = hikashop_getCurrency();
      echo '<span class="hikashop_product_price">';
      if($this->params->get('price_with_tax')){
        echo $this->currencyHelper->format($price->price_value_with_tax,$price->price_currency_id);
      }
      if($this->params->get('price_with_tax')==2){
        echo JText::_('PRICE_BEFORE_TAX');
      }
      if($this->params->get('price_with_tax')==2||!$this->params->get('price_with_tax')){
        echo $this->currencyHelper->format($price->price_value,$price->price_currency_id);
      }
      if($this->params->get('price_with_tax')==2){
        echo JText::_('PRICE_AFTER_TAX');
      }
      if($this->params->get('show_original_price','-1')=='-1'){
        $config =& hikashop_config();
        $defaultParams = $config->get('default_params');
        $this->params->set('show_original_price',$defaultParams['show_original_price']);
      }
      if($this->params->get('show_original_price') && !empty($price->price_orig_value)){
        echo JText::_('PRICE_BEFORE_ORIG');
        if($this->params->get('price_with_tax')){
          echo $this->currencyHelper->format($price->price_orig_value_with_tax,$price->price_orig_currency_id);
        }
        if($this->params->get('price_with_tax')==2){
          echo JText::_('PRICE_BEFORE_TAX');
        }
        if($this->params->get('price_with_tax')==2||!$this->params->get('price_with_tax')){
          echo $this->currencyHelper->format($price->price_orig_value,$price->price_orig_currency_id);
        }
        if($this->params->get('price_with_tax')==2){
          echo JText::_('PRICE_AFTER_TAX');
        }
        echo JText::_('PRICE_AFTER_ORIG');
      }
      echo '</span> ';
      if(!empty($this->row->discount)){
        if($this->params->get('show_discount',3)==3){
          $config =& hikashop_config();
          $defaultParams = $config->get('default_params');
          $this->params->set('show_discount',$defaultParams['show_discount']);
        }
        if($this->params->get('show_discount')==1){
          echo '<span class="hikashop_product_discount">'.JText::_('PRICE_DISCOUNT_START');
          if(bccomp($this->row->discount->discount_flat_amount,0,5)!==0){
            echo $this->currencyHelper->format(-1*$this->row->discount->discount_flat_amount,$price->price_currency_id);
          }else{
            echo -1*$this->row->discount->discount_percent_amount.'%';
          }
          echo JText::_('PRICE_DISCOUNT_END').'</span>';
        }elseif($this->params->get('show_discount')==2){
          echo '<span class="hikashop_product_price_before_discount">'.JText::_('PRICE_DISCOUNT_START');
          if($this->params->get('price_with_tax')){
            echo $this->currencyHelper->format($price->price_value_without_discount_with_tax,$price->price_currency_id);
          }
          if($this->params->get('price_with_tax')==2){
            echo JText::_('PRICE_BEFORE_TAX');
          }
          if($this->params->get('price_with_tax')==2||!$this->params->get('price_with_tax')){
            echo $this->currencyHelper->format($price->price_value_without_discount,$price->price_currency_id);
          }
          if($this->params->get('price_with_tax')==2){
            echo JText::_('PRICE_AFTER_TAX');
          }
          if($this->params->get('show_original_price') && !empty($price->price_orig_value_without_discount_with_tax)){
            echo JText::_('PRICE_BEFORE_ORIG');
            if($this->params->get('price_with_tax')){
              echo $this->currencyHelper->format($price->price_orig_value_without_discount_with_tax,$price->price_orig_currency_id);
            }
            if($this->params->get('price_with_tax')==2){
              echo JText::_('PRICE_BEFORE_TAX');
            }
            if($this->params->get('price_with_tax')==2||!$this->params->get('price_with_tax')){
              echo $this->currencyHelper->format($price->price_orig_value_without_discount,$price->price_orig_currency_id);
            }
            if($this->params->get('price_with_tax')==2){
              echo JText::_('PRICE_AFTER_TAX');
            }
            echo JText::_('PRICE_AFTER_ORIG');
          }
          echo JText::_('PRICE_DISCOUNT_END').'</span>';
        }
      }
    }
    echo JText::_('PRICE_END');
  }
  ?></span>

Please Log in or Create an account to join the conversation.

  • Posts: 206
  • Thank you received: 26
11 years 9 months ago #89175

I'm not an expert at this, if i post on your thread i'm doing so with the best of my knowledge and just trying to help :)
Last edit: 11 years 9 months ago by Jerome.

Please Log in or Create an account to join the conversation.

  • Posts: 82785
  • Thank you received: 13353
  • MODERATOR
11 years 9 months ago #89354

You can simply add the code below at the beginning of the listing_price view file:

<?php
$user = JFactory::getUser();
if($user->guest){
 echo "Hide the price";
 return;
}
?>

Please Log in or Create an account to join the conversation.

Time to create page: 0.105 seconds
Powered by Kunena Forum