• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2535
  • Last Modified:

Automatically assign new Virtuemart/Joomla members to shopper group

joomla 1.5.1.5 vm 1.1.4

I would like my new members to be assigned to a shopper group when they register.

A simple idea one would think, but how can this be achieved?

Please help, many thanks in advance.

p.s. have been considering advice on the following post: http://forum.virtuemart.net/index.php?topic=38226.0
0
TonyCabone
Asked:
TonyCabone
1 Solution
 
manomaniCommented:
Hi.,

Just  refer the link .

Shopper group extension v0.7.70

http://forum.virtuemart.net/index.php?topic=35677.0

It's a excellent option for virtuemart. where you can set individual product for individual user, and default usergroup assignment against new registration .. . etc.

any doubts or informations you can arise here.
0
 
Jesse MatlockUX EngineerCommented:
@manomani -- see my response to the other post you included this recommendation in:
"This is a decent extension, however it doesn't offer the ability to register two different kinds of user groups, it only allows to add new users to the default shipper group.. which is the main issue.

Also note, that even though Daniel has been working on this for a while, he'll tell you himself to use it on a live site at your own risk.. since it requires changes to core files."

Anytime we recommend users to hack core files we are putting them, their sites and potentially business, at risk. Hacking core files needs to be done with great knowledge of the implications and in a thought out manner.. to be successful.
0
 
TonyCaboneAuthor Commented:
Thank you both once again for your recommendations- see the other thread for a link to what it is exactly we're discussing. I think we can definitely work out a solution now.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Jesse MatlockUX EngineerCommented:
Sounds great... see you on the other thread.
0
 
TonyCaboneAuthor Commented:
Would this be suitable:

add a user field (type checkbox for example) to select the group at registration.
Then in the code :

add a test of the checkbox value before inserting the group in database (function add()) :


      if($fields['my_field']=="1")
      {

         $d['shopper_group_id']="my_group_id";
      }
     
     
      $customer_nr = uniqid( rand() );
      // Insert Shopper -ShopperGroup - Relationship
      $q  = "INSERT INTO #__{vm}_shopper_vendor_xref ";


and in the update() function :

   // Delete shopper_vendor_xref entries
      $q = "DELETE FROM #__{vm}_shopper_vendor_xref where user_id='" . $d["user_id"] . "'";
      $db->query($q);

      // UPDATE #__{vm}_shopper group relationship
      $q = "SELECT shopper_group_id FROM #__{vm}_shopper_vendor_xref ";

....
if($fields['my_field']=="1")
      {

         $d['shopper_group_id']="my_group_id";
      }
$q  = "INSERT INTO #__{vm}_shopper_vendor_xref ";
0
 
TonyCaboneAuthor Commented:
changing this code in administrator/components/com_virtuemart/classes/ps_shopper.php auto assigns new users to wholesale group:

If you change the code in line 419 which is

$d['shopper_group_id'] = $db->f("shopper_group_id") ;

To

$d['shopper_group_id'] = 7 ;

only thing is, when logged in there is an error 'unable to load user'

Any idea how to fix that?
0
 
Jesse MatlockUX EngineerCommented:
Hi Tony... yes, this could work.. if you are able to:

1) Have your default shopper group be the one without discounts applied.
2) Upon registration, the new user is added to shopper group WITH the discount.
This way, your store will show the non-discounted prices,.. however when someone registers, they will see the updated, discount pricing.

0
 
TonyCaboneAuthor Commented:
Hi cloud9

sorry can you remind me what file I'm supposed to put that code into, I'm a little overwhelmed at the moment!

T
0
 
Jesse MatlockUX EngineerCommented:
What code are you referring to? I wasn't recommending any hacks to the files..
0
 
TonyCaboneAuthor Commented:
No sorry I wasn't suggesting anything like that, I was lazy in my question writing so allow me to re-phrase:

I can't actually remember what file I pulled the attached code from initially, do you happen to recognize where it's from?

thanks
add a user field (type checkbox for example) to select the group at registration.
Then in the code :

add a test of the checkbox value before inserting the group in database (function add()) :


      if($fields['my_field']=="1")
      {

         $d['shopper_group_id']="my_group_id";
      }
     
     
      $customer_nr = uniqid( rand() );
      // Insert Shopper -ShopperGroup - Relationship
      $q  = "INSERT INTO #__{vm}_shopper_vendor_xref ";


and in the update() function :

   // Delete shopper_vendor_xref entries
      $q = "DELETE FROM #__{vm}_shopper_vendor_xref where user_id='" . $d["user_id"] . "'";
      $db->query($q);

      // UPDATE #__{vm}_shopper group relationship
      $q = "SELECT shopper_group_id FROM #__{vm}_shopper_vendor_xref ";

....
if($fields['my_field']=="1")
      {

         $d['shopper_group_id']="my_group_id";
      }
$q  = "INSERT INTO #__{vm}_shopper_vendor_xref ";

Open in new window

0
 
Jesse MatlockUX EngineerCommented:
That looks like it belongs in either ps_shopper.php or ps_user.php (both are located in admin/components/com_virtuemart/classes)

But, that looks like modified code and not VM core code.. just FYI :)
0
 
TonyCaboneAuthor Commented:
Thanks a million!
0
 
Jesse MatlockUX EngineerCommented:
Anytime.. glad to help you got it sorted out and working well :D
0
 
Amanda WatsonCommented:
Hello Tony and Cloud9manager

I see you guys have been working on something here that may help me out...??

http://www.experts-exchange.com/Software/Server_Software/Content_Management/WebBased_CMS/Joomla/Q_26231890.html

Heres my post, I hope to hear from you ;-)
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now