From 8c7c5396b4d0b510d0d64101e82d7081a3374e91 Mon Sep 17 00:00:00 2001 From: Kajan Date: Wed, 20 May 2015 10:27:26 +0100 Subject: [PATCH] CRM-16527 - Hide credit card section in membership contribution form --- .../CRM/Contribute/Form/Contribution/Main.tpl | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/templates/CRM/Contribute/Form/Contribution/Main.tpl b/templates/CRM/Contribute/Form/Contribution/Main.tpl index 2d9ed6c5de..df84e8382e 100644 --- a/templates/CRM/Contribute/Form/Contribution/Main.tpl +++ b/templates/CRM/Contribute/Form/Contribution/Main.tpl @@ -444,6 +444,7 @@ toggleConfirmButton(); enableHonorType(); showRecurHelp(); + skipPaymentMethod(); }); function showHidePayPalExpressOption() { @@ -457,6 +458,43 @@ } } + 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() { -- 2.25.1