Update the method for checking for a renewal invoice. VisitAlpena
authorSteve Sutton <steve@gaslightmedia.com>
Mon, 5 Aug 2019 13:19:25 +0000 (09:19 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Mon, 5 Aug 2019 13:19:25 +0000 (09:19 -0400)
Don't bother trying to get account id from line_items;

classes/billingSupport.php

index 071836c..8a2be1a 100644 (file)
@@ -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'] );
         }
     }