Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Role Based Cart Access
 
jwpadgett
Member
 
Total Posts:  69
Joined:  2007-09-05
 

Can I build a site with Magento that is “browse only” except for certain registered users?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Scott
Guru
 
Avatar
Total Posts:  333
Joined:  2007-08-31
Northwest Ohio
 

I believe you can. You’d do it by creating an additional customer group (I’ll name this group “cool members” because they must be cool if they’re gonna buy something from my “cool stuff” shop, hehe).

So then link all your products only to that group, and not the default group. Then, when someone creates an account they can essentially “apply” for membership. This is an implied membership application as you would still need to review all the new registrations, determine if they are worthy of membership, then assign them to the “cool members” customer group. But they can still create an account and browse any products you might have linked to the default customer group.

So in that sense, I’d say it’s certainly possible. You just gotta find all the sections that let you do what I instructed: customer groups, linking products to customer groups, editing each account manually for access to the “cool members” group.

Oh yeah, we’re cool now! cool smile

 
Magento Community Magento Community
Magento Community
Magento Community
 
jwpadgett
Member
 
Total Posts:  69
Joined:  2007-09-05
 

Scott,

What you suggested sounds like the products assigned to the “cool customers” group would not be visible to those not assigned to the group. I need all products to be visible to all people, but only let the “cool customers” have buying ability. Ideally, the site would not display any cart capabliity, only merchandising, to those not worthy enough to make a purchase.

My goal is to setup a dual purpose site. One that end-users can go to for information, but wholesalers can go to for purchasing. Makes sense?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Scott
Guru
 
Avatar
Total Posts:  333
Joined:  2007-08-31
Northwest Ohio
 

Aha, different ball game there.

I can’t think of a way to do it off hand. Do you mind if the non cool customers see the price and other attributes? I’m not sure that what you want to do it possible out of the box, but I’m sure it can be modified or extended to do so if it’s not already a feature. If it is, I’m not finding any way to enable it (and I’m sure you looked too).

Anyway, maybe Moshe or Yoav would have a better idea as to what’s possible.

 
Magento Community Magento Community
Magento Community
Magento Community
 
jwpadgett
Member
 
Total Posts:  69
Joined:  2007-09-05
 

Ideally no price will be shown to the “uncool,” but other attributes are ok. Again, all the retail customer would see is product details and a picture. This site would be more of an info site to non-wholesalers.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Moshe
Magento Team
 
Avatar
Total Posts:  1770
Joined:  2007-08-07
Los Angeles
 

I think it should be fairly simple to implement.

1. Search for all the files in “app/design/frontend/” directory that contain “getAddToCartUrl” link. Currently there are 11 files with 15 occurences.

2. Wrap the whole tag (<button> or <a>) in condition:

<?if ($this->helper('yourmodule')->canSell($_product):?>
<button>...</button>
<?endif?>
Notes:
* $_product is optional, if you want to add product specific logic. You might omit it in your case.
* $_product might need to be replaced with $_item, depending on context.
* create a custom theme and put changed files there to allow future upgreadability.

3. Create your helper class and method:

class Mage_YourModule_Helper_Product extends Mage_Core_Helper_Url
  
public function canSell($product)
  
{
    
// Fetch currently logged in customer's group id
    
$loggedInCustomerGroupId Mage::getSingleton('customer/session')->getCustomer()->getGroupId();

    
// Put your "cool" group id here.
    
$allowedGroupId 2
    
// Alternatively you could take it from configuration:
    // $allowedGroupId = Mage::getStoreConfig('yourmodule/cool_customers/group_id');

    // Validate button visibility
    
return $loggedInCustomerGroupId == $allowedGroupId;
  
}
}
It is possible to overload existing helper too.

To add configuration field, create app/code/local/Mage/YourModule/etc/system.xml by example from core modules.

There might be logical implication in other areas of the website, but this customization will give ability to control visibility of “Add to cart” buttons.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top