VirtueMart Forum

VirtueMart 2 + 3 + 4 => Administration & Configuration => Topic started by: tezza81 on November 23, 2015, 05:36:57 AM

Title: Remove button Add to Cart for only some groups of shopper groups
Post by: tezza81 on November 23, 2015, 05:36:57 AM
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 :)
Title: Re: Remove button Add to Cart for only some groups of shopper groups
Post by: GJC Web Design on November 23, 2015, 10:31:04 AM
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 }  ?>



Title: Re: Remove button Add to Cart for only some groups of shopper groups
Post by: ezynet on December 02, 2015, 22:02:49 PM
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.
Title: Re: Remove button Add to Cart for only some groups of shopper groups
Post by: GJC Web Design on December 02, 2015, 23:40:39 PM
 <?php if($allowcart) {  ?>
     <!-- add to cart stuff-->
      <?php }  ?>

put your add to cart code between the if
Title: Re: Remove button Add to Cart for only some groups of shopper groups
Post by: ezynet on December 09, 2015, 03:38:54 AM
thankyou.  on what file/folder do i do this on? exactly where in the code? sorry for the questions :)
Title: Re: Remove button Add to Cart for only some groups of shopper groups
Post by: GJC Web Design on December 09, 2015, 09:39:15 AM
on the product details page default.php

adjust for the category page
Title: Re: Remove button Add to Cart for only some groups of shopper groups
Post by: jenkinhill on December 09, 2015, 13:38:16 PM
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.
Title: Re: Remove button Add to Cart for only some groups of shopper groups
Post by: Studio 42 on December 10, 2015, 01:04:32 AM
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.