//unset the billing parameters if it is pay later mode
//to avoid creation of billing location
- if ($params['is_pay_later']) {
+ if ($params['is_pay_later'] && !$this->_isBillingAddressRequiredForPayLater) {
$billingFields = array(
'billing_first_name',
'billing_middle_name',
}
// Build payment processor form
- if ($this->_ppType && empty($_GET['onbehalf'])) {
+ if (($this->_ppType || $this->_isBillingAddressRequiredForPayLater) && empty($_GET['onbehalf'])) {
CRM_Core_Payment_ProcessorForm::buildQuickForm($this);
// Return if we are in an ajax callback
if ($this->_snippet) {
}
// also return if paylater mode
- if (CRM_Utils_Array::value('payment_processor', $fields) == 0) {
+ if (CRM_Utils_Array::value('payment_processor', $fields) == 0 && $self->_isBillingAddressRequiredForPayLater == 0) {
return empty($errors) ? TRUE : $errors;
}
* @var boolean
*/
public $_useForMember;
+
+ public $_isBillingAddressRequiredForPayLater;
/**
* Function to set variables up before form is built
*
if (CRM_Utils_Request::retrieve('cancel', 'Boolean', CRM_Core_DAO::$_nullObject)) {
self::cancelRecurring();
}
+
+ // check if billing block is required for pay later
+ if (CRM_Utils_Array::value('is_pay_later', $this->_values)) {
+ $this->_isBillingAddressRequiredForPayLater = CRM_Utils_Array::value('is_billing_required', $this->_values);
+ $this->assign('isBillingAddressRequiredForPayLater', $this->_isBillingAddressRequiredForPayLater);
+ }
}
/**
}
}
+ /**
+ * Function to add address block
+ *
+ * @param $form
+ * @param bool $useRequired
+ *
+ * @return void
+ * @access public
+ */
+ static function buildAddressBlock(&$form, $useRequired = FALSE) {
+ CRM_Core_Payment_Form::_setPaymentFields($form);
+ foreach ($form->_paymentFields as $name => $field) {
+ if (isset($field['cc_field']) &&
+ $field['cc_field']
+ ) {
+ $form->add($field['htmlType'],
+ $field['name'],
+ $field['title'],
+ $field['attributes'],
+ $useRequired ? $field['is_required'] : FALSE
+ );
+ }
+ }
+
+ // also take care of state country widget
+ $stateCountryMap = array(
+ 1 => array(
+ 'country' => "billing_country_id-{$form->_bltID}",
+ 'state_province' => "billing_state_province_id-{$form->_bltID}",
+ )
+ );
+ CRM_Core_BAO_Address::addStateCountryMap($stateCountryMap);
+ }
+
/**
* Make sure that credit card number and cvv are valid
* Called within the scope of a QF formRule function
$form->assign('profileAddressFields', $profileAddressFields);
}
+ // check if show billing setting is enabled
+ if ($form->getVar( '_ppType' ) == 0 && $form->_isBillingAddressRequiredForPayLater) {
+ CRM_Core_Payment_Form::buildAddressBlock($form);
+ return;
+ }
+
// before we do this lets see if the payment processor has implemented a buildForm method
if (method_exists($form->_paymentProcessor['instance'], 'buildForm') &&
is_callable(array($form->_paymentProcessor['instance'], 'buildForm'))) {
public $_forcePayement;
+ public $_isBillingAddressRequiredForPayLater;
+
/**
* Function to set variables up before form is built
*
if ($campID && CRM_Core_DAO::getFieldValue('CRM_Campaign_DAO_Campaign', $campID)) {
$this->_values['event']['campaign_id'] = $campID;
}
+
+ // check if billing block is required for pay later
+ if (CRM_Utils_Array::value('is_pay_later', $this->_values['event'])) {
+ $this->_isBillingAddressRequiredForPayLater = CRM_Utils_Array::value('is_billing_required', $this->_values['event']);
+ $this->assign('isBillingAddressRequiredForPayLater', $this->_isBillingAddressRequiredForPayLater);
+ }
}
/**
CRM_Event_Form_Registration_Confirm::fixLocationFields($value, $fields, $this);
//unset the billing parameters if it is pay later mode
//to avoid creation of billing location
- if ($this->_allowWaitlist || $this->_requireApproval || !empty($value['is_pay_later']) || empty($value['is_primary'])) {
+ if ($this->_allowWaitlist
+ || $this->_requireApproval
+ || (!empty($value['is_pay_later']) && !$this->_isBillingAddressRequiredForPayLater)
+ || empty($value['is_primary'])
+ ) {
$billingFields = array(
"email-{$this->_bltID}",
'billing_first_name',
}
// 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) {
//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 {
</div>
{/if}
- {if ( $contributeMode ne 'notify' and ! $is_pay_later and $is_monetary and ( $amount GT 0 OR $minimum_fee GT 0 ) ) or $email }
- {if $contributeMode ne 'notify' and ! $is_pay_later and $is_monetary and ( $amount GT 0 OR $minimum_fee GT 0 ) }
+ {if ( $contributeMode ne 'notify' and (!$is_pay_later or $isBillingAddressRequiredForPayLater) and $is_monetary and ( $amount GT 0 OR $minimum_fee GT 0 ) ) or $email }
+ {if $contributeMode ne 'notify' and (!$is_pay_later or $isBillingAddressRequiredForPayLater) and $is_monetary and ( $amount GT 0 OR $minimum_fee GT 0 ) }
{if $billingName or $address}
<div class="crm-group billing_name_address-group">
<div class="header-dark">
<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>
</div>
{/if}
- {if ( $contributeMode ne 'notify' and ! $is_pay_later and $is_monetary and ( $amount GT 0 OR $minimum_fee GT 0 ) ) or $email }
- {if $contributeMode ne 'notify' and ! $is_pay_later and $is_monetary and ( $amount GT 0 OR $minimum_fee GT 0 ) }
+ {if ( $contributeMode ne 'notify' and (!$is_pay_later or $isBillingAddressRequiredForPayLater) and $is_monetary and ( $amount GT 0 OR $minimum_fee GT 0 ) ) or $email }
+ {if $contributeMode ne 'notify' and (!$is_pay_later or $isBillingAddressRequiredForPayLater) and $is_monetary and ( $amount GT 0 OR $minimum_fee GT 0 ) }
{if $billingName or $address}
<div class="crm-group billing_name_address-group">
<div class="header-dark">
{/if}
</div>
</fieldset>
-
+ {else}
+ </fieldset>
+ {/if}
+{/if}
{if $profileAddressFields}
<input type="checkbox" id="billingcheckbox" value="0"> <label for="billingcheckbox">{ts}My billing address is the same as above{/ts}</label>
{/if}
</div>
</div>
</fieldset>
- {else}
- </fieldset>
- {/if}
+
</div>
{if $profileAddressFields}
{/literal}
</script>
{/if}
-{/if}
+
{/crmRegion}
{include file="CRM/Event/Form/Registration/DisplayProfile.tpl"}
- {if $contributeMode ne 'notify' and !$is_pay_later and $paidEvent and !$isAmountzero and !$isOnWaitlist and !$isRequireApproval}
+ {if $contributeMode ne 'notify' and (!$is_pay_later or $isBillingAddressRequiredForPayLater) and $paidEvent and !$isAmountzero and !$isOnWaitlist and !$isRequireApproval}
<div class="crm-group billing_name_address-group">
<div class="header-dark">
{ts}Billing Name and Address{/ts}
<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/Event/Form/Registration/Register.tpl" snippet=4}
{/if}
</div>
{/if}
{include file="CRM/Event/Form/Registration/DisplayProfile.tpl"}
-
- {if $contributeMode ne 'notify' and $paidEvent and ! $is_pay_later and ! $isAmountzero and !$isOnWaitlist and !$isRequireApproval}
+ {if $contributeMode ne 'notify' and (!$is_pay_later or $isBillingAddressRequiredForPayLater) and $paidEvent and !$isAmountzero and !$isOnWaitlist and !$isRequireApproval}
<div class="crm-group billing_name_address-group">
<div class="header-dark">
{ts}Billing Name and Address{/ts}
<script type="text/javascript">
function buildPaymentBlock( type ) {
- if ( type == 0 ) {
- if (cj("#billing-payment-block").length) {
- cj("#billing-payment-block").html('');
- }
- return;
+ {/literal}{if !$isBillingAddressRequiredForPayLater}{literal}
+ if (type == 0) {
+ if (cj("#billing-payment-block").length) {
+ cj("#billing-payment-block").html('');
}
+ return;
+ }
+ {/literal}{/if}{literal}
var dataUrl = {/literal}"{crmURL p=$urlPath h=0 q='snippet=4&type='}"{literal} + type;