break;
case 'insert':
+ $renewal_invoice = false;
// Get Data Class for Invoice Types
$InvoiceTypesObj = new GlmDataInvoiceTypes( $this->wpdb, $this->config );
// Set transaction_time to current time.
foreach ( $line_items as $key => $line_item ) {
// Get the invoice type
$invoiceType = $InvoiceTypesObj->getEntry( $line_item );
- //
+ if ( $invoiceType['recurring']['value'] ) {
+ $renewal_invoice = true;
+ }
// Add individual line item record
$this->wpdb->insert(
GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . 'line_items',
)
);
}
+ // If one of the invoice line items is recurring then mark the invoice as renewal.
+ if ( $renewal_invoice ) {
+ $this->wpdb->update(
+ GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . 'invoices',
+ array( 'renewal' => 1 ),
+ array( 'id' => $this->invoice_id ),
+ array( '%s' ),
+ array( '%d' )
+ );
+ }
}
}
$invoiceAdded = true;