Merge pull request #22449 from mattwire/phpnotices
[civicrm-core.git] / templates / CRM / common / paymentBlock.tpl
index 1d5c3e5e71ac784ff63e2cbc69289afd2794df14..95f907cf2814357e6ebcadec60fa5b2dfc2cb49a 100644 (file)
@@ -28,6 +28,8 @@
       payment_processor.hide();
       payment_information.hide();
       billing_block.hide();
+      // Ensure that jquery validation doesn't block submission when we don't need to fill in the billing details section
+      cj('#billing-payment-block select.crm-select2').addClass('crm-no-validate');
       // also unset selected payment methods
       cj('input[name="payment_processor_id"]').removeProp('checked');
     }
@@ -36,6 +38,7 @@
       payment_processor.show();
       payment_information.show();
       billing_block.show();
+      cj('#billing-payment-block select.crm-select2').removeClass('crm-no-validate');
       // also set selected payment methods
       cj('input[name="payment_processor_id"][checked=checked]').prop('checked', true);
     }
 
       var payment_instrument_id = $('#payment_instrument_id').val();
 
-      var dataUrl = "{crmURL p='civicrm/payment/form' h=0 q="formName=`$form.formName`&currency=`$currency`&`$urlPathVar``$isBackOfficePathVar``$profilePathVar``$contributionPageID``$preProfileID`processor_id="}" + type;
+      var currency = '{$currency}';
+      currency = currency == '' ? $('#currency').val() : currency;
+
+      var dataUrl = "{crmURL p='civicrm/payment/form' h=0 q="formName=`$form.formName``$urlPathVar``$isBackOfficePathVar``$profilePathVar``$contributionPageID``$preProfileID`processor_id="}" + type;
       {literal}
       if (typeof(CRM.vars) != "undefined") {
         if (typeof(CRM.vars.coreForm) != "undefined") {
           }
         }
       }
-      dataUrl =  dataUrl + "&payment_instrument_id=" + payment_instrument_id;
+      dataUrl =  dataUrl + "&payment_instrument_id=" + payment_instrument_id + "&currency=" + currency;
 
       // Processors like pp-express will hide the form submit buttons, so re-show them when switching
       $('.crm-submit-buttons', $form).show().find('input').prop('disabled', true);
       CRM.loadPage(dataUrl, {target: '#billing-payment-block'});
     }
 
-    $('[name=payment_processor_id]').on('change.paymentBlock', function() {
-        buildPaymentBlock($(this).val());
+    $('[name=payment_processor_id], #currency').on('change.paymentBlock', function() {
+      var payment_processor_id = $('[name=payment_processor_id]:checked').val() == undefined ? $('[name=payment_processor_id]').val() : $('[name=payment_processor_id]:checked').val();
+      if (payment_processor_id != undefined) {
+        buildPaymentBlock(payment_processor_id);
+      }
     });
 
     $('#payment_instrument_id').on('change.paymentBlock', function() {