Skip to content

Exclude carts with attempted payments from purgeIncompleteCarts #3684

Closed Answered by lukeholder
gopeter asked this question in Ideas
Discussion options

You must be logged in to vote

Thanks for requesting this. We added this event in 5.3.0.1.

Here is an example of how to modify the query to only target carts with a zero total price.

use craft\commerce\events\CartPurgeEvent;
use craft\commerce\services\Carts;
use yii\base\Event;

Event::on(
  Carts::class,
  Carts::EVENT_BEFORE_PURGE_INACTIVE_CARTS,
  function(CartPurgeEvent $event) {
      $event->inactiveCartsQuery = $event->inactiveCartsQuery->andWhere(['totalPrice' => 0]);
  }
);

Thanks!

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by lukeholder
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
None yet
2 participants