Author Topic: Attention no standard shopper group set  (Read 40193 times)

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 10153
  • VM3.9 Eagle Owl
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Attention no standard shopper group set
« Reply #15 on: March 01, 2012, 00:27:17 am »
use the updates/correct tables tool in the BE http://dev.virtuemart.net/projects/virtuemart/wiki/Tools
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

espatrizio

  • Beginner
  • *
  • Posts: 1
Re: Attention no standard shopper group set
« Reply #16 on: March 06, 2012, 16:45:57 pm »
Hi all,
I've Joomla 2.5 and VirtueMart 2.0.2; I tried modifiing the file administrator/components/com_virtuemart/models/shoppergroup.php like this:

 * Get default shoppergroup for anonymous and non anonymous
  * @param unknown_type $kind
  */
 function getDefault($kind = 0){

And everithing seems to work; updating the value on the value in the database with the following script
UPDATE joomla.whlq6_virtuemart_shoppergroups SET `default`=2 WHERE `virtuemart_shoppergroup_id`=1;
everithing work since a new user will be registered, so this is not the optimal solution. Updating the shoppergroup.php seems to work also after a new user registration.

I hope to be useful..

RG

  • Beginner
  • *
  • Posts: 4
Re: Attention no standard shopper group set
« Reply #17 on: March 07, 2012, 17:31:33 pm »
Had the same error with the newest of VC, Joomla, Wampserver.

The fix mentioned above worked instantly.
Tools - (Install tables or if necessary update them)

peter101

  • Beginner
  • *
  • Posts: 1
Re: Attention no standard shopper group set
« Reply #18 on: March 10, 2012, 03:59:06 am »
Update worked for me thanks guys

beltoforion

  • Jr. Member
  • **
  • Posts: 179
  • Everything is Possible!
    • Ofix-Comp
Re: Attention no standard shopper group set
« Reply #19 on: April 02, 2012, 02:38:45 am »
hello, I have the same issue, with Joomla 2.5 Virtuemart 2.0.2.
wanting to learn to create good templates

mbarry

  • Beginner
  • *
  • Posts: 47
Re: Attention no standard shopper group set
« Reply #20 on: April 28, 2012, 16:41:17 pm »
Hi, I have had same issue migrating to Joomla 2.5.4 and Virtuemart 2.0.6

If the migrate Tools run through to completion then it should create two default shopper groups (-anonymous- and -default-) the sql script that is called to do this is "install_required_data.sql" via script.virtuemart.php.
Shopper group -anonymous- has a 'default' value = 2 while -default- has 'default' =1

This all works fine until you want to change the Default shopper group from -default- to something else ie. you created a new shopper group called "Regular" and wanted this to be the default.

On changing the default to Regular, you will now find that Shoppers who are not logged in ie. Anonymous shoppers will now get the error message "Attention no standard shopper group set".

The problem is the function makeDefault($id,$kind = 1) (administrator/components/com_virtuemart/models/shoppergroup.php) as others have pointed to but for another reason.
The code first checks that you haven't tried to make the -anonymous- shopper the default for Registered users; this is correct.

It is the next line that is incorrect as it simply overwrites the 'default' values for all shopper groups with 0; now you no longer have an Anonymous shopper
$this->_db->setQuery('UPDATE  `#__virtuemart_shoppergroups`  SET `default` = 0');

The code then goes on to set the new default shopper for registered users as expected.

The suggested fix to the above line is to change it to
$this->_db->setQuery('UPDATE  `#__virtuemart_shoppergroups`  SET `default` = "0" WHERE `default` = "1"');
Now it will only reset the current default shopper group and leave the -anonymous- shopper group alone.

Finally, there appears to be another related problem wrt to shopper groups in function remove($ids) (administrator/components/com_virtuemart/models/shoppergroup.php) as pointed out by Thomas

$defaultSgId is never used.  The first test in this function is to prevent the Default shopper group from being deleted. The $defaultId should be changed to $defaultSgId otherwise the code will pass through and may delete it inadvertently should it reach the end of the tests.


I have tested both these suggested fixes by changing default shoppers, attempting to delete the anonymous shopper and attempting to delete the default shopper and appears to work as expected. The Admin page throws up the correct error messages while the shopper never sees the "Attention no standard shopper group set" error message.

I hope this helps, as a newbie to this forum I felt compelled to post what I had found after many long hours trying to migrate web site from Joomla 1.5.14 / Virtuemart 1.1.3. I'm not there yet, but these forums are really the only thing that makes it possible.




malibu2792

  • Beginner
  • *
  • Posts: 27
Re: Attention no standard shopper group set
« Reply #21 on: April 30, 2012, 17:12:55 pm »
Has anyone found a solution to this problem? I have been trying to fix this for about 2 hours.

As of right now, I have it where the error message is displaying when a shopper is not logged in. "Attention no standard shopper group set" When a user logs and is registered the message disappears.

I have updated the tables as instructed above.. tried almost everything I can think of.. Replaced the shoppergroup.php ( attached is the one I am currently using) I just want to get the site back to the way it was default.

I have tried installing an older version..

<?php
/**
*
* Data model for shopper group
*
* @package   VirtueMart
* @subpackage ShopperGroup
* @author Markus Öhler
* @author Max Milbers
* @link http://www.virtuemart.net
* @copyright Copyright (c) 2004 - 2010 VirtueMart Team. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* VirtueMart is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* @version $Id: shoppergroup.php 5419 2012-02-10 19:27:53Z Milbo $
*/

// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die('Restricted access');

// Load the model framework
jimport( 'joomla.application.component.model');

if(!class_exists('VmModel'))require(JPATH_VM_ADMINISTRATOR.DS.'helpers'.DS.'vmmodel.php');

/**
 * Model class for shopper group
 *
 * @package   VirtueMart
 * @subpackage ShopperGroup
 * @author Markus Öhler
 */
class VirtueMartModelShopperGroup extends VmModel {

   /**
    * constructs a VmModel
    * setMainTable defines the maintable of the model
    * @author Max Milbers
    */
   function __construct() {
      parent::__construct('virtuemart_shoppergroup_id');
      $this->setMainTable('shoppergroups');
   }

    /**
     * Retrieve the detail record for the current $id if the data has not already been loaded.
     *
     * @author Markus Öhler
     */
    function getShopperGroup() {

       if (empty($this->_data)) {
         $this->_data = $this->getTable('shoppergroups');
         $this->_data->load((int) $this->_id);
         if(!empty($this->_data->price_display)){
            $this->_data->price_display = unserialize($this->_data->price_display);
         } else{
            if(!class_exists('JParameter')) require(JPATH_VM_LIBRARIES.DS.'joomla'.DS.'html'.DS.'parameter.php' );
            $this->_data->price_display = new JParameter('');
         }
      }

      return $this->_data;
   }


    /**
     * Retireve a list of shopper groups from the database.
     *
     * @author Markus Öhler
     * @param string $noLimit True if no record count limit is used, false otherwise
     * @return object List of shopper group objects
     */
    function getShopperGroups($onlyPublished=false, $noLimit = false) {
       $db = JFactory::getDBO();

       $query = 'SELECT * FROM `#__virtuemart_shoppergroups` ORDER BY `virtuemart_vendor_id`,`shopper_group_name` ';

      if ($noLimit) {
         $this->_data = $this->_getList($query);
      }
      else {
         $this->_data = $this->_getList($query, $this->getState('limitstart'), $this->getState('limit'));
      }

       return $this->_data;
    }

   function store($data){

      $myfields = array('basePrice','variantModification','basePriceVariant',
                                 'basePriceWithTax','basePriceWithTax','discountedPriceWithoutTax',
                                 'salesPriceWithDiscount','salesPrice','priceWithoutTax',
                                 'discountAmount','taxAmount');

      $param ='show_prices='.$data['show_prices']."\n";
      foreach($myfields as $fields){
         $param .= $fields.'='.$data[$fields]."\n";      //attention there must be doublequotes
         $param .= $fields.'Text='.$data[$fields.'Text']."\n";
         $param .= $fields.'Rounding='.$data[$fields.'Rounding']."\n";
      }

      if(!class_exists('JParameter')) require(JPATH_VM_LIBRARIES.DS.'joomla'.DS.'html'.DS.'parameter.php' );
      $jparam = new JParameter($param);
      $data['price_display'] = serialize(new JParameter($param));

      return parent::store($data);
   }

   function makeDefault($id,$kind = 1) {

      //Prevent making anonymous Shoppergroup as default
      $adId = $this->getDefault(1);
      if($adId == $id){
         vmError(JText::sprintf('COM_VIRTUEMART_SHOPPERGROUP_DELETE_CANT_DEFAULT',$name,$id));
         return false;
      }
      $this->_db->setQuery('UPDATE  `#__virtuemart_shoppergroups`  SET `default` = 0');
      if (!$this->_db->query()) return ;
      $this->_db->setQuery('UPDATE  `#__virtuemart_shoppergroups`  SET `default` = "'.$kind.'" WHERE virtuemart_shoppergroup_id='.(int)$id);
      if (!$this->_db->query()) return ;
      return true;
   }

   /**
    *
    * Get default shoppergroup for anonymous and non anonymous
    * @param unknown_type $kind
    */
   function getDefault($kind = 1){

      $kind = $kind + 1;
      $this->_db->setQuery('SELECT * FROM `#__virtuemart_shoppergroups` WHERE `default` = "'.$kind.'" AND `virtuemart_vendor_id` = "1" ');

      if(!$res = $this->_db->loadObject()){
         $app = JFactory::getApplication();
         $app->enqueueMessage('Attention no standard shopper group set '.$this->_db->getErrorMsg());
      } else {
         return $res;
      }

   }

   function remove($ids){

      jimport( 'joomla.utilities.arrayhelper' );
      JArrayHelper::toInteger($ids);

      $table = $this->getTable($this->_maintablename);

      $defaultSgId = $this->getDefault(0);
      $anonymSgId = $this->getDefault(1);

      foreach($ids as $id){

         //Test if shoppergroup is default
         if($id == $defaultId->virtuemart_shoppergroup_id){
            $this->_db->setQuery('SELECT shopper_group_name FROM `#__virtuemart_shoppergroups`  WHERE `virtuemart_shoppergroup_id` = "'.(int)$id.'"');
            $name = $this->_db->loadResult();
            vmError(JText::sprintf('COM_VIRTUEMART_SHOPPERGROUP_DELETE_CANT_DEFAULT',$name,$id));
            continue;
         }

         //Test if shoppergroup is default
         if($id == $anonymSgId->virtuemart_shoppergroup_id){
            $this->_db->setQuery('SELECT shopper_group_name FROM `#__virtuemart_shoppergroups`  WHERE `virtuemart_shoppergroup_id` = "'.(int)$id.'"');
            $name = $this->_db->loadResult();
            vmError(JText::sprintf('COM_VIRTUEMART_SHOPPERGROUP_DELETE_CANT_DEFAULT',$name,$id));
            continue;
         }

         //Test if shoppergroup has members
         $this->_db->setQuery('SELECT * FROM `#__virtuemart_vmuser_shoppergroups`  WHERE `virtuemart_shoppergroup_id` = "'.(int)$id.'"');
         if($this->_db->loadResult()){
            $this->_db->setQuery('SELECT shopper_group_name FROM `#__virtuemart_shoppergroups`  WHERE `virtuemart_shoppergroup_id` = "'.(int)$id.'"');
            $name = $this->_db->loadResult();
            vmError(JText::sprintf('COM_VIRTUEMART_SHOPPERGROUP_DELETE_CANT_WITH_MEMBERS',$name,$id));
            continue;
         }

         if (!$table->delete($id)) {
            vmError(get_class( $this ).'::remove '.$table->getError());
            return false;
          }
      }

      return true;
   }

   /**
    * Retrieves the Shopper Group Info of the SG specified by $id
    *
    * @todo Vendor ID
    * @param int $id
    * @param boolean $default_group
    * @return array
    */
     function getShoppergroupById($id, $default_group = false) {
       $virtuemart_vendor_id = 1;
       $db = JFactory::getDBO();

       $q =  'SELECT `#__virtuemart_shoppergroups`.`virtuemart_shoppergroup_id`, `#__virtuemart_shoppergroups`.`shopper_group_name`, `default` AS default_shopper_group FROM `#__virtuemart_shoppergroups`';

       if (!empty($id) && !$default_group) {
            $q .= ', `#__virtuemart_vmuser_shoppergroups`';
            $q .= ' WHERE `#__virtuemart_vmuser_shoppergroups`.`virtuemart_user_id`="'.(int)$id.'" AND ';
            $q .= '`#__virtuemart_shoppergroups`.`virtuemart_shoppergroup_id`=`#__virtuemart_vmuser_shoppergroups`.`virtuemart_shoppergroup_id`';
       }
       else {
          $q .= ' WHERE `#__virtuemart_shoppergroups`.`virtuemart_vendor_id`="'.(int)$virtuemart_vendor_id.'" AND `default`="2"';
       }

       $db->setQuery($q);
       return $db->loadAssoc();
     }

}
// pure php no closing tag

mbarry

  • Beginner
  • *
  • Posts: 47
Re: Attention no standard shopper group set
« Reply #22 on: May 01, 2012, 14:10:12 pm »
Hi malibu2792

your posted code still has both bugs in it.

Suggest using the latest version of shoppergroup.php and make the following changes

In Function makeDefault($id,$kind = 1)

$this->_db->setQuery('UPDATE  `#__virtuemart_shoppergroups`  SET `default` = "0" WHERE `default` = "1"');

and function remove($ids)

if($id == $defaultSgId->virtuemart_shoppergroup_id)

Once you have made changes you will need to also update Table #__virtuemart_shoppergroups

INSERT INTO `#__virtuemart_shoppergroups` (`virtuemart_shoppergroup_id`, `virtuemart_vendor_id`, `shopper_group_name`, `shopper_group_desc`, `default`, `shared`, `published`) VALUES
(2, 1, '-default-', 'This is the default shopper group.', 1, 1, 1),                   <----- The modified code above will set this to "0" when the default shopper group is changed
(1, 1, '-anonymous-', 'Shopper group for anonymous shoppers', 2, 1, 1);            <----- This is the important entry, the original code would also set this to "0"; there should be no reason to change this, in fact, the code does not allow you to delete the -anonymous- shoppergroup nor make it the default shopper for registered shoppers.

I have attached my version of shoppergroup.php which fixed the problem for me.

Hope this helps.


[attachment cleanup by admin]

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 10153
  • VM3.9 Eagle Owl
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Attention no standard shopper group set
« Reply #23 on: May 02, 2012, 16:53:43 pm »
The problem is the function makeDefault($id,$kind = 1) (administrator/components/com_virtuemart/models/shoppergroup.php) as others have pointed to but for another reason.
The code first checks that you haven't tried to make the -anonymous- shopper the default for Registered users; this is correct.

It is the next line that is incorrect as it simply overwrites the 'default' values for all shopper groups with 0; now you no longer have an Anonymous shopper
$this->_db->setQuery('UPDATE  `#__virtuemart_shoppergroups`  SET `default` = 0');

Thanks, fixed ! Btw my fix works so
Code: [Select]
$this->_db->setQuery('UPDATE  `#__virtuemart_shoppergroups`  SET `default` = 0 WHERE `default`<"2"');
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

burntwear

  • Beginner
  • *
  • Posts: 6
Re: Attention no standard shopper group set
« Reply #24 on: July 06, 2012, 10:11:28 am »
I found out the hard way about this error after changing anonymous shopper group to default then back (experiment) then I got this error, I was afraid to use the updates/correct tables tool as was suggested here due to some of the other comments here about missing images, I tried modify the shoppergroup.php with no luck (maybe I did something wrong) , I next upgraded to 2.08 possibly some template error or something else but I go a new error "getProductPrices no object given query time" so I downloaded 2.06 and overwritten the 2.08 files back to a fresh start the error gone. I still need to figure out how to get florida taxes not to show untill a user enters their address which is why I was experimenting with the shoppergroup in the first place.

spyderwebdesign

  • Jr. Member
  • **
  • Posts: 132
Re: Attention no standard shopper group set
« Reply #25 on: August 06, 2012, 17:49:04 pm »
Once you have made changes you will need to also update Table #__virtuemart_shoppergroups

INSERT INTO `#__virtuemart_shoppergroups` (`virtuemart_shoppergroup_id`, `virtuemart_vendor_id`, `shopper_group_name`, `shopper_group_desc`, `default`, `shared`, `published`) VALUES
(2, 1, '-default-', 'This is the default shopper group.', 1, 1, 1),                   <----- The modified code above will set this to "0" when the default shopper group is changed
(1, 1, '-anonymous-', 'Shopper group for anonymous shoppers', 2, 1, 1);            <----- This is the important entry, the original code would also set this to "0"; there should be no reason to change this, in fact, the code does not allow you to delete the -anonymous- shoppergroup nor make it the default shopper for registered shoppers.

I am trying to run this fix and I get an sql error.

INSERT INTO `#__virtuemart_shoppergroups` (`virtuemart_shoppergroup_id`, `virtuemart_vendor_id`, `shopper_group_name`, `shopper_group_desc`, `default`, `shared`, `published`) VALUES (2, 1, '-default-', 'This is the default shopper group.', 1, 1, 1),

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

Can someone please post the exact sql statement to run?

spyderwebdesign

  • Jr. Member
  • **
  • Posts: 132
Re: Attention no standard shopper group set
« Reply #26 on: August 06, 2012, 18:12:31 pm »
Once you have made changes you will need to also update Table #__virtuemart_shoppergroups

INSERT INTO `#__virtuemart_shoppergroups` (`virtuemart_shoppergroup_id`, `virtuemart_vendor_id`, `shopper_group_name`, `shopper_group_desc`, `default`, `shared`, `published`) VALUES
(2, 1, '-default-', 'This is the default shopper group.', 1, 1, 1),                   <----- The modified code above will set this to "0" when the default shopper group is changed
(1, 1, '-anonymous-', 'Shopper group for anonymous shoppers', 2, 1, 1);            <----- This is the important entry, the original code would also set this to "0"; there should be no reason to change this, in fact, the code does not allow you to delete the -anonymous- shoppergroup nor make it the default shopper for registered shoppers.

I am trying to run this fix and I get an sql error.

INSERT INTO `#__virtuemart_shoppergroups` (`virtuemart_shoppergroup_id`, `virtuemart_vendor_id`, `shopper_group_name`, `shopper_group_desc`, `default`, `shared`, `published`) VALUES (2, 1, '-default-', 'This is the default shopper group.', 1, 1, 1),

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

Can someone please post the exact sql statement to run?

I figured it out. The very end should have ; and not ,

You also have to set your table name #__virtuemart_shoppergroups to yourprefix_virtuemart_shoppergroups

This still didn't fix the error msg. I even reverted my php file back and then went into the database and changed the default value to 2.

spyderwebdesign

  • Jr. Member
  • **
  • Posts: 132
Re: Attention no standard shopper group set
« Reply #27 on: August 14, 2012, 22:13:51 pm »
It's been a week and I still can't get rid of the "Attention no standard shopper group set" error message that shows on every single page of my store. Does anyone have a working solution for 2.0.6?

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 10153
  • VM3.9 Eagle Owl
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Attention no standard shopper group set
« Reply #28 on: August 15, 2012, 18:06:36 pm »
The easiest solution is to go in the table and ensure that one group and only one has the 1 set in the field default.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

spyderwebdesign

  • Jr. Member
  • **
  • Posts: 132
Re: Attention no standard shopper group set
« Reply #29 on: August 15, 2012, 18:16:15 pm »
The easiest solution is to go in the table and ensure that one group and only one has the 1 set in the field default.

Thanks for chiming in Milbo. Unfortunently, I have only one group set to 1 in the default field.

[attachment cleanup by admin]