From 9bf6545c7f6aad191c58fb923aa6fa53eed98ff3 Mon Sep 17 00:00:00 2001 From: Chuck Scott Date: Mon, 13 Nov 2017 16:29:50 -0500 Subject: [PATCH] Additional cleanup of misc issues. Fixed problem determining if cart had already been checked out. Billing contact form is now hidden if "Same as account info" is checked. Cart and checkout summaries are now checking to see if the rate data line should be displayed in cart. Avoiding certain work in the checkout process if checkout is not successful --- classes/regCartSupport.php | 4 +- models/front/registrations/cart.php | 7 +- .../front/registrations/checkoutProcess.php | 81 ++++++++++++++----- views/front/registrations/cart.html | 4 +- views/front/registrations/checkout.html | 44 ++++++---- views/front/registrations/summary.html | 13 +++ views/front/registrations/summaryStore.html | 4 +- 7 files changed, 115 insertions(+), 42 deletions(-) diff --git a/classes/regCartSupport.php b/classes/regCartSupport.php index f0349d7..4b750cb 100644 --- a/classes/regCartSupport.php +++ b/classes/regCartSupport.php @@ -294,11 +294,11 @@ class GlmRegCartSupport public function checkRegistrationRequest($requestId = false, $json = false, $noReturn = false) { - $this->cart['blockCheckout'] = false; - // Try to get the cart data $this->getRegistrationCart($requestId, false, true); + $this->cart['blockCheckout'] = false; + // If cart status is false, then we don't have a cart so return now if (!$this->cart['status']) { $this->cart['blockCheckout'] = true; diff --git a/models/front/registrations/cart.php b/models/front/registrations/cart.php index 0c3db44..0027e31 100644 --- a/models/front/registrations/cart.php +++ b/models/front/registrations/cart.php @@ -79,9 +79,10 @@ class GlmMembersFront_registrations_cart extends GlmRegCartSupport public function modelAction($actionData = false) { - $cartId = false; - $haveCart = false; - $option = false; + $cartId = false; + $haveCart = false; + $option = false; + $blockCheckout = false; // Get misc texts require_once GLM_MEMBERS_REGISTRATIONS_PLUGIN_CLASS_PATH.'/data/dataMisc.php'; diff --git a/models/front/registrations/checkoutProcess.php b/models/front/registrations/checkoutProcess.php index 8cd7e47..8de770f 100644 --- a/models/front/registrations/checkoutProcess.php +++ b/models/front/registrations/checkoutProcess.php @@ -99,6 +99,7 @@ class GlmMembersFront_registrations_checkoutProcess extends GlmRegCartSupport $regPayment = false; $cardData = false; $cardTypeMatch = false; + $billingSame = false; $billing = false; $payment = false; $ccConfirmation = ''; @@ -130,10 +131,44 @@ 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) { + + $messages[] = "This request has already been submitted!
The information below is a summary of your submitted request."; + + // 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 + ); + + } + /* * 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 @@ -543,24 +578,28 @@ class GlmMembersFront_registrations_checkoutProcess extends GlmRegCartSupport $request = $Request->getEntry($this->cart['request']['id']); $account = $Account->getEntry($request['account']); - // Produce HTML for storage and checkout page and add to request - $summaryData = array( - 'cart' => $this->cart, - 'request' => $request, - 'account' => $account, - 'payMethodsNumb' => $this->config['payment_method_numb'], - 'status' => $this->config['submission_status'], - 'misc' => $misc - ); - $summary = $this->generateCheckoutConfHTML($summaryData, 'front/registrations/summaryStore.html'); - $updated = $this->wpdb->update( - GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX.'reg_request', - array( - 'summary' => $summary - ), - array( 'id' => $requestId ), - array('%s') + if (count($messages) == 0) { + + // Produce HTML for storage and checkout page and add to request + $summaryData = array( + 'cart' => $this->cart, + 'request' => $request, + 'account' => $account, + 'payMethodsNumb' => $this->config['payment_method_numb'], + 'status' => $this->config['submission_status'], + 'misc' => $misc ); + $summary = $this->generateCheckoutConfHTML($summaryData, 'front/registrations/summaryStore.html'); + $updated = $this->wpdb->update( + GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX.'reg_request', + array( + 'summary' => $summary + ), + array( 'id' => $requestId ), + array('%s') + ); + + } if (count($messages) == 0) { @@ -570,13 +609,17 @@ class GlmMembersFront_registrations_checkoutProcess extends GlmRegCartSupport } - /* * If all is done correctly, use model redirect to go to Step 4 - Dispaly summary */ if (count($messages) != 0) { + + // Include the billing info same flag + $regAccount['billingSame'] = $billingSame; + $view = 'checkout'; + $templateData = array( 'request' => array('page' => 'checkout'), 'haveMessages' => count($messages), @@ -584,7 +627,7 @@ class GlmMembersFront_registrations_checkoutProcess extends GlmRegCartSupport 'regAccount' => $regAccount, 'regPayment' => $regPayment, 'payMethod' => $payMethod, - 'cardData' => $cardData + 'cardData' => $cardData, ); return array( 'status' => true, diff --git a/views/front/registrations/cart.html b/views/front/registrations/cart.html index b3ae08a..01ce669 100644 --- a/views/front/registrations/cart.html +++ b/views/front/registrations/cart.html @@ -63,8 +63,8 @@ {$registrant.fname} {$registrant.lname} {$registrant.event_time} - {if $registrant.registrantDiscount > 0} - {$registrant.registrantDiscount|number_format:2} + {if $registrant.registrantDiscounts > 0} + {$registrant.registrantDiscounts|number_format:2} {else}   {/if} diff --git a/views/front/registrations/checkout.html b/views/front/registrations/checkout.html index 08209ec..dc31865 100644 --- a/views/front/registrations/checkout.html +++ b/views/front/registrations/checkout.html @@ -118,28 +118,28 @@

Billing Information

-
 Same as Account Information
-
+
 Same as Account Information
+
First Name:
-
+
Last Name:
-
+
Address:
-
+
 
-
+
City:
-
+
State:
-
+
Zip/Postal Code:
-
+
Country:
-
+
Phone:
-
+
FAX:
@@ -294,7 +294,7 @@
 
General Registrations Terms and Conditions:
-
+
{foreach $cart.events as $event} @@ -364,13 +364,17 @@     {$class.class_name} {foreach $class.rates as $rate} + {if $rate.rateBaseCharge || $rate.registrant_credits}         {$rate.rate_name} - Base Rate ({$rate.registrant_credits} registrants included) - {$rate.rateBaseCharge|number_format:2} + + {if $rate.rateBaseCharge}{$rate.rateBaseCharge|number_format:2}{/if} + + {/if} {foreach $rate.registrants as $registrant}   @@ -422,7 +426,7 @@ $('.payMethodSelector').on('change', function() { // Get the value from the selected Payment Method - var payMethod = $(this).val() + var payMethod = $(this).val(); // Hide all pay method inputs and dissable them all $('.payMethodSelection').addClass('glm-hidden'); @@ -478,6 +482,18 @@ }); + $('#glm-reg-bill-same').on('change', function() { + isBillSameChecked(); + }); + function isBillSameChecked() { + if ($("#glm-reg-bill-same").is(':checked')) { + $('.glm-reg-bill-field').addClass('glm-hidden'); + } else { + $('.glm-reg-bill-field').removeClass('glm-hidden'); + } + }; + isBillSameChecked(); + // Various input masks for credit card input $(".cc-input").mask("9999999999999?999"); $(".expire-input").mask("99/99"); diff --git a/views/front/registrations/summary.html b/views/front/registrations/summary.html index f2f7147..f2b0caf 100644 --- a/views/front/registrations/summary.html +++ b/views/front/registrations/summary.html @@ -6,6 +6,19 @@
{$misc.summary_page_text}
+ +{if $haveMessages} +

 

+
+ Please Note: +
    +{foreach $messages as $m} +
  • {$m}
  • +{/foreach} +
+
+{/if} +