CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Discussion (deprecated) »
  • Feature Requests and Suggestions »
  • Usability Improvements (Moderator: Dave Greenberg) »
  • Hiding CC Info for Free Membership
Pages: [1]

Author Topic: Hiding CC Info for Free Membership  (Read 1358 times)

dtheweather9

  • I post occasionally
  • **
  • Posts: 57
  • Karma: 1
    • Students for the Exploration and Development of Space, USA
  • CiviCRM version: 4.4.0
  • CMS version: WordPress 3.8.1
  • MySQL version: 5.1.56
  • PHP version: 5.4.11
Hiding CC Info for Free Membership
July 01, 2013, 05:51:46 pm
Greetings Everyone,
I got playing around with Javascript for the first time, with the intent to try to get the credit card information hidden when the transaction was free on the membership registration page.  Seeing as its only 'required' by civicrm to be filled out if its a transaction that costs something (at least in my experience), then it seems its just a matter of a simple css hide script. 
Code: [Select]
<script type="text/javascript">// <![CDATA[
var int=self.setInterval(function(){sedscivi()},1500);
function sedscivi()
{
if (document.getElementsByTagName("div")["pricevalue"].textContent=="$ 0.00") {
document.getElementById('payment_information').style.display = "none";
} else {
document.getElementById('payment_information').style.display = "inherit";
}
}
// ]]></script>

This code has been working for me on civicrm on wordpress; I'm not sure however if it would work cross platform.
Also I have the feeling that its incredibly inefficient, as its more or less checking the 'pricevalue' textContent every second to see if has changed.  Is there a more efficient way of doing this?
Should or could something along these lines be rolled into the core?

-Dtheweather9

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: Hiding CC Info for Free Membership
July 01, 2013, 08:03:25 pm
2 issues here:

1) Congratulations on writing your first script. Learning JS is fun and rewarding.  You're off to a good start. I recommend reading up on jQuery as well as our own Javascript Reference. You can learn some better ways to do what you're trying to do, including event handlers to avoid the need for polling with setInterval, and closures to avoid creating global functions and variables.

2) To my eye this script should not be necessary; if Civi is asking for credit card number for free memberships, it's a bug. It would be good to note what version this bug came up in (assuming it worked correctly at some point).
Try asking your question on the new CiviCRM help site.

dtheweather9

  • I post occasionally
  • **
  • Posts: 57
  • Karma: 1
    • Students for the Exploration and Development of Space, USA
  • CiviCRM version: 4.4.0
  • CMS version: WordPress 3.8.1
  • MySQL version: 5.1.56
  • PHP version: 5.4.11
Re: Hiding CC Info for Free Membership
July 01, 2013, 08:54:34 pm
I tried it on the newest version of the Joomla demo site as well as the wordpress site I'm running; the credit card info isn't required, but the fields are still there; this basically hides the fields so as to not confuse customers.

Thanks for the links, Ill read up

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Discussion (deprecated) »
  • Feature Requests and Suggestions »
  • Usability Improvements (Moderator: Dave Greenberg) »
  • Hiding CC Info for Free Membership

This forum was archived on 2017-11-26.