Jump to content

How to delete old orders?


Recommended Posts

there is no button for this, but you can do this simply by doing the following. open the order in the backoffice, your browser will have a URL similar to this.

 

admin/index.php?tab=AdminOrders&id_order=1&vieworder&token=12345678

 

Now change the URL to delete following

 

admin/index.php?tab=AdminOrders&id_order=1&deleteorder&token=12345678
Link to comment
Share on other sites

Be aware using that method!

I used it and it messed up my database. Every time an order was placed, products from older (deleted) orders where automatically added.

After a lot of searching I discovered that the deleted orders where still present in the database.

So the safe way is to delete unwanted orders from you database using PhpMyAdmin in the ps_orders and ps_orders_detail table.

Regards,

 

-Dave

Link to comment
Share on other sites

So the safe way is to delete unwanted orders from you database using PhpMyAdmin in the ps_orders and ps_orders_detail table.

Even then, you will end up with an inconsistent database. There is a lot more to adding an order to database then a couple of tables, (customers, attributes, features, carriers etc tables to name a few). I would strongly recommend against deleting orders manually from database.

Link to comment
Share on other sites

bad advice is to use the delete method that the development team has created for every other object in the system? deleting customers, addresses, carts etc... all of these objects utilize this same basic feature.

 

instead of coming here and suggesting not to do things, how about provide some useful information on how to accomplish the task...

Link to comment
Share on other sites

this is for 1.4.5

 

add the following line to tabs/AdminOrders.php

 

$this->delete = true;

 

looks like this:

 

class AdminOrders extends AdminTab
{
public function __construct()
{
 global $cookie;
  $this->table = 'order';
  $this->className = 'Order';
  $this->view = true;
 $this->colorOnBackground = true;
 $this->delete = true;
  $this->_select = '

 

I'm not positive that this is either good or bad advice. I only use it to delete orders on our base ps.

Link to comment
Share on other sites

this is for 1.4.5

 

add the following line to tabs/AdminOrders.php

 

$this->delete = true;

 

looks like this:

 

class AdminOrders extends AdminTab
{
public function __construct()
{
 global $cookie;
  $this->table = 'order';
  $this->className = 'Order';
  $this->view = true;
 $this->colorOnBackground = true;
 $this->delete = true;
  $this->_select = '

 

I'm not positive that this is either good or bad advice. I only use it to delete orders on our base ps.

 

This change makes the trash can icon appear in the back office orders page. Clicking the icon invokes the following URL, which is exactly the same thing posted above.

 

admin/index.php?tab=AdminOrders&id_order=1&[b]deleteorder[/b]&token=12345678

 

So it accomplishes the same end result.

 

I can't say why the prestashop developers do not include this by default. Perhaps they are aware of an issue and choose not to address it. I have not encountered issues with this, but I also do not have any back office customizations.

 

Those with customizations, or even third party modules, may experience problems with this. My advise, back up your database before trying this.

  • Like 1
Link to comment
Share on other sites

 

This change makes the trash can icon appear in the back office orders page. Clicking the icon invokes the following URL, which is exactly the same thing posted above.

 

admin/index.php?tab=AdminOrders&id_order=1&[b]deleteorder[/b]&token=12345678

 

So it accomplishes the same end result.

 

I can't say why the prestashop developers do not include this by default. Perhaps they are aware of an issue and choose not to address it. I have not encountered issues with this, but I also do not have any back office customizations.

 

Those with customizations, or even third party modules, may experience problems with this. My advise, back up your database before trying this.

 

Until I ran across the post I wasn't aware of the potential problems having order delete capability available.

 

I had at first suspected a delete button has not been provided in the orders management for a security measure, i.e. sale/logistical not deleting orders and taking the payment money. :)

 

I will not include it with a production ps release. Thanks phrasepot!

Link to comment
Share on other sites

bad advice is to use the delete method that the development team has created for every other object in the system? deleting customers, addresses, carts etc... all of these objects utilize this same basic feature.

Yes, there is a reason said delete button is not available for orders. There is more to adding an order than entering it into orders table. After you perform your so called solution go and look at, for example, PREFIX_order_detail table or PREFIX_order_history table (there are others but I will leave to find those as an exercise to you). By deleting an order in the way you described, you placed your database in an inconsistent state.

 

 

instead of coming here and suggesting not to do things, how about provide some useful information on how to accomplish the task...

If you look at my post history you will see that I do provide useful information when the task needing accomplished has a correct and clean way of doing it, rather than coming here and providing information that will cause someone's installation to enter into an inconsistent state and cause more troubles than it allegedly solves. Besides I assumed you to know as much since you advertise a "software solutions" banner in your signature.

Link to comment
Share on other sites

Besides I assumed you to know as much since you advertise a "software solutions" banner in your signature

 

I do provide solutions, as the one outlined above. The user wanted to know how to delete the order, and I provided a workable solution. Leaving an orphaned record in the order_detail or order_history table has no ill effect on the software, since there is no order referencing those records anymore.

 

If you have a better way to solve the issue at hand, I applaud you to document it. Otherwise your warning for inconsistent database records has been noted in the thread, and users attempting this can use at their own risk.

Link to comment
Share on other sites

I do provide solutions, as the one outlined above.

OK, I should've not said that, it was a cheap shot taking the discussion out of technical merits of an operation. I apologise.

 

If you have a better way to solve the issue at hand, I applaud you to document it.

That is the problem, there is NO general, clean way of doing it. Not only it differs from version to version (e.g. DB tables involved) and installation to installation (e.g. other modules, stock settings), but even on the same installation it will differ from order to order depending on whether if it was a virtual product or not, bought buy a customer or guest, what carrier used, what payment method used, attributes product may have, number of the products in order, was it a package or not, whether any of the products has an attachment etc etc.

 

Is it impossible? Of course not, but the processes requires careful thought about the current version, current settings and the order involved on an order by order basis by someone familiar with internal workings of PrestaShop; not the type of thing the average shop owner should or would want to do. Documenting full steps required for a task like this is futile effort, outdated as soon as a new install and sale happens. I suspect this is the reason there is no delete button for order objects when there is one for almost every other object PS deals with.

 

Orphaned records may not seem to be an issue until an SQL statement is runs and returns rows with NULLs where a value is expected and then you have crash and burn with an extremely difficult problem to track down.

 

Anyway, we'll just have to agree to disagree. Peace.

Link to comment
Share on other sites

Anyway, we'll just have to agree to disagree. Peace.

 

well said.

 

perhaps in the future i will attempt to create a module or custom adminorders that will account for the various tables linked to ps_orders, and delete those associated records. i wonder what v1.5 might do about this...

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...