public function CommerceInvoiceEntityController::delete in Commerce Invoice 7
Deletes multiple invoices by ID.
Parameters
$invoice_ids: An array of invoice IDs to delete.
$transaction: An optional transaction object.
Return value
TRUE on success, FALSE otherwise.
Overrides DrupalCommerceEntityController::delete
File
- includes/
commerce_invoice.controller.inc, line 202 - The controller for the invoice entity containing the CRUD operations.
Class
- CommerceInvoiceEntityController
- The controller class for invoices contains methods for the order CRUD operations. The load method is inherited from the default controller.
Code
public function delete($invoice_ids, DatabaseTransaction $transaction = NULL) {
if (!empty($invoice_ids)) {
$invoices = $this
->load($invoice_ids, array());
$transaction = isset($transaction) ? $transaction : db_transaction();
try {
db_delete('commerce_invoice')
->condition('invoice_id', $invoice_ids, 'IN')
->execute();
// Reset the cache as soon as the changes have been applied.
$this
->resetCache($invoice_ids);
foreach ($invoices as $id => $invoice) {
$this
->invoke('delete', $invoice);
}
// Ignore slave server temporarily to give time for the
// saved invoice to be propagated to the slave.
db_ignore_slave();
} catch (Exception $e) {
$transaction
->rollback();
watchdog_exception('commerce_invoice', $e);
throw $e;
}
// Clear the page and block and line_item_load_multiple caches.
cache_clear_all();
$this
->resetCache();
}
return TRUE;
}