For more details see the Delete Order for Magento 2 extension page.
Upgrade your Magento 2 store order processing functionality with the Delete Order extension. Delete particular orders and all related information. Also, you can move them to archive where order data can be stored and then returned to the order grid.
Enable Orders Archive - Ser the option to 'yes' to activate the extension.
Hide Archived Orders on Frontend - Enable the option to remove archived orders from customer accounts.
Archive Orders Older Than- Specify the number of days before orders get archived.
Order Status to Apply to - Choose order statuses which should be archived. You can select multiple statuses at a time.
Archive Frequency - Choose one of 5 predefined options for archive frequency:
Notify after archiving is complete - Enable this option to inform your store administrator about each successful archive run.
Send to e-mail address - specify the email address to which notifications will be sent.
E-mail template - specify an email template for admin notifications. You can either choose the default one, you use your custom template.
Export Archived Orders - you can export all archived orders for further processing to CSV or XML files.
Remove from Archive - apply this action to restore archive orders. All restored orders will be displayed on the Orders Grid.
Delete Permanently - choose this action to deleted selected archive orders.
With the Order Archive for Magento 2 extension, you can manage your order archive using API. There are 3 operations you are able to perform. These are:
Let's dig into examples.
Operation: V1/amastyMoveToArchive
Description: Operation moves orders and order-related entities to archive tables amastyorderarchive%. Operation affects all the entities associated with the order: invoices, credit memos, shippings if they exist for the order.
Method: POST
Required:
orderids=(Array[integer]) example: orderids=12,1,4,5
Example:
{ "orderIds": [ 1, 4,5,12 ] } Success response code: 200 Success response: { "order_ids": [ 1, 4, 5, 12 ], "invoice_ids": [ 1 ], "creditmemo_ids": [ 4 ], "shipment_ids": [ 1, 12 ] }
Error Response: 401 code – Unauthorized, 400 – unexpected error
Operation: /V1/amastyMoveFromArchive
Description: Operation moves orders and order-related entities from archive tables “amastyorderarchive%”. Operation affect all the entities associated with the order: invoices, credit memos, shippings if they exist for the order.
Method: POST
Required:
orderids=(Array[integer]) example: orderids=12,1,4,5
Example:
{ "orderIds": [ 1, 4,5,12 ] } Success response code: 200 Success response: { "order_ids": [ 1, 4, 5, 12 ], "invoice_ids": [ 1 ], "creditmemo_ids": [ 4 ], "shipment_ids": [ 1, 12 ] }
Error Response: 401 code – Unauthorized, 400 – unexpected error
Operation: /V1/amastyRemovePermanently
Description: Completely removes orders and related data from the database without the possibility of their recovery.
Method: POST
Required: orderids=(Array[integer])
Example:
orderids=12,1,4,5 Success response code: 200 Success response: { "order_ids": [ "[\"5\"]" ], "invoice_ids": null, "creditmemo_ids": null, "shipment_ids": null }
Error Response: 401 code – Unauthorized, 400 – unexpected error