1

I've a Commerce store with orders dating back to September and have the following in my config:

'purgeInactiveCarts' => true,
'purgeInactiveCartsDuration' => 'P1M',

The docs say that the purging should be triggered by me visiting the Inactive carts area of the Commerce order section, but it isn't. Does anyone know if:

  1. The trigger is time limited, e.g. is only called once a day?
  2. There are any known issues with the purging of inactive carts?
  3. Anything else I could look at?
1

The mistake was not reading the docs properly and putting the config values in general.php. Instead, I needed to create a commerce.php config file and put the values in that. As soon as I did, the orders were purged.

  • Ahh... that would explain it, too. :) – Brad Bell Dec 21 '17 at 19:19
0
  1. The trigger is time limited, e.g. is only called once a day?

Nope. That logic runs every time the order index page is loaded.

  1. There are any known issues with the purging of inactive carts?

Nothing I'm aware of.

  1. Anything else I could look at?

Here's the method and SQL query Commerce uses to determine if there are carts to purge.

private function getCartsIdsToPurge()
{
    $configInterval = craft()->config->get('purgeInactiveCartsDuration', 'commerce');
    $edge = new \DateTime();
    $interval = new \DateInterval($configInterval);
    $interval->invert = 1;
    $edge->add($interval);

    return Craft::app()->db->createCommand()->select('orders.id')
        ->from('commerce_orders orders')
        ->where('isCompleted=:isCompleted AND dateUpdated <= :edge', [':isCompleted' => 'not 1','edge' => $edge->format('Y-m-d H:i:s')])
        ->queryColumn();
}

Open up the orders table in the database and find a cart you think should be getting purged, but isn't.

Check if it has a 0/null value in the isCompleted column and a dateUpdated column that is (in your case) greater than 1 month old.

  • Thanks Brad. Can confirm they have isCompleted set to 0 an the dateUpdated is more than one month ago. While I've been working on this (3 days now) I can see the orders are being purged that are more than 3 months old. So the purging is working, it's just my config setting overriding the duration that isn't. Actually, what I think might be the problem is I've got the value in my general.php file and not created a commerce.php config file. It does say that on craftcommerce.com/docs/configuration but I missed it. – Clive Portman Dec 21 '17 at 7:21
  • Yep. It was the values being in general.php and not commerce.php. Sorry. – Clive Portman Dec 21 '17 at 7:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.