There is a job in the CMS called Remove Expired Carts. Does this relate to all Commerce Carts that are in the system or does it only remove carts that are over 30 days or so old?
Is there away to Remove all carts that are older than TODAY? We have an events booking system so if they dont book the event within a time period we should empty their basket but there seem to be many that are not being deleted so I would like to run a scheduled job to remove all carts that are older than today (or a few hours if possible).
I looked at the code for the schedule job plugin (EPiServer.Business.Commerce.ScheduledJobs) and it looks like it is configurable, but the default value is 30.
I hope this helps!
Toni's answer is correct. Unfortunately the RemovedExpiredCartsJob will take 1 day as the minimum of time for expired carts, so no way to make it works for a few hours
I don't see any reason why you can't write a scheduled job yourself (I guess reflecting to see how RemovedExpiredCartsJob works?), which ignore the ExpiredCartJobDays settings, then set it to runs every, says, 3 hours as you need.
This is great - many thanks.
Whilst I have you can I explain why I wanted to reduce the ExpiredDates?
We have a few customers who are some how adding items to their Cart which is creating a duplicate cart entry. For example they would have two identical Cart entries in the Commerce CMS that have the same Name, amount, date stamp etc. I have no idea how this is happening but it is causing an issue when the user logs back into the site.
When a user logs back into the site, we check if they have any existing carts and if so delete them as we dont want Saved Carts in the system (it's an event booking system - on a first come first served experience) - because the Episerver Commerce in the getCart method uses a SingleOrDefault it throws an error as it is bringing back 2 identical records.
Do you know why there are duplicate cart entries?
Thanks for all your help,
You're correct that we don't allow a customer to have two carts with same market and same name. Is there any chance this is related to market?
This job should also notify users if it has crashed for some reason. An error is logged, but the job status just says "0 carts removed" - this should be changed to indicate that something crashed for some reason. A simple "0 carts removed. An error occured, see log for more details" would suffice.