Set Additional Option Using Observer
We can use “sales_model_service_quote_submit_before” event to copy additional option from quote item.
First of all we need to define it in events.xml. Write following code in events.xml file.
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:...
You can use and inject Magento\Customer\Model\Session in your observer class to get the logged in Customer Id. It doesn't matter whether the dispatched method has customer object, you can use this customer model session class to get the customer object.
Your observer should be like this
At Vendor\Module\Observer\NewCustomer, observer you need to use
$editedCustomerEmail = $observer->getEvent()->getCustomer()->getEmail();
$editedCustomerEmail = $observer->getEvent()->getEmail();
at customer_register_success event's Observer, you can get Customer data using $observer->getEvent()->getCustomer().
customer_save_before is an event linked to the customer model. So it's not a good idea to redirect from the observer on that event since you won't know exactly where is triggered.
You should just throw an instance of \Magento\Framework\Exception\LocalizedException in case your criteria does not match.
public function execute(....)
The observer code you shared in https://justpaste.it/7l2ka contains a die() which will break execution due to Fatal error (unexpected 'die' (T_EXIT))
public function paymenter($Observer)
$order = $Observer->getEvent();
die(); // !!!!!!!!!...
People report your code to work correctly on their installations, so the issue obviously is specific to your setup or magento project's code base.
https://justpaste.it/7l2ka proves that your observer class isn't being parsed as php would fail with a syntax error doing so. For magento backend development I rely on magerun. It provides all kind of useful ...
I have created module same as yours, Please check the below code.