case 'pay_by_credit_card':
// Do the Payment Processing.
$processErrors = $BillingSupport->processMemberRenewal( $accountID, $invoice_id, $invoice_data['amount'], $invoice_data['employees'] );
- // echo '<pre>$processErrors: ' . print_r( $processErrors, true ) . '</pre>';
if ( $processErrors ) {
- // $messages[] = '<pre>$processErrors: ' . print_r( $processErrors, true ) . '</pre>';
if ( count( $processErrors ) > 0 ) {
$error = true;
$BillingSupport->removeInvoiceById( $invoice_id );
// Get the invoice.
$invoiceHtml = $BillingSupport->viewInvoice( $invoice_id );
+
+ // If the member_type is changing then update member
+ // Get current member type
+ $member_id = filter_var( $_REQUEST['member'], FILTER_VALIDATE_INT );
+ if ( $member_id ) {
+ $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
+ )
+ );
+ $new_type = filter_var( $_REQUEST['member_renewing'], FILTER_VALIDATE_INT );
+ $new_member_type = $this->wpdb->get_var(
+ $this->wpdb->prepare(
+ "SELECT member_type
+ FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "invoice_types
+ WHERE id = %d",
+ $new_type
+ )
+ );
+ if ( $current_member_type != $new_member_type ) {
+ $this->update(
+ GLM_MEMBERS_PLUGIN_DB_PREFIX . 'members',
+ array( 'member_type' => $new_member_type ),
+ array( 'id' => $member_id ),
+ array( '%d' ),
+ array( '%d' )
+ );
+ }
+ }
}
}
-
- break;
-
case 'account':
// Check to see if we're adding an account or editing one.
if ( isset( $_REQUEST['ref_name'] ) ) {
case 'pay_by_credit_card':
// Do the Payment Processing.
$processErrors = $BillingSupport->processMemberRenewal( $accountID, $invoice_id, $invoice_data['amount'], $invoice_data['employees'] );
- // echo '<pre>$processErrors: ' . print_r( $processErrors, true ) . '</pre>';
if ( $processErrors ) {
- // $messages[] = '<pre>$processErrors: ' . print_r( $processErrors, true ) . '</pre>';
if ( count( $processErrors ) > 0 ) {
$error = true;
$BillingSupport->removeInvoiceById( $invoice_id );
// Get the invoice.
$invoiceHtml = $BillingSupport->viewInvoice( $invoice_id );
+
+ // If the member_type is changing then update member
+ // Get current member type
+ $member_id = filter_var( $_REQUEST['member'], FILTER_VALIDATE_INT );
+ if ( $member_id ) {
+ $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
+ )
+ );
+ $new_type = filter_var( $_REQUEST['member_renewing'], FILTER_VALIDATE_INT );
+ $new_member_type = $this->wpdb->get_var(
+ $this->wpdb->prepare(
+ "SELECT member_type
+ FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "invoice_types
+ WHERE id = %d",
+ $new_type
+ )
+ );
+ if ( $current_member_type != $new_member_type ) {
+ $this->update(
+ GLM_MEMBERS_PLUGIN_DB_PREFIX . 'members',
+ array( 'member_type' => $new_member_type ),
+ array( 'id' => $member_id ),
+ array( '%d' ),
+ array( '%d' )
+ );
+ }
+ }
}
}
$('#billing-amount').val( $(this).find('option:selected').data( 'amount') );
});
+ // Create a USD formatter
var formatter = new Intl.NumberFormat('en-US', {
style: 'currency',
currency: 'USD',
$('#billing-amount').val( $(this).find('option:selected').data( 'amount') );
});
+ // Create a USD formatter
+ var formatter = new Intl.NumberFormat('en-US', {
+ style: 'currency',
+ currency: 'USD',
+ minimunFractionDigits: 2
+ });
function getPageTotal(){
// Calculate the total for this page.
member_renewing_amount += parseFloat( $(this).data('amount') );
}
});
- $('#renew_total').html( '$' + member_renewing_amount );
+
+ $('#renew_total').html( formatter.format( member_renewing_amount ) );
$('#total_renew_amount').val( member_renewing_amount );
}