How to assign customer group automatically based on address information












0














How to assign customer group automatically following by address information



When customer register on our website, customer write the country where they live.
If customer live in United State, we would set the standard group(just default group).
If not like live in Jamaica, Spain, we'd like to assign to international group automatically.



So, it would show like this,
enter image description here



It seems like if-else statement on any languages but i didn't touch the code because i fix it myself one by one.



How can i do it?
app/code/core/Mage/Customer/Model
have the information about that i guess.










share|improve this question
















bumped to the homepage by Community yesterday


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.




















    0














    How to assign customer group automatically following by address information



    When customer register on our website, customer write the country where they live.
    If customer live in United State, we would set the standard group(just default group).
    If not like live in Jamaica, Spain, we'd like to assign to international group automatically.



    So, it would show like this,
    enter image description here



    It seems like if-else statement on any languages but i didn't touch the code because i fix it myself one by one.



    How can i do it?
    app/code/core/Mage/Customer/Model
    have the information about that i guess.










    share|improve this question
















    bumped to the homepage by Community yesterday


    This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.


















      0












      0








      0


      1





      How to assign customer group automatically following by address information



      When customer register on our website, customer write the country where they live.
      If customer live in United State, we would set the standard group(just default group).
      If not like live in Jamaica, Spain, we'd like to assign to international group automatically.



      So, it would show like this,
      enter image description here



      It seems like if-else statement on any languages but i didn't touch the code because i fix it myself one by one.



      How can i do it?
      app/code/core/Mage/Customer/Model
      have the information about that i guess.










      share|improve this question















      How to assign customer group automatically following by address information



      When customer register on our website, customer write the country where they live.
      If customer live in United State, we would set the standard group(just default group).
      If not like live in Jamaica, Spain, we'd like to assign to international group automatically.



      So, it would show like this,
      enter image description here



      It seems like if-else statement on any languages but i didn't touch the code because i fix it myself one by one.



      How can i do it?
      app/code/core/Mage/Customer/Model
      have the information about that i guess.







      magento-1.9 module customer group






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Feb 19 '17 at 10:27









      Nits

      1,242314




      1,242314










      asked Feb 15 '17 at 22:49









      3CE

      359213




      359213





      bumped to the homepage by Community yesterday


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







      bumped to the homepage by Community yesterday


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
























          2 Answers
          2






          active

          oldest

          votes


















          0














          Not sure what you're trying to get at here, but this sounds like something Customer Segments would be useful for here. You can create a segment which looks at the "Country" of the "Customer Address" to find a match. You'd create one segment for each country (or groups of countries) you want. The segment is updated automatically. You can then use the segment in price rules or whatever you want.



          If you can describe what your end goal is with putting users in different groups based on country, a better solution may be provided.



          Edit: Based on his comment, here's how to do that.



          Log in to your admin and go to Customer --> Customer Segments and click "Add Segment". Then fill in the information and click "Save and Continue Edit". Then click the "Conditions" tab and follow along.




          1. Click the green "(+)" icon and choose "Customer Address" from the dropdown. Select "Customer Address"

          2. From the new menu, select "Country". Select "Country"

          3. And finally select the single country you want. enter image description here

          4. To have it be a group of countries (like all of United Kingdom) click on the "ALL" in the sentence If Customer Addresses match ALL of these Conditions



          When you save, you can view the tab "Matched Customers" and see who all is included in these conditions.



          Since these are dynamic groups, they change all the time and you can adjust the conditions as necessary to get the correct grouping you want. You can also export the results easily from the "Matched Customers" tab.






          share|improve this answer























          • yeah that's what i'm saying
            – 3CE
            Feb 15 '17 at 22:59










          • Edited to show you how to do customer segments.
            – Brett
            Feb 17 '17 at 1:56



















          0














          Try to implement below process, hope it will help you





          1. appetcmodulesAman_Customergroup.xml




          <?xml version="1.0"?>
          <config>
          <modules>
          <Aman_Customergroup>
          <active>true</active>
          <codePool>local</codePool>
          </Aman_Customergroup>
          </modules>
          </config>




          1. appcodelocalAmanCustomergroupetcconfig.xml




          <?xml version="1.0"?>
          <config>
          <modules>
          <Aman_Customergroup>
          <version>0.1.0</version>
          </Aman_Customergroup>
          </modules>
          <global>
          <events>
          <customer_register_success>
          <observers>
          <Aman_Customergroup_customer_register_success>
          <type>singleton</type>
          <class>Aman_Customergroup_Model_Observer</class>
          <method>customerRegisterSuccess</method>
          </Aman_Customergroup_customer_register_success>
          </observers>
          </customer_register_success>
          </events>
          </global>
          </config>




          1. appcodelocalAmanCustomergroupModelObserver.php




          <?php
          class Aman_Customergroup_Model_Observer {
          public function customerRegisterSuccess(Varien_Event_Observer $observer) {
          $event = $observer->getEvent();
          $customer = $event->getCustomer();
          $country = $customer->getCountry(); //get value of your country attribute

          if($country=="US") {
          $customer->setGroupId(5); // or whatever the group id should be
          $customer->save();
          }
          }


          }
          ?>






          share|improve this answer























          • if( $country_id != "US"){ // if country is not US $customer->setData('group_id',27); //set groupid to 27(international group) $customer->save(); }
            – 3CE
            Feb 16 '17 at 14:58










          • so are you able to achieve what you are looking for?
            – aman
            Feb 17 '17 at 15:58










          • Not yet. I'm still struggling with this stuff..
            – 3CE
            Feb 17 '17 at 16:00










          • So you only want to assign customer group automatically after registration to Standard if its country of residence is US else International right?
            – aman
            Feb 19 '17 at 4:50










          • Have updated the answer with detailed steps so please have a look
            – aman
            Feb 19 '17 at 5:59











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "479"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f160143%2fhow-to-assign-customer-group-automatically-based-on-address-information%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          Not sure what you're trying to get at here, but this sounds like something Customer Segments would be useful for here. You can create a segment which looks at the "Country" of the "Customer Address" to find a match. You'd create one segment for each country (or groups of countries) you want. The segment is updated automatically. You can then use the segment in price rules or whatever you want.



          If you can describe what your end goal is with putting users in different groups based on country, a better solution may be provided.



          Edit: Based on his comment, here's how to do that.



          Log in to your admin and go to Customer --> Customer Segments and click "Add Segment". Then fill in the information and click "Save and Continue Edit". Then click the "Conditions" tab and follow along.




          1. Click the green "(+)" icon and choose "Customer Address" from the dropdown. Select "Customer Address"

          2. From the new menu, select "Country". Select "Country"

          3. And finally select the single country you want. enter image description here

          4. To have it be a group of countries (like all of United Kingdom) click on the "ALL" in the sentence If Customer Addresses match ALL of these Conditions



          When you save, you can view the tab "Matched Customers" and see who all is included in these conditions.



          Since these are dynamic groups, they change all the time and you can adjust the conditions as necessary to get the correct grouping you want. You can also export the results easily from the "Matched Customers" tab.






          share|improve this answer























          • yeah that's what i'm saying
            – 3CE
            Feb 15 '17 at 22:59










          • Edited to show you how to do customer segments.
            – Brett
            Feb 17 '17 at 1:56
















          0














          Not sure what you're trying to get at here, but this sounds like something Customer Segments would be useful for here. You can create a segment which looks at the "Country" of the "Customer Address" to find a match. You'd create one segment for each country (or groups of countries) you want. The segment is updated automatically. You can then use the segment in price rules or whatever you want.



          If you can describe what your end goal is with putting users in different groups based on country, a better solution may be provided.



          Edit: Based on his comment, here's how to do that.



          Log in to your admin and go to Customer --> Customer Segments and click "Add Segment". Then fill in the information and click "Save and Continue Edit". Then click the "Conditions" tab and follow along.




          1. Click the green "(+)" icon and choose "Customer Address" from the dropdown. Select "Customer Address"

          2. From the new menu, select "Country". Select "Country"

          3. And finally select the single country you want. enter image description here

          4. To have it be a group of countries (like all of United Kingdom) click on the "ALL" in the sentence If Customer Addresses match ALL of these Conditions



          When you save, you can view the tab "Matched Customers" and see who all is included in these conditions.



          Since these are dynamic groups, they change all the time and you can adjust the conditions as necessary to get the correct grouping you want. You can also export the results easily from the "Matched Customers" tab.






          share|improve this answer























          • yeah that's what i'm saying
            – 3CE
            Feb 15 '17 at 22:59










          • Edited to show you how to do customer segments.
            – Brett
            Feb 17 '17 at 1:56














          0












          0








          0






          Not sure what you're trying to get at here, but this sounds like something Customer Segments would be useful for here. You can create a segment which looks at the "Country" of the "Customer Address" to find a match. You'd create one segment for each country (or groups of countries) you want. The segment is updated automatically. You can then use the segment in price rules or whatever you want.



          If you can describe what your end goal is with putting users in different groups based on country, a better solution may be provided.



          Edit: Based on his comment, here's how to do that.



          Log in to your admin and go to Customer --> Customer Segments and click "Add Segment". Then fill in the information and click "Save and Continue Edit". Then click the "Conditions" tab and follow along.




          1. Click the green "(+)" icon and choose "Customer Address" from the dropdown. Select "Customer Address"

          2. From the new menu, select "Country". Select "Country"

          3. And finally select the single country you want. enter image description here

          4. To have it be a group of countries (like all of United Kingdom) click on the "ALL" in the sentence If Customer Addresses match ALL of these Conditions



          When you save, you can view the tab "Matched Customers" and see who all is included in these conditions.



          Since these are dynamic groups, they change all the time and you can adjust the conditions as necessary to get the correct grouping you want. You can also export the results easily from the "Matched Customers" tab.






          share|improve this answer














          Not sure what you're trying to get at here, but this sounds like something Customer Segments would be useful for here. You can create a segment which looks at the "Country" of the "Customer Address" to find a match. You'd create one segment for each country (or groups of countries) you want. The segment is updated automatically. You can then use the segment in price rules or whatever you want.



          If you can describe what your end goal is with putting users in different groups based on country, a better solution may be provided.



          Edit: Based on his comment, here's how to do that.



          Log in to your admin and go to Customer --> Customer Segments and click "Add Segment". Then fill in the information and click "Save and Continue Edit". Then click the "Conditions" tab and follow along.




          1. Click the green "(+)" icon and choose "Customer Address" from the dropdown. Select "Customer Address"

          2. From the new menu, select "Country". Select "Country"

          3. And finally select the single country you want. enter image description here

          4. To have it be a group of countries (like all of United Kingdom) click on the "ALL" in the sentence If Customer Addresses match ALL of these Conditions



          When you save, you can view the tab "Matched Customers" and see who all is included in these conditions.



          Since these are dynamic groups, they change all the time and you can adjust the conditions as necessary to get the correct grouping you want. You can also export the results easily from the "Matched Customers" tab.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Feb 17 '17 at 1:55

























          answered Feb 15 '17 at 22:58









          Brett

          1,497615




          1,497615












          • yeah that's what i'm saying
            – 3CE
            Feb 15 '17 at 22:59










          • Edited to show you how to do customer segments.
            – Brett
            Feb 17 '17 at 1:56


















          • yeah that's what i'm saying
            – 3CE
            Feb 15 '17 at 22:59










          • Edited to show you how to do customer segments.
            – Brett
            Feb 17 '17 at 1:56
















          yeah that's what i'm saying
          – 3CE
          Feb 15 '17 at 22:59




          yeah that's what i'm saying
          – 3CE
          Feb 15 '17 at 22:59












          Edited to show you how to do customer segments.
          – Brett
          Feb 17 '17 at 1:56




          Edited to show you how to do customer segments.
          – Brett
          Feb 17 '17 at 1:56













          0














          Try to implement below process, hope it will help you





          1. appetcmodulesAman_Customergroup.xml




          <?xml version="1.0"?>
          <config>
          <modules>
          <Aman_Customergroup>
          <active>true</active>
          <codePool>local</codePool>
          </Aman_Customergroup>
          </modules>
          </config>




          1. appcodelocalAmanCustomergroupetcconfig.xml




          <?xml version="1.0"?>
          <config>
          <modules>
          <Aman_Customergroup>
          <version>0.1.0</version>
          </Aman_Customergroup>
          </modules>
          <global>
          <events>
          <customer_register_success>
          <observers>
          <Aman_Customergroup_customer_register_success>
          <type>singleton</type>
          <class>Aman_Customergroup_Model_Observer</class>
          <method>customerRegisterSuccess</method>
          </Aman_Customergroup_customer_register_success>
          </observers>
          </customer_register_success>
          </events>
          </global>
          </config>




          1. appcodelocalAmanCustomergroupModelObserver.php




          <?php
          class Aman_Customergroup_Model_Observer {
          public function customerRegisterSuccess(Varien_Event_Observer $observer) {
          $event = $observer->getEvent();
          $customer = $event->getCustomer();
          $country = $customer->getCountry(); //get value of your country attribute

          if($country=="US") {
          $customer->setGroupId(5); // or whatever the group id should be
          $customer->save();
          }
          }


          }
          ?>






          share|improve this answer























          • if( $country_id != "US"){ // if country is not US $customer->setData('group_id',27); //set groupid to 27(international group) $customer->save(); }
            – 3CE
            Feb 16 '17 at 14:58










          • so are you able to achieve what you are looking for?
            – aman
            Feb 17 '17 at 15:58










          • Not yet. I'm still struggling with this stuff..
            – 3CE
            Feb 17 '17 at 16:00










          • So you only want to assign customer group automatically after registration to Standard if its country of residence is US else International right?
            – aman
            Feb 19 '17 at 4:50










          • Have updated the answer with detailed steps so please have a look
            – aman
            Feb 19 '17 at 5:59
















          0














          Try to implement below process, hope it will help you





          1. appetcmodulesAman_Customergroup.xml




          <?xml version="1.0"?>
          <config>
          <modules>
          <Aman_Customergroup>
          <active>true</active>
          <codePool>local</codePool>
          </Aman_Customergroup>
          </modules>
          </config>




          1. appcodelocalAmanCustomergroupetcconfig.xml




          <?xml version="1.0"?>
          <config>
          <modules>
          <Aman_Customergroup>
          <version>0.1.0</version>
          </Aman_Customergroup>
          </modules>
          <global>
          <events>
          <customer_register_success>
          <observers>
          <Aman_Customergroup_customer_register_success>
          <type>singleton</type>
          <class>Aman_Customergroup_Model_Observer</class>
          <method>customerRegisterSuccess</method>
          </Aman_Customergroup_customer_register_success>
          </observers>
          </customer_register_success>
          </events>
          </global>
          </config>




          1. appcodelocalAmanCustomergroupModelObserver.php




          <?php
          class Aman_Customergroup_Model_Observer {
          public function customerRegisterSuccess(Varien_Event_Observer $observer) {
          $event = $observer->getEvent();
          $customer = $event->getCustomer();
          $country = $customer->getCountry(); //get value of your country attribute

          if($country=="US") {
          $customer->setGroupId(5); // or whatever the group id should be
          $customer->save();
          }
          }


          }
          ?>






          share|improve this answer























          • if( $country_id != "US"){ // if country is not US $customer->setData('group_id',27); //set groupid to 27(international group) $customer->save(); }
            – 3CE
            Feb 16 '17 at 14:58










          • so are you able to achieve what you are looking for?
            – aman
            Feb 17 '17 at 15:58










          • Not yet. I'm still struggling with this stuff..
            – 3CE
            Feb 17 '17 at 16:00










          • So you only want to assign customer group automatically after registration to Standard if its country of residence is US else International right?
            – aman
            Feb 19 '17 at 4:50










          • Have updated the answer with detailed steps so please have a look
            – aman
            Feb 19 '17 at 5:59














          0












          0








          0






          Try to implement below process, hope it will help you





          1. appetcmodulesAman_Customergroup.xml




          <?xml version="1.0"?>
          <config>
          <modules>
          <Aman_Customergroup>
          <active>true</active>
          <codePool>local</codePool>
          </Aman_Customergroup>
          </modules>
          </config>




          1. appcodelocalAmanCustomergroupetcconfig.xml




          <?xml version="1.0"?>
          <config>
          <modules>
          <Aman_Customergroup>
          <version>0.1.0</version>
          </Aman_Customergroup>
          </modules>
          <global>
          <events>
          <customer_register_success>
          <observers>
          <Aman_Customergroup_customer_register_success>
          <type>singleton</type>
          <class>Aman_Customergroup_Model_Observer</class>
          <method>customerRegisterSuccess</method>
          </Aman_Customergroup_customer_register_success>
          </observers>
          </customer_register_success>
          </events>
          </global>
          </config>




          1. appcodelocalAmanCustomergroupModelObserver.php




          <?php
          class Aman_Customergroup_Model_Observer {
          public function customerRegisterSuccess(Varien_Event_Observer $observer) {
          $event = $observer->getEvent();
          $customer = $event->getCustomer();
          $country = $customer->getCountry(); //get value of your country attribute

          if($country=="US") {
          $customer->setGroupId(5); // or whatever the group id should be
          $customer->save();
          }
          }


          }
          ?>






          share|improve this answer














          Try to implement below process, hope it will help you





          1. appetcmodulesAman_Customergroup.xml




          <?xml version="1.0"?>
          <config>
          <modules>
          <Aman_Customergroup>
          <active>true</active>
          <codePool>local</codePool>
          </Aman_Customergroup>
          </modules>
          </config>




          1. appcodelocalAmanCustomergroupetcconfig.xml




          <?xml version="1.0"?>
          <config>
          <modules>
          <Aman_Customergroup>
          <version>0.1.0</version>
          </Aman_Customergroup>
          </modules>
          <global>
          <events>
          <customer_register_success>
          <observers>
          <Aman_Customergroup_customer_register_success>
          <type>singleton</type>
          <class>Aman_Customergroup_Model_Observer</class>
          <method>customerRegisterSuccess</method>
          </Aman_Customergroup_customer_register_success>
          </observers>
          </customer_register_success>
          </events>
          </global>
          </config>




          1. appcodelocalAmanCustomergroupModelObserver.php




          <?php
          class Aman_Customergroup_Model_Observer {
          public function customerRegisterSuccess(Varien_Event_Observer $observer) {
          $event = $observer->getEvent();
          $customer = $event->getCustomer();
          $country = $customer->getCountry(); //get value of your country attribute

          if($country=="US") {
          $customer->setGroupId(5); // or whatever the group id should be
          $customer->save();
          }
          }


          }
          ?>







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Feb 19 '17 at 5:59

























          answered Feb 16 '17 at 1:51









          aman

          58825




          58825












          • if( $country_id != "US"){ // if country is not US $customer->setData('group_id',27); //set groupid to 27(international group) $customer->save(); }
            – 3CE
            Feb 16 '17 at 14:58










          • so are you able to achieve what you are looking for?
            – aman
            Feb 17 '17 at 15:58










          • Not yet. I'm still struggling with this stuff..
            – 3CE
            Feb 17 '17 at 16:00










          • So you only want to assign customer group automatically after registration to Standard if its country of residence is US else International right?
            – aman
            Feb 19 '17 at 4:50










          • Have updated the answer with detailed steps so please have a look
            – aman
            Feb 19 '17 at 5:59


















          • if( $country_id != "US"){ // if country is not US $customer->setData('group_id',27); //set groupid to 27(international group) $customer->save(); }
            – 3CE
            Feb 16 '17 at 14:58










          • so are you able to achieve what you are looking for?
            – aman
            Feb 17 '17 at 15:58










          • Not yet. I'm still struggling with this stuff..
            – 3CE
            Feb 17 '17 at 16:00










          • So you only want to assign customer group automatically after registration to Standard if its country of residence is US else International right?
            – aman
            Feb 19 '17 at 4:50










          • Have updated the answer with detailed steps so please have a look
            – aman
            Feb 19 '17 at 5:59
















          if( $country_id != "US"){ // if country is not US $customer->setData('group_id',27); //set groupid to 27(international group) $customer->save(); }
          – 3CE
          Feb 16 '17 at 14:58




          if( $country_id != "US"){ // if country is not US $customer->setData('group_id',27); //set groupid to 27(international group) $customer->save(); }
          – 3CE
          Feb 16 '17 at 14:58












          so are you able to achieve what you are looking for?
          – aman
          Feb 17 '17 at 15:58




          so are you able to achieve what you are looking for?
          – aman
          Feb 17 '17 at 15:58












          Not yet. I'm still struggling with this stuff..
          – 3CE
          Feb 17 '17 at 16:00




          Not yet. I'm still struggling with this stuff..
          – 3CE
          Feb 17 '17 at 16:00












          So you only want to assign customer group automatically after registration to Standard if its country of residence is US else International right?
          – aman
          Feb 19 '17 at 4:50




          So you only want to assign customer group automatically after registration to Standard if its country of residence is US else International right?
          – aman
          Feb 19 '17 at 4:50












          Have updated the answer with detailed steps so please have a look
          – aman
          Feb 19 '17 at 5:59




          Have updated the answer with detailed steps so please have a look
          – aman
          Feb 19 '17 at 5:59


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Magento Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f160143%2fhow-to-assign-customer-group-automatically-based-on-address-information%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          An IMO inspired problem

          Management

          Has there ever been an instance of an active nuclear power plant within or near a war zone?