From e6ac320a48cc32bc8096f1ca3fff92919795f776 Mon Sep 17 00:00:00 2001 From: Dave Greenberg Date: Wed, 18 Jun 2014 15:13:02 -0700 Subject: [PATCH] CRM-14882 - hide billing block for online contrib forms when total is zero. This is a rebase of the billing block portions of https://github.com/civicrm/civicrm-core/pull/3498 ---------------------------------------- * CRM-14882: https://issues.civicrm.org/jira/browse/CRM-14882 --- .../CRM/Contribute/Form/Contribution/Main.tpl | 15 +++++++++++++++ templates/CRM/Price/Form/Calculate.tpl | 1 + 2 files changed, 16 insertions(+) diff --git a/templates/CRM/Contribute/Form/Contribution/Main.tpl b/templates/CRM/Contribute/Form/Contribution/Main.tpl index f628a06837..4bd752e2aa 100644 --- a/templates/CRM/Contribute/Form/Contribution/Main.tpl +++ b/templates/CRM/Contribute/Form/Contribution/Main.tpl @@ -458,6 +458,21 @@ } cj('#priceset input[type="radio"]').change(updatePriceSetHighlight); updatePriceSetHighlight(); + + function toggleBillingBlockIfFree(){ + var total_amount_tmp = $(this).data('raw-total'); + // Hide billing questions if this is free + if( total_amount_tmp == 0 ){ + cj("#billing-payment-block").hide(); + }else{ + cj("#billing-payment-block").show(); + } + } + CRM.$('#pricevalue').each( toggleBillingBlockIfFree); + + $('#priceset input').on('change', function() { + CRM.$('#pricevalue').each( toggleBillingBlockIfFree); + }); }); {/literal} diff --git a/templates/CRM/Price/Form/Calculate.tpl b/templates/CRM/Price/Form/Calculate.tpl index 8f1d4fcf70..f4273f4e8b 100644 --- a/templates/CRM/Price/Form/Calculate.tpl +++ b/templates/CRM/Price/Form/Calculate.tpl @@ -200,6 +200,7 @@ function display( totalfee ) { scriptfee = totalfee; scriptarray = price; cj('#total_amount').val( totalfee ); + cj('#pricevalue').data('raw-total', totalfee ); ( totalfee < 0 ) ? cj('table#pricelabel').addClass('disabled') : cj('table#pricelabel').removeClass('disabled'); if (typeof skipPaymentMethod == 'function') { -- 2.25.1