uvip Posted February 27, 2014 Share Posted February 27, 2014 I got a lot of deleted carts, some of them are registered customers generated and some are guests generated, how to automatically delete them when they are 7 days old? Thanks Link to comment Share on other sites More sharing options...
uvip Posted February 28, 2014 Author Share Posted February 28, 2014 Any suggestions? Thanks Link to comment Share on other sites More sharing options...
vekia Posted February 28, 2014 Share Posted February 28, 2014 you can do it in several ways, each of them need some customization. mysql trigger (how to) run it several times/day with code like: DELETE * from ps_cart where date_add < today-7days Cron job (how to) You can also do it with cron job with the same script, or with php code to remove cart object. Link to comment Share on other sites More sharing options...
bellini13 Posted February 28, 2014 Share Posted February 28, 2014 do you want to delete carts that have been converted to orders? Link to comment Share on other sites More sharing options...
uvip Posted March 1, 2014 Author Share Posted March 1, 2014 do you want to delete carts that have been converted to orders? Yes, I also want to delete carts that have been converted to orders, how to do it? And will it cause any issues? Thanks Link to comment Share on other sites More sharing options...
bellini13 Posted March 1, 2014 Share Posted March 1, 2014 Vekia has already addressed your question about how to do it. Link to comment Share on other sites More sharing options...
uvip Posted March 1, 2014 Author Share Posted March 1, 2014 Will this method delete the carts had already been transferred to orders? Since there is no delete button for the ones had already been converted to orders. Thanks Vekia has already addressed your question about how to do it. you can do it in several ways, each of them need some customization. mysql trigger (how to) run it several times/day with code like: DELETE * from ps_cart where date_add < today-7days Cron job (how to) You can also do it with cron job with the same script, or with php code to remove cart object. Link to comment Share on other sites More sharing options...
vekia Posted March 1, 2014 Share Posted March 1, 2014 Will this method delete the carts had already been transferred to orders? Since there is no delete button for the ones had already been converted to orders. Thanks yes, code will remove also carts that had already been transferred to orders Link to comment Share on other sites More sharing options...
uvip Posted March 2, 2014 Author Share Posted March 2, 2014 yes, code will remove also carts that had already been transferred to orders Will there be any issues if we delete the carts had been converted to orders? Will we be still able to see the former order's contents after the delete of the cart? Thanks a lot! Link to comment Share on other sites More sharing options...
vekia Posted March 2, 2014 Share Posted March 2, 2014 you will see order details because they are stored in ps_order_details Link to comment Share on other sites More sharing options...
uvip Posted March 3, 2014 Author Share Posted March 3, 2014 you will see order details because they are stored in ps_order_details So this code:DELETE * from ps_cart where date_add < today-7days will delete carts older than 7 days right? I am not very proficient on the coding here, so an explanation will be highly appreciated. Thanks Link to comment Share on other sites More sharing options...
vekia Posted March 3, 2014 Share Posted March 3, 2014 ofcourse instead of today-7days you have to use DATE format Link to comment Share on other sites More sharing options...
uvip Posted March 3, 2014 Author Share Posted March 3, 2014 ofcourse instead of today-7days you have to use DATE format Could you please be more specific about how to use the date format and what is the meaning of your code by writing today-7days ? For example, I want to delete carts older than 7 days, how should I put it? Sorry for my ignorance. Thanks a lot. Link to comment Share on other sites More sharing options...
vekia Posted March 3, 2014 Share Posted March 3, 2014 you said that you want to remove carts older than 7 days, so today - 7 days means: for example: 2013-10-29 14:42:44 - 7 days = 2013-10-22 14:42:44 2013-12-18 14:42:44 - 7 days = 2013-12-18 14:42:44 etc. Link to comment Share on other sites More sharing options...
bellini13 Posted March 3, 2014 Share Posted March 3, 2014 Vekia, i believe he wants you to provide a valid SQL statement that he can use Link to comment Share on other sites More sharing options...
uvip Posted March 4, 2014 Author Share Posted March 4, 2014 you said that you want to remove carts older than 7 days, so today - 7 days means: for example: 2013-10-29 14:42:44 - 7 days = 2013-10-22 14:42:44 2013-12-18 14:42:44 - 7 days = 2013-12-18 14:42:44 etc. Hi Vekia, I am wondering if you can give me the direct sql code that I can use to insert into the cron job. I want to auto delete carts over 7 days. Thanks a lot for your help there Link to comment Share on other sites More sharing options...
uvip Posted March 4, 2014 Author Share Posted March 4, 2014 you said that you want to remove carts older than 7 days, so today - 7 days means: for example: 2013-10-29 14:42:44 - 7 days = 2013-10-22 14:42:44 2013-12-18 14:42:44 - 7 days = 2013-12-18 14:42:44 etc. Hi Vekia, I am wondering if you can give me the direct sql code that I can use to insert into the cron job. I want to auto delete carts over 7 days. Thanks a lot for your help there Link to comment Share on other sites More sharing options...
uvip Posted March 4, 2014 Author Share Posted March 4, 2014 Vekia, i believe he wants you to provide a valid SQL statement that he can use Bingo! You got my meaning there:) Thanks Link to comment Share on other sites More sharing options...
uvip Posted March 5, 2014 Author Share Posted March 5, 2014 Hi Vekia, I am wondering if you can give me the direct sql code that I can use to insert into the cron job. I want to auto delete carts over 7 days. Thanks a lot for your help there you said that you want to remove carts older than 7 days, so today - 7 days means: for example: 2013-10-29 14:42:44 - 7 days = 2013-10-22 14:42:44 2013-12-18 14:42:44 - 7 days = 2013-12-18 14:42:44 etc. Hi Vekia, Your response will be highly appreciated! Thanks Link to comment Share on other sites More sharing options...
uvip Posted March 6, 2014 Author Share Posted March 6, 2014 Hi Vekia, Your response will be highly appreciated! Thanks Anyone's suggestion will be highly appreciated ! Hi Vekia, I am wondering if you read my message there? Thanks Link to comment Share on other sites More sharing options...
vekia Posted March 6, 2014 Share Posted March 6, 2014 i just thought that i already posted it DELETE from ps_cart where date_add < '2014-03-03 19:42:57' Link to comment Share on other sites More sharing options...
uvip Posted March 11, 2014 Author Share Posted March 11, 2014 i just thought that i already posted it DELETE from ps_cart where date_add < '2014-03-03 19:42:57' Hi Vekia, I am not sure about the code is right? Since I want to execute this code as a cron job, how can I make sure the code will auto delete the card from the day to the former 7 days? You only put a specific date there:'2014-03-03 19:42:57' and I think a variable should be a proper one instead of a specific date? Please correct me if I am wrong. Thanks Link to comment Share on other sites More sharing options...
vekia Posted March 11, 2014 Share Posted March 11, 2014 DELETE from ps_cart where date_add < DATE_FORMAT(NOW() - INTERVAL 7 DAY, '%Y-%m-%d %H:%i:%s'); date will be created automatically (-7 days) enjoy Link to comment Share on other sites More sharing options...
uvip Posted March 12, 2014 Author Share Posted March 12, 2014 DELETE from ps_cart where date_add < DATE_FORMAT(NOW() - INTERVAL 7 DAY, '%Y-%m-%d %H:%i:%s'); date will be created automatically (-7 days) enjoy Thanks for the information. I just figured out the cron job will control the date here, so I think if I set the cron job to run once a week, then I can just run a sript to delete the ps_cart content, there should be no need to define the date since the script will delete all of the content and the settings for once a week will control the time span. In this case, could you please let me know what the script would be? So it will be even simple and I think it will help many people who have the same request in the community. Thanks a lot for your help there:) Link to comment Share on other sites More sharing options...
uvip Posted March 12, 2014 Author Share Posted March 12, 2014 Thanks for the information. I just figured out the cron job will control the date here, so I think if I set the cron job to run once a week, then I can just run a sript to delete the ps_cart content, there should be no need to define the date since the script will delete all of the content and the settings for once a week will control the time span. In this case, could you please let me know what the script would be? So it will be even simple and I think it will help many people who have the same request in the community. Thanks a lot for your help there:) It is my fault to not think through the issue here, this code should be the one: DELETE from ps_cart where date_add < DATE_FORMAT(NOW() - INTERVAL 7 DAY, '%Y-%m-%d %H:%i:%s'); Anyone who want to delete the ps_cart, please use the script above. Thanks a lot for vekia's help! Link to comment Share on other sites More sharing options...
vekia Posted March 12, 2014 Share Posted March 12, 2014 you're welcome :-) you used php script to run cron job, or just this query only? Link to comment Share on other sites More sharing options...
uvip Posted March 12, 2014 Author Share Posted March 12, 2014 you're welcome :-) you used php script to run cron job, or just this query only? I use your script:DELETE from ps_cart where date_add < DATE_FORMAT(NOW() - INTERVAL 7 DAY, '%Y-%m-%d %H:%i:%s'); to run from the host cpanel end, they have a setting called cron job. Please correct me if I am doing the wrong way? Or you have better suggestions. Also, Vekia, did you test this cron job already from your end? I am using prestashop 1.4, is it safe to run this for the cron job with the setting of once a week? Will the script cause any issues or side effect? I just test to delete the ps_cart from the my sql and noticed the content still there for the orders, so anyone who will be deleting the ps_cart contents should be safe, but I am not sure with the running of this script will have any side effects, hope Vekia or anyone else can offer more test datas or experiences. Thanks Link to comment Share on other sites More sharing options...
uvip Posted March 17, 2014 Author Share Posted March 17, 2014 you're welcome :-) you used php script to run cron job, or just this query only? Hi Vekia, I ran this script as a cron job but the ps_cart table contents are still there? I believe all of the carts contents are older than 7 days. Please advise. Thanks Link to comment Share on other sites More sharing options...
vekia Posted March 17, 2014 Share Posted March 17, 2014 can you test this query in phpmyadmin ? Link to comment Share on other sites More sharing options...
uvip Posted March 18, 2014 Author Share Posted March 18, 2014 can you test this query in phpmyadmin ? Hi Vekia, I am wondering if you can help do a local test there since you are an expert on the code. Hope to see a perfect working script from you soon. Thanks a lot for your help there. Link to comment Share on other sites More sharing options...
vekia Posted March 18, 2014 Share Posted March 18, 2014 im testing this code in phpmyadmin and everything works Link to comment Share on other sites More sharing options...
uvip Posted March 20, 2014 Author Share Posted March 20, 2014 im testing this code in phpmyadmin and everything works It is weird that it does not work for the cron job as I executed in phpadmin and it also works. I am wondering if this script can be used for prestashop 1.3? Thanks Link to comment Share on other sites More sharing options...
vekia Posted March 22, 2014 Share Posted March 22, 2014 yes script can be used in prestashop 1.3i suppose that your cron job just doesnt support execution of mysql queries Link to comment Share on other sites More sharing options...
uvip Posted March 23, 2014 Author Share Posted March 23, 2014 yes script can be used in prestashop 1.3 i suppose that your cron job just doesnt support execution of mysql queries If cron job just doesnt support execution of mysql queries, is there any other ways to run the cron job and achieve the same goal? Thanks Link to comment Share on other sites More sharing options...
vekia Posted March 23, 2014 Share Posted March 23, 2014 you can create php script with this sql query, then execute this php script as a cron job Link to comment Share on other sites More sharing options...
uvip Posted March 30, 2014 Author Share Posted March 30, 2014 you can create php script with this sql query, then execute this php script as a cron job May I know how to create php script with this sql query? Thanks Link to comment Share on other sites More sharing options...
uvip Posted March 31, 2014 Author Share Posted March 31, 2014 you can create php script with this sql query, then execute this php script as a cron job I got this error from cron job:syntax error near unexpected token `(' Link to comment Share on other sites More sharing options...
vekia Posted April 1, 2014 Share Posted April 1, 2014 it just means that you php script has got some errors. make sure that you use correct php syntax. Link to comment Share on other sites More sharing options...
uvip Posted April 4, 2014 Author Share Posted April 4, 2014 it just means that you php script has got some errors. make sure that you use correct php syntax. I used the exactly script provided by you here: DELETE from ps_cart where date_add < DATE_FORMAT(NOW() - INTERVAL 7 DAY, '%Y-%m-%d %H:%i:%s'); Could you please double check the code your provided for cron job? Thanks Link to comment Share on other sites More sharing options...
uvip Posted April 8, 2014 Author Share Posted April 8, 2014 it just means that you php script has got some errors. make sure that you use correct php syntax. Hi Vekia, Could you please help me solve this issue there? Thanks a lot! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now