How to delete an order with Prestashop

19

You 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;
Posted in: Prestashop
Tags:

This article has 19 comments

  1. Predoi Bogdan 07/30/2009, 3:19 pm:

    Thanks a lot !

  2. Paul Campbell 07/31/2009, 2:59 pm:

    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

  3. Shai 08/05/2009, 5:03 pm:

    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.

  4. Henrique 12/08/2009, 7:32 pm:

    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 :-)

  5. Thomas Dam Jensen 04/27/2010, 1:31 pm:

    It worked !
    And i know, nothing about php
    Thanks a lot !

    Gretings
    Thomas Dam Jensen
    Denmark

  6. oscar 08/25/2010, 2:51 am:

    this was great! Thanks!!!!

  7. Sahin 10/03/2010, 7:40 am:

    Thanks a lot. I was wondering if I was blind. You saved my mind. Great assist,

  8. maximo 01/31/2011, 3:04 pm:

    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.

  9. Geek023 04/06/2011, 8:14 pm:

    Heya. Worked perfectly! Awesome, Cheers.

    Is there any chance you would we able to do this for Customer Messages?

    Cheers

  10. BesT 05/24/2011, 3:35 am:

    Thanks
    note: line 37 on v 1.4.1

  11. Rusmini Sulieman 05/24/2011, 12:48 pm:

    many thanks. May God bless you for your work and share it here.

  12. werepair 05/30/2011, 1:25 am:

    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……

  13. Karribu 07/27/2011, 4:46 pm:

    Thank you!! needed an easy way to get rid of test transactions!

  14. Benno Collings 09/08/2011, 8:35 am:

    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.

  15. Tony SKO 10/01/2011, 10:38 am:

    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

  16. Annuska Joosten 10/18/2011, 9:41 am:

    Delete it into phpmyadmin is much easier !!

  17. zulien 10/18/2011, 11:52 am:

    Tony SKO is right!!! If you delete order like this the order_details remains. And also data in another tables.

  18. NA 11/30/2011, 3:42 am:

    Perfect solution!

  19. Patrick 01/20/2012, 12:27 pm:

    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.

Leave a Reply

Your email address will not be published. Required fields are marked *

*




You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">