How to cancel order Programmatically without disabling URL security key in Magento 2?
Whenever the admin tries to cancel an order from the controller using order ID, it is required to disable the URL security key from Magento 2 admin configuration. Thereby, I am here with the code to cancel order programmatically without disabling URL security key in Magento 2. Let’s get started 🚀
Steps to cancel order Programmatically without disabling URL security key in Magento 2:
Step 1: Navigate to the following path:
app/code/VENDOR/EXTENSION/Controller/Adminhtml/Order/Cancel.php
And add the below code:
Step 2: Now, move to the following path:
app/code/VENDOR/EXTENSION/view/adminhtml/ui_component/sales_order_grid.xml
for more details: https://magecomp.com/blog/cancel-order-programmatically-without-disabling-url-security-key-magento-2/