From: Dave Greenberg Date: Tue, 21 Oct 2014 23:13:03 +0000 (-0700) Subject: CRM-15433 - Fix skipPayment function so it works regardless of currency localization. X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=461803d01348483012313d39c249a15bc818890b;p=civicrm-core.git CRM-15433 - Fix skipPayment function so it works regardless of currency localization. ---------------------------------------- * CRM-15433: Billing info and payment options blocks not hidden for $0 events with price sets when decimal delimiter is NOT a dot https://issues.civicrm.org/jira/browse/CRM-15433 --- diff --git a/templates/CRM/Event/Form/Registration/Register.tpl b/templates/CRM/Event/Form/Registration/Register.tpl index 6374ea42f9..ba0c30bfa2 100644 --- a/templates/CRM/Event/Form/Registration/Register.tpl +++ b/templates/CRM/Event/Form/Registration/Register.tpl @@ -200,14 +200,24 @@ toggleConfirmButton(); }); + cj("#additional_participants").change(function () { + skipPaymentMethod(); + }); + CRM.$(function($) { toggleConfirmButton(); skipPaymentMethod(); }); - // Called from display() in Calculate.tpl, depends on display() having been called + // Hides billing and payment options block - but only if a price set is used. + // Called from display() in Calculate.tpl, depends on display() having been called. function skipPaymentMethod() { - var symbol = '{/literal}{$currencySymbol}{literal}'; + // If we're in quick-config price set, we do not have the pricevalue hidden element, so just return. + if (cj('#pricevalue').length == 0) { + return; + } + // CRM-15433 Remove currency symbol, decimal separator so we can check for zero numeric total regardless of localization. + currentTotal = cj('#pricevalue').text().replace(/[^\/\d]/g,''); var isMultiple = '{/literal}{$event.is_multiple_registrations}{literal}'; var flag = 1; @@ -215,11 +225,12 @@ var payment_processor = cj("div.payment_processor-section"); var payment_information = cj("div#payment_information"); - if (isMultiple && cj("#additional_participants").val() && cj('#pricevalue').text() !== symbol + " 0.00") { + // Do not hide billing and payment blocks if user is registering additional participants, since we do not know total owing. + if (isMultiple && cj("#additional_participants").val() && currentTotal == 0) { flag = 0; } - if ((cj('#pricevalue').text() == symbol + " 0.00") && flag) { + if (currentTotal == 0 && flag) { payment_options.hide(); payment_processor.hide(); payment_information.hide();