From: Steve Sutton Date: Thu, 16 May 2019 13:15:48 +0000 (-0400) Subject: Fix billing save data from contact side. X-Git-Tag: v1.0.28^2 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=3f59716b29cf697109b0ecb6cea2c8accb2ec8b9;p=WP-Plugins%2Fglm-member-db-billing.git Fix billing save data from contact side. When using the contact plugin to update billing data needed to have correct invoice-type saved. --- diff --git a/classes/billingSupport.php b/classes/billingSupport.php index 666e584..b54a77f 100644 --- a/classes/billingSupport.php +++ b/classes/billingSupport.php @@ -1729,14 +1729,35 @@ class GlmBillingSupport ); } else { // Get the member name - $member_name = $this->wpdb->get_var( "SELECT name FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX . "members WHERE id = $member_id" ); + $member_name = $this->wpdb->get_var( "SELECT name FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX . "members WHERE id = $member_id" ); + $invoice_type = 0; + $current_member_type = $this->wpdb->get_var( + $this->wpdb->prepare( + "SELECT member_type + FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "members + WHERE id = %d", + $member_id + ) + ); + if ( $current_member_type ) { + $invoice_type = $this->wpdb->get_var( + $this->wpdb->prepare( + "SELECT id + FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "invoice_types + WHERE member_type = %d", + $current_member_type + ) + ); + } // Need to create an account record $billing_updated['ref_name'] = $member_name; // Use members name $billing_updated['ref_dest'] = $member_id; $billing_updated['anniversary_date'] = date('Y-m-d H:i:s'); + $billing_updated['invoice_type'] = $invoice_type; $billing_updated_format[] = '%s'; $billing_updated_format[] = '%d'; $billing_updated_format[] = '%s'; + $billing_updated_format[] = '%d'; $this->wpdb->insert( GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . 'accounts', $billing_updated, diff --git a/index.php b/index.php index f6b343c..04719b2 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.27 + * Version: 1.0.28 * 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.27 + * @version 1.0.28 */ /* @@ -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.27'); +define('GLM_MEMBERS_BILLING_PLUGIN_VERSION', '1.0.28'); define('GLM_MEMBERS_BILLING_PLUGIN_DB_VERSION', '0.0.26'); // This is the minimum version of the GLM Members DB plugin require for this plugin.