1/** 2 * Consultant join âadd productsâ browse mode (query param + session flag). 3 * Extension plugins add php_vars.idstc_join_cart_browse via the idstc_php_vars filter. 4 * Core reads only that object â no vendor-specific names here. 5 */ 6(function (w) { 7 w.idstcJoinCartBrowsePreserveContext = function () { 8 // This guard is the only thing standing between an "add products" round trip and the 9 // cart-clearing branches in app.js (replicated-site drift) and cartController.init (/order). 10 // Note the query-param source only exists on the first hop; every later page depends on the 11 // session flag, so log which source actually matched. 12 var preserveResult = false; 13 var preserveSource = 'none'; 14 var cfg = 15 typeof php_vars !== 'undefined' && php_vars && php_vars.idstc_join_cart_browse 16 ? php_vars.idstc_join_cart_browse 17 : null; 18 var qKey = cfg && cfg.queryKey != null ? String(cfg.queryKey) : ''; 19 var qVal = cfg && cfg.queryValue != null ? String(cfg.queryValue) : ''; 20 var sk = cfg && cfg.sessionKey != null ? String(cfg.sessionKey) : ''; 21 22 function reportPreserveContext() { 23 var queryParamPresent = false; 24 var sessionFlagPresent = false; 25 try { 26 var reportParams = w.location && w.location.search ? new URLSearchParams(w.location.search) : null; 27 queryParamPresent = !!(reportParams && qKey !== '' && reportParams.get(qKey) === qVal); 28 } catch (e4) {} 29 try { 30 sessionFlagPresent = !!(w.sessionStorage && sk !== '' && w.sessionStorage.getItem(sk) === '1'); 31 } catch (e5) {} 32 33 // This function gates the cart-clearing branches, so nothing in the report may throw. 34 var joinCartIdPresent = false; 35 var cartIdPresent = false; 36 try { 37 joinCartIdPresent = !!w.localStorage.getItem('JoinCartID'); 38 cartIdPresent = !!w.localStorage.getItem('CartID'); 39 } catch (e6) {} 40 41 try { 42 console.info('[Hosted Payment] Join browse preserve-context evaluated.', { 43 diagnosticVersion: '2026-07-29.3', 44 preserve: preserveResult, 45 source: preserveSource, 46 page: w.location.pathname + w.location.search, 47 configPresent: !!cfg, 48 preserveFlagEnabled: !!(cfg && cfg.preserveCartStorageOnSiteContextDrift), 49 queryParamPresent: queryParamPresent, 50 sessionFlagPresent: sessionFlagPresent, 51 replicatedSiteParamPresent: /[?&]u=/i.test(w.location.search || ''), 52 joinCartIdPresent: joinCartIdPresent, 53 cartIdPresent: cartIdPresent 54 }); 55 } catch (e7) {} 56 } 57 58 if (!cfg || !cfg.preserveCartStorageOnSiteContextDrift) { 59 preserveSource = 'disabled'; 60 reportPreserveContext(); 61 return false; 62 } 63 if (qKey !== '' && qVal !== '') { 64 try { 65 var params = w.location && w.location.search ? new URLSearchParams(w.location.search) : null; 66 if (params && params.get(qKey) === qVal) { 67 preserveResult = true; 68 preserveSource = 'queryParam'; 69 reportPreserveContext(); 70 return true; 71 } 72 } catch (e) {} 73 } 74 if (sk !== '') { 75 try { 76 if (w.sessionStorage && w.sessionStorage.getItem(sk) === '1') { 77 preserveResult = true; 78 preserveSource = 'sessionFlag'; 79 reportPreserveContext(); 80 return true; 81 } 82 } catch (e2) {} 83 } 84 try { 85 var enrollParams = w.location && w.location.search ? new URLSearchParams(w.location.search) : null; 86 if (enrollParams && enrollParams.get('checkout') === 'true') { 87 var joinId = w.localStorage.getItem('JoinCartID'); 88 var cartId = w.localStorage.getItem('CartID'); 89 if (joinId || cartId) { 90 preserveResult = true; 91 preserveSource = 'enrollmentCheckoutParam'; 92 reportPreserveContext(); 93 return true; 94 } 95 } 96 } catch (e3) {} 97 98 reportPreserveContext(); 99 return false; 100 }; 101 102 /** 103 * Append a query param once. Angular appService.makeReady and Vue AppService.makeReady 104 * both run on the same page; without coordination they can race and duplicate params (e.g. u=). 105 */ 106 w.idstcIsProtectedJoinOrderLine = function (orderLine, shoppingCartID) { 107 if (!orderLine) { 108 return false;
109 } 110 111 if (shoppingCartID != 90) { 112 return false; 113 } 114 115 var joinOptionId = orderLine.JoinOptionID != null ? orderLine.JoinOptionID : orderLine.joinOptionID; 116 return joinOptionId != null && joinOptionId !== '' && Number(joinOptionId) > 0; 117 }; 118 119 w.idstcAppendQueryParamIfMissing = function (paramName, paramValue, pathSegmentToSkip) { 120 if (paramName == null || paramName === '' || paramValue == null || paramValue === '') { 121 return; 122 } 123 124 var flagKey = 'idstcAppendedQueryParam_' + paramName; 125 if (w[flagKey]) { 126 return; 127 } 128 129 try { 130 var params = w.location && w.location.search ? new URLSearchParams(w.location.search) : null; 131 if (params && params.has(paramName)) { 132 w[flagKey] = true; 133 return; 134 } 135 } catch (e) {} 136 137 var path = w.location.pathname || ''; 138 var queryString = w.location.search || ''; 139 var newPath = path + queryString; 140 141 if (pathSegmentToSkip != null && pathSegmentToSkip !== '' && 142 newPath.toLowerCase().indexOf('/' + String(pathSegmentToSkip).toLowerCase()) !== -1) { 143 return; 144 } 145 146 w[flagKey] = true; 147 148 var appendText = paramName + '=' + paramValue; 149 appendText = queryString === '' ? '?' + appendText : '&' + appendText; 150 w.history.replaceState(null, null, newPath + appendText); 151 }; 152 153 /** 154 * Enrollment consultant-search redirect: preserve join cart storage across page bootstrap. 155 */ 156 w.idstcMarkConsultantJoinEnrollmentBeforeRedirect = function (joinCartId) { 157 var cfg = 158 typeof php_vars !== 'undefined' && php_vars && php_vars.idstc_join_cart_browse 159 ? php_vars.idstc_join_cart_browse 160 : null; 161 var sk = cfg && cfg.sessionKey != null ? String(cfg.sessionKey) : 'hlConsultantJoinShopping'; 162 try { 163 if (w.sessionStorage) { 164 w.sessionStorage.setItem(sk, '1'); 165 } 166 } catch (e) {} 167 168 if (joinCartId == null || joinCartId === '' || joinCartId === 'null') { 169 return; 170 } 171 172 try { 173 if (typeof w.idstc === 'function') { 174 w.idstc().setExpirableLocalStorageVar('JoinCartID', joinCartId); 175 w.idstc().setExpirableLocalStorageVar('CartID', joinCartId); 176 } 177 } catch (e2) {} 178 }; 179})(window);
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.