Jump to content

Carts delete ?


Recommended Posts

So here is the issue I see I have an online shop that is 1.6.0.6 that I have not upgraded because of customized theme and a few other things.

So what I decided to do was to build a fresh shop with 1.6.1.4 mainly because my 1.6.0.6 shop is and upgrade from 1.4 to 1.5 now 1.6, so I thought for future upgrades this would be better and gives me a chance to input everything fresh.

 

So after building the new shop customizing the theme I used the original database to import all carts,orders,customers and so on everything is OK except I noticed that on the carts page I can delete all carts not just the abandoned carts.

I thought at first this was an issue with the way I imported the carts and orders using sql until I looked at my 1.6.1.4 demo install and there all carts can also be deleted.

 

So is this normal is there a way I am unaware of to not have it like this so I can use select all at bottom of page and delete all abandoned carts but not those that were converted to orders.

Or is it OK just to remove the carts that were converted to orders.

 

I have not noticed this before now so not sure if this is by design or a bug.

 

I can not believe that I never noticed this or have never seen this questioned.

 

 

 

 

 

 

Link to comment
Share on other sites

Asked and answered, turns out had to modify the Admincartscontroller.php to remove the delete check box from carts that were turned into orders.

 

Changed this    lines 45-51

 

$this->_select = 'CONCAT(LEFT(c.`firstname`, 1), \'. \', c.`lastname`) `customer`, a.id_cart total, ca.name carrier,
IF (IFNULL(o.id_order, \''.$this->l('Non ordered').'\') = \''.$this->l('Non ordered').'\', IF(TIME_TO_SEC(TIMEDIFF(\''.pSQL(date('Y-m-d H:i:00', time())).'\', a.`date_add`)) > 86400, \''.$this->l('Abandoned cart').'\', \''.$this->l('Non ordered').'\'), o.id_order) AS status, IF(o.id_order, 1, 0) badge_success, IF(o.id_order, 0, 1) badge_danger, IF(co.id_guest, 1, 0) id_guest';
        $this->_join = 'LEFT JOIN '._DB_PREFIX_.'customer c ON (c.id_customer = a.id_customer)
LEFT JOIN '._DB_PREFIX_.'currency cu ON (cu.id_currency = a.id_currency)
LEFT JOIN '._DB_PREFIX_.'carrier ca ON (ca.id_carrier = a.id_carrier)
LEFT JOIN '._DB_PREFIX_.'orders o ON (o.id_cart = a.id_cart)
LEFT JOIN `'._DB_PREFIX_.'connections` co ON (a.id_guest = co.id_guest AND TIME_TO_SEC(TIMEDIFF(\''.pSQL(date('Y-m-d H:i:00', time())).'\', co.`date_add`)) < 1800)';
 
 
 

To this

 

$this->_select = 'CONCAT(LEFT(c.`firstname`, 1), \'. \', c.`lastname`) `customer`, a.id_cart total, ca.name carrier, IFNULL(o.id_order, \''.$this->l('Non ordered').'\') id_order, IF(o.id_order, 1, 0) badge_success, IF(o.id_order, 0, 1) badge_danger, IF(co.id_guest, 1, 0) id_guest';
   $this->_join = 'LEFT JOIN '._DB_PREFIX_.'customer c ON (c.id_customer = a.id_customer)
LEFT JOIN '._DB_PREFIX_.'currency cu ON (cu.id_currency = a.id_currency)
LEFT JOIN '._DB_PREFIX_.'carrier ca ON (ca.id_carrier = a.id_carrier)
LEFT JOIN '._DB_PREFIX_.'orders o ON (o.id_cart = a.id_cart)
LEFT JOIN `'._DB_PREFIX_.'connections` co ON (a.id_guest = co.id_guest AND TIME_TO_SEC(TIMEDIFF(NOW(), co.`date_add`)) < 1800)';
 
 
Removed this
 
 if (Tools::getValue('action') && Tools::getValue('action') == 'filterOnlyAbandonedCarts') {
            $this->_having = 'status = \''.$this->l('Abandoned cart').'\'';
        } else {
            $this->_use_found_rows = false;
        }

 

 

Then at line 65 changed 

 

'status'  to  'id_order'

 

 

Now you can use the bulk actions at the bottom of the page to delete all non ordered and abandoned carts without deleting carts that were converted to orders.

 

 

 

 

 

 

Link to comment
Share on other sites

  • 3 weeks later...

Well actually not 100% sure about this one is it OK to delete all carts even those converted to orders as long as you do not change the cart ID.

So if you had 100 carts 75 were converted to orders you might have order number ID 90 but the cart could be ID 100.

The only way I see an issue when I think about is is if you manually truncated the carts from MySql and rest to 1 then you would have overlapping carts pointing to orders that have already been placed.

Testing 1.7 I see that all carts can be deleted from the carts page, anyone have any thoughts on this.

Link to comment
Share on other sites

  • 3 weeks later...

Hello,

 

I don't find anything about this on forge.

I'm on 1.6.1.4 and i see all cart can be deleted from bo page admincart ? this is really bug and can make really problem to the shop for people that don't see this.

 

I want to try your change but will really prefer that you can confirm it is the good way to do it.

 

Regards,

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...