Skip to content

Commit

Permalink
added form-total field to calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
Igor-Tkachenko committed Nov 5, 2023
1 parent d927b4f commit e7e1005
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions public/js/gf-giftaid-field-frontend.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,20 @@ function gfGiftAidOnInputChange(elem) {
return;
}

const wrapperField = elem.closest('.gfield');
if (!(wrapperField instanceof HTMLElement)) {
if (! elem.classList.contains('ginput_total') && ! elem.classList.contains('ginput_amount')) {
return;
} else {
if (
!wrapperField.classList.contains('giftaid-value') &&
!elem.classList.contains('ginput_amount')
) {
return;
}
}

const parentForm = elem.closest('form');
if (!(parentForm instanceof HTMLFormElement)) {
return;
}

const totalEl = parentForm.querySelector('.ginput_total');
if (totalEl instanceof HTMLElement) {
elem = totalEl;
}

const spanTotal = parentForm.querySelectorAll('.gform_donation_total');
if (!(spanTotal instanceof NodeList) || 0 === spanTotal.length) {
return;
Expand Down

0 comments on commit e7e1005

Please sign in to comment.