0

Simple one but cant find it. How do i display quantity of a product for a group only (wholesale)?

Thanks!

2
  • Are you talking about a customer group?
    – scrowler
    Jun 2, 2016 at 2:59
  • yep only wanted to show it for wholesale group
    – Tom Allan
    Jun 2, 2016 at 3:02

1 Answer 1

2

You can try below code.

$customerSession = Mage::getSingleton('customer/session');
if($customerSession->isLoggedIn()){
      $groupId = $customerSession->getCustomerGroupId();
      $group = Mage::getModel('customer/group')->load($groupId);
      if ('wholesale' == $group->getCode()){ //or $group->getCustomerGroupCode() 
        $qty = (int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty();
        echo 'Available quantity is ' . $qty;
    }
}
4
  • what directory? view.phtml?
    – Tom Allan
    Jun 2, 2016 at 4:11
  • Yes, in view.phtml Jun 2, 2016 at 4:41
  • You can enable the template path hints to know the blocks and the template files being called on the page. Jun 2, 2016 at 4:41
  • How to add a wholesale qty after quantity section inventory admin Jul 2, 2018 at 16:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.