PageSourceSearch

https://annalsofcontinuingeducation.com/wp-content/plugins/paid-memberships-pro/js/pmpro-checkout.js?ver=3.6.2

js annalsofcontinuingeducation.com collected 2026-10-04 15:28:20 UTC 10,685 bytes, 256 lines download raw bytes

1jQuery(document).ready(function(){ 
2    // Discount code JS if we are showing discount codes.
3    if ( pmpro.show_discount_code ) {
4        //update discount code link to show field at top of form
5        jQuery('#other_discount_code_toggle').attr('href', 'javascript:void(0);');
6        jQuery('#other_discount_code_toggle').click(function() {
7            jQuery('#other_discount_code_fields').show();
8            jQuery('#other_discount_code_p').hide();
9            jQuery('#pmpro_other_discount_code').focus();
10        });
11
12        //update real discount code field as the other discount code field is updated
13        jQuery('#pmpro_other_discount_code').keyup(function() {
14            jQuery('#pmpro_discount_code').val(jQuery('#pmpro_other_discount_code').val());
15        });
16        jQuery('#pmpro_other_discount_code').blur(function() {
17            jQuery('#pmpro_discount_code').val(jQuery('#pmpro_other_discount_code').val());
18        });
19
20        //update other discount code field as the real discount code field is updated
21        jQuery('#pmpro_discount_code').keyup(function() {
22            jQuery('#pmpro_other_discount_code').val(jQuery('#pmpro_discount_code').val());
23        });
24        jQuery('#pmpro_discount_code').blur(function() {
25            jQuery('#pmpro_other_discount_code').val(jQuery('#pmpro_discount_code').val());
26        });
27
28        // Top discount code field click handler.
29        jQuery('#other_discount_code_button, #discount_code_button').click(function() {
30            var code = jQuery('#pmpro_other_discount_code').val();
31            var level_id = jQuery('#pmpro_level').val();
32            if ( ! level_id ) {
33                // If the level ID is not set, try to get it from the #level field for outdated checkout templates.
34                level_id = jQuery('#level').val();
35            }
36
37            if(code)
38            {
39                //hide any previous message
40                jQuery('.pmpro_discount_code_msg').hide();
41
42                //disable the apply button
43                jQuery('#pmpro_discount_code_button').attr('disabled', 'disabled');
44                jQuery('#other_discount_code_button').attr('disabled', 'disabled');
45
46                jQuery.ajax({
47                    url: pmpro.ajaxurl, type:'GET',timeout: pmpro.ajax_timeout,
48                    dataType: 'html',
49                    data: "action=applydiscountcode&code=" + code + "&pmpro_level=" + level_id + "&msgfield=pmpro_message",
50                    error: function(xml){
51                        alert('Error applying discount code [1]');
52
53                        //enable apply button
54                        jQuery('#pmpro_discount_code_button').removeAttr('disabled');
55                        jQuery('#other_discount_code_button').removeAttr('disabled');
56
57                    },
58                    success: function(responseHTML){
59                        if (responseHTML == 'error')
60                        {
61                            alert('Error applying discount code [2]');
62                        }
63                        else
64                        {
65                            jQuery('#pmpro_message').html(responseHTML);
66                        }
67
68                        //enable invite button
69                        jQuery('#pmpro_discount_code_button').removeAttr('disabled');
70                        jQuery('#other_discount_code_button').removeAttr('disabled');
71                    }
72                });
73            }
74        });
75    }
76	
77	// Validate credit card number and determine card type.
78	if ( typeof jQuery('#AccountNumber').validateCreditCard == 'function' ) {
79        jQuery('#AccountNumber').validateCreditCard(function(result) {
80    		var cardtypenames = {
81    			"amex"                      : "American Express",
82    			"diners_club_carte_blanche" : "Diners Club Carte Blanche",
83    			"diners_club_international" : "Diners Club International",
84    			"discover"                  : "Discover",
85    			"jcb"                       : "JCB",
86    			"laser"                     : "Laser",
87    			"maestro"                   : "Maestro",
88    			"mastercard"                : "Mastercard",
89    			"visa"                      : "Visa",
90    			"visa_electron"             : "Visa Electron"
91    		};
92
93    		if(result.card_type)
94    			jQuery('#CardType').val(cardtypenames[result.card_type.name]);
95    		else
96    			jQuery('#CardType').val('Unknown Card Type');
97    	});
98    }
99
100	// Password visibility toggle.
101	(function() {
102		const toggleElements = document.querySelectorAll('.pmpro_btn-password-toggle');
103
104		toggleElements.forEach(toggle => {
105			toggle.classList.remove('hide-if-no-js');
106			toggle.addEventListener('click', togglePassword);
107		});
108
109		function togglePassword() {
110			const status = this.getAttribute('data-toggle');
111			const passwordInputs = document.querySelectorAll('.pmpro_form_input-password');
112			const icon = this.getElementsByClassName('pmpro_icon')[0];
113			const state = this.getElementsByClassName('pmpro_form_field-password-toggle-state')[0];
114
115			if (parseInt(status, 10) === 0) {
116				this.setAttribute('data-toggle', 1);
117				passwordInputs.forEach(input => input.setAttribute('type', 'text'));
118				icon.innerHTML = `
119					<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="var(--pmpro--color--accent)" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-eye-off">
120						<path d="M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24"></path>
121						<line x1="1" y1="1" x2="23" y2="23"></line>
122					</svg>`;
123				state.textContent = pmpro.hide_password_text;
124			} else {
125				this.setAttribute('data-toggle', 0);
126				passwordInputs.forEach(input => input.setAttribute('type', 'password'));
127				icon.innerHTML = `
128					<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="var(--pmpro--color--accent)" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-eye">
129						<path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"></path>
130						<circle cx="12" cy="12" r="3"></circle>
131					</svg>`;
132				state.textContent = pmpro.show_password_text;
133			}
134		}
135	})();
136
137	// Find ALL <form> tags on your page
138	jQuery('form#pmpro_form').submit(function(){
139		// On submit disable its submit button
140		jQuery('input[type=submit]', this).attr('disabled', 'disabled');
141		jQuery('input[type=image]', this).attr('disabled', 'disabled');
142		jQuery('#pmpro_processing_message').css('visibility', 'visible');
143	});	
144
145	jQuery('.pmpro_form_field-required').each(function() {
146		// Check if there's an asterisk already
147		var $firstLabel = jQuery(this).find('.pmpro_form_label').first();
148		var $hasAsterisk = $firstLabel.find('.pmpro_asterisk').length > 0;
149	
150		// If there's no asterisk, add one
151		if ( ! $hasAsterisk ) {
152			$firstLabel.append('<span class="pmpro_asterisk"> <abbr title="Required Field">*</abbr></span>');
153		}
154
155		// Add the aria-required="true" attribute to the input.
156		jQuery(this).find('.pmpro_form_input').attr('aria-required', 'true');
157	});
158
159	jQuery('.pmpro_form_input-required').each(function() {
160		// Check if there's an asterisk already
161		var $fieldDiv = jQuery(this).closest('.pmpro_form_field');
162		var $firstLabel = $fieldDiv.find('.pmpro_form_label').first();
163		var $hasAsterisk = $firstLabel.find('.pmpro_asterisk').length > 0;
164
165		// If there's no asterisk, add one
166		if ( ! $hasAsterisk ) {
167			$firstLabel.append('<span class="pmpro_asterisk"> <abbr title="Required Field">*</abbr></span>');
168		}
169
170		// Add the aria-required="true" attribute to the input.
171		jQuery(this).find('.pmpro_form_input').attr('aria-required', 'true');
172	});
173
174	//unhighlight error fields when the user edits them
175	jQuery('.pmpro_form_input-error').bind("change keyup input", function() {
176		jQuery(this).removeClass('pmpro_form_input-error');
177	});
178
179	//click apply button on enter in discount code box
180	jQuery('#pmpro_discount_code').keydown(function (e){
181	    if(e.keyCode == 13){
182		   e.preventDefault();
183		   jQuery('#pmpro_discount_code_button').click();
184	    }
185	});
186
187	//hide apply button if a discount code was passed in
188	if( pmpro.discount_code_passed_in ) {
189		jQuery('#pmpro_discount_code_button').hide();
190		jQuery('#pmpro_discount_code').bind('change keyup', function() {
191			jQuery('#pmpro_discount_code_button').show();
192		});
193	}
194
195	//click apply button on enter in *other* discount code box
196	jQuery('#pmpro_other_discount_code').keydown(function (e){
197	    if(e.keyCode == 13){
198		   e.preventDefault();
199		   jQuery('#other_discount_code_button').click();
200	    }
201	});
202	
203	//add javascriptok hidden field to checkout
204	jQuery("input[name=submit-checkout]").after('<input type="hidden" name="javascriptok" value="1" />');
205	
206	// Keep bottom message box in sync with the top one.
207	let pmpro_msgObserver = new MutationObserver(() => {
208		setTimeout( function(){ pmpro_copyMessageToBottom() }, 200);
209	});
210	pmpro_msgObserver.observe( jQuery('#pmpro_message').get(0), {
211		childList: true,
212		subtree: true
213	});
214	
215	function pmpro_copyMessageToBottom() {
216		jQuery('#pmpro_message_bottom').html(jQuery('#pmpro_message').html());
217		jQuery('#pmpro_message_bottom').attr('class', jQuery('#pmpro_message').attr('class'));
218		if(jQuery('#pmpro_message').is(":visible")) {
219			jQuery('#pmpro_message_bottom').show();
220		} else {
221			jQuery('#pmpro_message_bottom').hide();
222		}
223	}
224
225	// If a user was created during this page load, update the nonce to be valid.
226	if ( pmpro.update_nonce ) {
227		jQuery.ajax({
228			url: pmpro.ajaxurl,
229			type: 'POST',
230			data: {
231				action: 'pmpro_get_checkout_nonce'
232			}
233		}).done(function(response) {
234			jQuery('input[name="pmpro_checkout_nonce"]').val(response);
235		});
236	}
237});
238
239// Get non-sensitive checkout form data to be sent to checkout_levels endpoint.
240function pmpro_getCheckoutFormDataForCheckoutLevels() {
241	// We need the level, discount code, and any field with the pmpro_alter_price CSS class.
242	const checkoutFormData = jQuery( "#level, #pmpro_level, #discount_code, #pmpro_discount_code, #pmpro_form .pmpro_alter_price" ).seri
242alizeArray();
243
244	// Double check to remove sensitive data from the array.
245	const sensitiveCheckoutRequestVars = pmpro.sensitiveCheckoutRequestVars;
246	for ( var i = 0; i < checkoutFormData.length; i++ ) {
247		if ( sensitiveCheckoutRequestVars.includes( checkoutFormData[i].name ) ) {
248			// Remove sensitive data from form data and adjust index to account for removed item.
249			checkoutFormData.splice( i, 1 );
250			i--;
251		}
252	}
253
254	// Return form data as string.
255	return jQuery.param( checkoutFormData );
256}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.