VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: Otto0815 on April 26, 2012, 18:04:01 PM

Title: How to get the shoppergroup id??
Post by: Otto0815 on April 26, 2012, 18:04:01 PM
Hi,

i would like to show some text in the mincart, depending on the shoppergroup....

So i've tried the following:

$db = JFactory::getDbo();
$user   = JFactory::getUser();
$user1 = ($user->get('id'));

$frage = 'SELECT `*` '
                . ' FROM `#__virtuemart_vmuser_shoppergroups` '
                . ' WHERE `virtuemart_user_id` =' .$user1 ;
               
       $frage2->mysql_query($frage);
echo $frage2;

But this doesn't work    (the echo is only for testing, later it should be used in an if query)

Title: Re: How to get the shoppergroup id??
Post by: Milbo on May 02, 2012, 16:48:21 PM
First you are not using the joomla database connector correctly.

Second, the information is already there imho. Just use vmdebug to print your prices. There are all rules with names listed.
Title: Re: How to get the shoppergroup id??(for use in minicart)
Post by: Otto0815 on May 03, 2012, 15:33:04 PM
Dunno if it's the correct way but it works:

$db = JFactory::getDbo();
$user   = JFactory::getUser();
$user1 = ($user->get('id'));   
   
      $query = 'SELECT `virtuemart_shoppergroup_id` '
                . ' FROM `#__virtuemart_vmuser_shoppergroups` '
                . ' WHERE `virtuemart_user_id` =' .$user1 ;
 
        $db->setQuery($query, 0, 10);
      
      $result1 = $db->loadResult();
   
   $link = JRoute::_('index.php?option=com_content&view=article&id=74&');
   $text = " zzgl. Versand";
   $text2 =" inkl. 19%MwSt.";
   
   if ( !empty($product['quantity']) ){   echo JHTML::_('link', $link, $text);}
if ($data->totalProduct && $result1 != '3')   echo $text2;

So it shows "inkl. 19% zzgl. Versand" to B2C customers, and if the Customer is B2B (setup as shoppergroup_id "3") then it's only "zzgl. Versand"....