News:

Looking for documentation? Take a look on our wiki

Main Menu

How to hide prices to unregistered user

Started by kentcheung2000, October 08, 2016, 03:03:26 AM

Previous topic - Next topic

kentcheung2000

I use joomla 2.5 and virtuemart 2.6.6.

I like to to hide prices to unregister users.  I search the forum and I got the following result but not understanding it.  Where I can find a simple and obvious solution?...

"Use template overrides for category & product prices with a check if the user is logged in. If not logged in then hide the price display.".....

Many Thanks.

AH

You could achieve this by setting the prices to only show for registered users at an individual price level.  If you have a lot of products, this can be quite painful, especially if you forget to do this.  BUt this is the functionality that VM provides to achieve what you wish, without making any changes to templates etc.

However this could also be achieved through an (possibly nasty) override to the price template - not sure what it will do to any modules such as promoted products but it might work for you.

\templates\yourtemplate\html\com_virtuemart\sublayouts\prices.php

You need to check for a user id and if there is one, the user is registered and logged in.


$user = JFactory::getUser();

if ( $user->id > 0 ) { ?>

display the prices

} else {

display something else
}
Regards
A

Joomla 4.4.5
php 8.1


bpratt

Quote from: technext2k on February 19, 2018, 23:57:11 PM
This extension can do what you need;
https://codingmall.com/products-mainmenu-8/198-virtuemart-keep-shop-private

A commercial one though.

Ouch, that is very expensive for what is apparently a simple function.

I'm very new to virtuemart, and doing up a e-commerce site for someone else, and will find it hard to convince them in the value of such an extension.

Very surprised that there isn't an internal option to displayed prices only to those logged in.  :(

loppan

It's just €29? Considering Virtuemart is free...  €29 for a specific feature is not much imo...

best

peter

bpratt

Quote from: loppan on March 14, 2018, 17:20:07 PM
It's just €29? Considering Virtuemart is free...  €29 for a specific feature is not much imo...

Yes, I know virtuemart is free, but this is what I'd think would be a simple option that should have been built in to virtuemart already.  :)

Hope the developers of virtuemart consider adding this option in an update. :)

jenkinhill

Or you could use this plugin:  https://shop.st42.fr/en/products/shortcodes.htm

Alternatively you can add code to hide prices & add to cart bar in template overrides, using tests for logged in/out. Sample code snippet given above by AH.

It is not likely to be added to the VM core as it would probably break existing sites using commercial templates.
Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

bpratt

Quote from: jenkinhill on March 14, 2018, 23:26:55 PM
Or you could use this plugin:  https://shop.st42.fr/en/products/shortcodes.htm

Yeah, that does a few things, so worthwhile spending money on it, versus that other one that only does one thing.

Quote
Alternatively you can add code to hide prices & add to cart bar in template overrides, using tests for logged in/out. Sample code snippet given above by AH.

Saw that one. Wish my coding skills were much better than what they are. :)

Quote
It is not likely to be added to the VM core as it would probably break existing sites using commercial templates.

That's a shame, but that's interesting to note that a change to VM would break existing commercial templates.