additional fixes for pay later
authorjitendrapurohit <jitendra.purohit@webaccessglobal.com>
Fri, 2 Sep 2016 08:35:22 +0000 (14:05 +0530)
committerjitendrapurohit <jitendra.purohit@webaccessglobal.com>
Fri, 2 Sep 2016 09:56:53 +0000 (15:26 +0530)
CRM/Contribute/Form/Contribution/Main.php
CRM/Contribute/Form/ContributionBase.php
templates/CRM/Contribute/Form/Contribution/Main.tpl
templates/CRM/Contribute/Form/Contribution/ThankYou.tpl
templates/CRM/Core/BillingBlock.tpl
tests/phpunit/WebTest/Contribute/OnlineContributionTest.php

index 1fee2ce6c77eefbfff67d02eb43ce874a0bec2a7..f36f4398d58f4ec57ceae38396b9500585fd6228 100644 (file)
@@ -62,7 +62,6 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu
   public function preProcess() {
     parent::preProcess();
 
-    $this->_ccid = CRM_Utils_Request::retrieve('ccid', 'Positive', $this);
     $this->_paymentProcessors = $this->get('paymentProcessors');
     $this->preProcessPaymentOptions();
 
@@ -341,7 +340,6 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu
     }
 
     $this->applyFilter('__ALL__', 'trim');
-    $hidePayLater = FALSE;
     if (empty($this->_ccid)) {
       $this->add('text', "email-{$this->_bltID}",
         ts('Email Address'),
@@ -353,11 +351,7 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu
     else {
       $this->addElement('hidden', "email-{$this->_bltID}", 1);
       $this->add('text', 'total_amount', ts('Total Amount'), array('readonly' => TRUE), FALSE);
-      if (!empty($this->_paymentProcessors[0])) {
-        $hidePayLater = TRUE;
-      }
     }
-    $this->assign('hidePayLater', $hidePayLater);
     $pps = array();
     //@todo - this should be replaced by a check as to whether billing fields are set
     $onlinePaymentProcessorEnabled = FALSE;
index 697eb6c99650b7caf6d1034676bb92fad6446602..4f6365e81b15e09544092721e8639950dc5b3a54 100644 (file)
@@ -197,6 +197,7 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_Form {
 
     // current contribution page id
     $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
+    $this->_ccid = CRM_Utils_Request::retrieve('ccid', 'Positive', $this);
     if (!$this->_id) {
       // seems like the session is corrupted and/or we lost the id trail
       // lets just bump this to a regular session error and redirect user to main page
@@ -291,6 +292,10 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_Form {
       // check for is_monetary status
       $isMonetary = CRM_Utils_Array::value('is_monetary', $this->_values);
       $isPayLater = CRM_Utils_Array::value('is_pay_later', $this->_values);
+      if (!empty($this->_ccid) && $isPayLater) {
+        $isPayLater = FALSE;
+        $this->_values['is_pay_later'] = FALSE;
+      }
 
       if ($isMonetary &&
         (!$isPayLater || !empty($this->_values['payment_processor']))
index a093570ef3e7c8c7e31969353c8727ba4072626c..388916feb576ba8f834759ba7c775eca76622d94 100644 (file)
   </div>
   {/if}
 </div>
-
 <script type="text/javascript">
   {if $isHonor}
   pcpAnonymous();
   {/if}
 
-  {if $hidePayLater}
-    hidePayLater();
-  {/if}
-
   {literal}
 
   cj('input[name="soft_credit_type_id"]').on('change', function() {
     }
   }
 
-  function hidePayLater() {
-    cj('#billingcheckbox').hide();
-    cj('#billingcheckbox').next('label').hide();
-    cj('input:radio[name="payment_processor_id"][value=0]').hide();
-    cj('input:radio[name="payment_processor_id"][value=0]').next('label').hide();
-  }
-
   cj('input[id="is_recur"]').on('change', function() {
     toggleRecur();
   });
index 7d63ffa9f0bfaeea1aefab422d29c5111921abdb..d29451e54e588d24c94e7860cbd44c1c1477f2b0 100644 (file)
@@ -79,7 +79,7 @@
         <div>
           {if $onBehalfEmail AND ($onBehalfEmail neq $email)}
             {ts 1=$email 2=$onBehalfEmail}An email receipt has also been sent to %1 and to %2{/ts}
-          {else}
+          {elseif $email}
             {ts 1=$email}An email receipt has also been sent to %1{/ts}
           {/if}
         </div>
index 0d9171ac46b49e0f6c8c0646888385e5a63aa928..4fd6aaabbb226e7e0569b0c36dbc192c4babe007 100644 (file)
@@ -54,7 +54,7 @@
     </fieldset>
   {/if}
   {if $billingDetailsFields|@count && $paymentProcessor.payment_processor_type neq 'PayPal_Express'}
-    {if $profileAddressFields}
+    {if $profileAddressFields && !$ccid}
       <input type="checkbox" id="billingcheckbox" value="0">
       <label for="billingcheckbox">{ts}My billing address is the same as above{/ts}</label>
     {/if}
index b3fe6192001d2fc8de12241142f58001bb4650d4..8c2f80e92948d4a45581f19d48949ae10f10a949 100644 (file)
@@ -631,7 +631,7 @@ class WebTest_Contribute_OnlineContributionTest extends CiviSeleniumTestCase {
     $this->assertFalse($this->isElementPresent("xpath=//div[@class='crm-public-form-item crm-section premium_block-section']"));
     $this->assertFalse($this->isElementPresent("xpath=//div[@class='crm-public-form-item crm-group custom_pre_profile-group']"));
     $this->assertFalse($this->isElementPresent("xpath=//input[@id=email-5]"));
-    $this->assertTrue($this->isElementPresent("xpath=//input[@name='payment_processor_id'][@value=0][@style='display: none;']"));
+    $this->assertFalse($this->isElementPresent("xpath=//input[@name='payment_processor_id'][@value=0]"));
     $this->click("xpath=//input[@name='payment_processor_id'][@value=1]");
     $this->waitForAjaxContent();