From: Chuck Scott Date: Tue, 25 Sep 2018 19:32:43 +0000 (-0400) Subject: Added checks that request is still in Cart status for registrations, cart, checkout... X-Git-Tag: v1.0.22^2~6 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/index.cgi?a=commitdiff_plain;h=0c0b58ba0e5ff0cc32a2322bf8c0ad92e0ce010e;p=WP-Plugins%2Fglm-member-db-registrations.git Added checks that request is still in Cart status for registrations, cart, checkout, and checkout process. --- diff --git a/classes/regCartSupport.php b/classes/regCartSupport.php old mode 100644 new mode 100755 index 113e0e2..6bbeb67 --- a/classes/regCartSupport.php +++ b/classes/regCartSupport.php @@ -84,6 +84,29 @@ class GlmRegCartSupport + /* + * Is the request at the supplied ID still in "Cart" status + * + * @param integer $id ID of request + * + * @return boolean True if still in "Cart" status or false + */ + function isCartStatus($id) { + + $cart = $this->wpdb->get_row(" + SELECT status + FROM ".GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX."reg_request + WHERE id = $id + ;", ARRAY_A); + + if ($cart['status'] == 0) { + return true; + } + + return false; + + } + /* * Create a new cart * @@ -375,11 +398,11 @@ class GlmRegCartSupport $this->cart['blockCheckout'] = false; - // If cart status is false, then we don't have a cart so block checkout, clear cart ID, and return - if (!$this->cart['status']) { + // If request returned status false or request is no longer in "cart" status , then we don't have a cart so block checkout, clear cart ID, and return + if (!$this->cart['status'] || $this->cart['request']['status']['value'] > 0) { $this->cart['blockCheckout'] = true; $_SESSION['glm_reg_cart_id'] = false; - trigger_error('Cart ID '.$requestId.' does not have matching reg_request record. Cart ID removed from session.'); + trigger_error('Request ID '.$requestId.' does not have matching reg_request record or no longer in cart status. Cart ID removed from session.'); return $this->cart; } diff --git a/models/front/registrations/cart.php b/models/front/registrations/cart.php old mode 100644 new mode 100755 index 61595fb..d3e3837 --- a/models/front/registrations/cart.php +++ b/models/front/registrations/cart.php @@ -132,18 +132,39 @@ class GlmMembersFront_registrations_cart extends GlmRegCartSupport // If we have a cart ID now if ($cartId) { + if (!$this->isCartStatus($cartId)) { + + // Clear session + $_SESSION['glm_reg_cart_id'] = false; + + // Compile template data + $templateData = array( + 'messages' => array('We are unable to access your request. Your session may have timed out or been submitted already.') + ); + + // Send user back to list page + return array( + 'status' => true, + 'menuItemRedirect' => 'registrations', + 'modelRedirect' => 'list', + 'view' => 'front/registrations/list.html', + 'data' => $templateData + ); + + } + // Try to get a Validated cart with updated totals $this->checkRegistrationRequest($cartId); - // If the cart checks out OK - if ($this->cart && $this->cart['status']) { + // If the cart loads OK + if ($this->cart) { // Mark it as good and stuff the cart ID in the current session $haveCart = true; $_SESSION['glm_reg_cart_id'] = $cartId; + // Otherwise request is not valid or is no longer in "Cart" status } - } // Compile template data diff --git a/models/front/registrations/checkout.php b/models/front/registrations/checkout.php old mode 100644 new mode 100755 index bb6c954..d2a7f6e --- a/models/front/registrations/checkout.php +++ b/models/front/registrations/checkout.php @@ -122,10 +122,34 @@ class GlmMembersFront_registrations_checkout extends GlmRegCartSupport if ($cartId) { + // Check if this request is not in Cart status + if (!$this->isCartStatus($cartId)) { + + // Clear session + $_SESSION['glm_reg_cart_id'] = false; + + // Compile template data + $templateData = array( + 'messages' => array('We are unable to access your request. Your session may have timed out or been submitted already.') + ); + + // Send user back to list page + return array( + 'status' => true, + 'menuItemRedirect' => 'registrations', + 'modelRedirect' => 'list', + 'view' => 'front/registrations/list.html', + 'data' => $templateData + ); + } + $this->getRegistrationCart($cartId); + // If cart ID is good and we have a cart if ($this->cart) { + $haveCart = true; + } } @@ -169,7 +193,6 @@ class GlmMembersFront_registrations_checkout extends GlmRegCartSupport } - } $regAccountId = $this->cart['request']['account']; diff --git a/models/front/registrations/checkoutProcess.php b/models/front/registrations/checkoutProcess.php index 886115f..2734b61 100755 --- a/models/front/registrations/checkoutProcess.php +++ b/models/front/registrations/checkoutProcess.php @@ -131,6 +131,26 @@ class GlmMembersFront_registrations_checkoutProcess extends GlmRegCartSupport $requestId = ($_SESSION['glm_reg_cart_id'] - 0); if ($requestId > 0) { + if (!$this->isCartStatus($requestId)) { + + // Clear session + $_SESSION['glm_reg_cart_id'] = false; + + // Compile template data + $templateData = array( + ); + + // Send user back to list page + return array( + 'status' => true, + 'menuItemRedirect' => 'registrations', + 'modelRedirect' => 'list', + 'view' => 'front/registrations/list.html', + 'data' => $templateData + ); + + } + // Try to get a validated cart $this->checkRegistrationRequest($requestId); @@ -164,7 +184,7 @@ class GlmMembersFront_registrations_checkoutProcess extends GlmRegCartSupport /* * This cart has been completed or is otherwise not in cart status anymore. Display the submitted results rather than process. */ - $messages[] = "This request has already been submitted!
The information below is a summary of your submitted request."; + $messages[] = "The request may have already been submitted!"; // Build check code for display of summary in iframe $summaryCheck = md5($this->cart['request']['id'].GLM_MEMBERS_REGISTRATIONS_PLUGIN_SECRET.$this->cart['request']['account']); diff --git a/models/front/registrations/list.php b/models/front/registrations/list.php old mode 100644 new mode 100755 index db43baf..58675c4 --- a/models/front/registrations/list.php +++ b/models/front/registrations/list.php @@ -74,6 +74,11 @@ $alphaSelected = false; $haveRegEvents = false; $regEventsCount = false; + $messages = false; + + if (isset($actionData['messages'])) { + $messages = $actionData['messages']; + } // Start by checking if we need to purge any old data - Once per hour $lastPurgeTime = get_option('glmMembersRegistrationsPluginLastPurgeTime'); @@ -167,6 +172,8 @@ // Compile template data $templateData = array( 'page' => 'register', + 'haveMessages' => count($messages), + 'messages' => $messages, 'regEventsCount' => $regEventsCount, 'haveRegEvents' => $haveRegEvents, 'regEvents' => $list, diff --git a/models/front/registrations/register.php b/models/front/registrations/register.php old mode 100644 new mode 100755 diff --git a/models/front/registrations/registration.php b/models/front/registrations/registration.php old mode 100644 new mode 100755 index 0d14fab..171ac9c --- a/models/front/registrations/registration.php +++ b/models/front/registrations/registration.php @@ -117,6 +117,29 @@ // If it's a positive integer, try to get the cart if ($cartId > 0) { + + // Ask if this request is not in Cart status + if (!$RegCart->isCartStatus($cartId)) { + + // Clear session + $_SESSION['glm_reg_cart_id'] = false; + + // Compile template data + $templateData = array( + 'messages' => array('We are unable to access your request. Your session may have timed out or been submitted already.') + ); + + // Send user back to list page + return array( + 'status' => true, + 'menuItemRedirect' => 'registrations', + 'modelRedirect' => 'list', + 'view' => 'front/registrations/list.html', + 'data' => $templateData + ); + } + + // Get cart and check for insufficient inventory $cart = $RegCart->checkRegistrationRequest( $cartId ); if ($cart !== false && is_array($cart)) { $haveCart = true; diff --git a/readme.txt b/readme.txt index 060f552..ea2e21a 100755 --- a/readme.txt +++ b/readme.txt @@ -25,6 +25,9 @@ e.g. 1. Activate the plugin through the 'Plugins' menu in WordPress == Changelog == += (pending) = +* Checkout page now shows "Billing Information" if there are charges or "Contact Information" if there's no charge. + = 1.0.20 = * Fixed date and time displayed for an event on registration page so it reflects only current or future dates and times. * Fixed time displayed for an event on registration page so it no longer shows a range of times, only the time for the date shown. diff --git a/views/admin/registrations/eventRegistrants.html b/views/admin/registrations/eventRegistrants.html old mode 100644 new mode 100755 index 00612ba..b0f43fa --- a/views/admin/registrations/eventRegistrants.html +++ b/views/admin/registrations/eventRegistrants.html @@ -122,7 +122,7 @@ {$r.account.email}

Not Attending
- Note that if check this the inventory will be returned to permit another {$terms.reg_term_attendee} to {$terms.reg_term_register}. + If checked this inventory will be returned to permit another {$terms.reg_term_attendee} to {$terms.reg_term_register}. If you un-check this it will check to see if inventory is available and if not will not change this to {$terms.reg_term_attending}.

diff --git a/views/front/registrations/checkout.html b/views/front/registrations/checkout.html index 8258664..ae23fcf 100755 --- a/views/front/registrations/checkout.html +++ b/views/front/registrations/checkout.html @@ -65,7 +65,13 @@
+ {if $cart.grandTotal > 0}

Billing Information

+ {else} +

Contact Information

+ {/if} + +
* Required Fields diff --git a/views/front/registrations/list.html b/views/front/registrations/list.html old mode 100644 new mode 100755 index 85cb7af..54fdc46 --- a/views/front/registrations/list.html +++ b/views/front/registrations/list.html @@ -9,6 +9,20 @@
+ +{if $haveMessages} +
+ Please Note: +
    +{foreach $messages as $m} +
  • {$m}
  • +{/foreach} +
+
+{/if} + + +
{if $reg_bulletin}