1(async () => { 2 const appInterval = setInterval(() => { 3 if (!window.args) return; 4 clearInterval(appInterval); 5 initZonos(); 6 }, 100); 7 8 function initZonos() { 9 if (Zonos && args?.apiKey && args?.storeId) { 10 Zonos.init({ 11 zonosApiKey: args.apiKey, 12 storeId: parseInt(args.storeId), 13 checkoutSettings: { 14 createCartId: async () => { 15 const response = await fetch("/wp-admin/admin-ajax.php", { 16 method: "POST", 17 headers: { 18 "Content-Type": "application/x-www-form-urlencoded", 19 }, 20 body: new URLSearchParams({ 21 action: "zonos_get_cart", 22 }), 23 }); 24 25 if (!response.ok) { 26 console.error( 27 "Network response was not ok:", 28 response.statusText 29 ); 30 return; 31 } 32 33 return await response.json(); 34 }, 35 onOrderSuccess: async ({zonosOrder}) => { 36 return await fetch("/wp-admin/admin-ajax.php", { 37 method: "POST", 38 headers: { 39 "Content-Type": "application/x-www-form-urlencoded", 40 }, 41 body: new URLSearchParams({ 42 action: "zonos_store_order", 43 orderId: zonosOrder.id, 44 nonce: args.nonce, 45 }), 46 }); 47 }, 48 }, 49 }); 50 } else { 51 if (!Zonos) { 52 console.error("There was an error loading the integration scripts"); 53 } 54 55 if (!args?.apiKey || !args?.storeId) { 56 console.error("There was an error reading the plugin settings"); 57 } 58 } 59 } 60 61 const urlParams = new URLSearchParams(window.location.search); 62 const zCountry = urlParams.get("zCountry"); 63 let country; 64 65 try { 66 country = sessionStorage.getItem("zonos--country") || zCountry; 67 } catch (e) { 68 country = zCountry; 69 } 70 71 const isDomestic = country === args?.domesticCountry; 72 73 if (args?.checkoutButtonSelector && !isDomestic) { 74 setInterval(() => { 75 awaitCheckout(args.checkoutButtonSelector); 76 }, 100); 77 } 78 79 function awaitCheckout(buttonSelector) { 80 if (buttonSelector) { 81 const checkoutButtons = document.querySelectorAll(buttonSelector); 82 checkoutButtons.forEach((button) => { 83 if (button.hasAttribute("zonos-listener")) { 84 return; 85 } 86 button.setAttribute("zonos-listener", "true"); 87 button.addEventListener("click", (e) => { 88 e.preventDefault(); 89 e.stopPropagation(); 90 triggerCheckoutOnZonosLoad(button); 91 }); 92 }); 93 } 94 } 95 96 const triggerCheckoutOnZonosLoad = (button) => { 97 const interval = setInterval(() => { 98 if (Zonos) { 99 clearInterval(interval); 100 button.click(); 101 } 102 }, 100); 103 }; 104})();
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.