VirtueMart Forum

VirtueMart 2 + 3 + 4 => Frontend Modules => Topic started by: welrachid on October 03, 2016, 13:16:53 PM

Title: VM show cart ONLY for logged in users and only admin can sign new users up
Post by: welrachid on October 03, 2016, 13:16:53 PM
Hi
Im using VM to make a shopping site for regular customers.
I need a plugin that can help me REQUIRE people to signin IF they press add-to-cart btn and i DONT want people to be able to sign up. ONLY admin should be able to sign new accounts up.
This is a "CLOSED SHOP" only for pre-registered regular users.
Do you know of a plugin, free or paid, i would really appreciate it.

Thanks
Wel
Title: Re: VM show cart ONLY for logged in users and only admin can sign new users up
Post by: Studio 42 on October 04, 2016, 02:54:03 AM
I think that a tempalte overide can solve this.
Check for user logged in and add a login button to replace add to cart button, if user is not logged in.
And disable display for anonymous the Joomla cart module, menu links, order ... TO make all private.
Title: Re: VM show cart ONLY for logged in users and only admin can sign new users up
Post by: welrachid on October 04, 2016, 13:39:25 PM
So far i've solved it using this:
   $not_allowed_views = array("cart","registration");

   if ($user->guest && in_array($app->input->get('view'),$not_allowed_views)) {
      $login_url = 'index.php?option=com_users&view=login';
      $app = JFactory::getApplication();
      $url = JRoute::_($login_url);
      $app->redirect($url);
   }
This should eliminate most users.. Not sure if one calls directly to the controllers and how to avoid that..
I'm using custom script to create new users directly from e-conomic debtors.
Title: Re: VM show cart ONLY for logged in users and only admin can sign new users up
Post by: Studio 42 on October 04, 2016, 15:04:51 PM
To eliminate a view, add a filter for the menu for cart and exclude anonymous user.
Registration menu link cannot completly disable else user cannot login. But you can add a position with this links and check for anonymous user too to not display it in this case or simply disable Joomla registration.