From: Steve Sutton Date: Tue, 31 Jul 2018 15:38:42 +0000 (-0400) Subject: When updating the billing info add account if non exists. X-Git-Tag: v1.0.10^2~32 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/index.cgi?a=commitdiff_plain;h=e71ad956ff43fcd90a443c00f96d368b1f9cf490;p=WP-Plugins%2Fglm-member-db-billing.git When updating the billing info add account if non exists. Setting up an account in billing when updating billing info if none exists. --- diff --git a/classes/billingSupport.php b/classes/billingSupport.php index 6417bc5..d8870fa 100644 --- a/classes/billingSupport.php +++ b/classes/billingSupport.php @@ -1572,9 +1572,9 @@ class GlmBillingSupport public function saveContactBillingData( $ref_dest ) { $required_fields = $errors = array(); - $city_name = ''; - $billingAccount = new GlmDataAccounts( $this->wpdb, $this->config ); - $billingFields = $billingAccount->fields; + $city_name = ''; + $billingAccount = new GlmDataAccounts( $this->wpdb, $this->config ); + $billingFields = $billingAccount->fields; if ( $billingFields ) { foreach( $billingFields as $field_name => $field ) { if ( $field['required'] ) { @@ -1702,6 +1702,21 @@ class GlmBillingSupport $billing_updated_format, array( '%d' ) ); + } else { + // Get the member name + $member_name = $this->wpdb->get_var( "SELECT name FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX . "members WHERE id = $member_id" ); + // 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_format[] = '%s'; + $billing_updated_format[] = '%d'; + $billing_updated_format[] = '%s'; + $this->wpdb->insert( + GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . 'accounts', + $billing_updated, + $billing_updated_format + ); } } else { return $errors;