1/** 2 * Detect user and send request to PHP, to create the cookie 3 */ 4function wpac_detect_user(action, email_or_hash) { 5 let url = wpac.ajax_url; 6 7 let params = { 8 method: 'POST', 9 credentials: 'same-origin', 10 headers: { 11 'Content-Type': 'application/x-www-form-urlencoded', 12 'Cache-Control': 'no-cache', 13 }, 14 body: new URLSearchParams({ 15 action: action, 16 wpac_nonce: wpac.nonce, 17 wpac_email: email_or_hash, 18 email_hash: email_or_hash, 19 crm_id: email_or_hash 20 }) 21 }; 22 23 fetch(url, params) 24 .then(function (response) { 25 return response.text(); 26 }) 27} 28 29/** 30 * Trigger after DOMLoaded 31 */ 32document.addEventListener('DOMContentLoaded', function() { 33 // Check if RaiseNow object exists and has stored_customer_email 34 if ( typeof rnTransactionData === 'object' && rnTransactionData.hasOwnProperty('stored_customer_email') ) { 35 wpac_detect_user('wpac_detect_user', rnTransactionData.stored_customer_email); 36 } 37 38 // check if email_hash GET param is present, and create the cookie via ajax 39 let params = new URLSearchParams(document.location.search.substring(1)); 40 if (params.get('email_hash') !== null) { 41 wpac_detect_user('wpac_add_cookie_from_email_hash', params.get('email_hash')); 42 } 43 44 if (params.get('crm_id') !== null) { 45 wpac_detect_user('wpac_add_cookie_from_crm_id', params.get('crm_id')); 46 } 47});
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.