PageSourceSearch

https://lavender-badger-208247.hostingersite.com/wp-content/plugin…/main/frontend.js?ver=cc54e8deda5197daf96d

js lavender-badger-208247.hostingersite.com collected 2026-10-03 04:31:16 UTC 9,744 bytes, 66 lines download raw bytes

vendor: 678 bytes, lines 1-13
1/*
2 * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
3 * This devtool is neither made for production nor for readable output files.
4 * It uses "eval()" calls to create a separate source file in the browser devtools.
5 * If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
6 * or disable the default devtool with "devtool: false".
7 * If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
8 */
9/******/ (() => { // webpackBootstrap
10/******/ 	"use strict";
11/******/ 	var __webpack_modules__ = ({
12
13/***/ "./src/
13main/frontend.js":
14/*!******************************************!*\
15  !*** ./src/main/frontend.js + 7 modules ***!
16  \******************************************/
17/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
18
19eval("// ESM COMPAT FLAG\n__webpack_require__.r(__webpack_exports__);\n\n// EXPORTS\n__webpack_require__.d(__webpack_exports__, {\n  WtScBlocksMain: () => (/* binding */ WtScBlocksMain)\n});\n\n;// CONCATENATED MODULE: ./src/main/block.json\nconst block_namespaceObject = JSON.parse('{\"$schema\":\"https://schemas.wp.org/trunk/block.json\",\"apiVersion\":3,\"name\":\"wt-sc-blocks/main\",\"version\":\"1.0.0\",\"title\":\"Smart coupon blocks\",\"category\":\"woocommerce\",\"parent\":[\"woocommerce/checkout-fields-block\",\"woocommerce/cart-items-block\"],\"attributes\":{\"lock\":{\"type\":\"object\",\"default\":{\"remove\":true,\"move\":true}}},\"textdomain\":\"wt-smart-coupons-for-woocommerce\"}');\n;// CONCATENATED MODULE: external [\"wp\",\"data\"]\nconst external_wp_data_namespaceObject = window[\"wp\"][\"data\"];\n;// CONCATENATED MODULE: external [\"wp\",\"i18n\"]\nconst external_wp_i18n_namespaceObject = window[\"wp\"][\"i18n\"];\n;// CONCATENATED MODULE: external [\"wp\",\"htmlEntities\"]\nconst external_wp_htmlEntities_namespaceObject = window[\"wp\"][\"htmlEntities\"];\n;// CONCATENATED MODULE: external [\"wc\",\"wcBlocksData\"]\nconst external_wc_wcBlocksData_namespaceObject = window[\"wc\"][\"wcBlocksData\"];\n;// CONCATENATED MODULE: external [\"wp\",\"element\"]\nconst external_wp_element_namespaceObject = window[\"wp\"][\"element\"];\n;// CONCATENATED MODULE: external [\"wc\",\"blocksCheckout\"]\nconst external_wc_blocksCheckout_namespaceObject = window[\"wc\"][\"blocksCheckout\"];\n;// CONCATENATED MODULE: ./src/main/frontend.js\n\n\n\n\n\n\n\n\n// Global import\nconst {\n  registerCheckoutBlock,\n  registerCheckoutFilters\n} = wc.blocksCheckout;\nlet isClickBinded = false;\nconst WtScBlocksMain = () => {\n  const {\n    applyCoupon,\n    removeCoupon\n  } = (0,external_wp_data_namespaceObject.useDispatch)(external_wc_wcBlocksData_namespaceObject.CART_STORE_KEY);\n  const {\n    createErrorNotice,\n    createSuccessNotice\n  } = (0,external_wp_data_namespaceObject.useDispatch)('core/notices');\n  if (!isClickBinded) {\n    /* Set `true` for preventing multiple event binding */\n    isClickBinded = true;\n\n    /* Click event triggered by plugin public JS file */\n    document.addEventListener('wt_sc_api_coupon_clicked', function (e) {\n      const couponCode = e.detail.coupon_code;\n      const couponId = e.detail.coupon_id;\n      const context = 'wc/cart'; /* message context */\n\n      applyCoupon(couponCode).then(response => {\n        /* Trigger a custom event */\n        const coupon_click_done_event = new CustomEvent(\"wt_sc_api_coupon_click_done\", {\n          detail: {\n            'coupon_code': couponCode,\n            'coupon_id': couponId,\n            'status': true\n          }\n        });\n        document.dispatchEvent(coupon_click_done_event);\n\n        /* Show success message */\n        if ((0,external_wc_blocksCheckout_namespaceObject.applyCheckoutFilter)({\n          filterName: 'showApplyCouponNotice',\n          defaultValue: true,\n          arg: {\n            couponCode,\n            context\n          }\n        })) {\n          createSuccessNotice((0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s coupon code. */\n          (0,external_wp_i18n_namespaceObject.__)('Coupon code \"%s\" has been applied to your cart.', 'wt-smart-coupons-for-woocommerce'), couponCode), {\n            id: 'coupon-form',\n            type: 'snackbar',\n            context\n          });\n        }\n      }).catch(error => {\n        /* Trigger a custom event */\n        const coupon_click_done_event = new CustomEvent(\"wt_sc_api_coupon_click_done\", {\n          detail: {\n            'coupon_code': couponCode,\n            'coupon_id': couponId,\n            'status': false,\n            'message': error.message\n          }\n        });\n        document.dispatchEvent(coupon_click_done_event);\n\n        /** Decode HTML entities (e.g., " → \") in error messages before displaying, as WooCommerce API responses may return encoded HTML in error.message */\n        const textarea = document.createElement('textarea');\n        textarea.innerHTML = error.message;\n\n        /* Show error message */\n        createErrorNotice(textarea.value, {\n          id: 'coupon-form',\n          type: 'snackbar',\n          context\n        });\n      });\n    });\n  }\n  return '';\n};\nconst options = {\n  metadata: block_namespaceObject,\n  component: WtScBlocksMain\n};\nregisterCheckoutBlock(options);\n\n/**\n * In WooCommerce, there is an option to set up specific payments only for specific shipping methods. For example, COD is only for 'free shipping'; if the user selected a shipping method other than 'free shipping,' the 'COD' will be removed, but it's not updating the session, which affects the coupon validation check.\n Another scenario is that WooCommerce has an option set to a specific shipping method only for a specific postal code or address. When there is a change in these shipping method changes, it can also affect a change in the payment method (as mentioned in the first scenario).\n The below code is that it will update the session whenever there is a change in the payment method. \n */\n\n/** Track previous payment method */\nlet prev_payment_method = null;\n\n/** Subscribe to payment method changes */\nwp.data.subscribe(() =>
19 {\n  const currentPaymentMethod = wp.data.select('wc/store/payment').getActivePaymentMethod();\n\n  /** Only proceed if payment method has changed */\n  if (currentPaymentMethod && prev_payment_method !== currentPaymentMethod) {\n    /** Update previous payment method */\n    prev_payment_method = currentPaymentMethod;\n\n    /** Update cart with new payment method */\n    wp.data.dispatch('wc/store/cart').applyExtensionCartUpdate({\n      namespace: 'wbte-sc-blocks-update-cart-payment-session',\n      data: {\n        payment_method: currentPaymentMethod\n      }\n    });\n  }\n});\n\n/**\n * The 'itemName' filter is used to edit the product name, but here we are adding coupon blocks HTML to the cart/checkout and returning the default value (product name).\n * \n * @since 2.2.1\n */\nconst addCouponBlocksHtml = (defaultValue, extensions, args) => {\n  jQuery(document).ready(function ($) {\n    $('.wbte_sc_block_coupon_wrapper_div').remove();\n    if ('undefined' !== typeof WTSmartCouponOBJ && \"1\" === WTSmartCouponOBJ?.is_cart) {\n      $('.wp-block-woocommerce-filled-cart-block').before(`<div class=\"wbte_sc_block_coupon_wrapper_div\">${args?.cart?.extensions?.wt_sc_blocks?.coupon_blocks_cart}</div>`);\n    } else {\n      $('.wp-block-woocommerce-checkout').before(`<div class=\"wbte_sc_block_coupon_wrapper_div\">${args?.cart?.extensions?.wt_sc_blocks?.coupon_blocks_checkout}</div>`);\n    }\n  });\n  return defaultValue;\n};\nregisterCheckoutFilters('wbte-sc-cart-checkout-coupon-blocks', {\n  itemName: addCouponBlocksHtml\n});\n\n//# sourceURL=webpack://wt-sc-blocks/./src/main/frontend.js_+_7_modules?");
20
21/***/ })
vendor: 1,809 bytes, lines 21-66
21
22
23/******/ 	});
24/************************************************************************/
25/******/ 	// The require scope
26/******/ 	var __webpack_require__ = {};
27/******/ 	
28/************************************************************************/
29/******/ 	/* webpack/runtime/define property getters */
30/******/ 	(() => {
31/******/ 		// define getter functions for harmony exports
32/******/ 		__webpack_require__.d = (exports, definition) => {
33/******/ 			for(var key in definition) {
34/******/ 				if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
35/******/ 					Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
36/******/ 				}
37/******/ 			}
38/******/ 		};
39/******/ 	})();
40/******/ 	
41/******/ 	/* webpack/runtime/hasOwnProperty shorthand */
42/******/ 	(() => {
43/******/ 		__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
44/******/ 	})();
45/******/ 	
46/******/ 	/* webpack/runtime/make namespace object */
47/******/ 	(() => {
48/******/ 		// define __esModule on exports
49/******/ 		__webpack_require__.r = (exports) => {
50/******/ 			if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
51/******/ 				Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
52/******/ 			}
53/******/ 			Object.defineProperty(exports, '__esModule', { value: true });
54/******/ 		};
55/******/ 	})();
56/******/ 	
57/************************************************************************/
58/******/ 	
59/******/ 	// startup
60/******/ 	// Load entry module and return exports
61/******/ 	// This entry module can't be inlined because the eval devtool is used.
62/******/ 	var __webpack_exports__ = {};
63/******/ 	__webpack_modules__["./src/main/frontend.js"](0, __webpack_exports__, __webpack_require__);
64/******/ 	
65/******/ })()
66;

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.