Fix billing save data from contact side.
authorSteve Sutton <steve@gaslightmedia.com>
Thu, 16 May 2019 13:15:48 +0000 (09:15 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Thu, 16 May 2019 13:15:48 +0000 (09:15 -0400)
When using the contact plugin to update billing data needed to have
correct invoice-type saved.

classes/billingSupport.php
index.php

index 666e584..b54a77f 100644 (file)
@@ -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,
index f6b343c..04719b2 100644 (file)
--- 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 <cscott@gaslightmedia.com>
  * @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.