Merge remote branch 'canonical/master' into merge-20140930
[civicrm-core.git] / CRM / Event / Form / Registration / Register.php
index c29dbf1d8bd820640f3138ffc5cb31f5f2ecfd92..a77e73cc22118153e157a9583ac9aab12490863d 100644 (file)
@@ -328,7 +328,7 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration {
     }
 
     // Build payment processor form
-    if ($this->_ppType) {
+    if ($this->_ppType || $this->_isBillingAddressRequiredForPayLater) {
       CRM_Core_Payment_ProcessorForm::buildQuickForm($this);
       // Return if we are in an ajax callback
       if ($this->_snippet) {
@@ -986,7 +986,8 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration {
     //set as Primary participant
     $params['is_primary'] = 1;
 
-    if ($this->_values['event']['is_pay_later'] && !array_key_exists('hidden_processor', $params)) {
+    if ($this->_values['event']['is_pay_later']
+      && (!array_key_exists('hidden_processor', $params) || $params['payment_processor'] == 0)) {
       $params['is_pay_later'] = 1;
     }
     else {
@@ -1084,6 +1085,9 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration {
       else {
         $lineItem = array();
         CRM_Price_BAO_PriceSet::processAmount($this->_values['fee'], $params, $lineItem);
+        if ($params['tax_amount']) {
+          $this->set('tax_amount', $params['tax_amount']);
+        }
         $this->set('lineItem', array($lineItem));
         $this->set('lineItemParticipantsCount', array($primaryParticipantCount));
       }