How to delete an order with Prestashop 25


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;

Leave a comment

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

25 thoughts on “How to delete an order with Prestashop

  • Paul Campbell

    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

  • maximo

    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.

  • werepair

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

  • Tony SKO

    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

  • Patrick

    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.

  • Pia

    THANK YOU!
    We are building our store and there is a lot of test-orders going on – we don’t want them there when we open the store for real!
    This worked like a clock!
    Thanks!

  • Kenneth

    This fix no longer work in 1.6 , the location of the file has been moveed to controllers folder, and layout of file has changed 🙁
    There is an existing $this->deleted = false; (noticed deleteD), changing this does not work, infact it breaks functionality.
    Adding the $this->delete = true; has no effect.