private function CommerceInvoiceEntityController::_save in Commerce Invoice 7
Saves an invoice (helper function)
Parameters
$invoice: The full invoice object to save.
$transaction: An optional transaction object.
Return value
The saved invoice object.
1 call to CommerceInvoiceEntityController::_save()
- CommerceInvoiceEntityController::save in includes/
commerce_invoice.controller.inc - Saves an invoice.
File
- includes/
commerce_invoice.controller.inc, line 89 - 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
private function _save($invoice, DatabaseTransaction $transaction = NULL) {
if (empty($invoice->invoice_id)) {
// Save the new invoice
drupal_write_record('commerce_invoice', $invoice);
field_attach_insert('commerce_invoice', $invoice);
}
else {
drupal_write_record('commerce_invoice', $invoice, 'invoice_id');
field_attach_update('commerce_invoice', $invoice);
}
// Ignore slave server temporarily to give time for the
// saved invoice to be propagated to the slave.
db_ignore_slave();
return $invoice;
}