Jump to content

Auto assign customer Group based on Zones or Country or States at the time registration


Recommended Posts

I using prestashop 1.5.4.1 how can i auto Auto assign customer Group based on state at the time of registration

 

If customer is from State A he should be assigned to group A once he saves his address

 

If customer is from State B he should be assigned to group B once he saves his address

 

so on

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

Ok found some thing on this post https://www.prestashop.com/forums/topic/330590-adding-customers-to-groups/  

 

Vekia explain how to add customer email to group can someone help on same principle how to add customer state (or state having ID) to group (or group having ID)

 

In below code i understood for

 

1) for ID_OF_GMAIL_GROUP i have to use ID of my group , If I am correct ;) 

 

 What I should use for this list($user, $domain) = explode('@', $_POST['email']); I think $user will remain as it is correct me if I am wrong Will $State replace $domain?

 

 

What will change for this part of code = explode('@', $_POST['email']);

 

below code check for gmail, hotmail how can I just check State by ID and assign them to group By ID

 

 

 

 

 

Vekia code code from above post

 

 

okay, so in file controllers/front/AuthController.php you can find code like:

 

$customer->addGroups(array((int)Configuration::get('PS_CUSTOMER_GROUP')));

 

change it to:

 

list($user, $domain) = explode('@', $_POST['email']);

if ($domain == 'gmail.com') {
$customer->addGroups(array(ID_OF_GMAIL_GROUP));
} elseif ($domain =='hotmail.com' ) {
$customer->addGroups(array(ID_OF_HOTMAIL_GROUP));
} else {
$customer->addGroups(array((int)Configuration::get('PS_CUSTOMER_GROUP')));
}

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

If not zones how about country I think controllers/front/AuthController.php can filer group based customer selecting country in front office if above code can filter customer based on email than it should be possible to fiter customer based on country ID and auto assign group But How ?

 

I am not programmer but I think by repacling correct variable or little change in above code we should able to automatically group customer by country

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

  • 1 year later...
  • 3 weeks later...

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...