Added checks that request is still in Cart status for registrations, cart, checkout...
authorChuck Scott <cscott@gaslightmedia.com>
Tue, 25 Sep 2018 19:32:43 +0000 (15:32 -0400)
committerChuck Scott <cscott@gaslightmedia.com>
Tue, 25 Sep 2018 19:32:43 +0000 (15:32 -0400)
classes/regCartSupport.php [changed mode: 0644->0755]
models/front/registrations/cart.php [changed mode: 0644->0755]
models/front/registrations/checkout.php [changed mode: 0644->0755]
models/front/registrations/checkoutProcess.php
models/front/registrations/list.php [changed mode: 0644->0755]
models/front/registrations/register.php [changed mode: 0644->0755]
models/front/registrations/registration.php [changed mode: 0644->0755]
readme.txt
views/admin/registrations/eventRegistrants.html [changed mode: 0644->0755]
views/front/registrations/checkout.html
views/front/registrations/list.html [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index 113e0e2..6bbeb67
@@ -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;
         }
 
old mode 100644 (file)
new mode 100755 (executable)
index 61595fb..d3e3837
@@ -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
old mode 100644 (file)
new mode 100755 (executable)
index bb6c954..d2a7f6e
@@ -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'];
index 886115f..2734b61 100755 (executable)
@@ -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!<br>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']);
old mode 100644 (file)
new mode 100755 (executable)
index db43baf..58675c4
         $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');
         // Compile template data
         $templateData = array(
             'page'              => 'register',
+            'haveMessages'      => count($messages),
+            'messages'          => $messages,
             'regEventsCount'    => $regEventsCount,
             'haveRegEvents'     => $haveRegEvents,
             'regEvents'         => $list,
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
index 0d14fab..171ac9c
 
             // 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;
index 060f552..ea2e21a 100755 (executable)
@@ -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.
old mode 100644 (file)
new mode 100755 (executable)
index 00612ba..b0f43fa
                                 <b>{$r.account.email}</b>
                                 <p>
                                     <input id="glmRegNotAttending_{$r.id}" type="checkbox" name="not_attending" value="1"{if $r.not_attending.value} checked{/if}> Not Attending<br>
-                                    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}.
                                 </p>
                                 <label>First Name</label>
index 8258664..ae23fcf 100755 (executable)
                     <div class="glm-reg-billing-info">
                         <div class="row">
                             <div class="columns medium-8 small-12 text-left glm-reg-required">
+      {if $cart.grandTotal > 0}
                             <h4>Billing Information</h4>
+      {else}
+                            <h4>Contact Information</h4>
+      {/if}                            
+                            
+                            
                             </div>
                             <div class="columns medium-4 small-12 glm-reg-required glm-reg-required-guide">
                                 * Required Fields
old mode 100644 (file)
new mode 100755 (executable)
index 85cb7af..54fdc46
@@ -9,6 +9,20 @@
             </ul>
         </div>
 </div>
+
+{if $haveMessages}
+<div class="glm-registrations-messages glm-reg-warning glm-row" style="clear: all;">
+    <i>Please Note:</i>
+    <ul>
+{foreach $messages as $m}
+        <li>{$m}</li>
+{/foreach}
+    </ul>
+</div>
+{/if}
+
+
+
 <div id="glm-reg-list" class="glm-reg-row">
     {if $reg_bulletin}
     <div id="reg_bulletin">