Fixed bill_state and bill_country in dataAccount.php.
authorChuck Scott <cscott@gaslightmedia.com>
Thu, 2 Nov 2017 20:58:11 +0000 (16:58 -0400)
committerChuck Scott <cscott@gaslightmedia.com>
Thu, 2 Nov 2017 21:02:10 +0000 (17:02 -0400)
Fixed cc_type field in dataRegRequest.php.
Fixed undefined referernce to glm_reg_card_id in regCartSummary() when no data supplied.
Added field data for credit card data in checkout.php and deselecting types not selected.
Added radio buttons for enabled payment methods.

classes/data/dataAccount.php
classes/data/dataRegRequest.php
classes/regCartSupport.php
models/front/registrations/checkout.php
views/front/registrations/checkout.html

index 40d3d4c..77c7518 100644 (file)
@@ -319,12 +319,13 @@ class GlmDataRegistrationsAccount extends GlmDataAbstract
                 'use'       => 'a'
             ),
 
-            //
+            // Bill State
             'bill_state' => array (
-                'field'     => 'bill_state',
-                'type'      => 'text',
-                'required'  => false,
-                'use'       => 'a'
+                'field' => 'bill_state',
+                'type' => 'list',
+                'list' => $this->config['states'],
+                'default'  => $this->config['settings']['default_state'],
+                'use' => 'a'
             ),
 
             //
@@ -335,12 +336,13 @@ class GlmDataRegistrationsAccount extends GlmDataAbstract
                 'use'       => 'a'
             ),
 
-            //
+            // Country
             'bill_country' => array (
-                'field'     => 'bill_country',
-                'type'      => 'text',
-                'required'  => false,
-                'use'       => 'a'
+                'field' => 'bill_country',
+                'type' => 'list',
+                'list' => $this->config['countries'],
+                'default' => 'US',
+                'use' => 'a'
             ),
 
             //
index ddb82b3..fe1eec1 100644 (file)
@@ -281,8 +281,8 @@ class GlmDataRegistrationsRegRequest extends GlmDataAbstract
             // Credit Card type (if used) - See credit_card in plugin.ini
             'cc_type' => array (
                 'field'     => 'cc_type',
-                'type'      => 'bitmap',
-                'bitmap'    => $this->config['credit_card'],
+                'type'      => 'list',
+                    'list'      => $this->config['credit_card'],
                 'default'   => 0, // none selected
                 'use'       => 'a'
             ),
index fc89a13..f0349d7 100644 (file)
@@ -974,7 +974,7 @@ class GlmRegCartSupport
     {
 
         // If we haven't been supplied a request (cart) ID
-        if (!$requestId) {
+        if (!$requestId && isset($_SESSION) && isset($_SESSION['glm_reg_cart_id'])) {
 
            // Try to get the ID from the current session
            $requestId = $_SESSION['glm_reg_cart_id'];
index 752088b..907812a 100644 (file)
@@ -111,9 +111,9 @@ class GlmMembersFront_registrations_checkout extends GlmRegCartSupport
 
         $view = 'checkout';
 
-        if ($cartId) {
+        if ($haveCart) {
 
-            // Try to get a Validate cart with updated totals
+            // Try to validate the cart with updated totals
             $this->checkRegistrationRequest($cartId);
 
         }
@@ -140,6 +140,29 @@ class GlmMembersFront_registrations_checkout extends GlmRegCartSupport
 
         }
 
+        // Setup credit cart input fields - Use dataRegRequest to generate the field data
+        require_once GLM_MEMBERS_REGISTRATIONS_PLUGIN_CLASS_PATH.'/data/dataRegRequest.php';
+        $RegRequest = new GlmDataRegistrationsRegRequest($this->wpdb, $this->config);
+        $regReq = $RegRequest->newEntry();
+
+        // Drop cards that are not currently selected in management
+        $cc_type = $regReq['fieldData']['cc_type'];
+        foreach ($cc_type['list'] as $k=>$v) {
+            $bitValue = pow(2,$k);
+            if (!($this->config['settings']['reg_cc_accepts'] & $bitValue)) {
+                unset($cc_type['list'][$k]);
+            }
+        }
+
+        // Add credit card field data to $regAccount['fieldData'] for use on form
+        $regAccount['fieldData']['cc_type'] = $cc_type;
+        $regAccount['fieldData']['cc_name'] = $regReq['fieldData']['cc_name'];
+        $regAccount['fieldData']['cc_numb'] = $regReq['fieldData']['cc_numb'];
+        $regAccount['fieldData']['cc_exp'] = $regReq['fieldData']['cc_exp'];
+        $regAccount['fieldData']['cc_cvv'] = $regReq['fieldData']['cc_cvv'];
+        $regAccount['fieldData']['cc_conf'] = $regReq['fieldData']['cc_conf'];
+// *** If redirected back, be sure to get the submitted data
+
         // Accounts list not needed
         unset($this->cart['accounts']);
 
index f048966..549d72d 100644 (file)
@@ -81,7 +81,7 @@
                             <select name="state">
                                 <option value=""></option>
                     {foreach $regAccount.fieldData.state.list as $s}
-                                <option value="{$s.value}"{if $memberInfo.fieldData.state.value == $s.value} selected="selected"{/if}>
+                                <option value="{$s.value}"{if $regAccount.fieldData.state.value == $s.value} selected="selected"{/if}>
                                     {$s.name}
                                 </option>
                     {/foreach}
@@ -98,7 +98,7 @@
                             <select name="country">
                                 <option value=""></option>
                     {foreach $regAccount.fieldData.country.list as $c}
-                                <option value="{$c.value}"{if $memberInfo.fieldData.country.value == $c.value} selected="selected"{/if}>
+                                <option value="{$c.value}"{if $regAccount.fieldData.country.value == $c.value} selected="selected"{/if}>
                                     {$c.name}
                                 </option>
                     {/foreach}
                             <select name="bill_state">
                                 <option value=""></option>
                     {foreach $regAccount.fieldData.bill_state.list as $s}
-                                <option value="{$s.value}"{if $memberInfo.fieldData.bill_state.value == $s.value} selected="selected"{/if}>
+                                <option value="{$s.value}"{if $regAccount.fieldData.bill_state.value == $s.value} selected="selected"{/if}>
                                     {$s.name}
                                 </option>
-                    {/foreach}
+                    {/foreach} 
                             </select>
                         </div>
                     </div>
                             <select name="bill_country">
                                 <option value=""></option>
                     {foreach $regAccount.fieldData.bill_country.list as $c}
-                                <option value="{$c.value}"{if $memberInfo.fieldData.bill_country.value == $c.value} selected="selected"{/if}>
+                                <option value="{$c.value}"{if $regAccount.fieldData.bill_country.value == $c.value} selected="selected"{/if}>
                                     {$c.name}
                                 </option>
                     {/foreach}
                     <h4>Payment Information</h4>
      
     {if $payMethods.{$payMethodsNumb.NoCharge}.default}
-                    <h5><input type="checkbox" name="payMethod_{$payMethodsNumb.NoCharge}"/> {$payMethods.{$payMethodsNumb.NoCharge}.name}</h5>
+                    <h5><input type="radio" name="payMethod_{$payMethodsNumb.NoCharge}"/> {$payMethods.{$payMethodsNumb.NoCharge}.name}</h5>
+    {/if}
+    {if $payMethods.{$payMethodsNumb.CompCode}.default}
+                    <h5><input type="radio" name="payMethod_{$payMethodsNumb.CompCode}"/> {$payMethods.{$payMethodsNumb.CompCode}.name}</h5>
+    {/if}
+    {if $payMethods.{$payMethodsNumb.Cash}.default}
+                    <h5><input type="radio" name="payMethod_{$payMethodsNumb.Cash}"/> {$payMethods.{$payMethodsNumb.Cash}.name}</h5>
+    {/if}
+    {if $payMethods.{$payMethodsNumb.Check}.default}
+                    <h5><input type="radio" name="payMethod_{$payMethodsNumb.Check}"/> {$payMethods.{$payMethodsNumb.Check}.name}</h5>
+    {/if}
+    {if $payMethods.{$payMethodsNumb.CallFromMerchant}.default}
+                    <h5><input type="radio" name="payMethod_{$payMethodsNumb.CallFromMerchant}"/> {$payMethods.{$payMethodsNumb.CallFromMerchant}.name}</h5>
     {/if}
     {if $payMethods.{$payMethodsNumb.CreditCard}.default}
-                    <h5><input type="checkbox" name="payMethod_{$payMethodsNumb.CreditCard}"/> {$payMethods.{$payMethodsNumb.CreditCard}.name}</h5>
+                    <h5><input type="radio" name="payMethod_{$payMethodsNumb.CreditCard}"/> {$payMethods.{$payMethodsNumb.CreditCard}.name}</h5>
                     <div class="glm-reg-row">
                         <div class="glm-large-3 glm-columns glm-reg-nowrap{if $regAccount.fieldRequired.cc_type} glm-reg-required{/if}">Card Type:</div>
-                        <div class="glm-large-9 glm-columns{if $regAccount.fieldFail.cc_type} glm-reg-fail{/if}"><input type="text" name="cc_type" value="{$regAccount.fieldData.cc_type}"{if $regAccount.fieldRequired.cc_type} required{/if}></div>
+                        <div class="glm-large-9 glm-columns{if $regAccount.fieldFail.cc_type} glm-reg-fail{/if}">
+                            <select name="cc_type">
+                                <option value=""></option>
+                    {foreach $regAccount.fieldData.cc_type.list as $c}
+                                <option value="{$c.value}"{if $regAccount.fieldData.cc_type.value == $c.value} selected="selected"{/if}>
+                                    {$c.name}
+                                </option>
+                    {/foreach}
+                            </select>
+                        </div>
                     </div>
                     <div class="glm-reg-row">
                         <div class="glm-large-3 glm-columns glm-reg-nowrap{if $regAccount.fieldRequired.cc_name} glm-reg-required{/if}">Name on Card:</div>
                     <div class="glm-reg-row">
                         <div class="glm-large-3 glm-columns glm-reg-nowrap{if $regAccount.fieldRequired.cc_cvv} glm-reg-required{/if}">CVV:</div>
                         <div class="glm-large-9 glm-columns{if $regAccount.fieldFail.cc_name} glm-reg-fail{/if}"><input type="text" placeholder="3 digit number on back of card" name="cc_name" value="{$regAccount.fieldData.cc_name}"{if $regAccount.fieldRequired.cc_name} required{/if}></div>
-<<<<<<< Updated upstream
-                    </div>
-=======
                     </div>                    
     {/if}
     {if $payMethods.{$payMethodsNumb.PayPal}.default}
-                    <h5><input type="checkbox" name="payMethod_{$payMethodsNumb.PayPal}"/> {$payMethods.{$payMethodsNumb.PayPal}.name}</h5>
+                    <h5><input type="radio" name="payMethod_{$payMethodsNumb.PayPal}"/> {$payMethods.{$payMethodsNumb.PayPal}.name}</h5>
     {/if}
-
->>>>>>> Stashed changes
+    
+    
+    
                 </div>
                 <div class="glm-large-6 glm-columns">
                     <h4>Global Custom Fields Go Here</h4>