naeem.prestashop Posted December 28, 2012 Share Posted December 28, 2012 Hello, Sir how i will empty my cart. I am developing my own module so i need to empty complete cart from cookie before add a new product into cart. Thanks Link to comment Share on other sites More sharing options...
suenda Posted December 28, 2012 Share Posted December 28, 2012 Well, I have never tried to empty a cart, but all i know is, prestashop does not just use cookie to hold the products that are in cart, there is also database involved. Have a look at ps_cart table and others, you can see in these tables all the products being added to your cart. So, if you want to get rid of products, you also need to delete the corresponding lines in the ps_cart and ps_cart_product table. Hope this helps Link to comment Share on other sites More sharing options...
naeem.prestashop Posted December 28, 2012 Author Share Posted December 28, 2012 thanks for your reply. I am going to check it now. Link to comment Share on other sites More sharing options...
naeem.prestashop Posted December 28, 2012 Author Share Posted December 28, 2012 In DB cart tables how can i know that this cart is mine? Link to comment Share on other sites More sharing options...
suenda Posted December 28, 2012 Share Posted December 28, 2012 A very good question and I did think you would have this problem at some point. Well, all I know is about this is, whenever a customer is logged in and he/she creates a cart, the id_customer in ps_cart is set to id of the customer. And, when the user is not logged in, id_guest is used to uniquely identify the guest. So, now it's up to you to find out the id of the guest being set when some anonymous user creates the cart, and you want to empty the cart for this user. Link to comment Share on other sites More sharing options...
naeem.prestashop Posted December 28, 2012 Author Share Posted December 28, 2012 In code how can i find the id_guest? is it will be in session or some where else? Link to comment Share on other sites More sharing options...
suenda Posted December 28, 2012 Share Posted December 28, 2012 No idea. I have never looked into that part of code. You need to help yourself in this case. 1 Link to comment Share on other sites More sharing options...
naeem.prestashop Posted December 28, 2012 Author Share Posted December 28, 2012 ok thanks alot. Link to comment Share on other sites More sharing options...
naeem.prestashop Posted January 21, 2013 Author Share Posted January 21, 2013 I did enough search but i could not find any thing. Plz help me if any one know. Link to comment Share on other sites More sharing options...
ramin Posted January 21, 2013 Share Posted January 21, 2013 I want to empty cart when a new product added to card In fact I want to allow only one product in cart And when a product added the old orders (products) deleted automatically how can i do this? Link to comment Share on other sites More sharing options...
El Patron Posted January 21, 2013 Share Posted January 21, 2013 (edited) try this:(1.4) 1.5 may be different (probably is) $this->deleteCartProducts() public function deleteCartProducts() { return Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.'cart_product` WHERE `id_product` = '.(int)($this->id)); } Edited January 21, 2013 by elpatron (see edit history) Link to comment Share on other sites More sharing options...
naeem.prestashop Posted January 22, 2013 Author Share Posted January 22, 2013 I want to empty complete cart? It is only for one product. Link to comment Share on other sites More sharing options...
Recommended Posts