Author Topic: How to hide prices to unregistered user  (Read 1248 times)

kentcheung2000

  • Beginner
  • *
  • Posts: 23
How to hide prices to unregistered user
« on: October 08, 2016, 03:03:26 am »
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

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 2768
  • VirtueMart Version: 3.2.15
Re: How to hide prices to unregistered user
« Reply #1 on: October 08, 2016, 10:14:24 am »
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.

Code: [Select]
$user = JFactory::getUser();

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

display the prices

} else {

display something else
}
regards
A

Joomla 3.8.8
php 7.0

technext2k

  • Beginner
  • *
  • Posts: 23
Re: How to hide prices to unregistered user
« Reply #2 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.

bpratt

  • Beginner
  • *
  • Posts: 3
  • A beginner
Re: How to hide prices to unregistered user
« Reply #3 on: March 14, 2018, 02:54:01 am »
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

  • Jr. Member
  • **
  • Posts: 131
    • CRASHDÏET Official Website
Re: How to hide prices to unregistered user
« Reply #4 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...

best

peter

bpratt

  • Beginner
  • *
  • Posts: 3
  • A beginner
Re: How to hide prices to unregistered user
« Reply #5 on: March 14, 2018, 23:12:59 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

  • UK Web Developer & Consultant
  • Global Moderator
  • Super Hero
  • *
  • Posts: 26922
  • Always on vacation
    • Jenkin Hill Internet
Re: How to hide prices to unregistered user
« Reply #6 on: March 14, 2018, 23:26:55 pm »
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

Jenkin Hill Internet,
Lowestoft, Suffolk, UK

Unsolicited PMs/emails will be ignored.

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

Currently using VM.3.2.15.9866 on Joomla 3.8.10 PHP 7.0.30

Testing VM.3.2.15.9898 on J3.8.10

bpratt

  • Beginner
  • *
  • Posts: 3
  • A beginner
Re: How to hide prices to unregistered user
« Reply #7 on: March 15, 2018, 00:15:33 am »
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.