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?
Solved! Go to Solution.
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!
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:
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!
<h1>hello</h1>