VirtueMart Forum

VirtueMart 2 + 3 + 4 => Administration & Configuration => Topic started by: stensbo on January 08, 2021, 11:44:01 AM

Title: Critical-shop for registered users only, display products and prices to public
Post by: stensbo on January 08, 2021, 11:44:01 AM
Using Joomla! 3.9.20,  Virtuemart 3.8.4 10335, PHP Version 7.4.14, vm overrides.
template Storefront version 3.25 - site danrider.dk

We have a shop (wholesale)- for registered users only.
Login module is assignet to a menu - for public
Virtuemart frontpage is assignet to a menu there is set for registered users only - all our vm modules is set for registered users only.
Despite that it sometimes popup with " you have to assign Virtuemart Component to a menu"
Google search on one of our products leads to a view of the product with price - that should not be possible.
- url:https://oursite.dk/index.php/component/virtuemart/.....and the product -

Have tried to disable template overrides by renaming the virtuemart_com folder in template/html - view still display
even after I was forced to set our site offline the view still display.

Any ideas?
Title: Re: Critical-shop for registered users only, display products and prices to public
Post by: StefanSTS on January 08, 2021, 12:20:36 PM
If you do not show prices for guest, they will not appear in Google. Some setting is wrong.

You should assign shopper groups.
Title: Re: Critical-shop for registered users only, display products and prices to public
Post by: stensbo on January 08, 2021, 12:38:42 PM
We have several shoppergroups and prices for each group.
When import product with csvi price goes in default shoppergroup - then we import prices for the other groups.

Normally when we ad a product link to a newsletter and customers click on that they get the login module
Title: Re: Critical-shop for registered users only, display products and prices to public
Post by: StefanSTS on January 08, 2021, 12:54:06 PM
If you use the template Storefront from Gavick, you might have come the way from VirtueMart 2 and something in the core or in some extensions is not up to date.

In that case, this won't be easy to solve via forum.

Title: Re: Critical-shop for registered users only, display products and prices to public
Post by: stensbo on January 08, 2021, 14:05:59 PM
Thanks but what do you mean by this "If you do not show prices for guest" - shopper can not register and have not access to our shop unless they have a username and passsword provided from us
Title: Re: Critical-shop for registered users only, display products and prices to public
Post by: Jörgen on January 08, 2021, 14:26:34 PM
I think Stefan means that if your prices are "accessible to everyone" it is not enough just to have login restrictions. Are your prices accessible to all user groups ?

Jörgen @ Kreativ Fotografi
Title: Re: Critical-shop for registered users only, display products and prices to public
Post by: stensbo on January 08, 2021, 14:53:49 PM
Okay thanks - yes we have prices available to all shoppergroups on some products.
If I add a link in browser for one such product I get the login formular and that i correct.
If I add https://oursite.dk/index.php/component/virtuemart...... I get the first category with products and prices  and that should not be possible - i think

edit: .. and it tell to add Virtuemart Component to a menu. Virtuemart frontpage is assigned to a menuitem that is for registered users only.
Title: Re: Critical-shop for registered users only, display products and prices to public
Post by: StefanSTS on January 08, 2021, 16:41:07 PM
Quote from: stensbo on January 08, 2021, 14:05:59 PM
Thanks but what do you mean by this "If you do not show prices for guest" - shopper can not register and have not access to our shop unless they have a username and passsword provided from us

If your prices are restricted to the shopper group Standard, Google will not be able to access your prices, because Google visits your site as guest.
If a user logs in, the user will be treated as in the group Standard, only after logging in, the user will see prices.

Please check, where you have restricted the access to the prices.

Once you can do it in your product, but you can also show different prices for different shopper groups. Check the setting in each individual shopper group for that.

Title: Re: Critical-shop for registered users only, display products and prices to public
Post by: stensbo on January 08, 2021, 17:53:33 PM
Thanks StefanSTS
QuotePlease check, where you have restricted the access to the prices.

Our shop is only for registered users - it's behind a login module - Virtuemart frontpage is assigned to a menuitem with access: registered - users are not able to register themselves -  so I think no one should be able to se anything in our shop unless we provide them with login info. Am I right ?

Title: Re: Critical-shop for registered users only, display products and prices to public
Post by: StefanSTS on January 08, 2021, 18:47:15 PM
Restricting the VirtueMart frontpage link is not the way to deny access to VirtueMart pages or prices.
It just doesn't show a direct link to VM.

You have to disable prices for guest users. Either in every product, or for the shopper group guest.
Enable "Show shoppergroup specific prices" in the shopper groups settings.

EDIT: If you additionally want to restrict the guest so far that they cannot see any products, you could set the categories to shopper group "Standard".
Not sure, if it would be possible to get products via direct link. You might be able to set some restrictions in the menu item setting.

Otherwise you have to disable VM completely for guest via ACL, I guess. Never did that. Most people want to show the products without prices at least.

Title: Re: Critical-shop for registered users only, display products and prices to public
Post by: stensbo on March 22, 2021, 16:06:25 PM
QuoteOtherwise you have to disable VM completely for guest via ACL, I guess.

That's what I thought we had but i found that we do not have the guest group in ACL - only Public (Public ACL settings for Virtuemart - not allowed), and I can read in Joomla forum that others, that have updated Joomla regularly from years back like us, have the guest group missing.

All modules, plugins, menus a.s.o that are used in Virtuemart are restricted to for registered users only

Have exported all our prices prices and found the prices that are available to all shoppergroups but they are convenient
when all shoppergroups have the same price for a product...so I would like to avoid to delete them but of course if necessary I will do so.

Also found that our virtuemarts 2 default shoppergroups is -anonymous- and -default- where in newer versions they are
Default Shopper Group/COM_VIRTUEMART_SHOPPERGROUP_DEFAULT and Guest Shopper Group/COM_VIRTUEMART_SHOPPERGROUP_GUEST

It seems to be something that is not being properly updated - that do you think?
Title: Re: Critical-shop for registered users only, display products and prices to public
Post by: Studio 42 on March 23, 2021, 09:00:36 AM
You can disable price and add to cart with PHP on checking the user is guest.
$user = JFactory::getUser();
if ($user->guest) return;
at the begin of the file you need to disable for public.
Using another method is not safe because you can access directly to your component using the non sef link index.php?option=com_virtuemart&...
Title: Re: Critical-shop for registered users only, display products and prices to public
Post by: stensbo on March 24, 2021, 16:44:58 PM
Thank you Studio 42
Found one of your other suggestions in another topic

<?php 
if(empty(JFactory::getUser()->id)) {
echo 
"My simple text";
return;
?>


and added it at the begin of
..templates/my_template/html/com_virtuemart/productdetails/default.php and
..templates/my_template/html/com_virtuemart/category/default.php
It seams to work:) In this way we should be able to keep prices "available to all" on some products and be sure they aren't displayed to not logged in users - right?
Title: Re: Critical-shop for registered users only, display products and prices to public
Post by: Studio 42 on March 25, 2021, 10:23:16 AM
If you want display price in some categories, then do a copy of default.php and remove the condition and in the category setting change the default layout with your new layout
Title: Re: Critical-shop for registered users only, display products and prices to public
Post by: stensbo on March 25, 2021, 13:49:18 PM
Okay - thank you but our intention is that only logged in users, with login provided by us, have access to and can see contents in our shop. I hope that we with your code have
closed the access directly to the component using the non sef link.