CRM-16527 - Hide credit card section in membership contribution form
authorKajan <kajan@vedaconsulting.co.uk>
Wed, 20 May 2015 09:27:26 +0000 (10:27 +0100)
committerEileen McNaughton <eileen@fuzion.co.nz>
Fri, 17 Jul 2015 07:12:15 +0000 (19:12 +1200)
templates/CRM/Contribute/Form/Contribution/Main.tpl

index 2d9ed6c5de4ed161d524183e905ba7226e2b3ac6..df84e8382ee2ec5f14e17f275be286589762b7d6 100644 (file)
     toggleConfirmButton();
     enableHonorType();
     showRecurHelp();
+    skipPaymentMethod();
   });
 
   function showHidePayPalExpressOption() {
     }
   }
 
+  function showHidePayment(flag) {
+    var payment_options = cj(".payment_options-group");
+    var payment_processor = cj("div.payment_processor-section");
+    var payment_information = cj("div#payment_information");
+    if (flag) {
+      payment_options.hide();
+      payment_processor.hide();
+      payment_information.hide();
+      // also unset selected payment methods
+      cj('input[name="payment_processor"]').removeProp('checked');
+    }
+    else {
+      payment_options.show();
+      payment_processor.show();
+      payment_information.show();
+    }
+  }
+  
+  function skipPaymentMethod() {
+    var flag = false;
+    cj('.price-set-option-content input').each( function(){
+      currentTotal = cj(this).attr('data-amount').replace(/[^\/\d]/g,'');
+      if( cj(this).is(':checked') && currentTotal == 0 ) {
+          flag = true;
+      }
+    });
+    cj('.price-set-option-content input').change( function () {
+      if (cj(this).attr('data-amount').replace(/[^\/\d]/g,'') == 0 ) {
+        flag = true;
+      } else {
+        flag = false;
+      }
+      showHidePayment(flag);
+    });
+    showHidePayment(flag);
+  }
+
   CRM.$(function($) {
     // highlight price sets
     function updatePriceSetHighlight() {