From: Steve Sutton Date: Tue, 15 May 2018 13:54:26 +0000 (-0400) Subject: Correcting link for Dashboard to billing X-Git-Tag: v1.0.0^2~16 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=04157ee031a2b92384547c54460e62514c0a39da;p=WP-Plugins%2Fglm-member-db-billing.git Correcting link for Dashboard to billing show pay invoice page if they have an invoice. --- diff --git a/models/admin/dashboard/billing.php b/models/admin/dashboard/billing.php index a3473e1..b7e8aa9 100644 --- a/models/admin/dashboard/billing.php +++ b/models/admin/dashboard/billing.php @@ -128,8 +128,24 @@ class GlmMembersAdmin_dashboard_billing //extends GlmDataBilling $billing_label = 'Billing Account Info'; break; case 'Pending': - $billing_link = 'glm_action=billing&member=' . $memberID . '&option=renew'; - $billing_label = 'Renewal Membership'; + // If they're pending check if they have an unpaid renewal invoice created. + $invoice_id = $this->wpdb->get_var( + $this->wpdb->prepare( + "SELECT id + FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "invoices + WHERE account = %d + AND paid <> true + AND renewal = true", + $accountID + ) + ); + if ( $invoice_id ) { + $billing_link = 'glm_action=billing&member=' . $memberID . '&option=makepayment'; + $billing_label = 'Pay Invoice'; + } else { + $billing_link = 'glm_action=billing&member=' . $memberID . '&option=renew'; + $billing_label = 'Renewal Membership'; + } break; case 'Expired': $billing_link = 'glm_action=billing&member=' . $memberID . '&option=renew';