From 554bd2a3deb62525310a9cef7493086e140a4d94 Mon Sep 17 00:00:00 2001 From: Chuck Scott Date: Wed, 21 Feb 2018 08:53:51 -0500 Subject: [PATCH] Completed Review of Checkout Processes Fixed issues with not being able to store results and other fixes in checkoutProcess.php Added remaining payment methods to summaryStore.html Updated summary header info for more complete payment status in cartSummary.html Addedd updateAccountBillingOnly() and create date set in post processing to dataAccount.php --- classes/data/dataAccount.php | 71 +++++++ models/front/registrations/checkout.php | 34 ++- .../front/registrations/checkoutProcess.php | 197 +++++++----------- models/front/registrations/list.php | 1 + views/front/registrations/cartSummary.html | 3 +- views/front/registrations/checkout.html | 51 +++-- views/front/registrations/list.html | 2 +- views/front/registrations/summaryStore.html | 27 ++- 8 files changed, 243 insertions(+), 143 deletions(-) diff --git a/classes/data/dataAccount.php b/classes/data/dataAccount.php index 4852678..d17786b 100644 --- a/classes/data/dataAccount.php +++ b/classes/data/dataAccount.php @@ -594,6 +594,39 @@ class GlmDataRegistrationsAccount extends GlmDataAbstract } + /** + * Entry Post Processing Call-Back Method + * + * Perform post-processing for all result entries. + * + * @param array $r Array of field result data for a single entry + * @param string $a Action being performed (l, i, g, ...) + * + * @return object Class object + * + */ + public function entryPostProcessing( $result_data, $action ) + { + + // If doing the following actions + if (in_array($action, array('i'))) { + + // Set the created date + $date = date('Y-m-d'); + $this->wpdb->update( + GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX."reg_request_event", + array('date_created' => $deate), + array('id' => $result_data['id']), + array('%s') + ); + + } + + return $result_data; + + } + + public function checkOther($r, $a) { @@ -638,4 +671,42 @@ class GlmDataRegistrationsAccount extends GlmDataAbstract return $r; } + + /** + * Update Account Billing Only + * + * @param integer $requestId ID of registration request + * + * @return object Class object + */ + public function updateAccountBillingOnly($accountId = false) + { + + $savedFields = $this->fields; + + $this->fields = array( + 'email' => $savedFields['email'], + 'bill_fname' => $savedFields['bill_fname'], + 'bill_lname' => $savedFields['bill_lname'], + 'bill_org' => $savedFields['bill_org'], + 'bill_title' => $savedFields['bill_title'], + 'bill_addr1' => $savedFields['bill_addr1'], + 'bill_addr2' => $savedFields['bill_addr2'], + 'bill_city' => $savedFields['bill_city'], + 'bill_state' => $savedFields['bill_state'], + 'bill_zip' => $savedFields['bill_zip'], + 'bill_country' => $savedFields['bill_country'], + 'bill_phone' => $savedFields['bill_phone'], + 'bill_fax' => $savedFields['bill_fax'] + ); + + $requestSimplified = $this->getEntry($accountId); + + $this->fields = $savedFields; + $this->postProcRegRequest = $savedPostProcess; + + return $requestSimplified; + + } + } diff --git a/models/front/registrations/checkout.php b/models/front/registrations/checkout.php index 7f7dd4e..70b3021 100644 --- a/models/front/registrations/checkout.php +++ b/models/front/registrations/checkout.php @@ -127,9 +127,6 @@ class GlmMembersFront_registrations_checkout extends GlmRegCartSupport } } - // Get any already submitted comp code - /**** NEED TO DO THIS ****/ - $view = 'checkout'; if ($haveCart) { @@ -137,6 +134,37 @@ class GlmMembersFront_registrations_checkout extends GlmRegCartSupport // Try to validate the cart with updated totals $this->checkRegistrationRequest($cartId); + // Check if cart has been successfully checked out or has been marked canceled. + if ($this->cart['request']['status']['value'] > 0) { + + $messages[] = "This request has already been submitted!
The information below is a summary of your submitted request."; + +echo "
".print_r($this->cart,1)."
"; + // Build check code for display of summary in iframe + $summaryCheck = md5($this->cart['request']['id'].GLM_MEMBERS_REGISTRATIONS_PLUGIN_SECRET.$this->cart['request']['account']); + + $view = 'summary'; + + // Compile template data + $templateData = array( + 'haveMessages' => count($messages), + 'messages' => $messages, + 'requestId' => $this->cart['request']['id'], + 'summaryCheck' => $summaryCheck, + 'misc' => $misc + ); + + // Return status, any suggested view, and any data to controller + return array( + 'status' => true, + 'modelRedirect' => false, + 'view' => 'front/registrations/' . $view . '.html', + 'data' => $templateData + ); + + } + + } $regAccountId = $this->cart['request']['account']; diff --git a/models/front/registrations/checkoutProcess.php b/models/front/registrations/checkoutProcess.php index fb58242..cd163bb 100644 --- a/models/front/registrations/checkoutProcess.php +++ b/models/front/registrations/checkoutProcess.php @@ -106,6 +106,8 @@ class GlmMembersFront_registrations_checkoutProcess extends GlmRegCartSupport $ccConfirmation = ''; $emailError = false; $passwordError = false; + $reqData = array(); + $reqFormat = array(); $Account = new GlmDataRegistrationsAccount($this->wpdb, $this->config); $Request = new GlmDataRegistrationsRegRequest($this->wpdb, $this->config); @@ -135,7 +137,7 @@ class GlmMembersFront_registrations_checkoutProcess extends GlmRegCartSupport } // Check if cart has been successfully checked out or has been marked canceled. - if ($this->cart['request']['status']['value'] > 0) { + if ($this->cart['request']['status']['name'] != 'CART') { $messages[] = "This request has already been submitted!
The information below is a summary of your submitted request."; @@ -167,11 +169,6 @@ class GlmMembersFront_registrations_checkoutProcess extends GlmRegCartSupport * Submission account? */ - // Check if we need to collect billing account information or if it's the same as the main contact -// if (isset($_REQUEST['billing_same']) && $_REQUEST['billing_same']) { -// $billingSame = true; -// } - if (count($messages) == 0) { // If there's a logged in registrations user - Cart should already be with this account @@ -184,25 +181,13 @@ class GlmMembersFront_registrations_checkoutProcess extends GlmRegCartSupport // Try to update the account information and if that works get the data for editing again if ($accountId > 0) { -/* - $regAccount = $Account->updateEntry($accountId); - - // If there was a problem, indicate that - if (!$regAccount) { - $messages[] = 'Unable to recall your account information. Please try again later.'; - - // Otherwise get the data again prepaired for editing - } else { -*/ - $regAccount = $Account->editEntry($accountId); - // } + $regAccount = $Account->updateAccountBillingOnly($accountId); } // Otherwise this is a guest so try to create the account using the submitted data } else { // Create the new account - $Account = new GlmDataRegistrationsAccount($this->wpdb, $this->config); $regAccount = $Account->insertEntry(); // If that was successful @@ -245,20 +230,12 @@ class GlmMembersFront_registrations_checkoutProcess extends GlmRegCartSupport } -// echo "Form Result:
".print_r($formResult,1)."
"; - // Save the results in the cart event data $this->cart['events'][$eventKey]['customForm'] = $formResult; } } -// echo "
".print_r($this->cart['events'],1)."
"; - - -// wp_die("KILLING WORDPRESS FOR TESTING IN checkoutProcess.php"); - - /* * Policies accepted? */ @@ -307,47 +284,23 @@ class GlmMembersFront_registrations_checkoutProcess extends GlmRegCartSupport $payMethod = ($_REQUEST['payMethod'] - 0); } - // Make sure that the selected payment method is available - if ($payMethod > 0 && ($management['reg_payment_methods']['bitmap'][$payMethod]['default'])) { - $payMethodName = $management['reg_payment_methods']['bitmap'][$payMethod]['name']; - } else { - $payMethod = false; - } - - // Check if Billing data source fields - $billPrefix = 'bill_'; - if (isset($_REQUEST['billing_same']) && $_REQUEST['billing_same']) { - $billPrefix = ''; - } + // Add billing information to billing array $billing = array( - 'fname' => $regAccount['fieldData'][$billPrefix.'fname'], - 'lname' => $regAccount['fieldData'][$billPrefix.'lname'], - 'addr1' => $regAccount['fieldData'][$billPrefix.'addr1'], - 'addr2' => $regAccount['fieldData'][$billPrefix.'addr2'], - 'city' => $regAccount['fieldData'][$billPrefix.'city'], - 'state' => $regAccount['fieldData'][$billPrefix.'state']['value'], - 'country' => $regAccount['fieldData'][$billPrefix.'country']['value'], - 'zip' => $regAccount['fieldData'][$billPrefix.'zip'], - 'phone' => $regAccount['fieldData'][$billPrefix.'phone'], + 'fname' => $regAccount['fieldData']['bill_fname'], + 'lname' => $regAccount['fieldData']['bill_lname'], + 'addr1' => $regAccount['fieldData']['bill_addr1'], + 'addr2' => $regAccount['fieldData']['bill_addr2'], + 'city' => $regAccount['fieldData']['bill_city'], + 'state' => $regAccount['fieldData']['bill_state']['value'], + 'country' => $regAccount['fieldData']['bill_country']['value'], + 'zip' => $regAccount['fieldData']['bill_zip'], + 'phone' => $regAccount['fieldData']['bill_phone'], 'email' => $regAccount['fieldData']['email'] ); // Execute selected payment method switch ($payMethod) { - /* - submission_status_numb['CART'] = 0 - submission_status_numb['COMPLETE'] = 10 - submission_status_numb['UNPAID'] = 20 - submission_status_numb['CC_PEND'] = 30 - submission_status_numb['CC_DECL'] = 40 - submission_status_numb['PAYMENT_PEND'] = 50 - submission_status_numb['ON_ARRIVAL'] = 60 - submission_status_numb['ADMIN_HOLD'] = 70 - submission_status_numb['FAILED'] = 80 - submission_status_numb['CANCELED'] = 99 - */ - // No Charge case $this->config['payment_method_numb']['NoCharge']: $cartStatus = $this->config['submission_status_numb']['COMPLETE']; @@ -367,21 +320,37 @@ class GlmMembersFront_registrations_checkoutProcess extends GlmRegCartSupport case $this->config['payment_method_numb']['Check']: // Get the check input - $cardData = array( - 'cc_name' => filter_input(INPUT_POST, 'cc_name', FILTER_SANITIZE_STRING), // Name on Check - 'cc_numb' => filter_input(INPUT_POST, 'cc_numb', FILTER_SANITIZE_NUMBER_INT) // Check Number + $checkData = array( + 'cc_name' => filter_input(INPUT_POST, 'cc_name', FILTER_SANITIZE_STRING), // Name on Check + 'cc_numb' => filter_input(INPUT_POST, 'cc_numb', FILTER_SANITIZE_NUMBER_INT) // Check Number ); - // Check all credit card input + // Check all check input if ( - $cardData['cc_name'] && $cardData['cc_name'] != '' && // Name on Check - $cardData['cc_numb'] && $cardData['cc_numb'] > 0 // Check Number + $checkData['cc_name'] && $checkData['cc_name'] != '' && // Name on Check + $checkData['cc_numb'] && $checkData['cc_numb'] > 0 // Check Number ) { $cartStatus = $this->config['submission_status_numb']['COMPLETE']; } else { $messages[] = 'You did not supply all required check information.'; } + // Add check data to storage + $reqData = array_merge( + $reqData, + array( + 'cc_name' => $checkData['cc_name'], // Name on Check + 'cc_numb' => $checkData['cc_numb'] // Check Number + ) + ); + $reqFormat = array_merge( + $reqFormat, + array( + '%s', + '%s' + ) + ); + break; // Payment Pending @@ -473,7 +442,7 @@ class GlmMembersFront_registrations_checkoutProcess extends GlmRegCartSupport $payment = array( 'name' => $this->config['settings']['reg_org_name'], // Name of venue - 'charge' => $this->cart['totalCharges'], // Total charges this venue + 'charge' => $this->cart['totalCharges'], // Total charges 'cctype' => $cardData['cc_type'], // Card Type 'ccname' => $cardData['cc_name'], // Name on Card 'ccnumb' => $cardData['cc_numb'], // Card Number @@ -487,41 +456,61 @@ class GlmMembersFront_registrations_checkoutProcess extends GlmRegCartSupport // If successful submission - say we're complete if (is_array($ccResult) && isset($ccResult['status']) && $ccResult['status'] == 1) { + $cartStatus = $this->config['submission_status_numb']['COMPLETE']; - } - // set $ccConfirmation + // Store Credit Card information + $cc_numb_store = '....'.substr($payment['ccnumb'], -4); + $reqData = array_merge( + $reqData, + array( + 'cc_type' => $payment['cctype'], + 'cc_name' => $payment['ccname'], + 'cc_numb' => $cc_numb_store, + 'cc_exp' => $payment['ccexp'], + 'cc_conf' => $ccConfirmation, + ) + ); + $reqFormat = array_merge( + $reqFormat, + array( + '%d', + '%s', + '%s', + '%s', + '%s', + ) + ); + + } } break; // Pay Pal - case $this->config['payment_method_numb']['PayPal']: - break; +// case $this->config['payment_method_numb']['PayPal']: +// break; // Payment Method unknown default: -// $payMethod = false; + $payMethod = false; + $messages[] = "I'm sorry, we couldn't tell which payment method you wanted to use. Please select one under \"Payment Information\" below."; break; } -exit; /* * Update the reg_request reccord: account id, billing, payment, status, etc... */ - $reqData = array(); - $reqFormat = array(); $now = date('Y-m-d H:i:s', time()); // Account ID $reqData['account'] = $accountId; $reqFormat[] = '%d'; - // Billing data - + // Add billing data to requesst update arrays $reqData = array_merge( $reqData, array( @@ -557,8 +546,8 @@ exit; ) ); - // If COMPLETE, save date, pay method, status, total - if ($cartStatus == $this->config['submission_status_numb']['COMPLETE'] && $billing['addr2'] != '*** DO NOT CLEAR ***') { + // Save date, pay method, status, total + if (count($messages) == '' && $billing['addr2'] != '*** DO NOT CLEAR ***') { $reqData = array_merge( $reqData, @@ -566,7 +555,7 @@ exit; 'date_submitted' => $now, 'pay_method' => $payMethod, 'status' => $cartStatus, - 'total' => $payment['charge'], + 'total' => $this->cart['totalCharges'], 'total_discounts' => $this->cart['totalDiscounts'], 'registrants' => $this->cart['totalRegistrants'] ) @@ -601,38 +590,6 @@ exit; $reqData['user_trace_info'] = serialize($trace); $reqFormat[] = '%s'; - // Credit Card information - $cc_numb_store = ''; - if (is_array($payment)) { - - $cc_numb_store = '....'.substr($payment['ccnumb'], -4); - - $reqData = array_merge( - $reqData, - array( - 'cc_type' => $payment['cctype'], - 'cc_name' => $payment['ccname'], - 'cc_numb' => $cc_numb_store, - 'cc_exp' => $payment['ccexp'], - 'cc_conf' => $ccConfirmation, - ) - ); - $reqFormat = array_merge( - $reqFormat, - array( - '%s', - '%s', - '%s', - '%s', - '%s', - ) - ); - - $reqData['cc_type'] = $payment['cctype']; - $reqFormat[] = '%s'; - - } - $reqFormat[] = '%s'; // Store the data @@ -706,7 +663,10 @@ exit; 'status' => $this->config['submission_status'], 'misc' => $misc ); + $summary = $this->generateHTML($summaryData, 'front/registrations/summaryStore.html'); + + // Store this summary in the request reccord $updated = $this->wpdb->update( GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX.'reg_request', array( @@ -714,10 +674,14 @@ exit; ), array( 'id' => $requestId ), array('%s') - ); + ); + if ($updated != 1 && $billing['addr2'] != '*** DO NOT CLEAR ***') { + $messages[] = 'Cart Summary did not store. This is a technical issue that means our systems could not store a summmary of what you submitted.'; + } - // Update inventory totals and send notifications + // Update inventory totals and send notifications unless this is a test submission if ($billing['addr2'] != '*** DO NOT CLEAR ***') { + $this->checkoutUpdateInventoryAndNotify($summary); } @@ -737,7 +701,6 @@ exit; unset($_SESSION['glm_reg_cart_id']); } - $view = 'summary'; // Build check code for display of summary in iframe @@ -745,6 +708,8 @@ exit; // Compile template data $templateData = array( + 'haveMessages' => count($messages), + 'messages' => $messages, 'guestAccount' => $guestAccount, 'requestId' => $requestId, 'summaryCheck' => $summaryCheck, diff --git a/models/front/registrations/list.php b/models/front/registrations/list.php index 33b4d81..109948e 100644 --- a/models/front/registrations/list.php +++ b/models/front/registrations/list.php @@ -63,6 +63,7 @@ public function modelAction($actionData = false) { + $start = 1; $limit = 20; $where = ''; diff --git a/views/front/registrations/cartSummary.html b/views/front/registrations/cartSummary.html index bc1e5cd..7753208 100644 --- a/views/front/registrations/cartSummary.html +++ b/views/front/registrations/cartSummary.html @@ -1,4 +1,3 @@ -{debug} {if $summaryType=="adminRequest"} {assign var="summaryColumnsItem" value="small-7 "} {assign var="summaryColumnsCharge" value="small-5 "} @@ -38,7 +37,7 @@
{$terms.reg_term_registration_cap} {$terms.reg_term_level_cap}: {$class.class_name}
-
+
{if $rate.rateBaseCharge > 0}{$rate.base_rate_money}{/if}
diff --git a/views/front/registrations/checkout.html b/views/front/registrations/checkout.html index 2c87310..d260b7a 100644 --- a/views/front/registrations/checkout.html +++ b/views/front/registrations/checkout.html @@ -14,21 +14,24 @@ {if $checkoutPageText}
- {$checkoutPageText} -
-{/if} +

{$checkoutPageText}

+ + {if $haveMessages} +
+ Please Note: + +
+ {/if} + -{if $haveMessages} -
- Please Note: -
{/if} + {if $haveCart}
@@ -119,8 +122,16 @@
FAX{if $regAccount.fieldRequired.bill_fax} *{/if}
-
+
+
+

Please provide your E-Mail address. Without this we will be unable to contact you reqarding updates to this registration request.

+
+
+
E-Mail Address{if $regAccount.fieldRequired.email} *{/if}
+
+
+
@@ -135,11 +146,11 @@

Payment Information

-
+
{foreach $payMethods as $payMethod} {$pmName = array_search($payMethod.value, $payMethodsNumb)} - {$pmNumb = $payMethodsNumb.{$pmName}} + {$pmNumb = $payMethodsNumb.{$pmName}} {$pmNumb}   {$payMethods.{$pmNumb}.name}     {/foreach}
@@ -305,11 +316,13 @@