1

I need to create an observer or plugin or something else that will run when an order is attempted to be created through the admin. I added a custom attribute for customers (offline/online). If the attribute is set to offline then an order can not be created for the customer. Is there event that can be observed or is there a better approach?

Thanks in advance.

enter image description here

1
  • Feel free to accept some answer if it helped Jul 8, 2022 at 20:56

2 Answers 2

0

Give a look to vendor/magento/module-sales/Controller/Adminhtml/Order/Create.php file

You'll find some events there, such as adminhtml_sales_order_create_process_data_before, adminhtml_sales_order_create_process_item_before, adminhtml_sales_order_create_process_data, etc...

Depending by which exact moment you need to run your validation you may choose one or another

Another approach: I believe you could use almost all generic order events during checkout in frontend, but just placing your events.xml file in etc/adminhtml folder in your module. This way they will run only in admin requests

0

You can create a Plugin aroundSavePaymentInformationAndPlaceOrder. This plugin will execute on the click of Place Order before order generation on checkout Page. Remember you need to overwrite two classes GuestPaymentInformationManagement and PaymentInformationManagement.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.