I created a customer attribute called "new_customer" with a value of 1 YES.
Once an order is successfully placed by the customer, I want update the customer's custom_attribute "new_customer" to 0(NO)
{
"id": 28,
"group_id": 1,
"created_at": "2021-07-21 18:39:00",
"updated_at": "2021-07-21 19:16:44",
"created_in": "Default Store View",
"email": "[email protected]",
"firstname": "NewMitchell2",
"lastname": "NewThompson22",
"gender": 0,
"store_id": 1,
"website_id": 1,
"addresses": [],
"disable_auto_group_change": 0,
"extension_attributes": {
"company_attributes": {
"customer_id": 28,
"company_id": 0
},
"is_subscribed": false
},
"custom_attributes": [
{
"attribute_code": "company_reg",
"value": "Jane Cffsdfo222"
},
{
"attribute_code": "has_purchased",
"value": "0"
},
{
"attribute_code": "new_customer",
"value": "1"
},
{
"attribute_code": "override_importer_of_record",
"value": "default"
}
]
}
Best Answer
You can use checkout_onepage_controller_success_action observer.
In your module create following file
app/code/Vendor/Mymodule/etc/frontend/events.xml
with following content
Then create the following file
Observer/Frontend/Checkout/OnepageControllerSuccessAction.php