Jump to content

Dead Carts


Recommended Posts

  On 4/25/2013 at 10:08 AM, vekia said:

In my opinion, it is better so don't delete it.

Why? In order variable - you've got another variable: cart object, so in this case - cart is necessary

 

Hi Vekia, Thanks for your quick reply. I wonder why they've done it that way. I take it that the really dead carts, that can be safely deleted, are only the ones without an order number then.

Link to comment
Share on other sites

  • 2 weeks later...
  On 4/25/2013 at 11:27 AM, vekia said:

im checking the order class code right now, maybe you've got right, im not sure at all.

Maybe the cart object in order classes arent related to the cart database, we will see :-)

 

Hi Vekia,

Did you get an answer to this question?

Regards,

Steve

Link to comment
Share on other sites

That's great news. Thanks for your research on that one. It will allow the page to load much quicker!

 

EDIT: Having just tried deleting some carts, it appears that the system will not actually let you delete any carts which have become orders - in which case, I don't see why they should still show the dustbin (indicating that it is possible to delete them!?!)

Edited by Porpoise (see edit history)
Link to comment
Share on other sites

I agree, no need to store cart information in that case. But I think we should leave it there due to some module about data mining need to collect data from them.

 

And in case we delete cart information about ps_cart, we have to change the code of classes, controllers, modules and back end heavily. So much of work.

Link to comment
Share on other sites

Well, Im also think that we should leave this data, but it isn't necessary to collect them. You can try to delete cart from database. (be carefully!)

 

@@PrestaMonster.com

  Quote
And in case we delete cart information about ps_cart, we have to change the code of classes, controllers, modules and back end heavily. So much of work.

 

Why? You mean, that if I delete some row from ps_cart it is necessary to change classes controllers? i dont think so

Link to comment
Share on other sites

  On 5/11/2013 at 9:51 AM, vekia said:

Well, Im also think that we should leave this data, but it isn't necessary to collect them. You can try to delete cart from database. (be carefully!)

 

@@PrestaMonster.com

 

 

Why? You mean, that if I delete some row from ps_cart it is necessary to change classes controllers? i dont think so

 

Hi vekia,

 

The first one I found is in ParentOrderController.php, in init() function

 

if (Tools::isSubmit('submitReorder') && $id_order = (int)Tools::getValue('id_order'))
 {
  $oldCart = new Cart(Order::getCartIdStatic($id_order, $this->context->customer->id));
  $duplication = $oldCart->duplicate();
  if (!$duplication || !Validate::isLoadedObject($duplication['cart']))
$this->errors[] = Tools::displayError('Sorry. We cannot renew your order.');
  else if (!$duplication['success'])
$this->errors[] = Tools::displayError('Some items are no longer available, and we are unable to renew your order.');
  else
  {
$this->context->cookie->id_cart = $duplication['cart']->id;
$this->context->cookie->write();
if (Configuration::get('PS_ORDER_PROCESS_TYPE') == 1)
 Tools::redirect('index.php?controller=order-opc');
Tools::redirect('index.php?controller=order');
  }
 }

 

That code is used for re-order function in order history page of customer.

 

I've checked code under classes/order, there is no code to refer old cart information. Look like it's not so complex to remove these rows in ps_cart, but I am not sure about third-party module (especially payment module) invoke cart information.

  • Like 1
Link to comment
Share on other sites

  On 5/11/2013 at 10:17 AM, PrestaMonster.com said:

Hi vekia,

 

The first one I found is in ParentOrderController.php, in init() function

 

...

 

That code is used for re-order function in order history page of customer.

 

I've checked code under classes/order, there is no code to refer old cart information. Look like it's not so complex to remove these rows in ps_cart, but I am not sure about third-party module (especially payment module) invoke cart information.

 

Now i totally agree with you :-)

Link to comment
Share on other sites

  On 5/11/2013 at 7:12 AM, Porpoise said:

That's great news. Thanks for your research on that one. It will allow the page to load much quicker!

 

EDIT: Having just tried deleting some carts, it appears that the system will not actually let you delete any carts which have become orders - in which case, I don't see why they should still show the dustbin (indicating that it is possible to delete them!?!)

 

I recommend to leave them there. But in case you need to delete it, you can do it by MySQL command

 

DELETE FROM ps_cart WHERE id_cart NOT IN (SELECT id_cart FROM ps_order);
DELETE FROM ps_cart_product WHERE id_cart NOT IN (SELECT id_cart FROM ps_orders);

Link to comment
Share on other sites

×
×
  • Create New...