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

[MODULE] Delete Test Orders

34 replies to this topic
#1
shaiss

    PrestaShop Apprentice

  • Members
  • PipPip
  • 67 posts
Heres a quick one I threw together for all those people first setting up PS and need to remove bogus test orders.
My inspiration was this post http://www.prestasho...iewthread/7828/ where there seemed to be lots of confusion.

I've tested this on v1.1.0.5 (Should work on 1.2, but not tested)

See the module instructions for exact info.

You have to check a box inside the config page, then click submit, only then will the orders be deleted.

You should uninstall/delete this module once your stores in production as it deletes ALL ORDERS!

UPDATE 9/16/09
Current Version 1.0
Downloaded from http://delete-test-o...etestorders.tar
Browse source @ http://code.google.c.../source/browse/

Attached Files



#2
San Diego

    PrestaShop Apprentice

  • Members
  • PipPip
  • 407 posts
hi
don´t want to hurt your feelings, but thanks anyway
can be done with one line of code:
http://www.prestasho...the_orders_page

sd

#3
jolvil

    PrestaShop Fanatic

  • Members
  • PipPipPipPip
  • 2706 posts
Don't you know a similar module updated for PS 1.2

http://www.prestasho...iewthread/15449

or this contribution

http://www.prestasho...iewthread/18231

#4
shaiss

    PrestaShop Apprentice

  • Members
  • PipPip
  • 67 posts

From 1249669632:

hi
don´t want to hurt your feelings, but thanks anyway
can be done with one line of code:
http://www.prestasho...the_orders_page

sd


No offence taken, but this is a different matter. Some store owners want to be able to delete orders in general, thats why they would do whats posted in that link.

But some new store owners run test orders into the 100s. This would be a pain having to click through each order.

There's also another point well illustrated by the comment Paul made @ http://www.nickbartl...ith-prestashop/

So, this is just another alternative.

#5
San Diego

    PrestaShop Apprentice

  • Members
  • PipPip
  • 407 posts
hi
you are right just want to give the other option if needed, to me it is easier,
so everyone can decide what fits his needs
great job anyway
greetings
sd

#6
shaiss

    PrestaShop Apprentice

  • Members
  • PipPip
  • 67 posts

From 1249670185:

Don't you know a similar module updated for PS 1.2

http://www.prestasho...iewthread/15449

or this contribution

http://www.prestasho...iewthread/18231


I havn't seen either of those and the first is a definite interest.
I guess this would be another alternative. A simple one liner.

#7
deepee

    PrestaShop Apprentice

  • Members
  • PipPip
  • 121 posts
Hi

After manually deleting some test orders today on my Prestashop Version 1.2.1.0 installation I got a "Invalid new order state" error when trying to place a new test order using the offline credit card module (the version merged with parceling option).
It had been working fine in previous tests, so it looks like something has been corrupted when the orders were deleted.

I checked Back Office > Orders and there was a credit card order showing as "cancelled"

I followed two threads to arrive at this thread and installed your module (for which I thank you!)
However, when I ran the module it returned the following error:-

Table 'digitalt_presta.ps_order_customization_return' doesn't exist
TRUNCATE `ps_order_customization_return`

But when I checked Back Office > Orders, the "cancelled" card order was gone.

I then tried placing another test credit card order and got the "Invalid new order state" error again.

Tried all of the above, three more times with the same results

I can place orders using the other payment methods.
I have uninstalled and re-installed the credit card module, which as previously mentioned, had been working fine until I started purging old orders.

Can anyone offer me any suggestions, please?

Thanks
Deepee

#8
shaiss

    PrestaShop Apprentice

  • Members
  • PipPip
  • 67 posts
UPDATE: I hard coded the table prefix. I've noted that as an issue to fix for the next release:
http://code.google.c...ues/detail?id=1
For now, just chage ps_ to YourPrefix_ (lines 140-155) in deletetestorders.php

I've also notated to add support for the offline credit card module in the next release
http://code.google.c...ues/detail?id=2

I think I may have mispelled something relating to ps_order_customization_return. Likely some typo in my php. Also.

The offline credit card might use it's own table that needs to e truncated. I'll check today and get back to you

#9
deepee

    PrestaShop Apprentice

  • Members
  • PipPip
  • 121 posts
Hi shaiss

Thanks for your reply.
I changed the prefixes in all lines as above but still get:

Table ‘digitalt_presta.ps_order_customization_return’ doesn’t exist
TRUNCATE `ps_order_customization_return`

Looks like it has to be specific to the offline module.

Thanks
Deepee

#10
shaiss

    PrestaShop Apprentice

  • Members
  • PipPip
  • 67 posts
post your deletetestorders.php on pastie.org and paste the link to it here.
I don't think you changed the prefixes correct. OR, I typo'd again.

#11
deepee

    PrestaShop Apprentice

  • Members
  • PipPip
  • 121 posts
Here you go:-
http://pastie.org/619546

Please also see line 156 which I added.

Just tried it again but it still getting “Invalid new order state” when I try to place a credit card order.

Thanks
Deepee

#12
shaiss

    PrestaShop Apprentice

  • Members
  • PipPip
  • 67 posts
My appologies lines 140 -155 are just for the config page.

The actual action doesn't happen till line 246 in your pastie.
The _DB_Prefix_ is used properly there.

Where did you see this error:
Table ‘digitalt_presta.ps_order_customization_return’ doesn’t exist
TRUNCATE `ps_order_customization_return`

Could you post a screenshot?

After you run the module, go through the tables listed in the DeleteOrders function and make sure they are empty.

Also, do you actually have a table named PREFIX_order_customization_return

#13
deepee

    PrestaShop Apprentice

  • Members
  • PipPip
  • 121 posts
Ah, o.k! Checked and there was no table named "digitalt_presta.ps_order_customization_return"

I deleted all references to that table from your code and added my "order_credit_data" amendment to line 262

Your module now works without error.

I'm still getting “Invalid new order state” when I try to place a credit card order so I suspect it has to be different issue with the module itself.

Thanks
Deepee

#14
TropischBruin

    PrestaShop Fanatic

  • Moderators
  • 2198 posts

From 1253135783:

Ah, o.k! Checked and there was no table I'm still getting “Invalid new order state” when I try to place a credit card order so I suspect it has to be different issue with the module itself.

Thanks
Deepee


That is correct.

It could be that this module does not work with the new way PS creates orderstate's.
Norman in 't VeldtModeratorPrestaShopForums
Help PrestaShop, make a donation!

#15
deepee

    PrestaShop Apprentice

  • Members
  • PipPip
  • 121 posts

From 1253162429:

From 1253135783:

Ah, o.k! Checked and there was no table I'm still getting “Invalid new order state” when I try to place a credit card order so I suspect it has to be different issue with the module itself.

Thanks
Deepee


That is correct.

It could be that this module does not work with the new way PS creates orderstate's.


Thanks for the feedback, TropischBruin.

On reflection I don't think it relates directly to the credit card module as it was working well until I started manually deleting test orders.
I suspect I may have inadvertently damaged the orderstates somewhere in this process.

I would like to try to restore this table to its default installed state.

Can anyone please guide me on the best way to do it?

Thanks
Deepee

#16
deepee

    PrestaShop Apprentice

  • Members
  • PipPip
  • 121 posts
[SOLVED]

Just replying to my own question as to how I fixed this in the hope it may help someone with the same issue.

I installed a new installation on my local computer (using Apache Friends XAMPP).

I installed the same modules and compared my site's database table "PS_ORDER_STATE" with the new one.

There were only 11 rows in my table but 12 rows in the new one (the 12th row has no description)

I dropped the old table and copied the new table to my existing database and everything now works correctly.

The 12th row must be required for the offline credit card module and I suspect I accidentally deleted it when I was deleting some test orders

#17
bluey

    PrestaShop Newbie

  • Members
  • Pip
  • 2 posts
Hi,

This module is removing the return order states, I think it shouldn't be truncating the following tables:

ps_order_return_state
ps_order_return_state_lang

In case someone ends up with missing order states, run as per install sql script (taking into account the table prefix):

INSERT INTO ps_order_return_state (`id_order_return_state`, `color`) VALUES (1, '#ADD8E6'),(2, '#EEDDFF'),(3, '#DDFFAA'),(4, '#FFD3D3'),(5, '#FFFFBB');

INSERT INTO ps_order_return_state_lang (`id_order_return_state`, `id_lang`, `name`) VALUES
(1, 1, 'Waiting for confirmation'),(2, 1, 'Waiting for package'),(3, 1, 'Package received'),
(4, 1, 'Return denied'),(5, 1, 'Return completed'),(1, 2, 'En attente de confirmation'),
(2, 2, 'En attente du colis'),(3, 2, 'Colis reçu'),(4, 2, 'Retour refusé'),
(5, 2, 'Retour terminé'),(1, 3, 'Pendiente de confirmación'),(2, 3, 'En espera de paquetes'),
(3, 3, 'Paquetes recibidos'),(4, 3, 'Volver negó'),(5, 3, 'Diligenciados');

The module is helpful otherwise, thanks! :-)

#18
Indra Hermawan

    PrestaShop Apprentice

  • Members
  • PipPip
  • 32 posts
The easiest way to delete order (does not require a module just add one line command) on AdminOrder.php
  $this->delete = true; 



Your original AdminOrder.php
 <?php

/**
* Orders tab for admin panel, AdminOrders.php
* @category admin
*
* @author PrestaShop
* @copyright PrestaShop
* @license http://www.opensource.org/licenses/osl-3.0.php Open-source licence 3.0
* @version 1.2
*
*/

include_once(PS_ADMIN_DIR.'/../classes/AdminTab.php');

class AdminOrders extends AdminTab
{
public function __construct()
{
global $cookie, $currentIndex;

$this->table = 'order';
$this->className = 'Order';
$this->view = 'noActionColumn';
$this->colorOnBackground = true;
.........


to

<?php

/**
* Orders tab for admin panel, AdminOrders.php
* @category admin
*
* @author PrestaShop
* @copyright PrestaShop
* @license http://www.opensource.org/licenses/osl-3.0.php Open-source licence 3.0
* @version 1.2
*
*/

include_once(PS_ADMIN_DIR.'/../classes/AdminTab.php');

class AdminOrders extends AdminTab
{
public function __construct()
{
global $cookie, $currentIndex;

$this->table = 'order';
$this->className = 'Order';
$this->delete = true;
$this->view = 'noActionColumn';
$this->colorOnBackground = true;
.......

Attached Files


prestashop 1.2.4

#19
bluey

    PrestaShop Newbie

  • Members
  • Pip
  • 2 posts
Thanks for that info Indra, if you are testing if everything is OK (important when dealing with translations, for example), and you make lots of orders to try the different modules, blocks, mails, etc, having some easy way to clean everything is important.

Would that process work for everything related to the orders and reset the counters so you can start with a clean list?

#20
uddhava

    PrestaShop Addict

  • Members
  • PipPipPip
  • 626 posts
I know this is maybe not the right post, but this "module" does not work, at least not on 1.3.0

Using these SQL statements (or even only deleting the PS_ORDERS and PS_ORDERS tables will create a mess.
Whenever you do this then your next order will fail with a "Invalid invoice number".
I have tried and failed to solve it.

There are many others who got this problem. Can't say it is related to a server configuration / etc but after tampering with the tables this error will start to appear.
Resetting the orders is of course nice to have (PS team pls).

If somebody has a good answer to this problem then say so. But pls dont post links to post that mention to clear the tables manually, the url to delete a order and the editing this php file in the Admin>Tabs directory.

Reinstalling again... 3th time...
Was your post not answered? Don't fret but DO give more info.. Some threads are so unclear that an answer will never come.

For hire for Prestashop customizations and iDeal integration