);
// find out if this invoice is a renewal.
- $is_renewal = $this->wpdb->get_var(
- $this->wpdb->prepare(
- "SELECT renewal
- FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "invoices
- WHERE id = %d",
- $invoice_id
- )
- );
+ $invoiceData = $this->getInvoiceById( $invoice_id );
+ $is_renewal = $invoiceData['renewal'];
// If this is a renewal then get all line items and update their renewal dates.
if ( $is_renewal ) {
- $line_items = $this->wpdb->get_results(
- $this->wpdb->prepare(
- "SELECT account
- FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "line_items
- WHERE invoice = %d",
- $invoice_id
- ),
- ARRAY_A
- );
- if ( $line_items ) {
- foreach ( $line_items as $account ) {
- $this->updateAccountRenewalDate( $account['account'] );
- }
- }
+ $this->updateAccountRenewalDate( $invoiceData['account'] );
}
}