Skip to content
This repository has been archived by the owner on Sep 14, 2021. It is now read-only.

Commit

Permalink
Code improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Kajakaran committed Dec 17, 2015
1 parent 1811458 commit 3c509d5
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 50 deletions.
6 changes: 2 additions & 4 deletions CRM/CiviDiscount/DiscountCalculator.php
Expand Up @@ -182,10 +182,8 @@ function setEntityDiscounts() {
}
if ($this->checkDiscountsByEntity($discount, $this->entity, $this->entity_id, 'filters')) {
$this->entity_discounts[$discount_id] = $discount;
/* Added by BOT
* To decide if discount text box should be displayed, no need to loop through all discount codes
*/
if( empty( $this->code ) ) {
// Added by BOT To decide if discount text box should be displayed, no need to loop through all discount codes
if (empty($this->code)) {
break;
}
}
Expand Down
2 changes: 2 additions & 0 deletions cividiscount.php
Expand Up @@ -166,6 +166,8 @@ function cividiscount_civicrm_buildForm($fname, &$form) {
$addDiscountField = $discountCalculator->isShowDiscountCodeField();
}
elseif ($fname == 'CRM_Contribute_Form_Contribution_Main') {
CRM_Core_Resources::singleton()
->addScriptFile('org.civicrm.module.cividiscount', 'js/main.js');
$ids = _cividiscount_get_discounted_membership_ids();
if(!empty($form->_membershipBlock['membership_types'])){
$memtypes = explode(',', $form->_membershipBlock['membership_types']);
Expand Down
32 changes: 32 additions & 0 deletions js/main.js
@@ -0,0 +1,32 @@
CRM.$(function($) {
if ($('#discountcode').length > 0) {
skipPaymentMethod();
function showHidePayment(flag) {
$('.payment_options-group, div.payment_processor-section, #payment_information').toggle(!flag);
if (flag) {
// also unset selected payment methods
$('input[name="payment_processor"]').prop('checked', false);
}
}

function skipPaymentMethod() {
var flag = false;
$('.price-set-option-content input').each( function(){
currentTotal = $(this).attr('data-amount').replace(/[^\/\d]/g,'');
if( $(this).is(':checked') && currentTotal == 0 ) {
flag = true;
}
});
$('.price-set-option-content input').change( function () {
if ($(this).attr('data-amount').replace(/[^\/\d]/g,'') == 0 ) {
flag = true;
} else {
flag = false;
}
showHidePayment(flag);
});
showHidePayment(flag);
}
}
});

46 changes: 0 additions & 46 deletions templates/CRM/Contribute/Form/Contribution/Main.extra.tpl

This file was deleted.

0 comments on commit 3c509d5

Please sign in to comment.