From 7f21981ae2a92bfad25fdeb0a6c68dc7d84c443c Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Mon, 5 Aug 2019 09:19:25 -0400 Subject: [PATCH] Update the method for checking for a renewal invoice. Don't bother trying to get account id from line_items; --- classes/billingSupport.php | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/classes/billingSupport.php b/classes/billingSupport.php index 071836c..8a2be1a 100644 --- a/classes/billingSupport.php +++ b/classes/billingSupport.php @@ -241,31 +241,12 @@ class GlmBillingSupport ); // 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'] ); } } -- 2.17.1