Re: only show the product price registered users

  • Posts: 46
  • Thank you received: 0
13 years 3 months ago #47786

Hi, I want to show the product price only for registered users, guests can only see the products without the price please help me to configure that.

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

  • Posts: 84219
  • Thank you received: 13671
  • MODERATOR
13 years 3 months ago #47867

You can do that by restricting prices to only some user groups with the Business edition of HikaShop.

The following user(s) said Thank You: ghaithge

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

  • Posts: 91
  • Thank you received: 3
11 years 6 months ago #141891

I can't find where to do that :(

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

  • Posts: 84219
  • Thank you received: 13671
  • MODERATOR
11 years 6 months ago #141975

When you edit a product, you have a prices area on the right. There, you can add several prices. Once you save the product with the several prices, you have an icon which appears in the 'access level' column of that prices listing and you can click on it to restrict each price to one or several user groups.

The following user(s) said Thank You: miracle

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

  • Posts: 91
  • Thank you received: 3
11 years 6 months ago #142192

Thank you, I found it. As a feature request I would suggest being able to have a basic setting for that, so you can change this at shop level or category level instead of only product level.

Furthermore... keep up the good work! :)

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

  • Posts: 84219
  • Thank you received: 13671
  • MODERATOR
11 years 6 months ago #142219

Thank you for your feedback.

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

  • Posts: 1
  • Thank you received: 0
7 years 11 months ago #276620

i need to show prices only to registered users, i have thousand of articles i cannot set this option for each article... how can i set as default?

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

  • Posts: 84219
  • Thank you received: 13671
  • MODERATOR
7 years 11 months ago #277539

Hi,

When you create the price in the product, you'll find an "access level" setting that you can use to restrict the price to some user groups.
So select "registered" there and the price will only show to registered users.

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

  • Posts: 39
  • Thank you received: 6
1 year 6 months ago #358719

Hi,
I have a similar problem. I want to restrict E-Books to be purchasable by registered users only.

If I set the access level for the product, the product gives a 404 if the user clicks a link that leads to the product page.

If I set the access level for the price, the product is displayed as being free.

Right now, I use a Language Override to change the "free" text so that it urges the user to login.

This is kind of dirty, is there a better way?

EDIT: I looked in product / show.php for the code that generates the "Add to Cart" button, but couldn't quite find it. If I knew where these buttons were generated I could (presumably) just add this check: if ($user->id > 0)

Last edit: 1 year 6 months ago by NTV.

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

  • Posts: 84219
  • Thank you received: 13671
  • MODERATOR
1 year 6 months ago #358720

Hi,

No. That's how we've been telling merchants to do it for more than 10 years and it does the job fine, so we never saw the need to make it differently.

Between a view override and a translation override, I personally think that a translation override is better. It's much more lightweight and won't be able to cause any issue in the future. With a view override, if some code we have in there isn't compatible with Joomla 6 or 7, or PHP 9 or 10, it could break the pages and necessitate some work in the future.

Now, if you want to find which view file is used where, I would recommend you to activate the "Display view files" setting of the HikaShop configuration page:
www.hikashop.com/support/documentation/1...-display.html#layout

Last edit: 1 year 6 months ago by nicolas.

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

  • Posts: 39
  • Thank you received: 6
4 days 6 hours ago #368188

Hi, the inevitable happened: We now require the actual functionality of having free items available in our shop.

Still, E-Books need to only be purchasable by registered users.

I suppose now there is no way around overriding the view in question?

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

  • Posts: 84219
  • Thank you received: 13671
  • MODERATOR
4 days 3 hours ago #368191

Hi,

Indeed, in that case, you'll want to have a view override to change the "free" text dynamically based on whether the product is truly free or its price is not accessible to the current user.
I think you'll want to edit the file product / listing_price.
There, you have this line:

echo JText::_('FREE_PRICE');
So you can have something like this:
$db = JFactory::getDBO();
$db->setQuery('SELECT price_id FROM #__hikashop_price WHERE price_product_id == '.(int)$this->row->product_id);
$hasPrice = $db->loadResult();
if($hasPrice){
    echo JText::_('YOU_NEED_TO_REGISTER');
} else {
    echo JText::_('FREE_PRICE');
}

Last edit: 4 days 4 hours ago by nicolas.
The following user(s) said Thank You: NTV

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

  • Posts: 39
  • Thank you received: 6
3 days 7 hours ago #368194

Hi nicolas,

I did the following to avoid the database query:

      if (JFactory::getUser()->id == 0)
      {
        echo JText::_('YOU_NEED_TO_REGISTER');
      }
      else {
	    echo JText::_('FREE_PRICE');
      }

This works well so far.

However, I also need to implement the check where the button for adding to cart is being generated (I only want it to show for registered users).

Which views do I need to change?

I tried displaying which views are being used in the frontend but could not quite find the right ones (looking for both the corresponding product and category view).

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

  • Posts: 84219
  • Thank you received: 13671
  • MODERATOR
3 days 4 hours ago #368195

Hi,

To find the correct view file when you want to do an override, you can use the "Display view files" setting:
www.hikashop.com/support/documentation/5...g.html#advanced_main
For the add to cart button on the product details page, it's in the product / quantity view file:

echo $this->loadHkLayout('button', array( 'attributes' => $attributes, 'content' => $content, 'fallback_url' => hikashop_completeLink($classical_url)));

The following user(s) said Thank You: NTV

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

  • Posts: 39
  • Thank you received: 6
3 days 3 hours ago #368198

Okay, I managed to get the result I wanted by changing the views we mentioned previously as well as product / add_to_cart_ajax (for the category view).

Thanks for the help.

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

Time to create page: 0.105 seconds
Powered by Kunena Forum