Changeset 3195809
- Timestamp:
- 11/24/2024 10:54:54 AM (16 months ago)
- Location:
- ambikly
- Files:
-
- 30 edited
- 1 copied
-
tags/0.0.8 (copied) (copied from ambikly/trunk)
-
tags/0.0.8/ambikly.php (modified) (2 diffs)
-
tags/0.0.8/assets/admin/css/dashboard-style.css (modified) (2 diffs)
-
tags/0.0.8/assets/admin/css/dashboard-style.css.map (modified) (1 diff)
-
tags/0.0.8/assets/js/checkout-script.js (modified) (1 diff)
-
tags/0.0.8/assets/js/checkout-script.js.map (modified) (1 diff)
-
tags/0.0.8/changelog.txt (modified) (1 diff)
-
tags/0.0.8/languages/ambikly.pot (modified) (3 diffs)
-
tags/0.0.8/readme.txt (modified) (2 diffs)
-
tags/0.0.8/src/Admin/Pages/DashboardPage.php (modified) (1 diff)
-
tags/0.0.8/src/Assets.php (modified) (3 diffs)
-
tags/0.0.8/src/Controllers/CheckoutController.php (modified) (1 diff)
-
tags/0.0.8/src/Forms/CheckoutForm.php (modified) (2 diffs)
-
tags/0.0.8/src/Gateways/PayPal/PayPal.php (modified) (1 diff)
-
tags/0.0.8/src/Gateways/PayPal/Settings.php (modified) (1 diff)
-
tags/0.0.8/src/Shortcodes/CheckoutShortcode.php (modified) (1 diff)
-
trunk/ambikly.php (modified) (2 diffs)
-
trunk/assets/admin/css/dashboard-style.css (modified) (2 diffs)
-
trunk/assets/admin/css/dashboard-style.css.map (modified) (1 diff)
-
trunk/assets/js/checkout-script.js (modified) (1 diff)
-
trunk/assets/js/checkout-script.js.map (modified) (1 diff)
-
trunk/changelog.txt (modified) (1 diff)
-
trunk/languages/ambikly.pot (modified) (3 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/src/Admin/Pages/DashboardPage.php (modified) (1 diff)
-
trunk/src/Assets.php (modified) (3 diffs)
-
trunk/src/Controllers/CheckoutController.php (modified) (1 diff)
-
trunk/src/Forms/CheckoutForm.php (modified) (2 diffs)
-
trunk/src/Gateways/PayPal/PayPal.php (modified) (1 diff)
-
trunk/src/Gateways/PayPal/Settings.php (modified) (1 diff)
-
trunk/src/Shortcodes/CheckoutShortcode.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
ambikly/tags/0.0.8/ambikly.php
r3186894 r3195809 6 6 * Author: ambikly 7 7 * Author URI: https://profiles.wordpress.org/ambikly 8 * Version: 0.0. 78 * Version: 0.0.8 9 9 * License: GPLv3+ 10 10 * License URI: https://www.gnu.org/licenses/gpl-3.0.html … … 28 28 // Define AMBIKLY_VERSION. 29 29 if (!defined('AMBIKLY_VERSION')) { 30 define('AMBIKLY_VERSION', '0.0. 7');30 define('AMBIKLY_VERSION', '0.0.8'); 31 31 } 32 32 -
ambikly/tags/0.0.8/assets/admin/css/dashboard-style.css
r3184536 r3195809 17 17 justify-content: space-between; 18 18 margin-bottom: 20px; 19 gap: 20px; 19 20 } 20 21 … … 25 26 box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); 26 27 padding: 20px; 27 margin: 0 10px;28 margin: 0; 28 29 text-align: center; 29 30 } -
ambikly/tags/0.0.8/assets/admin/css/dashboard-style.css.map
r3184536 r3195809 1 {"version":3,"file":"../css/dashboard-style.css","mappings":";;;AAOA;AACA;AACA;AACA;AACA;AACA;EACE;EACA;EACA;AANF;;AASA;EACE;EACA;EACA; AANF;;AASA;EACE;EACA,yBAvBmB;EAwBnB;EACA;EACA;EACA;EACA;AANF;AAQE;EACE;EACA,cAnCM;EAoCN;AANJ;AASE;EACE;EACA;EACA,cAzCM;EA0CN;AAPJ;;AAWA;EACE;AARF;AAUE;EACE;EACA,cAnDM;EAoDN;AARJ;;AAYA;EACE;AATF;AAWE;EACE;EACA;EACA,yBA3DiB;EA4DjB,cA9DM;EA+DN;EACA;EACA;EACA;EACA;AATJ;AAWI;EACE,yBAnEe;AA0DrB;;AAcA;EACE;IACE;EAXF;EAaA;IACE;EAXF;EAcE;IACE;EAZJ;AACF,C","sources":["webpack://ambikly/./assets/src/admin/scss/dashboard.scss"],"names":[],"sourceRoot":""}1 {"version":3,"file":"../css/dashboard-style.css","mappings":";;;AAOA;AACA;AACA;AACA;AACA;AACA;EACE;EACA;EACA;AANF;;AASA;EACE;EACA;EACA;EACA;AANF;;AASA;EACE;EACA,yBAxBmB;EAyBnB;EACA;EACA;EACA;EACA;AANF;AAQE;EACE;EACA,cApCM;EAqCN;AANJ;AASE;EACE;EACA;EACA,cA1CM;EA2CN;AAPJ;;AAWA;EACE;AARF;AAUE;EACE;EACA,cApDM;EAqDN;AARJ;;AAYA;EACE;AATF;AAWE;EACE;EACA;EACA,yBA5DiB;EA6DjB,cA/DM;EAgEN;EACA;EACA;EACA;EACA;AATJ;AAWI;EACE,yBApEe;AA2DrB;;AAcA;EACE;IACE;EAXF;EAaA;IACE;EAXF;EAcE;IACE;EAZJ;AACF,C","sources":["webpack://ambikly/./assets/src/admin/scss/dashboard.scss"],"names":[],"sourceRoot":""} -
ambikly/tags/0.0.8/assets/js/checkout-script.js
r3184536 r3195809 277 277 return; 278 278 checkoutForm.addEventListener('submit', handleSubmit); 279 var billingCountry = checkoutForm.querySelector('[name="billing_country"]'); 280 billingCountry.addEventListener('change', handleCountryChange); 281 //initLib(); 282 } 283 function handleCountryChange(e) { 284 var _a; 285 // Ignoring type errors for Select2 286 // @ts-ignore 287 var country = e.target.value; 288 // @ts-ignore 289 var states = (_a = ambikly.states[country]) !== null && _a !== void 0 ? _a : {}; 290 if (Object.keys(states).length < 1 || !states) { 291 return; 292 } 293 var checkoutForm = document.querySelector('.ambikly-checkout-form'); 294 if (!checkoutForm) 295 return; 296 var billingStateGroup = checkoutForm.querySelector('.ambikly-field-billing_state'); 297 if (!billingStateGroup) 298 return; 299 var billingStateInput = billingStateGroup.querySelector('#billing_state'); 300 if (billingStateInput) { 301 billingStateInput.remove(); 302 } 303 var selectElement = document.createElement('select'); 304 selectElement.name = 'billing_state'; 305 selectElement.id = 'billing_state'; 306 selectElement.required = true; // Keep the "required" attribute 307 // Add a placeholder option 308 var placeholderOption = document.createElement('option'); 309 placeholderOption.value = ''; 310 placeholderOption.textContent = '-- Select State --'; 311 placeholderOption.disabled = true; 312 placeholderOption.selected = true; 313 selectElement.appendChild(placeholderOption); 314 // Populate the select element with states 315 for (var _i = 0, _b = Object.entries(states); _i < _b.length; _i++) { 316 var _c = _b[_i], stateCode = _c[0], stateName = _c[1]; 317 var option = document.createElement('option'); 318 option.value = stateCode; 319 // @ts-ignore 320 option.textContent = stateName; 321 selectElement.appendChild(option); 322 } 323 // Append the select element to the form group 324 billingStateGroup.appendChild(selectElement); 279 325 } 280 326 // Form submit handler -
ambikly/tags/0.0.8/assets/js/checkout-script.js.map
r3184536 r3195809 1 {"version":3,"file":"checkout-script.js","mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEO,SAAe,UAAU;wDAC5B,GAAW,EACX,OAA4B;;QAA5B,sCAA4B;;;;oBAErB,KAAuC,OAAO,OAA/B,EAAf,MAAM,mBAAG,MAAM,OAAE,KAAsB,OAAO,QAAjB,EAAZ,OAAO,mBAAG,EAAE,OAAE,IAAI,GAAI,OAAO,KAAX,CAAY;;;;oBAGlD,OAAO,CAAC,GAAG,CAAC,SAAS,GAAG,GAAG,CAAC,CAAC;oBACZ,qBAAM,KAAK,CAAC,GAAG,EAAE;4BAC9B,MAAM;4BACN,OAAO,eACA,OAAO,CACb;4BACD,IAAI;yBACP,CAAC;;oBANI,QAAQ,GAAG,SAMf;oBACF,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;oBAE3B,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;wBACf,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;oBACnD,CAAC;oBAEY,qBAAM,QAAQ,CAAC,IAAI,EAAE;;oBAA5B,IAAI,GAAG,SAAqB;oBAClC,sBAAO,IAAI,EAAC;;;oBAEZ,OAAO,CAAC,KAAK,CAAC,uBAAuB,EAAE,OAAK,CAAC,CAAC;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C,QAAQ,CAAC,IAAI,GAAG,YAAY,CAAC,YAAa,CAAC;QACtD,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,2BAA2B;IACzC,CAAC;AACL,CAAC;AAED,uEAAuE;AACvE,SAAS,YAAY,CAAC,QAAyD;IAC3E,8CAA8C;IAC9C,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;QAC/B,OAAO,QAAQ,CAAC,CAAC,8BAA8B;IACnD,CAAC;IAED,IAAI,eAAe,GAAG,MAAM,CAAC;IAE7B,yDAAyD;IACzD,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC1B,QAAQ,CAAC,OAAO,CAAC,iBAAO;YACpB,eAAe,IAAI,cAAO,OAAO,UAAO,CAAC,CAAC,kCAAkC;QAChF,CAAC,CAAC,CAAC;IACP,CAAC;IACD,oDAAoD;SAC/C,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;QACpC,KAAK,IAAM,KAAK,IAAI,QAAQ,EAAE,CAAC;YAC3B,IAAI,QAAQ,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,CAAC;gBACjC,QAAQ,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,iBAAO;oBAC3B,eAAe,IAAI,cAAO,OAAO,UAAO,CAAC,CAAC,kCAAkC;gBAChF,CAAC,CAAC,CAAC;YACP,CAAC;QACL,CAAC;IACL,CAAC;IAED,eAAe,IAAI,OAAO,CAAC;IAC3B,OAAO,eAAe,CAAC;AAC3B,CAAC;AAED,oEAAoE;AACpE,QAAQ,CAAC,gBAAgB,CAAC,kBAAkB,EAAE,uBAAuB,CAAC,CAAC","sources":["webpack://ambikly/./assets/src/frontend/utility/apiRequest.ts","webpack://ambikly/./assets/src/frontend/utility/message.ts","webpack://ambikly/./assets/src/frontend/utility/messageTypes.ts","webpack://ambikly/webpack/bootstrap","webpack://ambikly/webpack/runtime/define property getters","webpack://ambikly/webpack/runtime/hasOwnProperty shorthand","webpack://ambikly/webpack/runtime/make namespace object","webpack://ambikly/./assets/src/frontend/checkout.ts"],"sourcesContent":["import {ApiRequestType} from '../type/ApiRequestType';\n\nexport async function apiRequest(\n url: string,\n options: ApiRequestType = {}\n): Promise<any> {\n const {method = 'POST', headers = {}, body} = options;\n\n try {\n console.log(\"URL IS \" + url);\n const response = await fetch(url, {\n method,\n headers: {\n ...headers,\n },\n body,\n });\n console.log(\"Api called \");\n\n if (!response.ok) {\n throw new Error('Network response was not ok');\n }\n\n const data = await response.text();\n return data;\n } catch (error) {\n console.error('Error during request:', error);\n throw error; // Rethrow error for further handling\n }\n}\n","import { MessageType } from './messageTypes';\n\nexport function displayMessage(\n htmlElement: HTMLElement,\n message: string,\n type: MessageType,\n insertBefore: boolean = false,\n scrollToMessage: boolean = false // New argument for scrolling\n): void {\n const existingMessage = document.querySelector('.ambikly-message');\n if (existingMessage) {\n existingMessage.remove(); // Remove any existing messages\n }\n\n const messageElement = document.createElement('div');\n messageElement.className = `ambikly-message ${type}-message`; // Add class based on message type\n messageElement.innerHTML = message; // Set the plain message\n messageElement.style.display = 'none'; // Initially hide the message\n messageElement.style.marginTop = '10px'; // Add margin for spacing\n\n if (insertBefore) {\n htmlElement.parentNode?.insertBefore(messageElement, htmlElement); // Insert message before the htmlElement\n } else {\n htmlElement.parentNode?.insertBefore(messageElement, htmlElement.nextSibling); // Insert message after the htmlElement\n }\n\n // Show the message after inserting\n messageElement.style.display = 'block'; // Show the message\n\n // Scroll to the message element's parent if scrollToMessage is true\n if (scrollToMessage) {\n const parentElement = messageElement.parentElement;\n if (parentElement) {\n parentElement.scrollIntoView({\n behavior: 'smooth', // Smooth scrolling\n block: 'start', // Align to the top of the view\n });\n }\n }\n}\n","// Define message types as constants\nexport const MessageType = {\n SUCCESS: 'success',\n ERROR: 'error',\n} as const;\n\nexport type MessageType = typeof MessageType[keyof typeof MessageType]; // Type for message types\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import {displayMessage} from './utility/message';\nimport {MessageType} from './utility/messageTypes'; // Adjust the path according to your folder structure\nimport {apiRequest} from './utility/apiRequest'; // Assuming you have an apiRequest utility\n\n// Interface for the expected structure of the AJAX response\ninterface AjaxResponse {\n order_status?: string;\n order_action?: string;\n redirect_url?: string;\n message: string | { [key: string]: string[] }; // message can be either a string or an object\n}\n// Function to initialize checkout form submission handling\nfunction initCheckoutFormHandler(): void {\n const checkoutForm = document.querySelector('.ambikly-checkout-form') as HTMLFormElement;\n if (!checkoutForm) return;\n\n checkoutForm.addEventListener('submit', handleSubmit);\n}\n\n// Form submit handler\nasync function handleSubmit(e: Event): Promise<void> {\n e.preventDefault();\n const checkoutForm = e.target as HTMLFormElement;\n const formData = new FormData(checkoutForm);\n\n try {\n const jsonResponse = await submitCheckoutForm(formData);\n handleResponse(jsonResponse, checkoutForm);\n } catch (error) {\n console.error('Error during form submission:', error);\n displayMessage(checkoutForm, 'An error occurred while submitting the form.', MessageType.ERROR, true, true);\n }\n}\n\n// Function to submit the checkout form via an API request\nasync function submitCheckoutForm(formData: FormData): Promise<AjaxResponse> {\n const response = await apiRequest((window as any).ambikly.ajax_url, {\n method: 'POST',\n body: formData,\n });\n return JSON.parse(response) as AjaxResponse;\n}\n\n// Function to handle the server response after form submission\nfunction handleResponse(jsonResponse: AjaxResponse, checkoutForm: HTMLFormElement): void {\n if (jsonResponse.order_status === 'success') {\n handleSuccessResponse(jsonResponse, checkoutForm);\n } else if (jsonResponse.order_status === 'failed' && jsonResponse.message) {\n const errorMessages = buildMessage(jsonResponse.message);\n displayMessage(checkoutForm, errorMessages, MessageType.ERROR, true, true);\n } else {\n displayMessage(checkoutForm, 'Order failed or was canceled.', MessageType.ERROR, true, true);\n }\n}\n\n// Function to handle successful order responses\nfunction handleSuccessResponse(jsonResponse: AjaxResponse, checkoutForm: HTMLFormElement): void {\n const message = buildMessage(jsonResponse.message);\n displayMessage(checkoutForm, message, MessageType.SUCCESS);\n\n if (jsonResponse.order_action === 'redirect' && jsonResponse.redirect_url) {\n setTimeout(() => {\n window.location.href = jsonResponse.redirect_url!;\n }, 2000); // Redirect after 2 seconds\n }\n}\n\n// Function to build an HTML string containing a list of error messages\nfunction buildMessage(messages: string | string[] | { [key: string]: string[] }): string {\n // If messages is a string, return it directly\n if (typeof messages === 'string') {\n return messages; // Return the message directly\n }\n\n let messageListHTML = '<ul>';\n\n // If messages is an array of strings, iterate through it\n if (Array.isArray(messages)) {\n messages.forEach(message => {\n messageListHTML += `<li>${message}</li>`; // Add each message as a list item\n });\n }\n // If messages is an object, iterate over its fields\n else if (typeof messages === 'object') {\n for (const field in messages) {\n if (messages.hasOwnProperty(field)) {\n messages[field].forEach(message => {\n messageListHTML += `<li>${message}</li>`; // Add each message as a list item\n });\n }\n }\n }\n\n messageListHTML += '</ul>';\n return messageListHTML;\n}\n\n// Wait for DOM content to be loaded and initialize the form handler\ndocument.addEventListener('DOMContentLoaded', initCheckoutFormHandler);\n"],"names":[],"sourceRoot":""}1 {"version":3,"file":"checkout-script.js","mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEO,SAAe,UAAU;wDAC5B,GAAW,EACX,OAA4B;;QAA5B,sCAA4B;;;;oBAErB,KAAuC,OAAO,OAA/B,EAAf,MAAM,mBAAG,MAAM,OAAE,KAAsB,OAAO,QAAjB,EAAZ,OAAO,mBAAG,EAAE,OAAE,IAAI,GAAI,OAAO,KAAX,CAAY;;;;oBAGlD,OAAO,CAAC,GAAG,CAAC,SAAS,GAAG,GAAG,CAAC,CAAC;oBACZ,qBAAM,KAAK,CAAC,GAAG,EAAE;4BAC9B,MAAM;4BACN,OAAO,eACA,OAAO,CACb;4BACD,IAAI;yBACP,CAAC;;oBANI,QAAQ,GAAG,SAMf;oBACF,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;oBAE3B,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;wBACf,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;oBACnD,CAAC;oBAEY,qBAAM,QAAQ,CAAC,IAAI,EAAE;;oBAA5B,IAAI,GAAG,SAAqB;oBAClC,sBAAO,IAAI,EAAC;;;oBAEZ,OAAO,CAAC,KAAK,CAAC,uBAAuB,EAAE,OAAK,CAAC,CAAC;oBAC9C,MAAM,OAAK,CAAC,CAAC,qCAAqC;;;;;CAEzD;;;;;;;;;;;;;;;AC3BM,SAAS,cAAc,CAC1B,WAAwB,EACxB,OAAe,EACf,IAAiB,EACjB,YAA6B,EAC7B,eAAgC,CAAC,6BAA6B;;;IAD9D,mDAA6B;IAC7B,yDAAgC;IAEhC,IAAM,eAAe,GAAG,QAAQ,CAAC,aAAa,CAAC,kBAAkB,CAAC,CAAC;IACnE,IAAI,eAAe,EAAE,CAAC;QAClB,eAAe,CAAC,MAAM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;AAC3B,CAAC;AAED,oEAAoE;AACpE,QAAQ,CAAC,gBAAgB,CAAC,kBAAkB,EAAE,uBAAuB,CAAC,CAAC","sources":["webpack://ambikly/./assets/src/frontend/utility/apiRequest.ts","webpack://ambikly/./assets/src/frontend/utility/message.ts","webpack://ambikly/./assets/src/frontend/utility/messageTypes.ts","webpack://ambikly/webpack/bootstrap","webpack://ambikly/webpack/runtime/define property getters","webpack://ambikly/webpack/runtime/hasOwnProperty shorthand","webpack://ambikly/webpack/runtime/make namespace object","webpack://ambikly/./assets/src/frontend/checkout.ts"],"sourcesContent":["import {ApiRequestType} from '../type/ApiRequestType';\n\nexport async function apiRequest(\n url: string,\n options: ApiRequestType = {}\n): Promise<any> {\n const {method = 'POST', headers = {}, body} = options;\n\n try {\n console.log(\"URL IS \" + url);\n const response = await fetch(url, {\n method,\n headers: {\n ...headers,\n },\n body,\n });\n console.log(\"Api called \");\n\n if (!response.ok) {\n throw new Error('Network response was not ok');\n }\n\n const data = await response.text();\n return data;\n } catch (error) {\n console.error('Error during request:', error);\n throw error; // Rethrow error for further handling\n }\n}\n","import { MessageType } from './messageTypes';\n\nexport function displayMessage(\n htmlElement: HTMLElement,\n message: string,\n type: MessageType,\n insertBefore: boolean = false,\n scrollToMessage: boolean = false // New argument for scrolling\n): void {\n const existingMessage = document.querySelector('.ambikly-message');\n if (existingMessage) {\n existingMessage.remove(); // Remove any existing messages\n }\n\n const messageElement = document.createElement('div');\n messageElement.className = `ambikly-message ${type}-message`; // Add class based on message type\n messageElement.innerHTML = message; // Set the plain message\n messageElement.style.display = 'none'; // Initially hide the message\n messageElement.style.marginTop = '10px'; // Add margin for spacing\n\n if (insertBefore) {\n htmlElement.parentNode?.insertBefore(messageElement, htmlElement); // Insert message before the htmlElement\n } else {\n htmlElement.parentNode?.insertBefore(messageElement, htmlElement.nextSibling); // Insert message after the htmlElement\n }\n\n // Show the message after inserting\n messageElement.style.display = 'block'; // Show the message\n\n // Scroll to the message element's parent if scrollToMessage is true\n if (scrollToMessage) {\n const parentElement = messageElement.parentElement;\n if (parentElement) {\n parentElement.scrollIntoView({\n behavior: 'smooth', // Smooth scrolling\n block: 'start', // Align to the top of the view\n });\n }\n }\n}\n","// Define message types as constants\nexport const MessageType = {\n SUCCESS: 'success',\n ERROR: 'error',\n} as const;\n\nexport type MessageType = typeof MessageType[keyof typeof MessageType]; // Type for message types\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import {displayMessage} from './utility/message';\nimport {MessageType} from './utility/messageTypes'; // Adjust the path according to your folder structure\nimport {apiRequest} from './utility/apiRequest'; // Assuming you have an apiRequest utility\n\n// Interface for the expected structure of the AJAX response\ninterface AjaxResponse {\n order_status?: string;\n order_action?: string;\n redirect_url?: string;\n message: string | { [key: string]: string[] }; // message can be either a string or an object\n}\n\n// Function to initialize checkout form submission handling\nfunction initCheckoutFormHandler(): void {\n const checkoutForm = document.querySelector('.ambikly-checkout-form') as HTMLFormElement;\n if (!checkoutForm) return;\n\n checkoutForm.addEventListener('submit', handleSubmit);\n const billingCountry = checkoutForm.querySelector('[name=\"billing_country\"]') as HTMLInputElement;\n billingCountry.addEventListener('change', handleCountryChange);\n //initLib();\n}\n\nfunction handleCountryChange(e: Event) {\n // Ignoring type errors for Select2\n // @ts-ignore\n const country = e.target.value;\n // @ts-ignore\n const states = ambikly.states[country] ?? {}\n\n if (Object.keys(states).length < 1 || !states) {\n\n return;\n }\n\n const checkoutForm = document.querySelector('.ambikly-checkout-form') as HTMLFormElement;\n\n if (!checkoutForm) return;\n\n\n const billingStateGroup = checkoutForm.querySelector('.ambikly-field-billing_state');\n\n if (!billingStateGroup) return;\n\n const billingStateInput = billingStateGroup.querySelector('#billing_state');\n if (billingStateInput) {\n billingStateInput.remove();\n }\n const selectElement = document.createElement('select');\n selectElement.name = 'billing_state';\n selectElement.id = 'billing_state';\n selectElement.required = true; // Keep the \"required\" attribute\n\n // Add a placeholder option\n const placeholderOption = document.createElement('option');\n placeholderOption.value = '';\n placeholderOption.textContent = '-- Select State --';\n placeholderOption.disabled = true;\n placeholderOption.selected = true;\n selectElement.appendChild(placeholderOption);\n\n // Populate the select element with states\n for (const [stateCode, stateName] of Object.entries(states)) {\n const option = document.createElement('option');\n option.value = stateCode;\n // @ts-ignore\n option.textContent = stateName;\n selectElement.appendChild(option);\n }\n\n // Append the select element to the form group\n billingStateGroup.appendChild(selectElement);\n}\n\n// Form submit handler\nasync function handleSubmit(e: Event): Promise<void> {\n e.preventDefault();\n const checkoutForm = e.target as HTMLFormElement;\n const formData = new FormData(checkoutForm);\n\n try {\n const jsonResponse = await submitCheckoutForm(formData);\n handleResponse(jsonResponse, checkoutForm);\n } catch (error) {\n console.error('Error during form submission:', error);\n displayMessage(checkoutForm, 'An error occurred while submitting the form.', MessageType.ERROR, true, true);\n }\n}\n\n// Function to submit the checkout form via an API request\nasync function submitCheckoutForm(formData: FormData): Promise<AjaxResponse> {\n const response = await apiRequest((window as any).ambikly.ajax_url, {\n method: 'POST',\n body: formData,\n });\n return JSON.parse(response) as AjaxResponse;\n}\n\n// Function to handle the server response after form submission\nfunction handleResponse(jsonResponse: AjaxResponse, checkoutForm: HTMLFormElement): void {\n if (jsonResponse.order_status === 'success') {\n handleSuccessResponse(jsonResponse, checkoutForm);\n } else if (jsonResponse.order_status === 'failed' && jsonResponse.message) {\n const errorMessages = buildMessage(jsonResponse.message);\n displayMessage(checkoutForm, errorMessages, MessageType.ERROR, true, true);\n } else {\n displayMessage(checkoutForm, 'Order failed or was canceled.', MessageType.ERROR, true, true);\n }\n}\n\n// Function to handle successful order responses\nfunction handleSuccessResponse(jsonResponse: AjaxResponse, checkoutForm: HTMLFormElement): void {\n const message = buildMessage(jsonResponse.message);\n displayMessage(checkoutForm, message, MessageType.SUCCESS);\n\n if (jsonResponse.order_action === 'redirect' && jsonResponse.redirect_url) {\n setTimeout(() => {\n window.location.href = jsonResponse.redirect_url!;\n }, 2000); // Redirect after 2 seconds\n }\n}\n\n// Function to build an HTML string containing a list of error messages\nfunction buildMessage(messages: string | string[] | { [key: string]: string[] }): string {\n // If messages is a string, return it directly\n if (typeof messages === 'string') {\n return messages; // Return the message directly\n }\n\n let messageListHTML = '<ul>';\n\n // If messages is an array of strings, iterate through it\n if (Array.isArray(messages)) {\n messages.forEach(message => {\n messageListHTML += `<li>${message}</li>`; // Add each message as a list item\n });\n }\n // If messages is an object, iterate over its fields\n else if (typeof messages === 'object') {\n for (const field in messages) {\n if (messages.hasOwnProperty(field)) {\n messages[field].forEach(message => {\n messageListHTML += `<li>${message}</li>`; // Add each message as a list item\n });\n }\n }\n }\n\n messageListHTML += '</ul>';\n return messageListHTML;\n}\n\n// Wait for DOM content to be loaded and initialize the form handler\ndocument.addEventListener('DOMContentLoaded', initCheckoutFormHandler);\n"],"names":[],"sourceRoot":""} -
ambikly/tags/0.0.8/changelog.txt
r3186894 r3195809 1 = 0.0.7 - 2024-11-13 2 * Fix - PHP Compatibility issue fixed 3 1 4 = 0.0.6 - 2024-11-12 2 5 * Add - Customer List table -
ambikly/tags/0.0.8/languages/ambikly.pot
r3186894 r3195809 7 7 "Content-Type: text/plain; charset=UTF-8\n" 8 8 "Content-Transfer-Encoding: 8bit\n" 9 "POT-Creation-Date: 2024-11- 13 03:59+0000\n"9 "POT-Creation-Date: 2024-11-24 10:53+0000\n" 10 10 "X-Poedit-Basepath: ..\n" 11 11 "X-Poedit-KeywordsList: __;_e;_ex:1,2c;_n:1,2;_n_noop:1,2;_nx:1,2,4c;_nx_noop:1,2,3c;_x:1,2c;esc_attr__;esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c\n" … … 235 235 msgstr "" 236 236 237 #: ../src/Forms/CheckoutForm.php:13, ../src/ListTable/CustomersListTable.php:27 237 #: ../src/Forms/CheckoutForm.php:12 238 msgid "-- Select Country --" 239 msgstr "" 240 241 #: ../src/Forms/CheckoutForm.php:17, ../src/ListTable/CustomersListTable.php:27 238 242 msgid "First Name" 239 243 msgstr "" 240 244 241 #: ../src/Forms/CheckoutForm.php:1 5245 #: ../src/Forms/CheckoutForm.php:19 242 246 msgid "Enter your first name" 243 247 msgstr "" 244 248 245 #: ../src/Forms/CheckoutForm.php:2 0, ../src/ListTable/CustomersListTable.php:28249 #: ../src/Forms/CheckoutForm.php:24, ../src/ListTable/CustomersListTable.php:28 246 250 msgid "Last Name" 247 251 msgstr "" 248 252 249 #: ../src/Forms/CheckoutForm.php:2 2253 #: ../src/Forms/CheckoutForm.php:26 250 254 msgid "Enter your last name" 251 255 msgstr "" 252 256 253 #: ../src/Forms/CheckoutForm.php:3 0257 #: ../src/Forms/CheckoutForm.php:34 254 258 msgid "Phone" 255 259 msgstr "" 256 260 257 #: ../src/Forms/CheckoutForm.php:3 2261 #: ../src/Forms/CheckoutForm.php:36 258 262 msgid "Enter your phone number" 259 263 msgstr "" 260 264 261 #: ../src/Forms/CheckoutForm.php:3 5265 #: ../src/Forms/CheckoutForm.php:39 262 266 msgid "Country" 263 267 msgstr "" 264 268 265 #: ../src/Forms/CheckoutForm.php: 38269 #: ../src/Forms/CheckoutForm.php:42 266 270 msgid "Enter your country" 267 271 msgstr "" 268 272 269 #: ../src/Forms/CheckoutForm.php: 48273 #: ../src/Forms/CheckoutForm.php:52 270 274 msgid "State" 271 275 msgstr "" 272 276 273 #: ../src/Forms/CheckoutForm.php:5 1277 #: ../src/Forms/CheckoutForm.php:55 274 278 msgid "Enter your state" 275 279 msgstr "" 276 280 277 #: ../src/Forms/CheckoutForm.php: 59281 #: ../src/Forms/CheckoutForm.php:63 278 282 msgid "City" 279 283 msgstr "" 280 284 281 #: ../src/Forms/CheckoutForm.php:6 2285 #: ../src/Forms/CheckoutForm.php:66 282 286 msgid "Enter your city" 283 287 msgstr "" 284 288 285 #: ../src/Forms/CheckoutForm.php:6 5289 #: ../src/Forms/CheckoutForm.php:69 286 290 msgid "Address" 287 291 msgstr "" 288 292 289 #: ../src/Forms/CheckoutForm.php: 68293 #: ../src/Forms/CheckoutForm.php:72 290 294 msgid "Enter your address" 291 295 msgstr "" 292 296 293 #: ../src/Forms/CheckoutForm.php:7 2297 #: ../src/Forms/CheckoutForm.php:76 294 298 msgid "Zip Code" 295 299 msgstr "" 296 300 297 #: ../src/Forms/CheckoutForm.php:7 5301 #: ../src/Forms/CheckoutForm.php:79 298 302 msgid "Enter your zip code" 299 303 msgstr "" 300 304 301 #: ../src/Forms/CheckoutForm.php:8 4, ../src/Options/OrderOptions.php:72, ../src/Options/OrderOptions.php:74305 #: ../src/Forms/CheckoutForm.php:88, ../src/Options/OrderOptions.php:72, ../src/Options/OrderOptions.php:74 302 306 msgid "Order Note" 303 307 msgstr "" 304 308 305 #: ../src/Forms/CheckoutForm.php: 86309 #: ../src/Forms/CheckoutForm.php:90 306 310 msgid "Add any notes about your order" 307 311 msgstr "" … … 10501 10505 10502 10506 #: ../src/Gateways/PayPal/Settings.php:42 10503 msgid "PayPal Email."10507 msgid "PayPal account email address" 10504 10508 msgstr "" 10505 10509 -
ambikly/tags/0.0.8/readme.txt
r3186894 r3195809 1 === Ambikly - The easiest way to start selling online ===1 === Ambikly - The easiest way to start selling online, WordPress eCommerce plugin === 2 2 Contributors: Ambikly 3 Tags: ecommerce, online store, payments, ecommerce plugin 3 Tags: ecommerce, online store, payments, ecommerce plugin, sell 4 4 Requires at least: 5.4 5 5 Tested up to: 6.7 6 6 Requires PHP: 7.4 7 Stable tag: 0.0. 77 Stable tag: 0.0.8 8 8 License: GPLv3 9 9 License URI: https://www.gnu.org/licenses/gpl-3.0.html … … 60 60 61 61 == Changelog == 62 = 0.0.7 - 2024-11-13 63 * Fix - PHP Compatibility issue fixed 62 = 0.0.8 - 2024-11-24 63 * Fix - Guest checkout issue fixed 64 * Fix - Cart Issue fixed 64 65 65 66 [See changelog for all versions](https://plugins.svn.wordpress.org/ambikly/trunk/changelog.txt). -
ambikly/tags/0.0.8/src/Admin/Pages/DashboardPage.php
r3184536 r3195809 7 7 use Ambikly\Controllers\ReportController; 8 8 9 class DashboardPage 9 class DashboardPage extends BasePage 10 10 { 11 11 public function __construct() -
ambikly/tags/0.0.8/src/Assets.php
r3184536 r3195809 13 13 public function register() 14 14 { 15 // Libraries 16 wp_register_style( 17 'ambikly-select2-style', 18 AMBIKLY_ASSETS_URI . 'lib/select2/css/select2.css', 19 ); 20 wp_register_script( 21 'ambikly-select2-script', 22 AMBIKLY_ASSETS_URI . 'lib/select2/js/select2.js' 23 ); 24 15 25 wp_register_script( 16 26 'ambikly-common-js', … … 67 77 'ambikly-checkout-style', 68 78 AMBIKLY_ASSETS_URI . 'css/checkout-style.css', 69 array('ambikly-common-style' )79 array('ambikly-common-style', 'ambikly-select2-style') 70 80 ); 71 81 wp_register_script( 72 82 'ambikly-checkout-js', 73 83 AMBIKLY_ASSETS_URI . 'js/checkout-script.js', 74 array('ambikly-common-js' ),84 array('ambikly-common-js', 'ambikly-select2-script'), 75 85 AMBIKLY_VERSION, 76 86 true … … 101 111 ); 102 112 } 103 wp_localize_script('ambikly-common-js', 'ambikly', [ 113 114 $localize_data = [ 104 115 'ajax_url' => admin_url('admin-ajax.php'), 105 ]); 116 ]; 117 118 if (get_the_ID() == ambikly_get_checkout_page()) { 119 $localize_data['states'] = include AMBIKLY_ABSPATH . 'src/Helpers/states.php'; 120 } 121 122 123 wp_localize_script('ambikly-common-js', 'ambikly', $localize_data); 106 124 107 125 } -
ambikly/tags/0.0.8/src/Controllers/CheckoutController.php
r3186548 r3195809 94 94 do_action('ambikly_process_' . $this->payment_method . '_payment', $order_id, $payment_method, $sanitized_data, $this); 95 95 96 //$this->cart_controller->clear_cart();96 $this->cart_controller->clear_cart(); 97 97 } 98 98 -
ambikly/tags/0.0.8/src/Forms/CheckoutForm.php
r3184536 r3195809 8 8 protected function initialize_fields() 9 9 { 10 $countries = ambikly_get_countries(); 11 12 $countries = array_merge(['' => __('-- Select Country --', 'ambikly')], $countries); 13 10 14 $this->fields = [ 11 15 … … 37 41 'required' => true, 38 42 'placeholder' => esc_html__('Enter your country', 'ambikly'), 39 'options' => ambikly_get_countries(),43 'options' => $countries, 40 44 'class' => 'half', 41 45 'attributes' => [ -
ambikly/tags/0.0.8/src/Gateways/PayPal/PayPal.php
r3184536 r3195809 191 191 192 192 193 $args['option_index_0'] = $args_index;193 $args['option_index_0'] = ($args_index-1); 194 194 195 195 $order_code = $order_details['order_code'] ?? ''; -
ambikly/tags/0.0.8/src/Gateways/PayPal/Settings.php
r3184536 r3195809 40 40 'label' => esc_html__('PayPal Email', 'ambikly'), 41 41 'name' => $this->id . '_email', 42 'placeholder' => esc_html__('PayPal Email.', 'ambikly'),42 'placeholder' => esc_html__('PayPal account email address', 'ambikly'), 43 43 ], 44 44 -
ambikly/tags/0.0.8/src/Shortcodes/CheckoutShortcode.php
r3184536 r3195809 18 18 19 19 wp_enqueue_script('ambikly-checkout-js'); 20 20 21 /** 21 22 * @var $ambikly_cart Cart -
ambikly/trunk/ambikly.php
r3186894 r3195809 6 6 * Author: ambikly 7 7 * Author URI: https://profiles.wordpress.org/ambikly 8 * Version: 0.0. 78 * Version: 0.0.8 9 9 * License: GPLv3+ 10 10 * License URI: https://www.gnu.org/licenses/gpl-3.0.html … … 28 28 // Define AMBIKLY_VERSION. 29 29 if (!defined('AMBIKLY_VERSION')) { 30 define('AMBIKLY_VERSION', '0.0. 7');30 define('AMBIKLY_VERSION', '0.0.8'); 31 31 } 32 32 -
ambikly/trunk/assets/admin/css/dashboard-style.css
r3184536 r3195809 17 17 justify-content: space-between; 18 18 margin-bottom: 20px; 19 gap: 20px; 19 20 } 20 21 … … 25 26 box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); 26 27 padding: 20px; 27 margin: 0 10px;28 margin: 0; 28 29 text-align: center; 29 30 } -
ambikly/trunk/assets/admin/css/dashboard-style.css.map
r3184536 r3195809 1 {"version":3,"file":"../css/dashboard-style.css","mappings":";;;AAOA;AACA;AACA;AACA;AACA;AACA;EACE;EACA;EACA;AANF;;AASA;EACE;EACA;EACA; AANF;;AASA;EACE;EACA,yBAvBmB;EAwBnB;EACA;EACA;EACA;EACA;AANF;AAQE;EACE;EACA,cAnCM;EAoCN;AANJ;AASE;EACE;EACA;EACA,cAzCM;EA0CN;AAPJ;;AAWA;EACE;AARF;AAUE;EACE;EACA,cAnDM;EAoDN;AARJ;;AAYA;EACE;AATF;AAWE;EACE;EACA;EACA,yBA3DiB;EA4DjB,cA9DM;EA+DN;EACA;EACA;EACA;EACA;AATJ;AAWI;EACE,yBAnEe;AA0DrB;;AAcA;EACE;IACE;EAXF;EAaA;IACE;EAXF;EAcE;IACE;EAZJ;AACF,C","sources":["webpack://ambikly/./assets/src/admin/scss/dashboard.scss"],"names":[],"sourceRoot":""}1 {"version":3,"file":"../css/dashboard-style.css","mappings":";;;AAOA;AACA;AACA;AACA;AACA;AACA;EACE;EACA;EACA;AANF;;AASA;EACE;EACA;EACA;EACA;AANF;;AASA;EACE;EACA,yBAxBmB;EAyBnB;EACA;EACA;EACA;EACA;AANF;AAQE;EACE;EACA,cApCM;EAqCN;AANJ;AASE;EACE;EACA;EACA,cA1CM;EA2CN;AAPJ;;AAWA;EACE;AARF;AAUE;EACE;EACA,cApDM;EAqDN;AARJ;;AAYA;EACE;AATF;AAWE;EACE;EACA;EACA,yBA5DiB;EA6DjB,cA/DM;EAgEN;EACA;EACA;EACA;EACA;AATJ;AAWI;EACE,yBApEe;AA2DrB;;AAcA;EACE;IACE;EAXF;EAaA;IACE;EAXF;EAcE;IACE;EAZJ;AACF,C","sources":["webpack://ambikly/./assets/src/admin/scss/dashboard.scss"],"names":[],"sourceRoot":""} -
ambikly/trunk/assets/js/checkout-script.js
r3184536 r3195809 277 277 return; 278 278 checkoutForm.addEventListener('submit', handleSubmit); 279 var billingCountry = checkoutForm.querySelector('[name="billing_country"]'); 280 billingCountry.addEventListener('change', handleCountryChange); 281 //initLib(); 282 } 283 function handleCountryChange(e) { 284 var _a; 285 // Ignoring type errors for Select2 286 // @ts-ignore 287 var country = e.target.value; 288 // @ts-ignore 289 var states = (_a = ambikly.states[country]) !== null && _a !== void 0 ? _a : {}; 290 if (Object.keys(states).length < 1 || !states) { 291 return; 292 } 293 var checkoutForm = document.querySelector('.ambikly-checkout-form'); 294 if (!checkoutForm) 295 return; 296 var billingStateGroup = checkoutForm.querySelector('.ambikly-field-billing_state'); 297 if (!billingStateGroup) 298 return; 299 var billingStateInput = billingStateGroup.querySelector('#billing_state'); 300 if (billingStateInput) { 301 billingStateInput.remove(); 302 } 303 var selectElement = document.createElement('select'); 304 selectElement.name = 'billing_state'; 305 selectElement.id = 'billing_state'; 306 selectElement.required = true; // Keep the "required" attribute 307 // Add a placeholder option 308 var placeholderOption = document.createElement('option'); 309 placeholderOption.value = ''; 310 placeholderOption.textContent = '-- Select State --'; 311 placeholderOption.disabled = true; 312 placeholderOption.selected = true; 313 selectElement.appendChild(placeholderOption); 314 // Populate the select element with states 315 for (var _i = 0, _b = Object.entries(states); _i < _b.length; _i++) { 316 var _c = _b[_i], stateCode = _c[0], stateName = _c[1]; 317 var option = document.createElement('option'); 318 option.value = stateCode; 319 // @ts-ignore 320 option.textContent = stateName; 321 selectElement.appendChild(option); 322 } 323 // Append the select element to the form group 324 billingStateGroup.appendChild(selectElement); 279 325 } 280 326 // Form submit handler -
ambikly/trunk/assets/js/checkout-script.js.map
r3184536 r3195809 1 {"version":3,"file":"checkout-script.js","mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEO,SAAe,UAAU;wDAC5B,GAAW,EACX,OAA4B;;QAA5B,sCAA4B;;;;oBAErB,KAAuC,OAAO,OAA/B,EAAf,MAAM,mBAAG,MAAM,OAAE,KAAsB,OAAO,QAAjB,EAAZ,OAAO,mBAAG,EAAE,OAAE,IAAI,GAAI,OAAO,KAAX,CAAY;;;;oBAGlD,OAAO,CAAC,GAAG,CAAC,SAAS,GAAG,GAAG,CAAC,CAAC;oBACZ,qBAAM,KAAK,CAAC,GAAG,EAAE;4BAC9B,MAAM;4BACN,OAAO,eACA,OAAO,CACb;4BACD,IAAI;yBACP,CAAC;;oBANI,QAAQ,GAAG,SAMf;oBACF,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;oBAE3B,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;wBACf,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;oBACnD,CAAC;oBAEY,qBAAM,QAAQ,CAAC,IAAI,EAAE;;oBAA5B,IAAI,GAAG,SAAqB;oBAClC,sBAAO,IAAI,EAAC;;;oBAEZ,OAAO,CAAC,KAAK,CAAC,uBAAuB,EAAE,OAAK,CAAC,CAAC;oBAC9C,MAAM,OAAK,CAAC,CAAC,qCAAqC;;;;;CAEzD;;;;;;;;;;;;;;;AC3BM,SAAS,cAAc,CAC1B,WAAwB,EACxB,OAAe,EACf,IAAiB,EACjB,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AuE;AACvE,SAAS,YAAY,CAAC,QAAyD;IAC3E,8CAA8C;IAC9C,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;QAC/B,OAAO,QAAQ,CAAC,CAAC,8BAA8B;IACnD,CAAC;IAED,IAAI,eAAe,GAAG,MAAM,CAAC;IAE7B,yDAAyD;IACzD,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC1B,QAAQ,CAAC,OAAO,CAAC,iBAAO;YACpB,eAAe,IAAI,cAAO,OAAO,UAAO,CAAC,CAAC,kCAAkC;QAChF,CAAC,CAAC,CAAC;IACP,CAAC;IACD,oDAAoD;SAC/C,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;QACpC,KAAK,IAAM,KAAK,IAAI,QAAQ,EAAE,CAAC;YAC3B,IAAI,QAAQ,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,CAAC;gBACjC,QAAQ,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,iBAAO;oBAC3B,eAAe,IAAI,cAAO,OAAO,UAAO,CAAC,CAAC,kCAAkC;gBAChF,CAAC,CAAC,CAAC;YACP,CAAC;QACL,CAAC;IACL,CAAC;IAED,eAAe,IAAI,OAAO,CAAC;IAC3B,OAAO,eAAe,CAAC;AAC3B,CAAC;AAED,oEAAoE;AACpE,QAAQ,CAAC,gBAAgB,CAAC,kBAAkB,EAAE,uBAAuB,CAAC,CAAC","sources":["webpack://ambikly/./assets/src/frontend/utility/apiRequest.ts","webpack://ambikly/./assets/src/frontend/utility/message.ts","webpack://ambikly/./assets/src/frontend/utility/messageTypes.ts","webpack://ambikly/webpack/bootstrap","webpack://ambikly/webpack/runtime/define property getters","webpack://ambikly/webpack/runtime/hasOwnProperty shorthand","webpack://ambikly/webpack/runtime/make namespace object","webpack://ambikly/./assets/src/frontend/checkout.ts"],"sourcesContent":["import {ApiRequestType} from '../type/ApiRequestType';\n\nexport async function apiRequest(\n url: string,\n options: ApiRequestType = {}\n): Promise<any> {\n const {method = 'POST', headers = {}, body} = options;\n\n try {\n console.log(\"URL IS \" + url);\n const response = await fetch(url, {\n method,\n headers: {\n ...headers,\n },\n body,\n });\n console.log(\"Api called \");\n\n if (!response.ok) {\n throw new Error('Network response was not ok');\n }\n\n const data = await response.text();\n return data;\n } catch (error) {\n console.error('Error during request:', error);\n throw error; // Rethrow error for further handling\n }\n}\n","import { MessageType } from './messageTypes';\n\nexport function displayMessage(\n htmlElement: HTMLElement,\n message: string,\n type: MessageType,\n insertBefore: boolean = false,\n scrollToMessage: boolean = false // New argument for scrolling\n): void {\n const existingMessage = document.querySelector('.ambikly-message');\n if (existingMessage) {\n existingMessage.remove(); // Remove any existing messages\n }\n\n const messageElement = document.createElement('div');\n messageElement.className = `ambikly-message ${type}-message`; // Add class based on message type\n messageElement.innerHTML = message; // Set the plain message\n messageElement.style.display = 'none'; // Initially hide the message\n messageElement.style.marginTop = '10px'; // Add margin for spacing\n\n if (insertBefore) {\n htmlElement.parentNode?.insertBefore(messageElement, htmlElement); // Insert message before the htmlElement\n } else {\n htmlElement.parentNode?.insertBefore(messageElement, htmlElement.nextSibling); // Insert message after the htmlElement\n }\n\n // Show the message after inserting\n messageElement.style.display = 'block'; // Show the message\n\n // Scroll to the message element's parent if scrollToMessage is true\n if (scrollToMessage) {\n const parentElement = messageElement.parentElement;\n if (parentElement) {\n parentElement.scrollIntoView({\n behavior: 'smooth', // Smooth scrolling\n block: 'start', // Align to the top of the view\n });\n }\n }\n}\n","// Define message types as constants\nexport const MessageType = {\n SUCCESS: 'success',\n ERROR: 'error',\n} as const;\n\nexport type MessageType = typeof MessageType[keyof typeof MessageType]; // Type for message types\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import {displayMessage} from './utility/message';\nimport {MessageType} from './utility/messageTypes'; // Adjust the path according to your folder structure\nimport {apiRequest} from './utility/apiRequest'; // Assuming you have an apiRequest utility\n\n// Interface for the expected structure of the AJAX response\ninterface AjaxResponse {\n order_status?: string;\n order_action?: string;\n redirect_url?: string;\n message: string | { [key: string]: string[] }; // message can be either a string or an object\n}\n// Function to initialize checkout form submission handling\nfunction initCheckoutFormHandler(): void {\n const checkoutForm = document.querySelector('.ambikly-checkout-form') as HTMLFormElement;\n if (!checkoutForm) return;\n\n checkoutForm.addEventListener('submit', handleSubmit);\n}\n\n// Form submit handler\nasync function handleSubmit(e: Event): Promise<void> {\n e.preventDefault();\n const checkoutForm = e.target as HTMLFormElement;\n const formData = new FormData(checkoutForm);\n\n try {\n const jsonResponse = await submitCheckoutForm(formData);\n handleResponse(jsonResponse, checkoutForm);\n } catch (error) {\n console.error('Error during form submission:', error);\n displayMessage(checkoutForm, 'An error occurred while submitting the form.', MessageType.ERROR, true, true);\n }\n}\n\n// Function to submit the checkout form via an API request\nasync function submitCheckoutForm(formData: FormData): Promise<AjaxResponse> {\n const response = await apiRequest((window as any).ambikly.ajax_url, {\n method: 'POST',\n body: formData,\n });\n return JSON.parse(response) as AjaxResponse;\n}\n\n// Function to handle the server response after form submission\nfunction handleResponse(jsonResponse: AjaxResponse, checkoutForm: HTMLFormElement): void {\n if (jsonResponse.order_status === 'success') {\n handleSuccessResponse(jsonResponse, checkoutForm);\n } else if (jsonResponse.order_status === 'failed' && jsonResponse.message) {\n const errorMessages = buildMessage(jsonResponse.message);\n displayMessage(checkoutForm, errorMessages, MessageType.ERROR, true, true);\n } else {\n displayMessage(checkoutForm, 'Order failed or was canceled.', MessageType.ERROR, true, true);\n }\n}\n\n// Function to handle successful order responses\nfunction handleSuccessResponse(jsonResponse: AjaxResponse, checkoutForm: HTMLFormElement): void {\n const message = buildMessage(jsonResponse.message);\n displayMessage(checkoutForm, message, MessageType.SUCCESS);\n\n if (jsonResponse.order_action === 'redirect' && jsonResponse.redirect_url) {\n setTimeout(() => {\n window.location.href = jsonResponse.redirect_url!;\n }, 2000); // Redirect after 2 seconds\n }\n}\n\n// Function to build an HTML string containing a list of error messages\nfunction buildMessage(messages: string | string[] | { [key: string]: string[] }): string {\n // If messages is a string, return it directly\n if (typeof messages === 'string') {\n return messages; // Return the message directly\n }\n\n let messageListHTML = '<ul>';\n\n // If messages is an array of strings, iterate through it\n if (Array.isArray(messages)) {\n messages.forEach(message => {\n messageListHTML += `<li>${message}</li>`; // Add each message as a list item\n });\n }\n // If messages is an object, iterate over its fields\n else if (typeof messages === 'object') {\n for (const field in messages) {\n if (messages.hasOwnProperty(field)) {\n messages[field].forEach(message => {\n messageListHTML += `<li>${message}</li>`; // Add each message as a list item\n });\n }\n }\n }\n\n messageListHTML += '</ul>';\n return messageListHTML;\n}\n\n// Wait for DOM content to be loaded and initialize the form handler\ndocument.addEventListener('DOMContentLoaded', initCheckoutFormHandler);\n"],"names":[],"sourceRoot":""}1 {"version":3,"file":"checkout-script.js","mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;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.ts","webpack://ambikly/./assets/src/frontend/utility/message.ts","webpack://ambikly/./assets/src/frontend/utility/messageTypes.ts","webpack://ambikly/webpack/bootstrap","webpack://ambikly/webpack/runtime/define property getters","webpack://ambikly/webpack/runtime/hasOwnProperty shorthand","webpack://ambikly/webpack/runtime/make namespace object","webpack://ambikly/./assets/src/frontend/checkout.ts"],"sourcesContent":["import {ApiRequestType} from '../type/ApiRequestType';\n\nexport async function apiRequest(\n url: string,\n options: ApiRequestType = {}\n): Promise<any> {\n const {method = 'POST', headers = {}, body} = options;\n\n try {\n console.log(\"URL IS \" + url);\n const response = await fetch(url, {\n method,\n headers: {\n ...headers,\n },\n body,\n });\n console.log(\"Api called \");\n\n if (!response.ok) {\n throw new Error('Network response was not ok');\n }\n\n const data = await response.text();\n return data;\n } catch (error) {\n console.error('Error during request:', error);\n throw error; // Rethrow error for further handling\n }\n}\n","import { MessageType } from './messageTypes';\n\nexport function displayMessage(\n htmlElement: HTMLElement,\n message: string,\n type: MessageType,\n insertBefore: boolean = false,\n scrollToMessage: boolean = false // New argument for scrolling\n): void {\n const existingMessage = document.querySelector('.ambikly-message');\n if (existingMessage) {\n existingMessage.remove(); // Remove any existing messages\n }\n\n const messageElement = document.createElement('div');\n messageElement.className = `ambikly-message ${type}-message`; // Add class based on message type\n messageElement.innerHTML = message; // Set the plain message\n messageElement.style.display = 'none'; // Initially hide the message\n messageElement.style.marginTop = '10px'; // Add margin for spacing\n\n if (insertBefore) {\n htmlElement.parentNode?.insertBefore(messageElement, htmlElement); // Insert message before the htmlElement\n } else {\n htmlElement.parentNode?.insertBefore(messageElement, htmlElement.nextSibling); // Insert message after the htmlElement\n }\n\n // Show the message after inserting\n messageElement.style.display = 'block'; // Show the message\n\n // Scroll to the message element's parent if scrollToMessage is true\n if (scrollToMessage) {\n const parentElement = messageElement.parentElement;\n if (parentElement) {\n parentElement.scrollIntoView({\n behavior: 'smooth', // Smooth scrolling\n block: 'start', // Align to the top of the view\n });\n }\n }\n}\n","// Define message types as constants\nexport const MessageType = {\n SUCCESS: 'success',\n ERROR: 'error',\n} as const;\n\nexport type MessageType = typeof MessageType[keyof typeof MessageType]; // Type for message types\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import {displayMessage} from './utility/message';\nimport {MessageType} from './utility/messageTypes'; // Adjust the path according to your folder structure\nimport {apiRequest} from './utility/apiRequest'; // Assuming you have an apiRequest utility\n\n// Interface for the expected structure of the AJAX response\ninterface AjaxResponse {\n order_status?: string;\n order_action?: string;\n redirect_url?: string;\n message: string | { [key: string]: string[] }; // message can be either a string or an object\n}\n\n// Function to initialize checkout form submission handling\nfunction initCheckoutFormHandler(): void {\n const checkoutForm = document.querySelector('.ambikly-checkout-form') as HTMLFormElement;\n if (!checkoutForm) return;\n\n checkoutForm.addEventListener('submit', handleSubmit);\n const billingCountry = checkoutForm.querySelector('[name=\"billing_country\"]') as HTMLInputElement;\n billingCountry.addEventListener('change', handleCountryChange);\n //initLib();\n}\n\nfunction handleCountryChange(e: Event) {\n // Ignoring type errors for Select2\n // @ts-ignore\n const country = e.target.value;\n // @ts-ignore\n const states = ambikly.states[country] ?? {}\n\n if (Object.keys(states).length < 1 || !states) {\n\n return;\n }\n\n const checkoutForm = document.querySelector('.ambikly-checkout-form') as HTMLFormElement;\n\n if (!checkoutForm) return;\n\n\n const billingStateGroup = checkoutForm.querySelector('.ambikly-field-billing_state');\n\n if (!billingStateGroup) return;\n\n const billingStateInput = billingStateGroup.querySelector('#billing_state');\n if (billingStateInput) {\n billingStateInput.remove();\n }\n const selectElement = document.createElement('select');\n selectElement.name = 'billing_state';\n selectElement.id = 'billing_state';\n selectElement.required = true; // Keep the \"required\" attribute\n\n // Add a placeholder option\n const placeholderOption = document.createElement('option');\n placeholderOption.value = '';\n placeholderOption.textContent = '-- Select State --';\n placeholderOption.disabled = true;\n placeholderOption.selected = true;\n selectElement.appendChild(placeholderOption);\n\n // Populate the select element with states\n for (const [stateCode, stateName] of Object.entries(states)) {\n const option = document.createElement('option');\n option.value = stateCode;\n // @ts-ignore\n option.textContent = stateName;\n selectElement.appendChild(option);\n }\n\n // Append the select element to the form group\n billingStateGroup.appendChild(selectElement);\n}\n\n// Form submit handler\nasync function handleSubmit(e: Event): Promise<void> {\n e.preventDefault();\n const checkoutForm = e.target as HTMLFormElement;\n const formData = new FormData(checkoutForm);\n\n try {\n const jsonResponse = await submitCheckoutForm(formData);\n handleResponse(jsonResponse, checkoutForm);\n } catch (error) {\n console.error('Error during form submission:', error);\n displayMessage(checkoutForm, 'An error occurred while submitting the form.', MessageType.ERROR, true, true);\n }\n}\n\n// Function to submit the checkout form via an API request\nasync function submitCheckoutForm(formData: FormData): Promise<AjaxResponse> {\n const response = await apiRequest((window as any).ambikly.ajax_url, {\n method: 'POST',\n body: formData,\n });\n return JSON.parse(response) as AjaxResponse;\n}\n\n// Function to handle the server response after form submission\nfunction handleResponse(jsonResponse: AjaxResponse, checkoutForm: HTMLFormElement): void {\n if (jsonResponse.order_status === 'success') {\n handleSuccessResponse(jsonResponse, checkoutForm);\n } else if (jsonResponse.order_status === 'failed' && jsonResponse.message) {\n const errorMessages = buildMessage(jsonResponse.message);\n displayMessage(checkoutForm, errorMessages, MessageType.ERROR, true, true);\n } else {\n displayMessage(checkoutForm, 'Order failed or was canceled.', MessageType.ERROR, true, true);\n }\n}\n\n// Function to handle successful order responses\nfunction handleSuccessResponse(jsonResponse: AjaxResponse, checkoutForm: HTMLFormElement): void {\n const message = buildMessage(jsonResponse.message);\n displayMessage(checkoutForm, message, MessageType.SUCCESS);\n\n if (jsonResponse.order_action === 'redirect' && jsonResponse.redirect_url) {\n setTimeout(() => {\n window.location.href = jsonResponse.redirect_url!;\n }, 2000); // Redirect after 2 seconds\n }\n}\n\n// Function to build an HTML string containing a list of error messages\nfunction buildMessage(messages: string | string[] | { [key: string]: string[] }): string {\n // If messages is a string, return it directly\n if (typeof messages === 'string') {\n return messages; // Return the message directly\n }\n\n let messageListHTML = '<ul>';\n\n // If messages is an array of strings, iterate through it\n if (Array.isArray(messages)) {\n messages.forEach(message => {\n messageListHTML += `<li>${message}</li>`; // Add each message as a list item\n });\n }\n // If messages is an object, iterate over its fields\n else if (typeof messages === 'object') {\n for (const field in messages) {\n if (messages.hasOwnProperty(field)) {\n messages[field].forEach(message => {\n messageListHTML += `<li>${message}</li>`; // Add each message as a list item\n });\n }\n }\n }\n\n messageListHTML += '</ul>';\n return messageListHTML;\n}\n\n// Wait for DOM content to be loaded and initialize the form handler\ndocument.addEventListener('DOMContentLoaded', initCheckoutFormHandler);\n"],"names":[],"sourceRoot":""} -
ambikly/trunk/changelog.txt
r3186894 r3195809 1 = 0.0.7 - 2024-11-13 2 * Fix - PHP Compatibility issue fixed 3 1 4 = 0.0.6 - 2024-11-12 2 5 * Add - Customer List table -
ambikly/trunk/languages/ambikly.pot
r3186894 r3195809 7 7 "Content-Type: text/plain; charset=UTF-8\n" 8 8 "Content-Transfer-Encoding: 8bit\n" 9 "POT-Creation-Date: 2024-11- 13 03:59+0000\n"9 "POT-Creation-Date: 2024-11-24 10:53+0000\n" 10 10 "X-Poedit-Basepath: ..\n" 11 11 "X-Poedit-KeywordsList: __;_e;_ex:1,2c;_n:1,2;_n_noop:1,2;_nx:1,2,4c;_nx_noop:1,2,3c;_x:1,2c;esc_attr__;esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c\n" … … 235 235 msgstr "" 236 236 237 #: ../src/Forms/CheckoutForm.php:13, ../src/ListTable/CustomersListTable.php:27 237 #: ../src/Forms/CheckoutForm.php:12 238 msgid "-- Select Country --" 239 msgstr "" 240 241 #: ../src/Forms/CheckoutForm.php:17, ../src/ListTable/CustomersListTable.php:27 238 242 msgid "First Name" 239 243 msgstr "" 240 244 241 #: ../src/Forms/CheckoutForm.php:1 5245 #: ../src/Forms/CheckoutForm.php:19 242 246 msgid "Enter your first name" 243 247 msgstr "" 244 248 245 #: ../src/Forms/CheckoutForm.php:2 0, ../src/ListTable/CustomersListTable.php:28249 #: ../src/Forms/CheckoutForm.php:24, ../src/ListTable/CustomersListTable.php:28 246 250 msgid "Last Name" 247 251 msgstr "" 248 252 249 #: ../src/Forms/CheckoutForm.php:2 2253 #: ../src/Forms/CheckoutForm.php:26 250 254 msgid "Enter your last name" 251 255 msgstr "" 252 256 253 #: ../src/Forms/CheckoutForm.php:3 0257 #: ../src/Forms/CheckoutForm.php:34 254 258 msgid "Phone" 255 259 msgstr "" 256 260 257 #: ../src/Forms/CheckoutForm.php:3 2261 #: ../src/Forms/CheckoutForm.php:36 258 262 msgid "Enter your phone number" 259 263 msgstr "" 260 264 261 #: ../src/Forms/CheckoutForm.php:3 5265 #: ../src/Forms/CheckoutForm.php:39 262 266 msgid "Country" 263 267 msgstr "" 264 268 265 #: ../src/Forms/CheckoutForm.php: 38269 #: ../src/Forms/CheckoutForm.php:42 266 270 msgid "Enter your country" 267 271 msgstr "" 268 272 269 #: ../src/Forms/CheckoutForm.php: 48273 #: ../src/Forms/CheckoutForm.php:52 270 274 msgid "State" 271 275 msgstr "" 272 276 273 #: ../src/Forms/CheckoutForm.php:5 1277 #: ../src/Forms/CheckoutForm.php:55 274 278 msgid "Enter your state" 275 279 msgstr "" 276 280 277 #: ../src/Forms/CheckoutForm.php: 59281 #: ../src/Forms/CheckoutForm.php:63 278 282 msgid "City" 279 283 msgstr "" 280 284 281 #: ../src/Forms/CheckoutForm.php:6 2285 #: ../src/Forms/CheckoutForm.php:66 282 286 msgid "Enter your city" 283 287 msgstr "" 284 288 285 #: ../src/Forms/CheckoutForm.php:6 5289 #: ../src/Forms/CheckoutForm.php:69 286 290 msgid "Address" 287 291 msgstr "" 288 292 289 #: ../src/Forms/CheckoutForm.php: 68293 #: ../src/Forms/CheckoutForm.php:72 290 294 msgid "Enter your address" 291 295 msgstr "" 292 296 293 #: ../src/Forms/CheckoutForm.php:7 2297 #: ../src/Forms/CheckoutForm.php:76 294 298 msgid "Zip Code" 295 299 msgstr "" 296 300 297 #: ../src/Forms/CheckoutForm.php:7 5301 #: ../src/Forms/CheckoutForm.php:79 298 302 msgid "Enter your zip code" 299 303 msgstr "" 300 304 301 #: ../src/Forms/CheckoutForm.php:8 4, ../src/Options/OrderOptions.php:72, ../src/Options/OrderOptions.php:74305 #: ../src/Forms/CheckoutForm.php:88, ../src/Options/OrderOptions.php:72, ../src/Options/OrderOptions.php:74 302 306 msgid "Order Note" 303 307 msgstr "" 304 308 305 #: ../src/Forms/CheckoutForm.php: 86309 #: ../src/Forms/CheckoutForm.php:90 306 310 msgid "Add any notes about your order" 307 311 msgstr "" … … 10501 10505 10502 10506 #: ../src/Gateways/PayPal/Settings.php:42 10503 msgid "PayPal Email."10507 msgid "PayPal account email address" 10504 10508 msgstr "" 10505 10509 -
ambikly/trunk/readme.txt
r3186894 r3195809 1 === Ambikly - The easiest way to start selling online ===1 === Ambikly - The easiest way to start selling online, WordPress eCommerce plugin === 2 2 Contributors: Ambikly 3 Tags: ecommerce, online store, payments, ecommerce plugin 3 Tags: ecommerce, online store, payments, ecommerce plugin, sell 4 4 Requires at least: 5.4 5 5 Tested up to: 6.7 6 6 Requires PHP: 7.4 7 Stable tag: 0.0. 77 Stable tag: 0.0.8 8 8 License: GPLv3 9 9 License URI: https://www.gnu.org/licenses/gpl-3.0.html … … 60 60 61 61 == Changelog == 62 = 0.0.7 - 2024-11-13 63 * Fix - PHP Compatibility issue fixed 62 = 0.0.8 - 2024-11-24 63 * Fix - Guest checkout issue fixed 64 * Fix - Cart Issue fixed 64 65 65 66 [See changelog for all versions](https://plugins.svn.wordpress.org/ambikly/trunk/changelog.txt). -
ambikly/trunk/src/Admin/Pages/DashboardPage.php
r3184536 r3195809 7 7 use Ambikly\Controllers\ReportController; 8 8 9 class DashboardPage 9 class DashboardPage extends BasePage 10 10 { 11 11 public function __construct() -
ambikly/trunk/src/Assets.php
r3184536 r3195809 13 13 public function register() 14 14 { 15 // Libraries 16 wp_register_style( 17 'ambikly-select2-style', 18 AMBIKLY_ASSETS_URI . 'lib/select2/css/select2.css', 19 ); 20 wp_register_script( 21 'ambikly-select2-script', 22 AMBIKLY_ASSETS_URI . 'lib/select2/js/select2.js' 23 ); 24 15 25 wp_register_script( 16 26 'ambikly-common-js', … … 67 77 'ambikly-checkout-style', 68 78 AMBIKLY_ASSETS_URI . 'css/checkout-style.css', 69 array('ambikly-common-style' )79 array('ambikly-common-style', 'ambikly-select2-style') 70 80 ); 71 81 wp_register_script( 72 82 'ambikly-checkout-js', 73 83 AMBIKLY_ASSETS_URI . 'js/checkout-script.js', 74 array('ambikly-common-js' ),84 array('ambikly-common-js', 'ambikly-select2-script'), 75 85 AMBIKLY_VERSION, 76 86 true … … 101 111 ); 102 112 } 103 wp_localize_script('ambikly-common-js', 'ambikly', [ 113 114 $localize_data = [ 104 115 'ajax_url' => admin_url('admin-ajax.php'), 105 ]); 116 ]; 117 118 if (get_the_ID() == ambikly_get_checkout_page()) { 119 $localize_data['states'] = include AMBIKLY_ABSPATH . 'src/Helpers/states.php'; 120 } 121 122 123 wp_localize_script('ambikly-common-js', 'ambikly', $localize_data); 106 124 107 125 } -
ambikly/trunk/src/Controllers/CheckoutController.php
r3186548 r3195809 94 94 do_action('ambikly_process_' . $this->payment_method . '_payment', $order_id, $payment_method, $sanitized_data, $this); 95 95 96 //$this->cart_controller->clear_cart();96 $this->cart_controller->clear_cart(); 97 97 } 98 98 -
ambikly/trunk/src/Forms/CheckoutForm.php
r3184536 r3195809 8 8 protected function initialize_fields() 9 9 { 10 $countries = ambikly_get_countries(); 11 12 $countries = array_merge(['' => __('-- Select Country --', 'ambikly')], $countries); 13 10 14 $this->fields = [ 11 15 … … 37 41 'required' => true, 38 42 'placeholder' => esc_html__('Enter your country', 'ambikly'), 39 'options' => ambikly_get_countries(),43 'options' => $countries, 40 44 'class' => 'half', 41 45 'attributes' => [ -
ambikly/trunk/src/Gateways/PayPal/PayPal.php
r3184536 r3195809 191 191 192 192 193 $args['option_index_0'] = $args_index;193 $args['option_index_0'] = ($args_index-1); 194 194 195 195 $order_code = $order_details['order_code'] ?? ''; -
ambikly/trunk/src/Gateways/PayPal/Settings.php
r3184536 r3195809 40 40 'label' => esc_html__('PayPal Email', 'ambikly'), 41 41 'name' => $this->id . '_email', 42 'placeholder' => esc_html__('PayPal Email.', 'ambikly'),42 'placeholder' => esc_html__('PayPal account email address', 'ambikly'), 43 43 ], 44 44 -
ambikly/trunk/src/Shortcodes/CheckoutShortcode.php
r3184536 r3195809 18 18 19 19 wp_enqueue_script('ambikly-checkout-js'); 20 20 21 /** 21 22 * @var $ambikly_cart Cart
Note: See TracChangeset
for help on using the changeset viewer.