From: Chuck Scott Date: Tue, 14 Nov 2017 18:34:00 +0000 (-0500) Subject: Enhancements to cart widget pop-up cart list, checkout, and cart summaries. X-Git-Tag: v1.0.0^2~274 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=baba14b22008ad116d37f674191494e402478a7c;p=WP-Plugins%2Fglm-member-db-registrations.git Enhancements to cart widget pop-up cart list, checkout, and cart summaries. 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 --- diff --git a/classes/regCartSupport.php b/classes/regCartSupport.php index 9d58664..bb95f9f 100644 --- a/classes/regCartSupport.php +++ b/classes/regCartSupport.php @@ -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'])) { diff --git a/models/front/registrations/cart.php b/models/front/registrations/cart.php index e937097..0027e31 100644 --- a/models/front/registrations/cart.php +++ b/models/front/registrations/cart.php @@ -154,7 +154,7 @@ class GlmMembersFront_registrations_cart extends GlmRegCartSupport 'cartPageText' => $misc['cart_page_text'] ); - echo "
".print_r($templateData,1)."
"; + // echo "
".print_r($templateData,1)."
"; // Return status, any suggested view, and any data to controller return array( diff --git a/models/front/registrations/checkout.php b/models/front/registrations/checkout.php index aa395b7..269b0b8 100644 --- a/models/front/registrations/checkout.php +++ b/models/front/registrations/checkout.php @@ -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'], diff --git a/models/front/registrations/login.php b/models/front/registrations/login.php index b43c9c2..76cf51e 100644 --- a/models/front/registrations/login.php +++ b/models/front/registrations/login.php @@ -92,6 +92,55 @@ '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'; diff --git a/views/front/registrations/cart.html b/views/front/registrations/cart.html index bd455b6..f23f136 100644 --- a/views/front/registrations/cart.html +++ b/views/front/registrations/cart.html @@ -77,6 +77,32 @@ {/if} + {assign var="acct" value=$cart.accounts.{$registrant.account}} + {if $acct.validated.value} + +   + + {if $acct.email != ''}E-Mail: {$acct.email}
{/if} + (Account information is restricted) + + + {else} + {if $acct.addr != '' || $acct.phone != '' || $acct.email != ''} + +   + + {if $acct.org != ''} {$acct.title}, {$acct.org}
{/if} + {if $acct.addr1 != ''} {$acct.addr1}
{/if} + {if $acct.addr2 != ''} {$acct.addr2}
{/if} + {if $acct.city != ''} {$acct.city}, {$acct.state.value} {$acct.zip}
{/if} + {if $acct.country.name != ''} {$acct.country.name}
{/if} + {if $acct.phone != ''} Phone: {$acct.phone}
{/if} + {if $acct.fax != ''} Fax: {$acct.fax}
{/if} + {if $acct.email != ''} E-Mail: {$acct.email} {/if} + + + {/if} + {/if} {/foreach} {* registrants *} {/foreach} {* rates *} {/foreach} {* classes *} diff --git a/views/front/registrations/cartLinkWidget.html b/views/front/registrations/cartLinkWidget.html index 82cc733..8a15ad0 100644 --- a/views/front/registrations/cartLinkWidget.html +++ b/views/front/registrations/cartLinkWidget.html @@ -31,7 +31,7 @@
- + {foreach $regRequests as $rr} @@ -41,6 +41,8 @@ + + + {assign var="acct" value=$cart.accounts.{$registrant.account}} + {if $acct.validated.value} + + + + + {else} + {if $acct.addr1 != '' || $acct.phone != '' || $acct.email != ''} + + + + + {/if} + {/if} {/foreach} {/foreach} {/foreach} diff --git a/views/front/registrations/summaryStore.html b/views/front/registrations/summaryStore.html index b5b6dc2..974fa6b 100644 --- a/views/front/registrations/summaryStore.html +++ b/views/front/registrations/summaryStore.html @@ -171,6 +171,32 @@ {/if} + {assign var="acct" value=$cart.accounts.{$registrant.account}} + {if $acct.validated.value} + + + + + {else} + {if $acct.addr != '' || $acct.phone != '' || $acct.email != ''} + + + + + {/if} + {/if} {/foreach} {/foreach} {/foreach}
IDDate createdDate last updatedSelected
IDDate createdDate last updatedEventsRegistrantsSelected
{$rr.date_created.datetime} {$rr.last_update.datetime}{$rr.numb_events}{$rr.numb_registrants} {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 () { diff --git a/views/front/registrations/checkout.html b/views/front/registrations/checkout.html index 8935254..d233050 100644 --- a/views/front/registrations/checkout.html +++ b/views/front/registrations/checkout.html @@ -79,7 +79,7 @@
 
-
+
City:
@@ -133,7 +133,7 @@
 
-
+
City:
@@ -395,6 +395,32 @@ {/if}
  + {if $acct.email != ''}E-Mail: {$acct.email}
{/if} + (Account information is restricted) +
  + {if $acct.org != ''} {$acct.title}, {$acct.org}
{/if} + {if $acct.addr1 != ''} {$acct.addr1}
{/if} + {if $acct.addr2 != ''} {$acct.addr2}
{/if} + {if $acct.city != ''} {$acct.city}, {$acct.state.value} {$acct.zip}
{/if} + {if $acct.country.name != ''} {$acct.country.name}
{/if} + {if $acct.phone != ''} Phone: {$acct.phone}
{/if} + {if $acct.fax != ''} Fax: {$acct.fax}
{/if} + {if $acct.email != ''} E-Mail: {$acct.email} {/if} +
  + {if $acct.email != ''}E-Mail: {$acct.email}
{/if} + (Account information is restricted) +
  + {if $acct.org != ''} {$acct.title}, {$acct.org}
{/if} + {if $acct.addr1 != ''} {$acct.addr1}
{/if} + {if $acct.addr2 != ''} {$acct.addr2}
{/if} + {if $acct.city != ''} {$acct.city}, {$acct.state.value} {$acct.zip}
{/if} + {if $acct.country.name != ''} {$acct.country.name}
{/if} + {if $acct.phone != ''} Phone: {$acct.phone}
{/if} + {if $acct.fax != ''} Fax: {$acct.fax}
{/if} + {if $acct.email != ''} E-Mail: {$acct.email} {/if} +