Nopw supplying glm_reg_guest_account_id in session if it was a guest checkout
authorChuck Scott <cscott@gaslightmedia.com>
Mon, 8 Jan 2018 21:27:49 +0000 (16:27 -0500)
committerChuck Scott <cscott@gaslightmedia.com>
Mon, 8 Jan 2018 21:30:12 +0000 (16:30 -0500)
Also now setting a "guestAccount" flag in the template data to check for this in the template.
Also storing with this some pending database changes

models/front/registrations/checkoutProcess.php
setup/databaseScripts/update_database_V0.0.21.sql [new file with mode: 0644]

index 90e1e4f..e32f254 100644 (file)
@@ -90,6 +90,7 @@ class GlmMembersFront_registrations_checkoutProcess extends GlmRegCartSupport
         $cartStatus     = 0;            // Default to CART
         $requestId      = false;
         $accountId      = 0;
+        $guestAccount   = false;
         $regAccount     = false;
         $modelRedirect  = false;
         $view           = 'checkout';
@@ -204,6 +205,7 @@ class GlmMembersFront_registrations_checkoutProcess extends GlmRegCartSupport
                 // If that was successful
                 if ($regAccount) {
                     $accountId = $regAccount['fieldData']['id'];
+                    $guestAccount = true;
                 } else {
                     $messages[] = 'Unable to create a guest account for this request. Please try again later.';
                 }
@@ -687,17 +689,20 @@ class GlmMembersFront_registrations_checkoutProcess extends GlmRegCartSupport
         // Send acknowledgement to person submitting request
         mail($request['email'], $misc['submission_ack_subject'], $summary);
 
+        // If this is a guest submission set a guest account ID so it can be used to create a user account
+        if ($guestAccount) {
+            $_SESSION['glm_reg_guest_account_id'] = $accountId;
+        }
 
         /*
          * Remove cart from session
          *
-         * Save cart ID in session as 'glm_reg_competed_cart_id' for use after checkout but clear the cart session
          */
-        $_SESSION['glm_reg_competed_cart_id'] = $_SESSION['glm_reg_cart_id'];
         if ($billing['addr2'] != '*** DO NOT CLEAR ***') {
             unset($_SESSION['glm_reg_cart_id']);
         }
 
+
         $view = 'summary';
 
         // Build check code for display of summary in iframe
@@ -705,6 +710,7 @@ class GlmMembersFront_registrations_checkoutProcess extends GlmRegCartSupport
 
         // Compile template data
         $templateData = array(
+            'guestAccount'  => $guestAccount,
             'requestId'     => $requestId,
             'summaryCheck'  => $summaryCheck,
             'misc'          => $misc
diff --git a/setup/databaseScripts/update_database_V0.0.21.sql b/setup/databaseScripts/update_database_V0.0.21.sql
new file mode 100644 (file)
index 0000000..6ad98d8
--- /dev/null
@@ -0,0 +1,22 @@
+-- Gaslight Media Members Database  - Registratiuons Add-On
+-- File Created: 10/03/17 11:00:00
+-- Database Version: 0.0.16
+-- Database Update From Previous Version Script
+--
+-- To permit each query below to be executed separately,
+-- all queries must be separated by a line with four dashes
+
+CREATE TABLE {prefix}reg_request_pay_code (
+    id INT NOT NULL AUTO_INCREMENT,
+    payment_code INT NULL,                                      -- Pointer to payment code
+    reg_request INT NULL,                                       -- Pointer to the registration request record
+    credit DOUBLE PRECISION NULL                                -- Total credit for this payment code
+    PRIMARY KEY (id),
+    INDEX (payment_code),
+    INDEX (reg_request)
+);
+
+----
+
+
+