vendor: 112 bytes, lines 1-5
1/******/ (() => { // webpackBootstrap 2/******/ "use strict"; 3/******/ var __webpack_modules__ = ({ 4 5/***/ "./s
5rc/js/ka-gr-checkout-block/block.js": 6/*!**********************************************!*\ 7 !*** ./src/js/ka-gr-checkout-block/block.js ***! 8 \**********************************************/ 9/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { 10 11__webpack_require__.r(__webpack_exports__); 12/* harmony export */ __webpack_require__.d(__webpack_exports__, { 13/* harmony export */ Block: () => (/* binding */ Block) 14/* harmony export */ }); 15/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react"); 16/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__); 17/* harmony import */ var _wordpress_api_fetch__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/api-fetch */ "@wordpress/api-fetch"); 18/* harmony import */ var _wordpress_api_fetch__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_api_fetch__WEBPACK_IMPORTED_MODULE_1__); 19/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @wordpress/element */ "@wordpress/element"); 20/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_2__); 21 22/** 23 * External dependencies 24 */ 25 26 27console.log(kgr_php_vars.checkout.title); 28const Block = ({ 29 checkoutExtensionData 30}) => { 31 const { 32 setExtensionData 33 } = checkoutExtensionData; 34 const [isReCaptchaValid, setIsReCaptchaValid] = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_2__.useState)(false); // For checkout reCAPTCHA 35 const [isReCaptchaPaymentValid, setIsReCaptchaPaymentValid] = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_2__.useState)(false); // For payment reCAPTCHA 36 const isCheckoutEnabled = kgr_php_vars.checkout; 37 const isPaymentEnabled = kgr_php_vars.payment; 38 if (isCheckoutEnabled) { 39 var KgrSiteKey = kgr_php_vars.checkout.google_recapta_site_key; 40 var KgrTitle = kgr_php_vars.checkout.title; 41 var KaThemeColor = kgr_php_vars.checkout.themeColor; 42 var KaSize = kgr_php_vars.checkout.size; 43 var KaCapchaPosition = kgr_php_vars.checkout.ka_captcha_position; 44 var dynamicCallback = kgr_php_vars.checkout.dynamicCallback; 45 var ka_grc_classes = kgr_php_vars.checkout.ka_grc_classes; 46 } 47 if (isPaymentEnabled) { 48 var KgrSiteKeyPayment = kgr_php_vars.payment.google_recapta_site_key; 49 var KgrPaymentTitle = kgr_php_vars.payment.title; 50 var KaPaymentThemeColor = kgr_php_vars.payment.themeColor; 51 var KaPaymentSize = kgr_php_vars.payment.size; 52 var KaPaymentCapchaPosition = kgr_php_vars.payment.ka_captcha_position; 53 var PaymentdynamicCallback = kgr_php_vars.payment.dynamicCallback; 54 var ka_Payment_classes = kgr_php_vars.payment.ka_grc_classes; 55 } 56 if (!isCheckoutEnabled && !isPaymentEnabled) { 57 return null; 58 } 59 // Ensure WooCommerce Checkout Block spacing is not overridden by logical margin styles. 60 (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_2__.useEffect)(() => { 61 const style = document.createElement('style'); 62 style.textContent = '.kl-ga-main-wrap { margin: 0 0 20px !important; margin-bottom: 20px !important; margin-block-end: 20px !important; }'; 63 document.head.appendChild(style); 64 return () => style.remove(); 65 }, []); 66 (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_2__.useEffect)(() => { 67 if (isCheckoutEnabled) { 68 const $captchaWrap = jQuery('.kl-ga-main-wrap'); 69 jQuery('.kl-ga-main-wrap').not($captchaWrap.first()).remove(); 70 71 // Proceed only if it exists 72 if ($captchaWrap.length === 0) return; 73 setTimeout(() => { 74 switch (KaCapchaPosition) { 75 case 'woocommerce_checkout_before_customer_details': 76 jQuery('.kl-ga-main-wrap').insertBefore('.wc-block-checkout__use-address-for-billing'); 77 jQuery('.kl-ga-main-wrap').css("width", "100%"); 78 break; 79 case 'woocommerce_before_checkout_billing_form': 80 jQuery('.kl-ga-main-wrap').insertBefore('.wp-block-woocommerce-checkout-contact-information-block'); 81 break; 82 case 'woocommerce_before_order_notes': 83 jQuery('.kl-ga-main-wrap').insertBefore('.wc-block-checkout__order-notes'); 84 break; 85 case 'woocommerce_after_order_notes': 86 jQuery('.kl-ga-main-wrap').insertAfter('.wc-block-checkout__order-notes'); 87 break; 88 case 'woocommerce_review_order_before_payment': 89 jQuery('.kl-ga-main-wrap').insertBefore('.wc-block-checkout__payment-method'); 90 break; 91 case 'woocommerce_review_order_before_submit': 92 jQuery('.kl-ga-main-wrap').insertBefore('.wp-block-woocommerce-checkout-actions-block'); 93 break; 94 case 'woocommerce_review_order_after_submit': 95 jQuery('.kl-ga-main-wrap').insertAfter('.wp-block-woocommerce-checkout-actions-block'); 96 break; 97 default: 98 jQuery('.kl-ga-main-wrap').insertBefore('.wp-block-woocommerce-checkout-actions-block'); 99 } 100 }, 1000); 101 } 102 if (isPaymentEnabled) { 103 setTimeout(() => { 104 jQuery('.kl-ga-payment-wrap').insertBefore('.wc-block-checkout__payment-method'); 105 }, 1000); 106 } 107 }, [KaCapchaPosition, isPaymentEnabled, isCheckoutEnabled]); 108 109 // Render the reCAPTCHA widgets 110 (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_2__.useEffect)(() => { 111 const renderReCaptcha = () => { 112 if (window.grecaptcha) { 113 // Render checkout reCAPTCHA 114 if (isCheckoutEnabled && !document.getElementById("kl-ga-main-wrap").childElementCount) { 115 window.grecaptcha.render('kl-ga-main-wrap', { 116 sitekey: KgrSiteKey, 117 theme: KaThemeColor, 118 size: KaSize, 119 callback: onCheckoutReCaptchaSuccess, 120 'expired-callback': onCheckoutReCaptchaExpired 121 }); 122 } 123 124 // Render payment reCAPTCHA 125 if (isPaymentEnabled && !document.getElementById("kl-ga-payment-wrap").childElementCount) { 126 window.grecaptcha.render('kl-ga-payment-wrap', { 127 sitekey: KgrSiteKeyPayment, 128 theme: KaPaymentThemeColor, 129 size: KaPaymentSize, 130 callback: onPaymentReCaptchaSuccess, 131 'expired-callback': onPaymentReCaptchaExpired 132 }); 133 } 134 } 135 }; 136 137 // Load reCAPTCHA script 138 const script = document.createElement('script'); 139 script.src = 'https://www.google.com/recaptcha/api.js?onload=onReCaptchaLoad&render=explicit'; 140 script.async = true; 141 script.defer = true; 142 document.body.appendChild(script); 143 window.onReCaptchaLoad = renderReCaptcha; 144 145 // Cleanup 146 return () => { 147 document.body.removeChild(script); 148 delete window.onReCaptchaLoad; 149 }; 150 }, [isCheckoutEnabled, isPaymentEnabled]); 151 152 // Handle success for checkout reCAPTCHA 153 const onCheckoutReCaptchaSuccess = response => { 154 setIsReCaptchaValid(true); 155 setExtensionData('kgr_google_recaptcha', 'kgr_checkout_recaptcha', response); 156 }; 157 158 // Handle expiration for checkout reCAPTCHA 159 const onCheckoutReCaptchaExpired = () => { 160 setIsReCaptchaValid(false); 161 setExtensionData('kgr_google_recaptcha', 'kgr_checkout_recaptcha', ''); 162 }; 163 164 // Handle success for payment reCAPTCHA 165 const onPaymentReCaptchaSuccess = response => { 166 setIsReCaptchaPaymentValid(true); 167 setExtensionData('kgr_google_recaptcha', 'kgr_payment_recaptcha', response); 168 const payemnt_place_order = document.querySelector('.wc-block-components-checkout-place-order-button'); 169 setTimeout(() => { 170 var paymentcookies = getCookieBlock('ka_button_disabled_until'); 171 if (paymentcookies) { 172 payemnt_place_order.disabled = true; 173 } 174 }, 2000); 175 }; 176 177 // Handle expiration for payment reCAPTCHA 178 const onPaymentReCaptchaExpired = () => { 179 setIsReCaptchaPaymentValid(false); 180 setExtensionData('kgr_google_recaptcha', 'kgr_payment_recaptcha', ''); 181 }; 182 183 // Disable/enable payment methods and Place Order button 184 (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_2__.useEffect)(() => { 185 setTimeout(() => { 186 const placeOrderButton = document.querySelector('.wc-block-components-checkout-place-order-button'); 187 const paymentRadioButtons = document.querySelectorAll('.wc-block-components-radio-control-accordion-option input[type="radio"]'); 188 const paymentRadioButtonsShipping = document.querySelectorAll('.wc-block-components-shipping-rates-control input[type="radio"]'); 189 190 // Disable/enable Place Order button based on checkout reCAPTCHA 191 if (placeOrderButton) { 192 placeOrderButton.disabled = isCheckoutEnabled && !isReCaptchaValid; 193 } 194 195 // Disable/enable payment methods based on payment reCAPTCHA 196 if (isPaymentEnabled && paymentRadioButtons.length > 0 || paymentRadioButtonsShipping > 0) { 197 paymentRadioButtons.forEach(radio => { 198 radio.disabled = !isReCaptchaPaymentValid; 199 }); 200 paymentRadioButtonsShipping.forEach(radio => { 201 radio.disabled = !isReCaptchaPaymentValid; 202 }); 203 } 204 }, 1000); 205 }, [isReCaptchaValid, isReCaptchaPaymentValid, isPaymentEnabled, isCheckoutEnabled]); 206 207 // Attach click event for Place Order button to send reCAPTCHA responses 208 (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_2__.useEffect)(() => { 209 const placeOrderButton = document.querySelector('.wc-block-components-checkout-place-order-button'); 210 const handlePlaceOrderClick = () => {
211 const checkoutResponse = window.grecaptcha?.getResponse(0); // Get checkout reCAPTCHA response 212 const paymentResponse = window.grecaptcha?.getResponse(1); // Get payment reCAPTCHA response 213 214 setExtensionData('kgr_google_recaptcha', 'kgr_checkout_recaptcha', checkoutResponse || ''); 215 setExtensionData('kgr_google_recaptcha', 'kgr_payment_recaptcha', paymentResponse || ''); 216 }; 217 if (placeOrderButton) { 218 placeOrderButton.addEventListener('click', handlePlaceOrderClick); 219 } 220 return () => { 221 if (placeOrderButton) { 222 placeOrderButton.removeEventListener('click', handlePlaceOrderClick); 223 } 224 }; 225 }, []); 226 227 // Attach click event for Place Order button to send reCAPTCHA responses 228 (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_2__.useEffect)(() => { 229 const placeCheckoutButton = document.querySelector('.wp-block-woocommerce-checkout'); 230 const handleCheckoutClick = () => { 231 if (jQuery('.kl-ga-inner-wrap').length) { 232 setTimeout(function () { 233 const paymentDefuatOrderButton = document.querySelector('.wc-block-components-checkout-place-order-button'); 234 if (!isReCaptchaValid) { 235 paymentDefuatOrderButton.disabled = isCheckoutEnabled && !isReCaptchaValid; 236 } 237 }, 2000); 238 } 239 setTimeout(function () { 240 const defaultPlaceOrderButton = document.querySelector('.wc-block-components-checkout-place-order-button'); 241 var paymentdisabledUntil = getCookieBlock('ka_button_disabled_until'); 242 if (paymentdisabledUntil) { 243 defaultPlaceOrderButton.disabled = true; 244 } 245 }, 2000); 246 }; 247 if (placeCheckoutButton) { 248 placeCheckoutButton.addEventListener('click', handleCheckoutClick); 249 } 250 return () => { 251 if (placeCheckoutButton) { 252 placeCheckoutButton.removeEventListener('click', handleCheckoutClick); 253 } 254 }; 255 }, [isReCaptchaValid]); 256 (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_2__.useEffect)(() => { 257 setTimeout(function () { 258 const placeOrderButton = document.querySelector('.wc-block-components-checkout-place-order-button'); 259 const disabledUntil = getCookieBlock('ka_button_disabled_until'); 260 const isCheckoutPage = document.querySelector('.woo_checkout'); 261 if (placeOrderButton) { 262 if (disabledUntil) { 263 placeOrderButton.disabled = true; 264 } else { 265 if (isCheckoutPage) { 266 placeOrderButton.disabled = !isReCaptchaValid; 267 } 268 } 269 } 270 }, 2000); 271 }, [isReCaptchaValid]); 272 function getCookieBlock(cookieName) { 273 const name = cookieName + "="; 274 const decodedCookies = decodeURIComponent(document.cookie); 275 const cookieArray = decodedCookies.split(';'); 276 for (let i = 0; i < cookieArray.length; i++) { 277 let cookie = cookieArray[i].trim(); 278 if (cookie.indexOf(name) === 0) { 279 return cookie.substring(name.length, cookie.length); 280 } 281 } 282 return null; // Return null if the cookie does not exist 283 } 284 return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(react__WEBPACK_IMPORTED_MODULE_0__.Fragment, null, isCheckoutEnabled && (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { 285 className: "kl-ga-main-wrap" 286 }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("label", { 287 className: "kgr_title" 288 }, KgrTitle), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { 289 id: "kl-ga-main-wrap", 290 className: `kl-ga-inner-wrap ${ka_grc_classes}` 291 })), isPaymentEnabled && (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { 292 className: "kl-ga-payment-wrap" 293 }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("label", { 294 className: "kgr_payment_title" 295 }, KgrPaymentTitle), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { 296 id: "kl-ga-payment-wrap", 297 className: `kl-ga-inner-wrap ${ka_Payment_classes}` 298 }))); 299}; 300 301/***/ }), 302 303/***/ "react": 304/*!************************!*\ 305 !*** external "React" ***! 306 \************************/ 307/***/ ((module) => { 308 309module.exports = window["React"]; 310 311/***/ }), 312 313/***/ "@woocommerce/blocks-checkout": 314/*!****************************************!*\
315 !*** external ["wc","blocksCheckout"] ***! 316 \****************************************/ 317/***/ ((module) => { 318 319module.exports = window["wc"]["blocksCheckout"]; 320 321/***/ }), 322 323/***/ "@wordpress/api-fetch": 324/*!**********************************!*\ 325 !*** external ["wp","apiFetch"] ***! 326 \**********************************/ 327/***/ ((module) => { 328 329module.exports = window["wp"]["apiFetch"]; 330 331/***/ }), 332 333/***/ "@wordpress/element": 334/*!*********************************!*\ 335 !*** external ["wp","element"] ***! 336 \*********************************/ 337/***/ ((module) => { 338 339module.exports = window["wp"]["element"]; 340 341/***/ }), 342
343/***/ "./src/js/ka-gr-checkout-block/block.json": 344/*!************************************************!*\ 345 !*** ./src/js/ka-gr-checkout-block/block.json ***! 346 \************************************************/ 347/***/ ((module) => { 348 349module.exports = /*#__PURE__*/JSON.parse('{"apiVersion":2,"name":"ka-gr-checkout-block/ka_gr_checkout_block","version":"1.0.0","category":"woocommerce","supports":{"html":false,"align":false,"multiple":false,"reusable":false},"parent":["woocommerce/checkout-order-summary-block"],"attributes":{"lock":{"type":"object","default":{"remove":true,"move":true}},"text":{"type":"string","default":""}},"textdomain":"recaptcha_verification"}'); 350 351/***/ })
vendor: 4,087 bytes, lines 351-449
351 352 353/******/ }); 354/************************************************************************/ 355/******/ // The module cache 356/******/ var __webpack_module_cache__ = {}; 357/******/ 358/******/ // The require function 359/******/ function __webpack_require__(moduleId) { 360/******/ // Check if module is in cache 361/******/ var cachedModule = __webpack_module_cache__[moduleId]; 362/******/ if (cachedModule !== undefined) { 363/******/ return cachedModule.exports; 364/******/ } 365/******/ // Create a new module (and put it into the cache) 366/******/ var module = __webpack_module_cache__[moduleId] = { 367/******/ // no module.id needed 368/******/ // no module.loaded needed 369/******/ exports: {} 370/******/ }; 371/******/ 372/******/ // Execute the module function 373/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); 374/******/ 375/******/ // Return the exports of the module 376/******/ return module.exports; 377/******/ } 378/******/ 379/************************************************************************/ 380/******/ /* webpack/runtime/compat get default export */ 381/******/ (() => { 382/******/ // getDefaultExport function for compatibility with non-harmony modules 383/******/ __webpack_require__.n = (module) => { 384/******/ var getter = module && module.__esModule ? 385/******/ () => (module['default']) : 386/******/ () => (module); 387/******/ __webpack_require__.d(getter, { a: getter }); 388/******/ return getter; 389/******/ }; 390/******/ })(); 391/******/ 392/******/ /* webpack/runtime/define property getters */ 393/******/ (() => { 394/******/ // define getter functions for harmony exports 395/******/ __webpack_require__.d = (exports, definition) => { 396/******/ for(var key in definition) { 397/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { 398/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); 399/******/ } 400/******/ } 401/******/ }; 402/******/ })(); 403/******/ 404/******/ /* webpack/runtime/hasOwnProperty shorthand */ 405/******/ (() => { 406/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) 407/******/ })(); 408/******/ 409/******/ /* webpack/runtime/make namespace object */ 410/******/ (() => { 411/******/ // define __esModule on exports 412/******/ __webpack_require__.r = (exports) => { 413/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { 414/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); 415/******/ } 416/******/ Object.defineProperty(exports, '__esModule', { value: true }); 417/******/ }; 418/******/ })(); 419/******/ 420/************************************************************************/ 421var __webpack_exports__ = {}; 422// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk. 423(() => { 424/*!*************************************************!*\ 425 !*** ./src/js/ka-gr-checkout-block/frontend.js ***! 426 \*************************************************/ 427__webpack_require__.r(__webpack_exports__); 428/* harmony import */ var _woocommerce_blocks_checkout__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @woocommerce/blocks-checkout */ "@woocommerce/blocks-checkout"); 429/* harmony import */ var _woocommerce_blocks_checkout__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_woocommerce_blocks_checkout__WEBPACK_IMPORTED_MODULE_0__); 430/* harmony import */ var _block__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./block */ "./src/js/ka-gr-checkout-block/block.js"); 431/* harmony import */ var _block_json__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./block.json */ "./src/js/ka-gr-checkout-block/block.json"); 432/** 433 * External dependencies 434 */ 435 436/** 437 * Internal dependencies 438 */ 439 440 441(0,_woocommerce_blocks_checkout__WEBPACK_IMPORTED_MODULE_0__.registerCheckoutBlock)({ 442 metadata: _block_json__WEBPACK_IMPORTED_MODULE_2__, 443 component: _block__WEBPACK_IMPORTED_MODULE_1__.Block 444}); 445})(); 446 447/******/ })() 448; 449//# sourceMappingURL=ka-gr-checkout-block-frontend.js.map
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.