PageSourceSearch

https://sealyme.com/wp-content/plugins/recoverabandoncart/assets/js/fp-rac-guest-checkout.js?ver=24.1.0

js sealyme.com collected 2026-10-07 20:53:29 UTC 12,709 bytes, 324 lines download raw bytes

1/* global rac_guest_params */
2
3jQuery( document ).ready( function ( ) {
4	'use strict';
5	var force_guest_email = rac_guest_params.force_guest == 'yes' ? true : false;
6	var check = force_guest_email ? true : rac_guest_params.popup_already_displayed != 'yes';
7	var already_cookie_occured = ( rac_guest_params.is_cookie_already_set == 1 ) ? true : false;
8	var popup_cookie_delay_time = ( rac_guest_params.popup_cookie_delay_time == 'yes' ) ? true : false;
9	if ( ( !already_cookie_occured ) && ( rac_guest_params.enable_popup == 'yes' ) ) {
10		if ( check && popup_cookie_delay_time ) {
11			common_function_get_guest_email_address_in_cookie( false );
12		}
13	}
14
15	function fp_rac_set_default_checkout_fields_data( ) {
16		if ( rac_guest_params.fp_rac_popup_email ) {
17			jQuery( "#billing_email" ).val( rac_guest_params.fp_rac_popup_email );
18		}
19
20		if ( rac_guest_params.fp_rac_first_name ) {
21			jQuery( "#billing_first_name" ).val( rac_guest_params.fp_rac_first_name );
22		}
23
24		if ( rac_guest_params.fp_rac_last_name ) {
25			jQuery( "#billing_last_name" ).val( rac_guest_params.fp_rac_last_name );
26		}
27
28		if ( rac_guest_params.fp_rac_phone_no ) {
29			jQuery( "#billing_phone" ).val( rac_guest_params.fp_rac_phone_no );
30		}
31
32	}
33
34	if ( rac_guest_params.is_checkout ) {
35
36		fp_rac_set_default_checkout_fields_data( );
37		var request = null;
38		jQuery( "#billing_email" ).on( "focusout", function ( ) {
39			fp_rac_common_function_for_checkout_fields( );
40		} );
41		jQuery( "#billing_first_name" ).on( "change", function ( ) {
42			fp_rac_common_function_for_checkout_fields( );
43		} );
44		jQuery( "#billing_last_name" ).on( "change", function ( ) {
45			fp_rac_common_function_for_checkout_fields( );
46		} );
47		jQuery( "#billing_phone" ).on( "change", function ( ) {
48			fp_rac_common_function_for_checkout_fields( );
49		} );
50		window.onbeforeunload = function ( ) {
51			fp_rac_common_function_for_checkout_fields( );
52		};
53		function fp_rac_common_function_for_checkout_fields( ) {
54			var fp_rac_mail = jQuery( "#billing_email" ).val( ),
55					atpos = fp_rac_mail.indexOf( "@" ),
56					dotpos = fp_rac_mail.lastIndexOf( "." );
57
58			if ( atpos < 1 || dotpos < atpos + 2 || dotpos + 2 >= fp_rac_mail.length ) {
59				console.log( rac_guest_params.console_error );
60			} else {
61				console.log( fp_rac_mail );
62				var fp_rac_first_name = jQuery( "#billing_first_name" ).val( );
63				var fp_rac_last_name = jQuery( "#billing_last_name" ).val( );
64				var fp_rac_phone = jQuery( "#billing_phone" ).val( );
65				var data = {
66					action: "rac_preadd_guest",
67					rac_email: fp_rac_mail,
68					rac_first_name: fp_rac_first_name,
69					rac_last_name: fp_rac_last_name,
70					rac_phone: fp_rac_phone,
71					rac_security: rac_guest_params.guest_entry,
72					rac_lang: rac_guest_params.current_lang_code
73				}
74				if ( request == null ) {
75					request = jQuery.post( rac_guest_params.ajax_url, data,
76							function ( response ) {
77								request = null;
78								console.log( response );
79							} );
80				}
81			}
82		}
83	}
84	var proceed_add_to_cart = false;
85	var force_guest_email = rac_guest_params.force_guest == 'yes' ? true : false;
86	var check = force_guest_email ? true : rac_guest_params.popup_already_displayed != 'yes';
87	if ( 'yes' == rac_guest_params.enable_popup ) {
88		jQuery( ".product_type_simple" ).on( "click", function ( event ) {
89			event.preventDefault( );
90			var object_clicked = jQuery( this );
91			jQuery( '.product_type_simple' ).removeClass( 'fp_rac_currently_clicked_atc' );
92			jQuery( '.single_add_to_cart_button' ).removeClass( 'fp_rac_currently_clicked_atc' );
93			jQuery( this ).addClass( 'fp_rac_currently_clicked_atc' );
94			if ( jQuery( this ).hasClass( 'ajax_add_to_cart' ) && !proceed_add_to_cart && ( !already_cookie_occured ) && ( rac_guest_params.enable_popup == 'yes' ) ) {
95				if ( ( !jQuery( this ).hasClass( 'rac_hide_guest_poup' ) ) && check ) {
96					if ( rac_guest_params.popup_disp_method == 1 ) {
97						common_function_get_guest_email_address_in_cookie( object_clicked )
98						return false;
99					} else {
100						var data = {
101							action: 'rac_popup_timedelay',
102							rac_security: rac_guest_params.rac_popup_delay_nonce,
103						};
104						jQuery.post( rac_guest_params.ajax_url, data, function ( response ) {
105							console.log( response );
106							proceed_add_to_cart = true;
107							if ( rac_guest_params.is_shop && rac_guest_params.ajax_add_to_cart != 'yes' ) {
108								var href = object_clicked.attr( 'href' );
109								window.location = href;
110							} else {
111								jQuery( '.fp_rac_currently_clicked_atc' ).trigger( 'click' );
112							}
113						} );
114						return false;
115					}
116				}
117			}
118		} );
119	}
120
121	jQuery( ".single_add_to_cart_button" ).on( "click", function ( ) {
122		var object_clicked = jQuery( this );
123		jQuery( '.product_type_simple' ).removeClass( 'fp_rac_currently_clicked_atc' );
124		jQuery( '.single_add_to_cart_button' ).removeClass( 'fp_rac_currently_clicked_atc' );
125		jQuery( this ).addClass( 'fp_rac_currently_clicked_atc' );
126		if ( !jQuery( this ).hasClass( 'wc-variation-selection-needed' ) && !proceed_add_to_cart && !jQuery( this ).hasClass( 'disabled' ) && ( !already_cookie_occured ) && ( rac_guest_params.enable_popup == 'yes' ) ) {
127			if ( ( !jQuery( this ).hasClass( 'rac_hide_guest_poup' ) ) && check ) {
128				if ( rac_guest_params.popup_disp_method == 1 ) {
129					common_function_get_guest_email_address_in_cookie( object_clicked );
130					return false;
131				} else {
132					var time_delay = new Date( ).getTime( );
133					var data = {
134						action: 'rac_popup_timedelay',
135						timedelay: time_delay,
136						rac_security: rac_guest_params.rac_popup_delay_nonce,
137					};
138					jQuery.post( rac_guest_params.ajax_url, data, function ( response ) {
139						console.log( response );
140						proceed_add_to_cart = true;
141						if ( rac_guest_params.is_shop && rac_guest_params.ajax_add_to_cart != 'yes' ) {
142							var href = object_clicked.attr( 'href' );
143							window.location = href;
144						} else {
145							jQuery( '.fp_rac_currently_clicked_atc' ).trigger( 'click' );
146						}
147					} );
148					return false;
149				}
150			}
151		}
152	} );
153	function common_function_get_guest_email_address_in_cookie( object_clicked, error, default_email, defaultfname, default_lname, default_phoneno ) {
154		var force_guest = rac_guest_params.force_guest == 'yes' ? false : true;
155		if ( typeof error === "undefined" || error === null ) {
156			error = "";
157		}
158
159		if ( typeof default_email === "undefined" || default_email === null ) {
160			default_email = "";
161		}
162		if ( typeof defaultfname === "undefined" || defaultfname === null ) {
163			defaultfname = "";
164		}
165		if ( typeof default_lname === "undefined" || default_lname === null ) {
166			default_lname = "";
167		}
168		if ( typeof default_phoneno === "undefined" || default_phoneno === null ) {
169			default_phoneno = "";
170		}
171
172		if ( force_guest ) {
173			jQuery( '.single_add_to_cart_button' ).addClass( 'rac_hide_guest_poup' );
174			jQuery( '.product_type_simple' ).addClass( 'rac_hide_guest_poup' );
175		}
176
177		var html = '';
178		if ( rac_guest_params.fp_rac_disp_notice_check ) {
179			html += '<div class="woocommerce-info" name="fp_rac_guest_notice" id="fp_rac_guest_notice">' + rac_guest_params.fp_rac_disp_notice + '</div>';
180		}
181		html += '<input type="text" name="fp_rac_guest_email_in_cookie" id="fp_rac_guest_email_in_cookie" value="' + default_email + '" placeholder="' + custom_css_btn_color.email_placeholder + '"><br><br>';
182		if ( rac_guest_params.show_guest_name ) {
183			html += '<input type="text" name="fp_rac_guest_fname_in_cookie" id="fp_rac_guest_fname_in_cookie" value="' + defaultfname + '" placeholder="' + custom_css_btn_color.fname_placeholder + '"><br><br>' + '<input type="text" name="fp_rac_guest_lname_in_cookie" id="fp_rac_guest_lname_in_cookie" value="' + default_lname + '" placeholder="' + custom_css_btn_color.lname_placeholder + '"><br><br>';
184		}
185
186		if ( rac_guest_params.show_guest_contactno ) {
187			html += '<input type="tel" name="fp_rac_guest_phoneno_in_cookie" id="fp_rac_guest_phoneno_in_cookie" value="' + default_phoneno + '" placeholder="' + custom_css_btn_color.phone_placeholder + '">';
188		}
189
190		if ( rac_guest_params.show_gdpr ) {
191			html += '<input type="checkbox" id="fp_rac_guest_popup_gdpr"><span class=""> ' + rac_guest_params.gdpr_description + '</span>';
192		}
193
194		var data = {
195			action: 'fp_rac_already_popup_displayed',
196			already_displayed: 'yes',
197			rac_security: rac_guest_params.guest_entry
198		};
199		var show_error = error != '' ? '<div style="color:red">' + error + '</div><br>' : '';
200		var error_msg = "";
201		jQuery.post( rac_guest_params.ajax_url, data, function ( ) {} );
202		swal( {
203			title: '<span class="rac_swal_popup_title">' + rac_guest_params.form_label + '</span>',
204			html: '<span class="rac_swal_popup_sub_title">' + rac_guest_params.popup_sub_header + '</span>' + show_error + html,
205			showCloseButton: true,
206			showCancelButton: true,
207			confirmButtonText: '<i class="fa fa-thumbs-up"></i>' + rac_guest_params.add_to_cart_label,
208			cancelButtonText: '<i class="fa fa-thumbs-down"></i>' + rac_guest_params.cancel_label,
209			background: '#' + custom_css_btn_color.popupcolor,
210			confirmButtonColor: '#' + custom_css_btn_color.confirmbtncolor,
211			cancelButtonColor: '#' + custom_css_btn_color.cancelbtncolor,
212		} ).then( function ( isConfirm ) {
213			if ( isConfirm ) {
214				var email_id = jQuery( '#fp_rac_guest_email_in_cookie' ).val( ),
215						first_name = jQuery( '#fp_rac_guest_fname_in_cookie' ).val( ),
216						last_name = jQuery( '#fp_rac_guest_lname_in_cookie' ).val( ),
217						phone_no = jQuery( '#fp_rac_guest_phoneno_in_cookie' ).val( ),
218						gdpr = jQuery( '#fp_rac_guest_popup_gdpr' ),
219						filter = /^[0-9-+]+$/;
220				try {
221					var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,3})?$/;
222					if ( email_id && !emailReg.test( email_id ) ) {
223						error_msg += rac_guest_params.email_address_not_valid + '<br>';
224					} else if ( !force_guest && email_id == "") {
225						error_msg += rac_guest_params.enter_email_address + '<br>';
226					}
227
228					if ( rac_guest_params.force_guest_name && first_name == "" ) {
229						error_msg += rac_guest_params.enter_first_name + '<br>';
230					}
231
232					if ( rac_guest_params.force_guest_name && last_name == "" ) {
233						error_msg += rac_guest_params.enter_last_name + '<br>';
234					}
235
236					if ( phone_no && !filter.test( phone_no ) ) {
237						error_msg += rac_guest_params.enter_valid_phone_no + '<br>';
238					} else if ( rac_guest_params.force_guest_contactno && phone_no == "" ) {
239						error_msg += rac_guest_params.enter_phone_no + '<br>';
240					}
241
242					if ( gdpr.length && !gdpr.is( ':checked' ) ) {
243						error_msg += rac_guest_params.gdpr_error + '<br>';
244					}
245
246					if ( error_msg ) {
247						common_function_get_guest_email_address_in_cookie( object_clicked, error_msg, email_id, first_name, last_name, phone_no );
248						return false;
249					}
250
251					var data = {
252						action: 'fp_rac_set_guest_email_in_cookie',
253						cookie_guest_email: email_id,
254						cookie_guest_fname: first_name,
255						cookie_guest_lname: last_name,
256						cookie_guest_phone_no: phone_no,
257						gdpr: 'yes',
258						rac_security: rac_guest_params.guest_entry
259					};
260					jQuery.post( rac_guest_params.ajax_url, data, function ( response ) {
261						console.log( response );
262						if ( response == 'success' && rac_guest_params.popup_disp_method != 2 ) {
263							proceed_add_to_cart = true;
264							if ( rac_guest_params.is_shop && rac_guest_params.ajax_add_to_cart != 'yes' ) {
265								var href = object_clicked.attr( 'href' );
266								window.location = href;
267							} else {
268								jQuery( '.fp_rac_currently_clicked_atc' ).trigger( 'click' );
269							}
270						}
271						if ( rac_guest_params.popup_disp_method != 1 ) {
272							window.location.reload( );
273						}
274					} );
275				} catch ( err ) {
276					swal( {
277						title: err,
278						type: "error"
279					} );
280				}
281			} else {
282				if ( !force_guest_email ) {
283					jQuery( '.fp_rac_currently_clicked_atc' ).trigger( 'click' );
284				}
285			}
286		} )
287		return false;
288	}
289
290	if ( rac_guest_params.show_checkout_gdpr && jQuery( '#billing_email' ).length ) {
291		jQuery( '#billing_email' ).after( rac_guest_params.checkout_gdpr_field );
292
293		jQuery( '#rac-checkout-gdpr-field' ).on( 'change', function ( event ) {
294			event.preventDefault();
295
296			var $this = jQuery( event.currentTarget );
297			if ( $this.is( ":checked" ) ) {
298				var gdpr_accepted = 'no';
299			} else {
300				var gdpr_accepted = 'yes';
301			}
302
303			var data = ( {
304				action: 'rac_handle_checkout_gdpr',
305				gdpr_accepted: gdpr_accepted,
306				rac_security: rac_guest_params.gdpr_nonce
307			} );
308
309			jQuery.post( rac_guest_params.ajax_url, data, function ( res ) {
310				if ( true === res.success ) {
311					if ( !$this.is( ":checked" ) ) {
312						jQuery( "#billing_email" ).trigger( 'focusout' );
313					}
314				} else {
315					alert( res.data.error );
316				}
317			}
318			);
319
320			return false;
321
322		} );
323	}
324} );

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.