You are here

public function CommerceOrderEntityController::delete in Commerce Core 7

Deletes multiple orders by ID.

Parameters

$order_ids: An array of order IDs to delete.

$transaction: An optional transaction object.

Return value

boolean TRUE on success, FALSE otherwise.

Overrides DrupalCommerceEntityController::delete

File

modules/order/includes/commerce_order.controller.inc, line 162
The controller for the order entity containing the CRUD operations.

Class

CommerceOrderEntityController
The controller class for orders contains methods for the order CRUD operations. The load method is inherited from the default controller.

Code

public function delete($order_ids, DatabaseTransaction $transaction = NULL) {
  if (!empty($order_ids)) {
    $orders = $this
      ->load($order_ids, array());

    // Ensure the orders can actually be deleted.
    foreach ((array) $orders as $order_id => $order) {
      if (in_array(FALSE, module_invoke_all('commerce_order_can_delete', $order))) {
        unset($orders[$order_id]);
      }
    }

    // If none of the specified orders can be deleted, return FALSE.
    if (empty($orders)) {
      return FALSE;
    }
    parent::delete($order_ids, $transaction);
    return TRUE;
  }
  else {
    return FALSE;
  }
}