Wordpress: S2 Member Plugin: Tiered Donation Support


/ Published in: jQuery
Save to your folder(s)

If you are using the Wordpress plugin S2 Member and want to accept donations at various levels. First create the form with a class of donation and 3 different dropdowns, then change the values of the hidden inputs using jQuery (which is this script)


Copy this code and paste it in your HTML
  1. <script type="text/javascript">
  2.  
  3. var $j = jQuery.noConflict();
  4.  
  5. jQuery(document).ready(function () {
  6. var title1 = "Single Occurance Downloader / 3 Days given to download";
  7. var title2 = "Member Level Supporter / 1 Year Membership";
  8. var title3 = "Gold Level Membership / 1 Year Membership with AN INCREDIBLY THANK YOU!!!";
  9. jQuery(".donation").change(function () {
  10. var checkDonateLevel = jQuery(this).attr("name");
  11. var donValue = jQuery(this).val();
  12. var applyButton = function (index) { // Sets the the proper values for the Donate button
  13. jQuery('input[name=a3]').val(donValue); // Whatever money value they select is how much they pay
  14. switch(checkDonateLevel)
  15. {
  16. case 'l1' :
  17. jQuery('input[name=t3]').val("D"); // Set to Days
  18. jQuery('input[name=p3]').val("3"); // Set to 2 Days
  19. jQuery('input[name=item_number]').val("1"); // Set user to Level 1
  20. jQuery('input[name=item_name]').val(title1); // Set description given to Paypal Page
  21. break;
  22. case 'l2' :
  23. jQuery('input[name=t3]').val("Y"); // Set to Years
  24. jQuery('input[name=p3]').val("1"); // Set to 1 Year
  25. jQuery('input[name=item_number]').val("2"); // Set user to Level 2
  26. jQuery('input[name=item_name]').val(title2); // Set description given to Paypal Page
  27. break;
  28. case 'l3' :
  29. jQuery('input[name=t3]').val("Y"); // Set to Years
  30. jQuery('input[name=p3]').val("1"); // Set to 1 Year
  31. jQuery('input[name=item_number]').val("3"); // Set user to Level 3
  32. jQuery('input[name=item_name]').val(title3); // Set description given to Paypal Page
  33. break;
  34. }
  35. }
  36. jQuery(".donation").ready(applyButton);
  37. var resetButton = function (index) { // Resets all the other donation dropdowns
  38. var donLevel = jQuery(this).attr("name");
  39. if (donLevel != checkDonateLevel) {
  40. jQuery(this).val('');
  41. }
  42. }
  43. jQuery(".donation").each(resetButton);
  44. });
  45. });
  46. </script>

URL: cameronpreston.com/membership-options

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.