Merge remote-tracking branch 'upstream/4.5' into 4.5-master-2014-10-14-11-24-52
[civicrm-core.git] / templates / CRM / Contribute / Form / Contribution / Main.tpl
index f628a06837e4e9315ed2ea418e9d18e108af0a4f..4a64c72409368facb2a4cd1b364391f75a87a54d 100644 (file)
 
   <div id="billing-payment-block">
     {* If we have a payment processor, load it - otherwise it happens via ajax *}
-    {if $ppType}
+    {if $ppType or $isBillingAddressRequiredForPayLater}
       {include file="CRM/Contribute/Form/Contribution/Main.tpl" snippet=4}
     {/if}
   </div>
     }
     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();
+        cj(".payment_options-group").hide();  
+      } 
+      else {
+        cj("#billing-payment-block").show();
+        cj(".payment_options-group").show(); 
+      }
+    }
+
+    $('#pricevalue').each(toggleBillingBlockIfFree).on('change', toggleBillingBlockIfFree);
   });
   {/literal}
 </script>