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 🚀

Name:  How-to-Cancel-Order-Programmatically-without-Disabling-URL-Security-Key-in-Magento-2-950x500.png
Views: 238
Size:  328.5 KB

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-ord...key-magento-2/

View more threads in the same category: