How do I delete an order in Prestashop?

You may have noticed that there is no “Delete” button for orders in the Prestashop back office.
This would be very useful.
You’ve gone through the entire Prestashop back office interface, without success.
So how do you go about it?
Is there really no way to delete an existing order in Prestashop?
Let’s find out.

delete prestashop order

Why can’t I delete an order in Prestashop?

Prestashop’s policy is that all orders must be stored.
Orders potentially contain confidential information, particularly with regard to customers’ means of payment.
In fact, as Prestashop states in its documentation:

In Europe, it is illegal to allow payment, billing or order information to be deleted.
This is why implementing a “Delete” button for orders would make PrestaShop illegal in Europe.

That’s why you won’t find a button allowing you to delete an order in Prestashop.
This European law was created to combat fraud.

Yes, but I have test orders!

Of course, your intention is absolutely not to defraud.
However, before you put your Prestashop site online, you had to create a number of test orders.

In themselves, these orders do not interfere with Prestashop or your online store.
If you can’t delete them, you can cancel them.

However, even when cancelled, these orders still exist.
Where they become a nuisance is in the calculation of your store statistics.
They will introduce erroneous information into Prestashop store statistics, and later, into sales reports.

So we need to find a way of permanently deleting all these test commands.

4 ways to delete an order in Prestashop

Rest assured, it is possible to get around this Prestashop limitation and delete all your test orders (and only your test orders, since you’ve understood that deleting a real order is illegal).

Several methods are available.
Some require programming skills, while others are cleaner.

1- The hacker method

It’s not really a “hacker” method, the term being a bit strong here.
Nevertheless, it does involve using a classic web site mechanism to bypass the limitation.

Note that all commands can be executed by passing the correct parameters to the browser in the site address.
This is not a “hack”, because to work, this method still requires you to be logged in as the site administrator.

To delete an order, follow the steps below:

  • Log in as administrator to the Prestashop site.
  • Display the details of the order you wish to delete.
  • Look at the url in the browser’s address bar: you should have a url like “https://votre_nom_de_domaine/admin/index.php?controller=AdminOrders&id_order=5&vieworder&token=...”.
  • Replace “vieworder” in the url with “deleteorder” and press “Enter”.

The order should be deleted, and a message confirming this should appear on the page.

The disadvantage of this method is that it’s not very “clean”, and if you have 50 orders to delete, you’ll have to repeat the operation for each one.
What’s more, if the order deletion method signature changes from one Prestashop version to the next, this “trick” may no longer work.
It is therefore by no means a permanent method.

prestashop database cleaning

2- The “tinkerer” method

This method consists of adding a “Delete” button in the order management section.

To achieve this, you’ll need to modify the Prestashop program, and write lines of code in PHP.
This isn’t very complicated in itself, but it can be quite risky.

We won’t go into detail here on the files and code portions to be modified.
There are many tutorials available on the web.
However, there are two main reasons why modifying Prestashop code is risky:

  • If you make a mistake about the location of the modification, the code added or deleted, or if you leave a space or an extra character somewhere, your Prestashop site may not work at all.
  • If you update your Prestashop, there’s every chance that your modified files will be overwritten by those of the new version.
    You’ll lose all your changes and have to start again.

It’s never a good idea to tinker until you’re sure of what you’re doing.
The risk of doing more harm than good is not negligible, and so we don’t recommend this method if you’re not a developer.

3- Lift the hood

This time, you don’t need to modify the code, but attack the database directly.
Here again, you need to be sure of what you’re doing and have the necessary skills to create an SQL query and connect to the database to execute it.

It’s very easy to make a mistake when writing the query, forgetting or mistaking a parameter that allows you to precisely target the order to be deleted.
If you make a mistake, you risk not only paralyzing your e-commerce site, but also losing all the information already in the database.

Here again, we’re talking about “fiddling”, which should be avoided when working on an e-commerce site that’s online and in operation.

4- Finally, a clean, risk-free method!

Now that we’ve looked at three methods that may work, but still present significant risks, let’s take a look at a clean, risk-free method.

As always with Prestashop, when you want to add functionality that isn’t available natively, you need to install a module.
Deleting an order is no exception to the rule.
It is possible to install a module that adds this functionality to the site.

There are several modules in the marketplace that do the job perfectly.
There’s even a desktop application, Store Manager, to manage the whole of Prestashop.
Naturally, all these solutions, like most Prestashop modules, have to be paid for.

To conclude on Prestashop order deletion

If you really need to delete orders from your Prestashop site, you now know that there are several solutions.
Keep in mind that deleting orders is possible for test purposes, but it’s illegal at European level if you’re dealing with real customer orders.

With several years’ experience on Prestashop projects, I’m in a position to assist and guide you in your projects.
Please don’t hesitate to contact me to discuss your needs.