Do not delete expired carts if locked

Created on 23 April 2025, 1 day ago

Describe your bug or feature request.

After activating the cart expiration feature on our site, we discovered that some people had paid successfully but could not find their order on the site because their cart had been deleted at checkout while the order was locked.

Proposed resolution

In CartExpiration, exclude locked carts to to prevent them from being deleted while the person is on the payment interface

Feature request
Status

Active

Version

2.0

Component

Cart

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @adelgado12
  • 🇫🇷France flocondetoile Lyon

    Hello. Better to do this at the query level no ?

    In the commerce_cart.cron service

    
    protected function getOrderIds($order_type_id, Interval $interval) {
        $current_date = new DrupalDateTime('now');
        $expiration_date = $interval->subtract($current_date);
        $ids = $this->orderStorage->getQuery()
          ->condition('type', $order_type_id)
          ->condition('changed', $expiration_date->getTimestamp(), '<=')
          ->condition('cart', TRUE)
          ->range(0, 250)
          ->accessCheck(FALSE)
          ->addTag('commerce_cart_expiration')
          ->execute();
    
        return $ids;
      }
    
  • 🇫🇷France flocondetoile Lyon

    But you need to check the status (as you do in your patch) too juste before deleting it. An order can be locked after being added in the queue expiration

Production build 0.71.5 2024