From: Steve Sutton Date: Wed, 10 Apr 2019 16:05:03 +0000 (-0400) Subject: Updating payment form X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=0cddf7e1a65ec659e22e1b66ec067caea125cb53;p=WP-Plugins%2Fglm-member-db-billing.git Updating payment form Give correct billing info when showing errors. Show billing form info from what was posted to form. --- diff --git a/models/front/billing/paymentForm.php b/models/front/billing/paymentForm.php index b154eb2..b2666e9 100644 --- a/models/front/billing/paymentForm.php +++ b/models/front/billing/paymentForm.php @@ -140,20 +140,20 @@ class GlmMembersFront_billing_paymentForm // extends GlmDataBilling $Accounts = new GlmDataAccounts( $this->wpdb, $this->config ); - if ( isset( $memberId ) && $memberId ) { - require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH . '/data/dataAccounts.php'; - $accountId = $this->wpdb->get_var( - $this->wpdb->prepare( - "SELECT id - FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "accounts - WHERE ref_dest = %d", - $this->memberId - ) - ); - if ( isset( $accountId ) && $accountId ) { - $account_status = apply_filters( 'glm-billing-get-account-status', '', $accountId ); - } - } + // if ( isset( $memberId ) && $memberId ) { + // require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH . '/data/dataAccounts.php'; + // $accountId = $this->wpdb->get_var( + // $this->wpdb->prepare( + // "SELECT id + // FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "accounts + // WHERE ref_dest = %d", + // $this->memberId + // ) + // ); + // if ( isset( $accountId ) && $accountId ) { + // $account_status = apply_filters( 'glm-billing-get-account-status', '', $accountId ); + // } + // } switch ( $option ) { case 'payment': @@ -174,12 +174,7 @@ class GlmMembersFront_billing_paymentForm // extends GlmDataBilling $management = $Management->getEntry( 1 ); require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH . '/data/dataAccounts.php'; - if ( $accountId ) { - // Need to see if there's an account for this member. - $account = $Accounts->editEntry( $accountId ); - } else { - $account = $Accounts->newEntry(); - } + $account = $Accounts->newEntry(); } break; @@ -231,8 +226,6 @@ class GlmMembersFront_billing_paymentForm // extends GlmDataBilling // Look at the payment option given $payment_option = filter_var( $_REQUEST['payment_option'], FILTER_SANITIZE_STRING ); - // echo '
$_REQUEST: ' . print_r( $_REQUEST, true ) . '
'; - // echo '
$payment_option: ' . print_r( $payment_option, true ) . '
'; switch ( $payment_option ) { case 'pay_by_credit_card': @@ -257,11 +250,6 @@ class GlmMembersFront_billing_paymentForm // extends GlmDataBilling // Get list of payable invoice_types $payable_types = $BillingSupport->getAllPayableInvoiceTypes(); - // $member_invoice_id = $BillingSupport->getMembersInvoiceTypeByRefDest( $this->memberId ); - // if ( $member_invoice_id ) { - // $member_invoice = $BillingSupport->getInvoiceTypeById( $member_invoice_id ); - // } - if ( $this->config['settings']['allow_employees'] ) { // Get a list of this accounts employees. If they have any. $employees = $BillingSupport->getListOfAccountEmployees( $this->memberId ); @@ -273,7 +261,36 @@ class GlmMembersFront_billing_paymentForm // extends GlmDataBilling $management = $Management->getEntry( 1 ); // Need to see if there's an account for this member. - $account = $Accounts->editEntry( $accountId ); + // $account = $Accounts->editEntry( $accountId ); + $account = $Accounts->newEntry(); + // Assign posted values to the $account object. + if ( $this->config['settings']['billing_contact_name_enabled'] ) { + if ( isset( $_REQUEST['billing_contact_name'] ) && $_REQUEST['billing_contact_name'] ) { + $account['fieldData']['billing_contact_name'] = $_REQUEST['billing_contact_name']; + } + } else { + if ( isset( $_REQUEST['billing_fname'] ) && $_REQUEST['billing_fname'] ) { + $account['fieldData']['billing_fname'] = $_REQUEST['billing_fname']; + } + if ( isset( $_REQUEST['billing_lname'] ) && $_REQUEST['billing_lname'] ) { + $account['fieldData']['billing_lname'] = $_REQUEST['billing_lname']; + } + } + if ( isset( $_REQUEST['billing_addr1'] ) && $_REQUEST['billing_addr1'] ) { + $account['fieldData']['billing_addr1'] = $_REQUEST['billing_addr1']; + } + if ( isset( $_REQUEST['billing_state'] ) && $_REQUEST['billing_state'] ) { + $account['fieldData']['billing_state']['value'] = $_REQUEST['billing_state']; + } + if ( isset( $_REQUEST['billing_city'] ) && $_REQUEST['billing_city'] ) { + $account['fieldData']['billing_city'] = $_REQUEST['billing_city']; + } + if ( isset( $_REQUEST['billing_zip'] ) && $_REQUEST['billing_zip'] ) { + $account['fieldData']['billing_zip'] = $_REQUEST['billing_zip']; + } + if ( isset( $_REQUEST['email'] ) && $_REQUEST['email'] ) { + $account['fieldData']['email'] = $_REQUEST['email']; + } } break; case 'pay_by_check':