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 button Add to Cart for only some groups of shopper groups

Started by tezza81, November 23, 2015, 05:36:57 AM

Previous topic - Next topic

tezza81

Hi,

I am using joomla 3.4.5 and virtuemart 3.0.12.

I have searched and feel like I've tried every conceivable help on this thread but I can't figure out how to rid my site of the add to cart button for registered guests and have it showing only for my shopper group 'Wholesale Clients'.  I did have a database query working for a while but it since stopped with the latest update that I did..

I found the below in a thread and this seems to be exactly what I need!  Could someone please tell me if this will happen in the near future??

Quote from: Milbo on December 28, 2011, 22:22:10 PM
This feature is at the moment missing, but it is relativly easy to add, we just need to extend the catalogue mode per shoppergroups.

Many thanks :)

GJC Web Design

this is always done afaik by detecting the shopper group and displaying or not the add to cart section in the template

something like


<?php
$userModel 
VmModel::getModel('user');

$vmuser $userModel->getCurrentUser();

$vmgroup $vmuser->shopper_groups;
        
$seecarts = array(3,4,6,7); //allowed to see add to cart
       
function isAllowed($vmgroup$alloweds) {

$isAllowed false;

 foreach ($alloweds as $allowed){

if(in_array($allowed$vmgroup)) {

$isAllowed true;

break;

}

}

return $isAllowed;

}

$allowcart isAllowed($vmgroup$seecarts); // $allowcart will be true if in array

       
if($allowcart) {  ?>

     <!-- cart stuuf-->
      <?php }  ?>



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

ezynet

This is also what i need... I want to only show the add to cart button to logged in users.  I have managed to turn off the pricing by following these threads but I'm confused as to how to turn off the add to cart button.  I am using Joomla 3.4.5 with Virtuemart 3.0.12 and the template I am using is Protostar.  Are you able to please help me know where and what code I need to change to only have the add to cart show up for my default shopper group (logged in) and not my annonymous shopper group (not logged in).  Any help you can give would be greatly appreciated.

GJC Web Design

 <?php if($allowcart) {  ?>
     <!-- add to cart stuff-->
      <?php }  ?>

put your add to cart code between the if
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

ezynet

thankyou.  on what file/folder do i do this on? exactly where in the code? sorry for the questions :)

GJC Web Design

on the product details page default.php

adjust for the category page
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

jenkinhill

I still use this to hide elements from unregistered viewers.

$user =& JFactory::getUser();
if($user->id != 0) {
## code to hide from non-registered ##
}


For category page the sublayout/products.php should be edited and overidden.
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

Studio 42

Hi,
Why removing the add to cart and display the price?
The safe way is to set price by shopper groups, and set price for anonymous user to 0 then add to cart is removed and price hide.
Another way is to disallow checkout for guest, this need no core changes but display add to cart.