How to delete an order in a drush command

Created on 2 February 2024, 5 months ago
Updated 17 February 2024, 4 months ago

It used to be that deleting an order programmatically was simply:

$order = $this->orderStorage->load($order_id);
$order->delete();

However, when I try to do this in a drush command I get:

Fatal error: Uncaught Error: Call to a member function inTransaction() on null in /var/www/html/backend/web/core/modules/mysql/src/Driver/Database/mysql/Connection.php on line 470

Error: Call to a member function inTransaction() on null in /var/www/html/backend/web/core/modules/mysql/src/Driver/Database/mysql/Connection.php on line 470

Call Stack:
    0.3365   38742928   1. Drupal\Core\Database\Transaction->__destruct() /var/www/html/backend/web/core/lib/Drupal/Core/Database/Transaction.php:0
    0.3365   38742928   2. Drupal\Core\Database\Connection->popTransaction($name = 'drupal_transaction') /var/www/html/backend/web/core/lib/Drupal/Core/Database/Transaction.php:71
    0.3365   38742928   3. Drupal\mysql\Driver\Database\mysql\Connection->popCommittableTransactions() /var/www/html/backend/web/core/lib/Drupal/Core/Database/Connection.php:1678
    0.3365   38743304   4. Drupal\mysql\Driver\Database\mysql\Connection->doCommit() /var/www/html/backend/web/core/modules/mysql/src/Driver/Database/mysql/Connection.php:402

Clearly I am doing something wrong, but I at a loss.

Is there some extra I need to do? Any suggestions?

πŸ’¬ Support request
Status

Fixed

Version

2.37

Component

Order

Created by

πŸ‡³πŸ‡±Netherlands Ronald van Belzen

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

Comments & Activities

Production build 0.69.0 2024