Jump to content

auto assign customer to group at time for registration based on there States or Country


Zen_j1

Recommended Posts

  • 2 weeks later...

Hello,
I've done a module which is doing this.
Unfortunately it works only under prestashop 1.6 for now.
But you can try to fork it on github in order to make it work on your version .
 

https://github.com/nenes25/prestashop_customerautogroups
http://www.h-hennes.fr/blog/2015/11/10/prestashop-ajouter-automatiquement-les-clients-a-un-groupe-lors-de-linscription/ (FR)

 

Regards,

  • Like 1
Link to comment
Share on other sites

Hello,

I've done a module which is doing this.

Unfortunately it works only under prestashop 1.6 for now.

But you can try to fork it on github in order to make it work on your version .

 

https://github.com/nenes25/prestashop_customerautogroups

http://www.h-hennes.fr/blog/2015/11/10/prestashop-ajouter-automatiquement-les-clients-a-un-groupe-lors-de-linscription/ (FR)

 

Regards,

 

Thank you so much for your reply last time you helped me for recaptcha module. I tried to install this module on prestashop 1.5.4.1 and getting error message can you please make this module compatible with prestashop 1.5. I don't know how to fork and make it compatible with prestashop 1.5

 

Error which I got while installing the module:- 

 

 

The following module(s) were not installed properly:

  • - customerautogroups : 

    The version of your module is not compliant with your PrestaShop version.

Edited by Zen_j1 (see edit history)
Link to comment
Share on other sites

Thank you for your help. I have successfully installed module on 1.5. As I would like to group customer by there country in back office of module I have set condition type as address and condition filed as id_country (In this case country US with ID no 21). Started registering new demo customer with country having US (ID 21) but they where not added to group US instead they where added to default customer group.

 

Then I went back in module setting that after saving id_country as condition and found that id_country is actually not saved it defaulted to back id_shop and not saving id_country where as it saving id_shop instead of id_country. I have attached to screen shots before save and after save please take a look.

 

I would also like to bring to kind attention that any condition field under condition type as customer is saved properly. I have not tested yet these condition type. But any condition filed under condition type address are not saved and defaulted back to id_shop.

post-375930-0-02592500-1447430556_thumb.jpg

post-375930-0-92464600-1447430574_thumb.jpg

Link to comment
Share on other sites

Hello,

 

In fact it  was only a display issue of the condition in administration.
The data are well entered in the database.
I've corrected it in the version 0.1.2

 

I've use it with success with the data you've entered, that's weird.
Could you try again ?

 

Regards,
 

  • Like 1
Link to comment
Share on other sites

In new version it is displaying field correctly under condition type address. I have tried again to group customer with ID 21 for country US but they are been added to default customer group. I have also again done fresh installation of prestashop 1.5.4.1 on localhost and tried again but it is still adding to default customer group instead of Group US. Is there any other setting to be done which I am missing.

Link to comment
Share on other sites

Thanks for your reply and sorry for replying late as I was out of town. I have tried another option to group customer by last name for e.g last name= smith. Module does group  customer by last name it adds customer to Group Smith and default group customer with success. 

 

but I failed to group customer by country_id I also tried go group customer by state_id without success I used same sitting as shown your screen shot. I have even tried condition filed "country" and typed United States in condition value but I had no success.

 

I have even tried group customer with there email ID for gmail.com and @gmail.com to group all customer having email with gmail. I was not successful.

 

I need to group customer by country or states. I deleted class_index file in cache folder and tried without success I am not sure why I am not able group customer by country ID or state ID but I can group customer by last name. 

Link to comment
Share on other sites

Hi there, 

 

        As you have already done so much with this module i would like make one more request to you. As module does automatically group customer places them in respective group. Is possible to automatically set there default group to there group for e.g customer added to group US should also have default group US. 

 

        As if now even if customer is added to US group his/her default group remain customer group, for each customer manually we have to change default group in there profile.  I hope you will take this request in consideration.

Edited by Zen_j1 (see edit history)
Link to comment
Share on other sites

Hello,

 

This kind of behaviour is not applicable with the module way of working.
As an user can be related to n groups, the default code cannot assign default group otherwise it will be a great mess.

 

So in order to correct your problem i sugget you to use a specific script like this one which will automaticaly change the user's default group.
You can put for example in file updateGroups.php in the customerautogroups module.

So you can call it with an url like : http://yoursite.com/customerautogroups/updateGroups.php

Like this :

<?php

include_once(dirname(__FILE__).'/../../config/config.php');

//Put here the ids of the groups for which you want to change the default groups
$idGroupsDefaults = array(5,8);

foreach ( $idGroupsDefaults as $idGroup ) {

$group = new Group($idGroup);
$customers = $group->getCustomers();

foreach ( $customers as $customer ) {
	$customer = new Customer($customer['id_customer');
	$customer->id_default_group = $idGroup;
	$customer->save();
}
}



?>

 

Link to comment
Share on other sites

Thanks for your reply. I followed your instruction but I think I am missing something from instruction I am writing down step which I have done to make this work I kindly request you to take a look at step and please let me know what I am missing so I can correct myself to make this work.

 

Step 1) I copied your code from above post as its, just changed the ID in array from (5,8) to (4,7) in my case ID 4 is for group US and ID 7 is for Group Canada and created and saved a file as updateGroups.php

 

Step 2) Copied and pasted this updateGroups.php file in localhost/mysite/module/customerautogroups/updateGroups.php (The module folder for customerautogroups)

 

Step 3) Copied and pasted this updateGroups.php file in localhost/mysite/customerautogroups/updateGroups.php (In this case I created a New folder customerautogroups in mysite folder to paste updateGroups.php

 

​Step 4) I started registering new customer from US and canada they are successfully added to there respective group US and Canada group but default remain customer group. They are NOT changed to default US (ID 4) and canada (ID 7) respectively.

 

I am doing something wrong in steps. Please guide me correct myself and make this work.     

Link to comment
Share on other sites

Sorry i give you a wrong path...
In fact you juste have to add this file in the customerautogroups directory.

modules/customerautogroups/updateGroups.php

 

But to be clear this page won't be called automaticaly, as it's not really linked to the module.
You have to call it with a cron task.

Link to comment
Share on other sites

Thanks for your reply. I will do research on google to find how to call it thru cron task as I have never used cron task. I was just wondering if possible provide a radio button in module with Yes or No to make particular Group default by including above code in module.  This is just a thought I have No knowledge of programming.

Link to comment
Share on other sites

  • 2 weeks later...

Hi there,

 

         Thanks for your reply. I a have installed v 2 of module and try to create a group it gives error given below

 

An error occurred while creating an object. autogroup_rule (Unknown column 'default_group' in 'field list')

Link to comment
Share on other sites

Hi there,

 

          I have downloaded prestashop 1.6.1.3 installed on my localhost and installed v2 of module on it. I do not get Error message in  1.6 which I am getting 1.5.4.1 but I would also like bring to kind attention that even if I set default group yes, stop processing yes default group still remain customer and default group is not set to US.

 

In second case I have all also set delete group to yes, default group yes, stop processing yes and checked with one more registration found that group access for customer group is removed and access to only US group is there But still the default group remain customer and it is not set US as default group. 

Link to comment
Share on other sites

  • 2 weeks later...

Perfect. Just perfect herve's module v 0.2.1 adds customer to there group and can also set them as default group. I worked with this module on prestashop 1.5.4.1 and 1.6.1.3 to group customers by country and also tested with states in both cases it provided result with success. Thank you very much herve for your work.

Link to comment
Share on other sites

  • 3 months later...

Hello.

This module is exactly what I need for my shop, but I cannot make it work. I installed it, and it appears in modules list, but for me it is not configurable. What did I do wrong?

I need to put customers in groups according to Countries they came from and separate Companies (this is for the taxsation purposes)

 

I would appriciate some help  :mellow:

Thank you.

Link to comment
Share on other sites

Hello,

 

You can read more about this module on my blog post :

http://www.h-hennes.fr/blog/2015/11/10/prestashop-ajouter-automatiquement-les-clients-a-un-groupe-lors-de-linscription/
It's in french but you can translate it using chrome.

 

When the module is installed a new link appears in the customer menu, in which you can create your specific rules.

 

Regards,

Link to comment
Share on other sites

  • 2 years later...

Hello,
at first thanks for the module. Ive installed it in 1.7 , no problems with installation.
I want to use the conditon field "company". If the user regist and gives a company name, than the user should be assigned to a group called B2B. The B2B mode is activated. But on registration process it doesnt assign new customer to new group. Do I something wrong?
Thanks in advice.
BR

1.thumb.jpg.49fe9cb13d1d4c33618f63865a8e02b5.jpg

Link to comment
Share on other sites

  • 2 years later...
On 11/22/2015 at 10:31 AM, herve25 said:

OK great you have found from where the issue comes from 🙂 !
I've forget to speak about it .

Hi herve25,
firts of all I want to thank you for your precious module, it solves a great prestashop missing function for me!
I've install your module on my prestashop 1.6.1.24, and after many test of registration, I was near to remove the module, I've understood I must activate "Standard registration (account and address creation)".
I'm here to ask you if it's possible to upgrade your beautyfull module assigning group on the insertion of address after registration, in this way I can leave separate Creation of customer account and insertion of address.
Thank you in advance.
Aled

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...