From: Steve Sutton Date: Tue, 15 May 2018 19:19:50 +0000 (-0400) Subject: Update payment form in member billing section. X-Git-Tag: v1.0.0^2~11 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=ae05e8fe4d5f9acaa5b17e64d0d8b151c55f3ce7;p=WP-Plugins%2Fglm-member-db-billing.git Update payment form in member billing section. Deal with more than one invoice correctly. --- diff --git a/classes/billingSupport.php b/classes/billingSupport.php index 1d2cf54..70d552d 100644 --- a/classes/billingSupport.php +++ b/classes/billingSupport.php @@ -1359,7 +1359,7 @@ class GlmBillingSupport } else { $result = array( 'status' => 0, - 'errors' => $ccResult['description'] + 'errors' => array( $ccResult['description'] ) ); } diff --git a/models/admin/member/billing.php b/models/admin/member/billing.php index 4059216..efe8131 100644 --- a/models/admin/member/billing.php +++ b/models/admin/member/billing.php @@ -267,7 +267,7 @@ class GlmMembersAdmin_member_billing // extends GlmDataBilling // Now that the invoice is created. Do payment Processing. - // If there's any errors then re-show the form. + // If there's any rrors then re-show the form. if ( $error ) { // Remove the invoice created. if ( $invoice_id ) { @@ -554,11 +554,14 @@ class GlmMembersAdmin_member_billing // extends GlmDataBilling // Make the Payment using Billing Support Class $errors = $BillingSupport->makePayment( $account_id, $invoices, $amount ); - // echo '
$errors: ' . print_r( $errors, true ) . '
'; + echo '
$errors: ' . print_r( $errors, true ) . '
'; - if ( $errors ) { + // Errors will be an array + if ( isset( $errors ) && !empty( $errors ) ) { $paymentError = true; - $messages[] = ''.$errors.''; + foreach ( $errors as $error ) { + $messages[] = ''.$error.''; + } // Load DataClass for Management. require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH . '/data/dataManagement.php'; $Management = new GlmDataBillingManagement( $this->wpdb, $this->config ); diff --git a/views/admin/billing/makePayment.html b/views/admin/billing/makePayment.html index f71c0fa..38a036a 100644 --- a/views/admin/billing/makePayment.html +++ b/views/admin/billing/makePayment.html @@ -13,7 +13,7 @@ {/if} -
+ @@ -33,7 +33,7 @@ {if $invoices} {foreach $invoices as $invoice} {/foreach} @@ -68,12 +68,28 @@ jQuery(document).ready(function($){ $('#billing-amount').val( $(this).find('option:selected').data( 'amount') ); }); + $('#PaymentForm').submit(function(){ + var invoice_amount = $('#total_amount').val(); + if ( invoice_amount == 0 ) { + alert( 'You have to select at least one invoice with an amount due.' ); + return false; + } else { + return true; + } + return false; + }); + function getPageTotal(){ // Calculate the total for this page. // Get the member_renewing amount. - if ( $('input[name^=invoices]:checked').length ) { + if ( $('input[name^=invoices]:checked').length === 1 ) { var invoice_amount = parseFloat( $('input[name^=invoices]:checked').data('amount') ); + } else if ( $('input[name^=invoices]:checked').length > 1 ) { + var invoice_amount = 0.00; + $('input[name^=invoices]:checked').each(function(){ + invoice_amount += parseFloat( $(this).data('amount') ); + }); } else { var invoice_amount = 0.00; }