News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Remove add to cart button on specific shopper group?

Started by discjockeyr, October 03, 2019, 13:25:11 PM

Previous topic - Next topic

discjockeyr

Hi there,
On my website until now i had a "wholesale" shopper group and i add the registered customers that i want to this group to see prices and place online orders. Now i want to add a new price group "Retail" that the price will be available for non registered visitors but if i do that in the page details there is an Add To Cart button. is there a way to hide this button for non registered users and keep the price?

Thanks

GJC Web Design

detect the shopper group in the template and either don't display or hide with css

find the shopper group with

$userModel = VmModel::getModel('user');
$vmuser = $userModel->getCurrentUser();
$vmgroup = $vmuser->shopper_groups;
//is an array
if(in_array(x, $vmgroup) {

}
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

Studio 42

Or simply use Joomla user, to check for guest. See all info for a Joomla user https://docs.joomla.org/Accessing_the_current_user_object
sample code :
$user = JFactory::getUser();

if (!$user->guest) {
  //any code for logged user
}

You can do an override in your template from components/com_virtuemart/sublayouts/addtocart.php in templates/YOURTEMPLATE/html/com_virtuemart/sublayouts/addtocart.php
for eg. after defined('_JEXEC') or die('Restricted access');
if(JFactory::getUser()->guest) return;

discjockeyr