Enhancements to cart widget pop-up cart list, checkout, and cart summaries.
authorChuck Scott <cscott@gaslightmedia.com>
Tue, 14 Nov 2017 18:34:00 +0000 (13:34 -0500)
committerChuck Scott <cscott@gaslightmedia.com>
Tue, 14 Nov 2017 18:34:00 +0000 (13:34 -0500)
Now displaying event and registrant totals in cart widget popup.
Now purging empty carts when account logs in.
Selecting latest non-empty cart when logging in.
Added more registrant info to cart and checkout summaries.
Fixed problems with not having account input data for checkout view when checking out as a guest

classes/regCartSupport.php
models/front/registrations/cart.php
models/front/registrations/checkout.php
models/front/registrations/login.php
views/front/registrations/cart.html
views/front/registrations/cartLinkWidget.html
views/front/registrations/checkout.html
views/front/registrations/summaryStore.html

index 9d58664..bb95f9f 100644 (file)
@@ -1015,7 +1015,7 @@ class GlmRegCartSupport
 
                 // Try to get the full list of pending carts for this user
                 $RegRequest = new GlmDataRegistrationsRegRequest($this->wpdb, $this->config);
-                $cartSummary['regRequests'] = $RegRequest->getRegRequestListSimplified($where);
+                $cartSummary['regRequests'] = $RegRequest->getRegRequestListSimplified($where, true);
 
                 if (is_array($cartSummary['regRequests']) && count($cartSummary['regRequests'])) {
 
index e937097..0027e31 100644 (file)
@@ -154,7 +154,7 @@ class GlmMembersFront_registrations_cart extends GlmRegCartSupport
             'cartPageText'  => $misc['cart_page_text']
         );
 
-        echo "<pre>".print_r($templateData,1)."</pre>";
+        // echo "<pre>".print_r($templateData,1)."</pre>";
 
         // Return status, any suggested view, and any data to controller
         return array(
index aa395b7..269b0b8 100644 (file)
@@ -153,8 +153,30 @@ class GlmMembersFront_registrations_checkout extends GlmRegCartSupport
         // Otherwise setup for a new account
         } else {
 
-            $regAccount = $Account->newEntry();
+            // Create an account record
+            $this->wpdb->insert(
+                GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX.'account',
+                array(
+                    'active' => true,
+                    'validated' => false,
+                    'date_created' => date('Y-m-d')
+                ),
+                array('%d', '%d', '%s')
+            );
+            $regAccountId = $this->wpdb->insert_id;
+
+            // Update request with account ID
+            $this->wpdb->update(
+                GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX.'reg_request',
+                array('account' => $regAccountId),
+                array( 'id' => $cartId ),
+                array('%d')
+            );
+
+            // Get the account again for editing with all fields
+            $regAccount = $Account->editEntry($regAccountId);
 
+            // Create a suggested password and add it to the account
             require_once GLM_MEMBERS_REGISTRATIONS_MAIN_PLUGIN_LIB_PATH.'/EasyPassword/EasyPassword.php';
             $EasyPassword = new EasyPassword();
             $regAccount['fieldData']['password'] = $EasyPassword->generateEasyPassword($type = 'firstlast');
@@ -233,9 +255,6 @@ class GlmMembersFront_registrations_checkout extends GlmRegCartSupport
 
 // *** If redirected back, be sure to get the submitted data
 
-        // Accounts list not needed
-        unset($this->cart['accounts']);
-
         $view = 'checkout';
 
 
@@ -248,7 +267,12 @@ class GlmMembersFront_registrations_checkout extends GlmRegCartSupport
         $Misc = new GlmDataRegistrationsMisc($this->wpdb, $this->config);
         $misc = $Misc->getEntry(1);
 
-                // Compile template data
+        // If we don't have billing same flag initialized, do it now
+        if (!isset($regAccount['billingSame'])) {
+            $regAccount['billingSame'] = false;
+        }
+
+        // Compile template data
         $templateData = array(
             'page'          => 'checkout',
             'regAccountId'  => $this->cart['request']['account'],
index b43c9c2..76cf51e 100644 (file)
                             'fname' => $returnData['fname'],
                             'lname' => $returnData['lname'],
                         );
+
+                        // Check for existing carts in "CART" status
+                        require_once GLM_MEMBERS_REGISTRATIONS_PLUGIN_CLASS_PATH.'/regCartSupport.php';
+                        $RegCartSupport = new GlmRegCartSupport($this->wpdb, $this->config);
+                        $regCartSummary = $RegCartSupport->regCartSummary($returnId);
+
+                        $RegRequest = false;
+                        $deleted = false;
+
+                        // If there's any current carts, get the last (most recent) one.
+                        if ($regCartSummary && isset($regCartSummary['regRequests']) && count($regCartSummary['regRequests']) > 0 ) {
+
+                            // If there's any carts with no events, delete them
+                            foreach ($regCartSummary as $rcs) {
+                                foreach ($rcs as $r) {
+
+                                    // If this cart is empty
+                                    if ($r['numb_events'] == 0) {
+
+                                        // If we haven't instatiated the reg request class
+                                        if ($RegRequest == false) {
+
+                                            require_once GLM_MEMBERS_REGISTRATIONS_PLUGIN_CLASS_PATH.'/data/dataRegRequest.php';
+                                            $RegRequest = new GlmDataRegistrationsRegRequest($this->wpdb, $this->config);
+                                        }
+
+                                        // Delete this entry
+                                        $RegRequest->deleteEntry($r['id'], true);
+
+                                        $deleted = true;
+                                    }
+
+                                }
+                            }
+
+                            // If any were deleted, but the cart summary again.
+                            if ($deleted) {
+                                $regCartSummary = $RegCartSupport->regCartSummary($returnId);
+                            }
+
+                            // If there's still any carts, make the latest one the current cart
+                            if (count($regCartSummary['regRequests']) > 0) {
+                                $mostRecent = end($regCartSummary['regRequests']);
+                                $_SESSION['glm_reg_cart_id'] = $mostRecent['id'];
+                            }
+
+                        }
+
+
                         $modelRedirect = 'index';
                         $_REQUEST['page'] = 'list';
 
index bd455b6..f23f136 100644 (file)
                     {/if}
                 </td>
             </tr>
+          {assign var="acct" value=$cart.accounts.{$registrant.account}}
+          {if $acct.validated.value}
+                <tr>
+                    <td colspan="2">&nbsp;</td>
+                    <td colspan="3">
+                      {if $acct.email != ''}E-Mail: {$acct.email}<br>{/if}
+                      (Account information is restricted)
+                    </td>
+                </tr>
+          {else}
+            {if $acct.addr != '' || $acct.phone != '' || $acct.email != ''}
+                <tr>
+                    <td colspan="2">&nbsp;</td>
+                    <td colspan="3">
+                      {if $acct.org != ''}          {$acct.title}, {$acct.org}<br>                      {/if}
+                      {if $acct.addr1 != ''}        {$acct.addr1}<br>                                   {/if}
+                      {if $acct.addr2 != ''}        {$acct.addr2}<br>                                   {/if}
+                      {if $acct.city != ''}         {$acct.city}, {$acct.state.value} {$acct.zip}<br>   {/if}
+                      {if $acct.country.name != ''} {$acct.country.name}<br>                            {/if}
+                      {if $acct.phone != ''}        Phone: {$acct.phone}<br>                            {/if}
+                      {if $acct.fax != ''}          Fax: {$acct.fax}<br>                                {/if}
+                      {if $acct.email != ''}        E-Mail: {$acct.email}                               {/if}
+                    </td>
+                </tr>
+            {/if}
+          {/if}
         {/foreach}  {* registrants *}
       {/foreach}  {* rates *}
     {/foreach}  {* classes *}
index 82cc733..8a15ad0 100644 (file)
@@ -31,7 +31,7 @@
             <center>
                 <table>
                     <thead>
-                        <tr><th>ID</th><th style="white-space: nowrap;">Date created</th><th style="white-space: nowrap;">Date last updated</th><th>Selected</th></tr>
+                        <tr><th>ID</th><th style="white-space: nowrap;">Date created</th><th style="white-space: nowrap;">Date last updated</th><th>Events</th><th>Registrants</th><th>Selected</th></tr>
                     </thead>
                     <tbody>
                     {foreach $regRequests as $rr}
@@ -41,6 +41,8 @@
                             </td>
                             <td style="white-space: nowrap;">{$rr.date_created.datetime}</td>
                             <td style="white-space: nowrap;">{$rr.last_update.datetime}</td>
+                            <td style="white-space: nowrap;">{$rr.numb_events}</td>
+                            <td style="white-space: nowrap;">{$rr.numb_registrants}</td>
                             <td>
                             {if $rr.id == $id}
                                 Yes
@@ -77,7 +79,7 @@ jQuery(document).ready(function($) {
             autoOpen: true,
             resizable: false,
             modal: true,
-            width: 500,
+            width: "auto",
             closeText: "hide",
             buttons: {
                 "Cancel": function () {
index 8935254..d233050 100644 (file)
@@ -79,7 +79,7 @@
                     </div>
                     <div class="glm-reg-row">
                         <div class="glm-large-3 glm-columns glm-reg-nowrap{if $regAccount.fieldRequired.addr2} glm-reg-required{/if}">&nbsp;</div>
-                        <div class="glm-large-9 glm-columns{if $regAccount.fieldFail.addr1} glm-reg-fail{/if}"><input type="text" name="addr2" value="{$regAccount.fieldData.addr2}"{if $regAccount.fieldRequired.addr2} required{/if}></div>
+                        <div class="glm-large-9 glm-columns{if $regAccount.fieldFail.addr2} glm-reg-fail{/if}"><input type="text" name="addr2" value="{$regAccount.fieldData.addr2}"{if $regAccount.fieldRequired.addr2} required{/if}></div>
                     </div>
                     <div class="glm-reg-row">
                         <div class="glm-large-3 glm-columns glm-reg-nowrap{if $regAccount.fieldRequired.city} glm-reg-required{/if}">City:</div>
                     </div>
                     <div class="glm-reg-row glm-reg-bill-field">
                         <div class="glm-large-3 glm-columns glm-reg-nowrap{if $regAccount.fieldRequired.bill_addr2} glm-reg-required{/if}">&nbsp;</div>
-                        <div class="glm-large-9 glm-columns{if $regAccount.fieldFail.bill_addr1} glm-reg-fail{/if}"><input type="text" name="bill_addr2" value="{$regAccount.fieldData.bill_addr2}"{if $regAccount.fieldRequired.bill_addr2} required{/if}></div>
+                        <div class="glm-large-9 glm-columns{if $regAccount.fieldFail.bill_addr2} glm-reg-fail{/if}"><input type="text" name="bill_addr2" value="{$regAccount.fieldData.bill_addr2}"{if $regAccount.fieldRequired.bill_addr2} required{/if}></div>
                     </div>
                     <div class="glm-reg-row glm-reg-bill-field">
                         <div class="glm-large-3 glm-columns glm-reg-nowrap{if $regAccount.fieldRequired.bill_city} glm-reg-required{/if}">City:</div>
                         {/if}
                     </td>
                 </tr>
+          {assign var="acct" value=$cart.accounts.{$registrant.account}}
+          {if $acct.validated.value}
+                <tr>
+                    <td colspan="2">&nbsp;</td>
+                    <td colspan="3">
+                      {if $acct.email != ''}E-Mail: {$acct.email}<br>{/if}
+                      (Account information is restricted)
+                    </td>
+                </tr>
+          {else}
+            {if $acct.addr1 != '' || $acct.phone != '' || $acct.email != ''}
+                <tr>
+                    <td colspan="2">&nbsp;</td>
+                    <td colspan="3">
+                      {if $acct.org != ''}          {$acct.title}, {$acct.org}<br>                      {/if}
+                      {if $acct.addr1 != ''}        {$acct.addr1}<br>                                   {/if}
+                      {if $acct.addr2 != ''}        {$acct.addr2}<br>                                   {/if}
+                      {if $acct.city != ''}         {$acct.city}, {$acct.state.value} {$acct.zip}<br>   {/if}
+                      {if $acct.country.name != ''} {$acct.country.name}<br>                            {/if}
+                      {if $acct.phone != ''}        Phone: {$acct.phone}<br>                            {/if}
+                      {if $acct.fax != ''}          Fax: {$acct.fax}<br>                                {/if}
+                      {if $acct.email != ''}        E-Mail: {$acct.email}                               {/if}
+                    </td>
+                </tr>
+            {/if}
+          {/if}
         {/foreach}
       {/foreach}
     {/foreach}
index b5b6dc2..974fa6b 100644 (file)
                         {/if}
                     </td>
                 </tr>
+            {assign var="acct" value=$cart.accounts.{$registrant.account}}
+            {if $acct.validated.value}
+                <tr>
+                    <td colspan="2">&nbsp;</td>
+                    <td colspan="3">
+                      {if $acct.email != ''}E-Mail: {$acct.email}<br>{/if}
+                      (Account information is restricted)
+                    </td>
+                </tr>
+              {else}
+                {if $acct.addr != '' || $acct.phone != '' || $acct.email != ''}
+                <tr>
+                    <td colspan="2">&nbsp;</td>
+                    <td colspan="3">
+                      {if $acct.org != ''}          {$acct.title}, {$acct.org}<br>                      {/if}
+                      {if $acct.addr1 != ''}        {$acct.addr1}<br>                                   {/if}
+                      {if $acct.addr2 != ''}        {$acct.addr2}<br>                                   {/if}
+                      {if $acct.city != ''}         {$acct.city}, {$acct.state.value} {$acct.zip}<br>   {/if}
+                      {if $acct.country.name != ''} {$acct.country.name}<br>                            {/if}
+                      {if $acct.phone != ''}        Phone: {$acct.phone}<br>                            {/if}
+                      {if $acct.fax != ''}          Fax: {$acct.fax}<br>                                {/if}
+                      {if $acct.email != ''}        E-Mail: {$acct.email}                               {/if}
+                    </td>
+                </tr>
+                {/if}
+              {/if}
             {/foreach}
           {/foreach}
         {/foreach}