- Posts: 46
- Thank you received: 0
Re: only show the product price registered users
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Furthermore... keep up the good work!
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
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.
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)
Please Log in or Create an account to join the conversation.
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
Please Log in or Create an account to join the conversation.
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.
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:
Please Log in or Create an account to join the conversation.
I did the following to avoid the database query:
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.
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:
Please Log in or Create an account to join the conversation.
Thanks for the help.
Please Log in or Create an account to join the conversation.