How to delete an order with Prestashop
19You probably found this blog post because you’re wondering the same thing I was this morning… the ability to delete an order is a very basic function and yet, I cannot find the delete button! Well, the delete button is is not a permission, but instead an option you must turn on by modifying the code. WTF!?! A lot of people that don’t speak PHP will not be happy. Anyway, the delete button will appear at the bottom of your order list by adding the following line of code in the construct of the AdminOrders class.
1. In the renamed admin directory of your store, go to tabs/AdminOrders.php.
2. Around line 28 below $this->colorOnBackground = true; , add $this->delete = true; so it looks like this -
1 2 3 4 5 6 7 8 9 | class AdminOrders extends AdminTab { public function __construct() { $this->table = 'order'; $this->className = 'Order'; $this->view = 'noActionColumn'; $this->colorOnBackground = true; $this->delete = true; |
Hi I'm Nick Bartlett and thanks for visiting my blog. I'm not much of a writer; many of my posts are short and to the point while others are meant to be a reference for myself and other web developers.
Thanks a lot !
While I agree that being able to delete an order is kind of handy in a way, especially during testing (on behalf of a customer for example)….. I think the whole point of NOT allowing you to delete an order is in fact a sound one, although I too baulked at the idea when I first started using Prestashop.
The theory goes that you should be able to account for every customer interaction on your site, even those which may have a negative outcome (i.e. the order is abandoned, refunded or cancelled). By deleting orders you are in effect manipulating your overall performance and could potentially be missing a trick by not using the information you’re gathering – there’s always the possibility that by analysing these very orders you could learn something about your store that could be used to your advantage.
Paul
I’d have to agree with Paul on that one.
I elected to use the SQL query @ http://www.prestashop.com/forums/viewreply/88606/
to delete all my test orders before opening the store.
Thanks,
Jesus, is it that bad to have the option “on” an let the user decide? what are we? isn’t our business?
merry Christmas
It worked !
And i know, nothing about php
Thanks a lot !
Gretings
Thomas Dam Jensen
Denmark
this was great! Thanks!!!!
Thanks a lot. I was wondering if I was blind. You saved my mind. Great assist,
Great pal!! That should be a damned liberty, by default.
If you don’t mind, Do you know what I could do in order to make the optional order message field in the cart a required field?
The one that reads ‘If you want to leave us comment about your order, please write it below’.
I’m making a home delivery pizza website and couldn’t find a specific module to add to the cart to let the customer select a time they’d like to have their order delivered.
So I thought I’d get them to compile that textarea.
Heya. Worked perfectly! Awesome, Cheers.
Is there any chance you would we able to do this for Customer Messages?
Cheers
Thanks
note: line 37 on v 1.4.1
many thanks. May God bless you for your work and share it here.
works a treat on prestashop 1.4.2, i also think the admin should be able to delete orders at there discretion…. it is a very handy tool to keep your admin orders page clean instaead of siving through old test orders this now allows to view only legit orders, i personally think this is a great inclusion and should be included in prestashop as default.
thanks for the great info……
Thank you!! needed an easy way to get rid of test transactions!
Legend, needed this module and you delivered. So simple and effective.
Using 1.4.2 for those that want to know if it works on your site.
prestashop did not turn it on because there is reason, order # will be conflict with shipping invoice when just delete the order, and many more… figure out yourself after delete u will seee
Delete it into phpmyadmin is much easier !!
Tony SKO is right!!! If you delete order like this the order_details remains. And also data in another tables.
Perfect solution!
If deleting an order in this way doesn’t erase all the orders data, including invoices and whatever else, is because Prestashop has a very bad architecture.
Entities aren’t related on a logical level and are all treated one by one.
The MVC structure of Prestashop is a joke, as experienced people can see. In a true MVC I don’t need to query the DB to obtain products list, I ask it directly to the Product controller, or at a deeper lever, directly to the Product model.
For the same reason I should have something link $order->delete($id) to delete the order and all the related data, but this simply doesn’t exist.
This is the same reason that allows many modules to go to much deeper in the structure and breaks your workflow.