cancel
Showing results for 
Search instead for 
Did you mean: 

EE - Move customer to another customer group after his first purchase

SOLVED

EE - Move customer to another customer group after his first purchase

We try to move a customer to another customer group after his first purchase is completed.

Do we need to program this, or is Magento 2 Enterprise able to do this via Backend Rules?

1 ACCEPTED SOLUTION

Accepted Solutions

Re: EE - Move customer to another customer group after his first purchase

Hi @Eddcapone 

Just follow below code for your requirement:
Step1 : Create a event file: events.xml

Fiel path : app/code/<vendorname>/<modulename>/etc/frontend/events.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
    <event name="sales_convert_quote_to_order">
        <observer name="mp_display_text" instance="<vendorname>\<modulename>\Observer\AfterOrder" />
    </event>
</config>

Step2 : Create Observer class
Now create a class to execute above event.

app/code/<vendorname>/<modulename>/Observer/AfterOrder.php

<?php

namespace <vendorname>\<modulename>\Observer;

class ChangeDisplayText implements \Magento\Framework\Event\ObserverInterface
{
	public function execute(\Magento\Framework\Event\Observer $observer)
	{
		/*Do your customization with customer group*/
	}
}

Step 3: Flush cache and check the result

 

It will help you to set your customer group.
If issue resolve, please click on 'Kudos' & Accept as Solution!

Problem solved? Click Accept as Solution!

View solution in original post

2 REPLIES 2

Re: EE - Move customer to another customer group after his first purchase

@Eddcapone 


Magento dont have this feature, you have to customize it. You can achieve by Magento plugins or observers.

 

<event name="sales_order_shipment_save_after"> <observer name="change_user_Group" instance="Custom\Module\Observer\ChangeUserGroupObserver" /> </event> 

create file in custom module located @ magento\app\code\Custom\Module\etc\adminhtml\events.xml


Or here sharing plugin example:

https://magento.stackexchange.com/questions/125058/whats-the-best-event-way-to-listen-for-all-order-...

Manish Mittal
https://www.manishmittal.com/

Re: EE - Move customer to another customer group after his first purchase

Hi @Eddcapone 

Just follow below code for your requirement:
Step1 : Create a event file: events.xml

Fiel path : app/code/<vendorname>/<modulename>/etc/frontend/events.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
    <event name="sales_convert_quote_to_order">
        <observer name="mp_display_text" instance="<vendorname>\<modulename>\Observer\AfterOrder" />
    </event>
</config>

Step2 : Create Observer class
Now create a class to execute above event.

app/code/<vendorname>/<modulename>/Observer/AfterOrder.php

<?php

namespace <vendorname>\<modulename>\Observer;

class ChangeDisplayText implements \Magento\Framework\Event\ObserverInterface
{
	public function execute(\Magento\Framework\Event\Observer $observer)
	{
		/*Do your customization with customer group*/
	}
}

Step 3: Flush cache and check the result

 

It will help you to set your customer group.
If issue resolve, please click on 'Kudos' & Accept as Solution!

Problem solved? Click Accept as Solution!