1(async () => { 2 // Append international checkout button 3 const observer = new MutationObserver(() => { 4 document.querySelectorAll(args.domesticCheckoutButtonSelector).forEach((button) => { 5 if (button.hasAttribute("zonos-int-btn-attached")) { 6 return; 7 } 8 if (args?.secondCheckoutButtonToggle) { 9 const intBtn = document.createElement("button"); 10 intBtn.textContent = 11 args?.internationalCheckoutButtonText || "International Checkout"; 12 intBtn.disabled = true; 13 if (args?.internationalCheckoutButtonCssStyle) { 14 intBtn.style.cssText = args.internationalCheckoutButtonCssStyle; 15 } else { 16 intBtn.classList.add("zonos-international-checkout-button"); 17 } 18 intBtn.classList.add("zonos-checkout-button"); 19 20 button.setAttribute("zonos-int-btn-attached", "true"); 21 button.insertAdjacentElement("beforebegin", intBtn); 22 } else { 23 button.classList.add("zonos-checkout-button"); 24 } 25 }); 26 }); 27 28 // Initialize Zonos 29 function initZonos() { 30 if (Zonos && args?.apiKey && args?.storeId) { 31 Zonos.init({ 32 zonosApiKey: args.apiKey, 33 storeId: parseInt(args.storeId), 34 checkoutSettings: { 35 placeOrderButtonSelector: args.secondCheckoutButtonToggle ? ".zonos-checkout-button" : args.domesticCheckoutButtonSelector, 36 createCartId: async () => { 37 const response = await fetch(ZonosAjax.ajax_url, { 38 method: "POST", 39 headers: { 40 "Content-Type": "application/x-www-form-urlencoded", 41 }, 42 body: new URLSearchParams({ 43 action: "zonosch_get_cart", 44 _ajax_nonce: ZonosAjax.nonce, 45 }), 46 }); 47 48 if (!response.ok) { 49 console.error( 50 "Network response was not ok:", 51 response.statusText 52 ); 53 return; 54 } 55 56 return await response.json(); 57 }, 58 onOrderSuccess: async ({zonosOrder}) => { 59 return await fetch(ZonosAjax.ajax_url, { 60 method: "POST", 61 headers: { 62 "Content-Type": "application/x-www-form-urlencoded", 63 }, 64 body: new URLSearchParams({ 65 action: "zonosch_store_order", 66 orderId: zonosOrder.id, 67 nonce: args.nonce, 68 }), 69 }); 70 }, 71 onInventoryCheck: async (items) => { 72 const response = await fetch(ZonosAjax.ajax_url, { 73 method: "POST", 74 headers: { 75 "Content-Type": "application/x-www-form-urlencoded", 76 }, 77 body: new URLSearchParams({ 78 action: "zonosch_check_inventory", 79 nonce: args.nonce, 80 }), 81 }); 82 const itemsOutOfStock = await response.json(); 83 if (itemsOutOfStock.length === 1) { 84 return `${itemsOutOfStock[0].product_name} is out of stock.`; 85 } else if (itemsOutOfStock.length > 1) { 86 const productNames = itemsOutOfStock.map(item => item.product_name).join(', '); 87 return `The following products are out of stock: ${productNames}.`; 88 } 89 } 90 }, 91 }); 92 } else { 93 if (!Zonos) { 94 console.error("There was an error loading the integration scripts"); 95 } 96 97 if (!args?.apiKey || !args?.storeId) { 98 console.error("There was an error reading the plugin settings"); 99 } 100 } 101 } 102 103 document.addEventListener("DOMContentLoaded", () => { 104 if (args?.domesticCheckoutButtonSelector) { 105 observer.observe(document.body, { 106 childList: true, 107 subtree: true, 108 }); 109 } 110 111 initZonos(); 112 }); 113})();
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.