1/******/ (() => { // webpackBootstrap 2/******/ "use strict"; 3/******/ var __webpack_modules__ = ({ 4 5/***/ "react/jsx-runtime": 6/*!**********************************!*\ 7 !*** external "ReactJSXRuntime" ***! 8 \**********************************/ 9/***/ ((module) => { 10 11module.exports = window["ReactJSXRuntime"]; 12 13/***/ }) 14 15/******/ }); 16/************************************************************************/ 17/******/ // The module cache 18/******/ var __webpack_module_cache__ = {}; 19/******/ 20/******/ // The require function 21/******/ function __webpack_require__(moduleId) { 22/******/ // Check if module is in cache 23/******/ var cachedModule = __webpack_module_cache__[moduleId]; 24/******/ if (cachedModule !== undefined) { 25/******/ return cachedModule.exports; 26/******/ } 27/******/ // Create a new module (and put it into the cache) 28/******/ var module = __webpack_module_cache__[moduleId] = { 29/******/ // no module.id needed 30/******/ // no module.loaded needed 31/******/ exports: {} 32/******/ }; 33/******/ 34/******/ // Execute the module function 35/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); 36/******/ 37/******/ // Return the exports of the module 38/******/ return module.exports; 39/******/ } 40/******/ 41/************************************************************************/ 42/******/ /* webpack/runtime/compat get default export */ 43/******/ (() => { 44/******/ // getDefaultExport function for compatibility with non-harmony modules 45/******/ __webpack_require__.n = (module) => { 46/******/ var getter = module && module.__esModule ? 47/******/ () => (module['default']) : 48/******/ () => (module); 49/******/ __webpack_require__.d(getter, { a: getter }); 50/******/ return getter; 51/******/ }; 52/******/ })(); 53/******/ 54/******/ /* webpack/runtime/define property getters */ 55/******/ (() => { 56/******/ // define getter functions for harmony exports 57/******/ __webpack_require__.d = (exports, definition) => { 58/******/ for(var key in definition) { 59/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { 60/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); 61/******/ } 62/******/ } 63/******/ }; 64/******/ })(); 65/******/ 66/******/ /* webpack/runtime/hasOwnProperty shorthand */ 67/******/ (() => { 68/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) 69/******/ })(); 70/******/ 71/******/ /* webpack/runtime/make namespace object */ 72/******/ (() => { 73/******/ // define __esModule on exports 74/******/ __webpack_require__.r = (exports) => { 75/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { 76/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); 77/******/ } 78/******/ Object.defineProperty(exports, '__esModule', { value: true }); 79/******/ }; 80/******/ })(); 81/******/ 82/************************************************************************/ 83var __webpack_exports__ = {}; 84// This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk. 85(() => { 86/*!**********************************!*\ 87 !*** ./assets/blocks/blocks.jsx ***! 88 \**********************************/ 89__webpack_require__.r(__webpack_exports__); 90/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react/jsx-runtime */ "react/jsx-runtime"); 91/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__); 92 93/* global wc, wp */ 94(() => { 95 // Bail if Blocks globals arenât present 96 if (!window.wp || !window.wc) return; 97 const { 98 __, 99 sprintf 100 } = wp.i18n || { 101 __: s => s, 102 sprintf: s => s 103 }; 104 const { 105 registerPlugin 106 } = wp.plugins; 107 const { 108 Notice 109 } = wp.components; 110 const { 111 useState 112 } = wp.element; 113 const { 114 useDispatch, 115 useSelect 116 } = wp.data; 117 118 // Woo Blocks slot and helpers 119 const blocksCheckout = wc.blocksCheckout || wc.blocks || {}; 120 const { 121 ExperimentalOrderMeta, 122 extensionCartUpdate 123 } = blocksCheckout || {}; 124 125 // Cart data store key 126 const cartStore = wc.wcBlocksData && wc.wcBlocksData.cartStore || 'wc/store/cart'; 127 if (!ExperimentalOrderMeta || !useDispatch || !useSelect) return; 128 129 // Store API extensions namespace 130 const NAMESPACE = 'pw-gift-cards'; 131 const ApplyGiftCard = () => { 132 const [code, setCode] = useState(''); 133 const [isSubmitting, setIsSubmitting] = useState(false); 134 const [notice, setNotice] = useState(null); 135 136 // Get full cart data so we can read our extension data 137 const cartData = useSelect(select => { 138 const s = select(cartStore); 139 return s && s.getCartData ? s.getCartData() : null; 140 }, []); 141 142 // Applied gift cards coming from the Store API extensions payload 143 const giftCards = cartData && cartData.extensions && cartData.extensions[NAMESPACE] && cartData.extensions[NAMESPACE].gift_cards || []; 144 const submit = async () => { 145 if (!code) { 146 setNotice({ 147 status: 'error', 148 message: __('Enter a gift card code.', 'pw-woocommerce-gift-cards') 149 }); 150 return; 151 } 152 setIsSubmitting(true); 153 setNotice(null);
154 try { 155 await extensionCartUpdate({ 156 namespace: NAMESPACE, 157 data: { 158 code 159 } 160 }); 161 setCode(''); 162 } catch (err) { 163 setNotice({ 164 status: 'error', 165 message: err?.message || __('Something went wrong.', 'pw-woocommerce-gift-cards') 166 }); 167 } finally { 168 setIsSubmitting(false); 169 } 170 }; 171 const handleRemove = async cardNumber => { 172 setIsSubmitting(true); 173 setNotice(null); 174 try { 175 await extensionCartUpdate({ 176 namespace: NAMESPACE, 177 data: { 178 code: cardNumber, 179 remove: true 180 } 181 }); 182 } catch (err) { 183 setNotice({ 184 status: 'error', 185 message: err?.message || __('Unable to remove gift card.', 'pw-woocommerce-gift-cards') 186 }); 187 } finally { 188 setIsSubmitting(false); 189 } 190 }; 191 return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(ExperimentalOrderMeta, { 192 children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", { 193 id: "pwgc-redeem-gift-card-container", 194 children: [giftCards.length > 0 && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", { 195 className: "pwgc-applied-gift-cards", 196 children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("div", { 197 className: "pwgc-applied-gift-cards-title", 198 children: __('Gift cards applied', 'pw-woocommerce-gift-cards') 199 }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("ul", { 200 className: "pwgc-applied-gift-cards-list", 201 children: giftCards.map(card => /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("li", { 202 className: "pwgc-applied-gift-cards-item", 203 children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", { 204 className: "pwgc-applied-gift-cards-left", 205 children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("div", { 206 className: "pwgc-gift-card-number", 207 children: card.number 208 }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("div", { 209 className: "pwgc-gift-card-remaining-balance", 210 children: card.balance && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("div", { 211 className: "pwgc-gift-card-balance", 212 children: sprintf(__('Remaining balance is %s', 'pw-woocommerce-gift-cards'), card.balance) 213 }) 214 })] 215 }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("div", { 216 className: "pwgc-applied-gift-cards-right", 217 children: card.amount && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("span", { 218 className: "pwgc-gift-card-amount", 219 children: [card.amount, /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("button", { 220 type: "button", 221 className: "pwgc-remove-gift-card", 222 onClick: () => handleRemove(card.number), 223 "aria-label": sprintf(__('Remove gift card %s', 'pw-woocommerce-gift-cards'), card.number), 224 disabled: isSubmitting, 225 children: "\xD7" 226 })] 227 }) 228 })] 229 }, card.number)) 230 })] 231 }), !window.pwgcBlocks.hideRedeemForm && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("form", { 232 id: "pwgc-redeem-gift-card-form", 233 onSubmit: e => { 234 e.preventDefault(); 235 submit(); 236 }, 237 noValidate: true, 238 children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("label", { 239 htmlFor: "pwgc-redeem-gift-card-number", 240 children: __('Have a gift card?', 'pw-woocommerce-gift-cards') 241 }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("input", { 242 id: "pwgc-redeem-gift-card-number", 243 type: "text", 244 value: code, 245 onChange: e => setCode(e.target.value), 246 placeholder: __('Gift card number', 'pw-woocommerce-gift-cards'), 247 "aria-label": __('Gift card number', 'pw-woocommerce-gift-cards'), 248 disabled: isSubmitting 249 }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("button", { 250 type: "submit", 251 className: `pwgc-apply-gift-card-button wc-block-components-button ${isSubmitting ? 'is-loading' : ''}`, 252 disabled: isSubmitting, 253 "aria-busy": isSubmitting, 254 children: __('Apply Gift Card', 'pw-woocommerce-gift-cards') 255 }), notice && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(Notice, { 256 status: notice.status, 257 isDismissible: false, 258 children: notice.message 259 })] 260 })] 261 }) 262 }); 263 }; 264 265 // Register for both checkout and cart scopes 266 registerPlugin('pw-apply-gift-card-checkout', { 267 render: ApplyGiftCard, 268 scope: 'woocommerce-checkout' 269 }); 270 registerPlugin('pw-apply-gift-card-cart', { 271 render: ApplyGiftCard, 272 scope: 'woocommerce-cart' 273 }); 274})(); 275})(); 276 277/******/ })() 278; 279//# sourceMappingURL=blocks.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.