From 2706859dfbf416670cabd8a064b1d676da0b17e1 Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Wed, 27 Jun 2018 15:10:39 -0400 Subject: [PATCH] Update cron to reset renewal dates for free memberships If the billing account has invoice_type of 0 then reset the renewal date plus one year. --- index.php | 6 +++--- models/admin/ajax/billingFlagExpiredUsers.php | 11 +++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/index.php b/index.php index d3574bf..72f5924 100644 --- a/index.php +++ b/index.php @@ -3,7 +3,7 @@ * Plugin Name: GLM Members Billing * Plugin URI: http://www.gaslightmedia.com/ * Description: This is glmAssociate Billing Module - * Version: 1.0.5 + * Version: 1.0.6 * Author: Gaslight Media * Author URI: http://www.gaslightmedia.com/ * License: GPL2 @@ -19,7 +19,7 @@ * @package glmMembersBillingAddOn * @author Chuck Scott * @license http://www.gaslightmedia.com Gaslightmedia - * @version 1.0.5 + * @version 1.0.6 */ /* @@ -37,7 +37,7 @@ * so that we're sure the other add-ons see an up to date * version from this plugin. */ -define('GLM_MEMBERS_BILLING_PLUGIN_VERSION', '1.0.5'); +define('GLM_MEMBERS_BILLING_PLUGIN_VERSION', '1.0.6'); define('GLM_MEMBERS_BILLING_PLUGIN_DB_VERSION', '0.0.25'); // This is the minimum version of the GLM Members DB plugin require for this plugin. diff --git a/models/admin/ajax/billingFlagExpiredUsers.php b/models/admin/ajax/billingFlagExpiredUsers.php index 0cb1dfe..0f0e5c9 100644 --- a/models/admin/ajax/billingFlagExpiredUsers.php +++ b/models/admin/ajax/billingFlagExpiredUsers.php @@ -80,6 +80,17 @@ class GlmMembersAdmin_ajax_billingFlagExpiredUsers // Find all member contacts (by ref_dest) with accounts that are expired. // With those set their contact_role to 30 (login only) if ( $days_after_expired = filter_var( $days_after_expired, FILTER_VALIDATE_INT ) ) { + // Update any account that has invoice_type set to 0 and have an expired renewal_date + // These would be memberships that are free so they don't pay. + // They just get updated renewal dates. + $this->wpdb->query( + "UPDATE " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "accounts + SET renewal_date = renewal_date + INTERVAL 1 YEAR + WHERE renewal_date + INTERVAL 1 YEAR + INTERVAL $days_after_expired DAY <= '$current_date' + AND invoice_type = 0" + ); + + // Grab the member accounts that need to be updated $members = $this->wpdb->get_results( "SELECT ref_dest FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "accounts -- 2.17.1