PrestaShop Forum

The best place in the world to ask questions about PrestaShop and get advice from our passionate community!

PrestaShop Forum

Jump to content

 

[Solved] Deleting test orders

29 replies to this topic
#1
debugginglife

    PrestaShop Apprentice

  • Members
  • PipPip
  • 26 posts
Hi,

I set up prestashop and modified according to the needs of our business. However, during modification i made too many test orders (more than 100). Thus, i want to delete orders without any trace or causing misbehavior in scripts. Database index number can be at its last value there is no problem with index. Could you offer me a way ?


Regards,
Ali

#2
debugginglife

    PrestaShop Apprentice

  • Members
  • PipPip
  • 26 posts
I have been looking for an answer from an expert

#3
Matthieu Biart

    PrestaShop Fanatic

  • Members
  • PipPipPipPip
  • 1166 posts
Hi debugginglife!

We already replied thousand of time to that question.
Please do a search inside the forum.
Matthieu BiartCore developer | Développeur coeurPrestaShop
Help PrestaShop, make a donation! • Aidez la communauté, soumettez vos rapports de bug uniquement en anglais

#4
debugginglife

    PrestaShop Apprentice

  • Members
  • PipPip
  • 26 posts
Hi,

As a conclusion from the previous messages, it is obvious that there is no X button for deleting order in back office. However, i am looking for some database editing ( with a tool like phpmyadmin or else), here can be some experts who did such changes before. If i delete both customer and its orders from database, will the script misbehave?

Not being able to delete an order is a good feature to prevent the store form theft or lose of information, but there could be a manual method to remove test orders or bad orders ( like orders from some hacking attempts)

#5
spott

    PrestaShop Apprentice

  • Members
  • PipPip
  • 448 posts
First - all orders need to stored! This is like accounting program, where You need to store all information. When You don't need this order, then You can cancel that.

But when You still want delete orders - then You can do that at database. Look tables orders and order* tables.
The Box said Windows XP or better!
So I installed Linux

PrestaPortal- Presta themes, modules, tricks etc

#6
macandcheese

    PrestaShop Apprentice

  • Members
  • PipPip
  • 45 posts
i want to delete test orders too. .what table in mysql??

#7
d0m1n1k

    PrestaShop Apprentice

  • Members
  • PipPip
  • 284 posts
delete from ps_cart;
delete from ps_cart_product;
delete from ps_message;
delete from ps_order_detail;
delete from ps_order_history;
delete from ps_orders;


i'm not responsible if it doesn't work as expected.
you must create a DB backup before executing this sql commands.

but:
worked for me ;)

#8
kyrre

    PrestaShop Apprentice

  • Members
  • PipPip
  • 53 posts

From 1227297010:

Hi debugginglife!

We already replied thousand of time to that question.
Please do a search inside the forum.


Sorry for bringing up this old thread - but I just had to comment.

You say "thousand of time"? That's the overstatement of the decade. I search for "delete order" and got 72 hits - and four of them was directly related to my search.

If only people who know where to find information replyed, the web would be faster. If you don't have anything useful to say - don't say it!

The challenge with forums like this is that there are people from all over the world using it. The spoken languages are many, and not all understand or writes english (or french for that matter) that well - me included!

A little help and understanding is all that is needed for people to smile. And this software is all about smiling, because it's GREAT! :)
Regards
Kyrre

#9
MahmutGulerce

    PrestaShop Addict

  • Moderators
  • 559 posts
u can use this sql querry but before that you must create a backup

TRUNCATE `ps_orders`;
TRUNCATE `ps_order_customization_return`;
TRUNCATE `ps_order_detail`;
TRUNCATE `ps_order_discount`;
TRUNCATE `ps_order_history`;
TRUNCATE `ps_order_message`;
TRUNCATE `ps_order_message_lang`;
TRUNCATE `ps_order_return`;
TRUNCATE `ps_order_return_detail`;
TRUNCATE `ps_order_return_state`;
TRUNCATE `ps_order_return_state_lang`;
TRUNCATE `ps_order_slip`;
TRUNCATE `ps_order_slip_detail`;
TRUNCATE `ps_order_state`;
TRUNCATE `ps_order_state_lang`;

warning this deletes all orders and dont expand which is real order which is for test.

#10
shaiss

    PrestaShop Apprentice

  • Members
  • PipPip
  • 67 posts
Thank you mahmutta, that worked for me!
After going back to do some more test orders I received "invalid order state" in the store front, and no orders show in the BO.

Thats because the SQL query above empties 2 important tables

TRUNCATE `ps_order_state`;
TRUNCATE `ps_order_state_lang`;


I'm still testing this, but I'd also add the below to the query above
 TRUNCATE `ps_message`;


And remember if you get a mysql error, check your table prefix!

#11
shaiss

    PrestaShop Apprentice

  • Members
  • PipPip
  • 67 posts
Sorry for a duplicate post, but heres the SQL query that does work, tested 10 times over

TRUNCATE `ps_orders`;
TRUNCATE `ps_order_customization_return`;
TRUNCATE `ps_order_detail`;
TRUNCATE `ps_order_discount`;
TRUNCATE `ps_order_history`;
TRUNCATE `ps_order_message`;
TRUNCATE `ps_order_message_lang`;
TRUNCATE `ps_order_return`;
TRUNCATE `ps_order_return_detail`;
TRUNCATE `ps_order_return_state`;
TRUNCATE `ps_order_return_state_lang`;
TRUNCATE `ps_order_slip`;
TRUNCATE `ps_order_slip_detail`;
TRUNCATE `ps_message`;
TRUNCATE `ps_cart`;
TRUNCATE `ps_cart_product`;


as mahmutta said, this will delete ALL ORDERS!!!
this will NOT delete customers. but that can be done through the BO.

Also, remeber that some modules use there own tables with order id relations, so be sure to check on those.

#12
shaiss

    PrestaShop Apprentice

  • Members
  • PipPip
  • 67 posts
I put together a module just for this purpose
http://www.prestasho...ewthread/24710/

#13
MahmutGulerce

    PrestaShop Addict

  • Moderators
  • 559 posts
OK
1-) Open /prestashop site root/admin/tabs/AdminOrders.php via your fav editor.
2-) Find this code about 25th line
        $this->colorOnBackground = true;

3-) After this add this line
$this->delete = true;


Thats all
Now you can delete any of orders at back office regular ;)
i recomend add // comment start of the added line after delete


#14
jarane

    PrestaShop Newbie

  • Members
  • Pip
  • 7 posts
For Presta 1.3.1 you have to use

TRUNCATE `ps_orders`;
TRUNCATE `ps_order_detail`;
TRUNCATE `ps_order_discount`;
TRUNCATE `ps_order_history`;
TRUNCATE `ps_order_message`;
TRUNCATE `ps_order_message_lang`;
TRUNCATE `ps_order_return`;
TRUNCATE `ps_order_return_detail`;
TRUNCATE `ps_order_return_state`;
TRUNCATE `ps_order_return_state_lang`;
TRUNCATE `ps_order_slip`;
TRUNCATE `ps_order_slip_detail`;
TRUNCATE `ps_message`;
TRUNCATE `ps_cart`;
TRUNCATE `ps_cart_product`;


Beacuse ps_order_customization_return doesn't exist.

#15
pv

    PrestaShop Newbie

  • Members
  • Pip
  • 3 posts
to delete one order at at time...

Click on one of the orders ( in the back office) and replace the parameters “vieworder” with “deleteorder” from the url

For example

http://yourdomain.co...0d828eb3f2a8621

Change it to:

http://yourdomain.co...0d828eb3f2a8621

Works like a charm!

#16
peanut

    PrestaShop Apprentice

  • Members
  • PipPip
  • 154 posts

From 1286892210:

to delete one order at at time...

Click on one of the orders ( in the back office) and replace the parameters “vieworder” with “deleteorder” from the url

For example

http://yourdomain.co...0d828eb3f2a8621

Change it to:

http://yourdomain.co...0d828eb3f2a8621

Works like a charm!


Thank you soooo much..I was getting worried as I kept reading this thread but your simple trick made my life so easy!! Yay...thanks! :-)

#17
Pippo3000

    PrestaShop Apprentice

  • Members
  • PipPip
  • 411 posts

From 1286892210:


Works like a charm!


affirmative, pv. that's been one of the best and easiest tricks I've ever seen so far. greatly appreciated.
phil
PS v1.3.2.x

#18
Clothahump

    PrestaShop Newbie

  • Members
  • Pip
  • 11 posts
Maybe a simple Delete button would work well :roll:

#19
krum

    PrestaShop Newbie

  • Members
  • Pip
  • 1 posts
I tried the tip to alter the vieworder url which seems to work great. My question is, with this tip is anyone concerned with the fact that it only seems to truncate that record from ps_orders and does not affect the corresponding related tables ala:

`ps_order_detail`;
`ps_order_history`;
`ps_message`;
`ps_cart`;
`ps_cart_product`;

Is it recommended to truncate these tables manually anyway when you delete an order or can you leave as is? Also, are there any issues with auto_ids to truncating these tables?

#20
nero_77

    PrestaShop Apprentice

  • Members
  • PipPip
  • 51 posts
Great thread, very useful thanks