Plugin Directory

Changeset 3195809


Ignore:
Timestamp:
11/24/2024 10:54:54 AM (16 months ago)
Author:
ambikly
Message:

Update to version 0.0.8 from GitHub

Location:
ambikly
Files:
30 edited
1 copied

Legend:

Unmodified
Added
Removed
  • ambikly/tags/0.0.8/ambikly.php

    r3186894 r3195809  
    66 * Author: ambikly
    77 * Author URI: https://profiles.wordpress.org/ambikly
    8  * Version: 0.0.7
     8 * Version: 0.0.8
    99 * License: GPLv3+
    1010 * License URI: https://www.gnu.org/licenses/gpl-3.0.html
     
    2828// Define AMBIKLY_VERSION.
    2929if (!defined('AMBIKLY_VERSION')) {
    30     define('AMBIKLY_VERSION', '0.0.7');
     30    define('AMBIKLY_VERSION', '0.0.8');
    3131}
    3232
  • ambikly/tags/0.0.8/assets/admin/css/dashboard-style.css

    r3184536 r3195809  
    1717  justify-content: space-between;
    1818  margin-bottom: 20px;
     19  gap: 20px;
    1920}
    2021
     
    2526  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    2627  padding: 20px;
    27   margin: 0 10px;
     28  margin: 0;
    2829  text-align: center;
    2930}
  • 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  
    277277        return;
    278278    checkoutForm.addEventListener('submit', handleSubmit);
     279    var billingCountry = checkoutForm.querySelector('[name="billing_country"]');
     280    billingCountry.addEventListener('change', handleCountryChange);
     281    //initLib();
     282}
     283function 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);
    279325}
    280326// 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;oBACl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C,YAAY,KAAK,UAAU,IAAI,YAAY,CAAC,YAAY,EAAE,CAAC;QACxE,UAAU,CAAC;YACP,MAAM,CAAC,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,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AC;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\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
    14= 0.0.6 -   2024-11-12
    25* Add   -   Customer List table
  • ambikly/tags/0.0.8/languages/ambikly.pot

    r3186894 r3195809  
    77"Content-Type: text/plain; charset=UTF-8\n"
    88"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"
    1010"X-Poedit-Basepath: ..\n"
    1111"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"
     
    235235msgstr ""
    236236
    237 #: ../src/Forms/CheckoutForm.php:13, ../src/ListTable/CustomersListTable.php:27
     237#: ../src/Forms/CheckoutForm.php:12
     238msgid "-- Select Country --"
     239msgstr ""
     240
     241#: ../src/Forms/CheckoutForm.php:17, ../src/ListTable/CustomersListTable.php:27
    238242msgid "First Name"
    239243msgstr ""
    240244
    241 #: ../src/Forms/CheckoutForm.php:15
     245#: ../src/Forms/CheckoutForm.php:19
    242246msgid "Enter your first name"
    243247msgstr ""
    244248
    245 #: ../src/Forms/CheckoutForm.php:20, ../src/ListTable/CustomersListTable.php:28
     249#: ../src/Forms/CheckoutForm.php:24, ../src/ListTable/CustomersListTable.php:28
    246250msgid "Last Name"
    247251msgstr ""
    248252
    249 #: ../src/Forms/CheckoutForm.php:22
     253#: ../src/Forms/CheckoutForm.php:26
    250254msgid "Enter your last name"
    251255msgstr ""
    252256
    253 #: ../src/Forms/CheckoutForm.php:30
     257#: ../src/Forms/CheckoutForm.php:34
    254258msgid "Phone"
    255259msgstr ""
    256260
    257 #: ../src/Forms/CheckoutForm.php:32
     261#: ../src/Forms/CheckoutForm.php:36
    258262msgid "Enter your phone number"
    259263msgstr ""
    260264
    261 #: ../src/Forms/CheckoutForm.php:35
     265#: ../src/Forms/CheckoutForm.php:39
    262266msgid "Country"
    263267msgstr ""
    264268
    265 #: ../src/Forms/CheckoutForm.php:38
     269#: ../src/Forms/CheckoutForm.php:42
    266270msgid "Enter your country"
    267271msgstr ""
    268272
    269 #: ../src/Forms/CheckoutForm.php:48
     273#: ../src/Forms/CheckoutForm.php:52
    270274msgid "State"
    271275msgstr ""
    272276
    273 #: ../src/Forms/CheckoutForm.php:51
     277#: ../src/Forms/CheckoutForm.php:55
    274278msgid "Enter your state"
    275279msgstr ""
    276280
    277 #: ../src/Forms/CheckoutForm.php:59
     281#: ../src/Forms/CheckoutForm.php:63
    278282msgid "City"
    279283msgstr ""
    280284
    281 #: ../src/Forms/CheckoutForm.php:62
     285#: ../src/Forms/CheckoutForm.php:66
    282286msgid "Enter your city"
    283287msgstr ""
    284288
    285 #: ../src/Forms/CheckoutForm.php:65
     289#: ../src/Forms/CheckoutForm.php:69
    286290msgid "Address"
    287291msgstr ""
    288292
    289 #: ../src/Forms/CheckoutForm.php:68
     293#: ../src/Forms/CheckoutForm.php:72
    290294msgid "Enter your address"
    291295msgstr ""
    292296
    293 #: ../src/Forms/CheckoutForm.php:72
     297#: ../src/Forms/CheckoutForm.php:76
    294298msgid "Zip Code"
    295299msgstr ""
    296300
    297 #: ../src/Forms/CheckoutForm.php:75
     301#: ../src/Forms/CheckoutForm.php:79
    298302msgid "Enter your zip code"
    299303msgstr ""
    300304
    301 #: ../src/Forms/CheckoutForm.php:84, ../src/Options/OrderOptions.php:72, ../src/Options/OrderOptions.php:74
     305#: ../src/Forms/CheckoutForm.php:88, ../src/Options/OrderOptions.php:72, ../src/Options/OrderOptions.php:74
    302306msgid "Order Note"
    303307msgstr ""
    304308
    305 #: ../src/Forms/CheckoutForm.php:86
     309#: ../src/Forms/CheckoutForm.php:90
    306310msgid "Add any notes about your order"
    307311msgstr ""
     
    1050110505
    1050210506#: ../src/Gateways/PayPal/Settings.php:42
    10503 msgid "PayPal Email."
     10507msgid "PayPal account email address"
    1050410508msgstr ""
    1050510509
  • 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 ===
    22Contributors: Ambikly
    3 Tags: ecommerce, online store, payments, ecommerce plugin
     3Tags: ecommerce, online store, payments, ecommerce plugin, sell
    44Requires at least: 5.4
    55Tested up to: 6.7
    66Requires PHP: 7.4
    7 Stable tag: 0.0.7
     7Stable tag: 0.0.8
    88License: GPLv3
    99License URI: https://www.gnu.org/licenses/gpl-3.0.html
     
    6060
    6161== 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
    6465
    6566[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  
    77use Ambikly\Controllers\ReportController;
    88
    9 class DashboardPage
     9class DashboardPage extends BasePage
    1010{
    1111    public function __construct()
  • ambikly/tags/0.0.8/src/Assets.php

    r3184536 r3195809  
    1313    public function register()
    1414    {
     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
    1525        wp_register_script(
    1626            'ambikly-common-js',
     
    6777            'ambikly-checkout-style',
    6878            AMBIKLY_ASSETS_URI . 'css/checkout-style.css',
    69             array('ambikly-common-style')
     79            array('ambikly-common-style', 'ambikly-select2-style')
    7080        );
    7181        wp_register_script(
    7282            'ambikly-checkout-js',
    7383            AMBIKLY_ASSETS_URI . 'js/checkout-script.js',
    74             array('ambikly-common-js'),
     84            array('ambikly-common-js', 'ambikly-select2-script'),
    7585            AMBIKLY_VERSION,
    7686            true
     
    101111            );
    102112        }
    103         wp_localize_script('ambikly-common-js', 'ambikly', [
     113
     114        $localize_data = [
    104115            '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);
    106124
    107125    }
  • ambikly/tags/0.0.8/src/Controllers/CheckoutController.php

    r3186548 r3195809  
    9494            do_action('ambikly_process_' . $this->payment_method . '_payment', $order_id, $payment_method, $sanitized_data, $this);
    9595
    96             //$this->cart_controller->clear_cart();
     96            $this->cart_controller->clear_cart();
    9797        }
    9898
  • ambikly/tags/0.0.8/src/Forms/CheckoutForm.php

    r3184536 r3195809  
    88    protected function initialize_fields()
    99    {
     10        $countries = ambikly_get_countries();
     11
     12        $countries = array_merge(['' => __('-- Select Country --', 'ambikly')], $countries);
     13
    1014        $this->fields = [
    1115
     
    3741                'required' => true,
    3842                'placeholder' => esc_html__('Enter your country', 'ambikly'),
    39                 'options' => ambikly_get_countries(),
     43                'options' => $countries,
    4044                'class' => 'half',
    4145                'attributes' => [
  • ambikly/tags/0.0.8/src/Gateways/PayPal/PayPal.php

    r3184536 r3195809  
    191191
    192192
    193         $args['option_index_0'] = $args_index;
     193        $args['option_index_0'] = ($args_index-1);
    194194
    195195        $order_code = $order_details['order_code'] ?? '';
  • ambikly/tags/0.0.8/src/Gateways/PayPal/Settings.php

    r3184536 r3195809  
    4040                    'label' => esc_html__('PayPal Email', 'ambikly'),
    4141                    'name' => $this->id . '_email',
    42                     'placeholder' => esc_html__('PayPal Email.', 'ambikly'),
     42                    'placeholder' => esc_html__('PayPal account email address', 'ambikly'),
    4343                ],
    4444
  • ambikly/tags/0.0.8/src/Shortcodes/CheckoutShortcode.php

    r3184536 r3195809  
    1818
    1919        wp_enqueue_script('ambikly-checkout-js');
     20
    2021        /**
    2122         * @var $ambikly_cart Cart
  • ambikly/trunk/ambikly.php

    r3186894 r3195809  
    66 * Author: ambikly
    77 * Author URI: https://profiles.wordpress.org/ambikly
    8  * Version: 0.0.7
     8 * Version: 0.0.8
    99 * License: GPLv3+
    1010 * License URI: https://www.gnu.org/licenses/gpl-3.0.html
     
    2828// Define AMBIKLY_VERSION.
    2929if (!defined('AMBIKLY_VERSION')) {
    30     define('AMBIKLY_VERSION', '0.0.7');
     30    define('AMBIKLY_VERSION', '0.0.8');
    3131}
    3232
  • ambikly/trunk/assets/admin/css/dashboard-style.css

    r3184536 r3195809  
    1717  justify-content: space-between;
    1818  margin-bottom: 20px;
     19  gap: 20px;
    1920}
    2021
     
    2526  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    2627  padding: 20px;
    27   margin: 0 10px;
     28  margin: 0;
    2829  text-align: center;
    2930}
  • 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  
    277277        return;
    278278    checkoutForm.addEventListener('submit', handleSubmit);
     279    var billingCountry = checkoutForm.querySelector('[name="billing_country"]');
     280    billingCountry.addEventListener('change', handleCountryChange);
     281    //initLib();
     282}
     283function 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);
    279325}
    280326// 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;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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,CA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AC,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\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
    14= 0.0.6 -   2024-11-12
    25* Add   -   Customer List table
  • ambikly/trunk/languages/ambikly.pot

    r3186894 r3195809  
    77"Content-Type: text/plain; charset=UTF-8\n"
    88"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"
    1010"X-Poedit-Basepath: ..\n"
    1111"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"
     
    235235msgstr ""
    236236
    237 #: ../src/Forms/CheckoutForm.php:13, ../src/ListTable/CustomersListTable.php:27
     237#: ../src/Forms/CheckoutForm.php:12
     238msgid "-- Select Country --"
     239msgstr ""
     240
     241#: ../src/Forms/CheckoutForm.php:17, ../src/ListTable/CustomersListTable.php:27
    238242msgid "First Name"
    239243msgstr ""
    240244
    241 #: ../src/Forms/CheckoutForm.php:15
     245#: ../src/Forms/CheckoutForm.php:19
    242246msgid "Enter your first name"
    243247msgstr ""
    244248
    245 #: ../src/Forms/CheckoutForm.php:20, ../src/ListTable/CustomersListTable.php:28
     249#: ../src/Forms/CheckoutForm.php:24, ../src/ListTable/CustomersListTable.php:28
    246250msgid "Last Name"
    247251msgstr ""
    248252
    249 #: ../src/Forms/CheckoutForm.php:22
     253#: ../src/Forms/CheckoutForm.php:26
    250254msgid "Enter your last name"
    251255msgstr ""
    252256
    253 #: ../src/Forms/CheckoutForm.php:30
     257#: ../src/Forms/CheckoutForm.php:34
    254258msgid "Phone"
    255259msgstr ""
    256260
    257 #: ../src/Forms/CheckoutForm.php:32
     261#: ../src/Forms/CheckoutForm.php:36
    258262msgid "Enter your phone number"
    259263msgstr ""
    260264
    261 #: ../src/Forms/CheckoutForm.php:35
     265#: ../src/Forms/CheckoutForm.php:39
    262266msgid "Country"
    263267msgstr ""
    264268
    265 #: ../src/Forms/CheckoutForm.php:38
     269#: ../src/Forms/CheckoutForm.php:42
    266270msgid "Enter your country"
    267271msgstr ""
    268272
    269 #: ../src/Forms/CheckoutForm.php:48
     273#: ../src/Forms/CheckoutForm.php:52
    270274msgid "State"
    271275msgstr ""
    272276
    273 #: ../src/Forms/CheckoutForm.php:51
     277#: ../src/Forms/CheckoutForm.php:55
    274278msgid "Enter your state"
    275279msgstr ""
    276280
    277 #: ../src/Forms/CheckoutForm.php:59
     281#: ../src/Forms/CheckoutForm.php:63
    278282msgid "City"
    279283msgstr ""
    280284
    281 #: ../src/Forms/CheckoutForm.php:62
     285#: ../src/Forms/CheckoutForm.php:66
    282286msgid "Enter your city"
    283287msgstr ""
    284288
    285 #: ../src/Forms/CheckoutForm.php:65
     289#: ../src/Forms/CheckoutForm.php:69
    286290msgid "Address"
    287291msgstr ""
    288292
    289 #: ../src/Forms/CheckoutForm.php:68
     293#: ../src/Forms/CheckoutForm.php:72
    290294msgid "Enter your address"
    291295msgstr ""
    292296
    293 #: ../src/Forms/CheckoutForm.php:72
     297#: ../src/Forms/CheckoutForm.php:76
    294298msgid "Zip Code"
    295299msgstr ""
    296300
    297 #: ../src/Forms/CheckoutForm.php:75
     301#: ../src/Forms/CheckoutForm.php:79
    298302msgid "Enter your zip code"
    299303msgstr ""
    300304
    301 #: ../src/Forms/CheckoutForm.php:84, ../src/Options/OrderOptions.php:72, ../src/Options/OrderOptions.php:74
     305#: ../src/Forms/CheckoutForm.php:88, ../src/Options/OrderOptions.php:72, ../src/Options/OrderOptions.php:74
    302306msgid "Order Note"
    303307msgstr ""
    304308
    305 #: ../src/Forms/CheckoutForm.php:86
     309#: ../src/Forms/CheckoutForm.php:90
    306310msgid "Add any notes about your order"
    307311msgstr ""
     
    1050110505
    1050210506#: ../src/Gateways/PayPal/Settings.php:42
    10503 msgid "PayPal Email."
     10507msgid "PayPal account email address"
    1050410508msgstr ""
    1050510509
  • 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 ===
    22Contributors: Ambikly
    3 Tags: ecommerce, online store, payments, ecommerce plugin
     3Tags: ecommerce, online store, payments, ecommerce plugin, sell
    44Requires at least: 5.4
    55Tested up to: 6.7
    66Requires PHP: 7.4
    7 Stable tag: 0.0.7
     7Stable tag: 0.0.8
    88License: GPLv3
    99License URI: https://www.gnu.org/licenses/gpl-3.0.html
     
    6060
    6161== 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
    6465
    6566[See changelog for all versions](https://plugins.svn.wordpress.org/ambikly/trunk/changelog.txt).
  • ambikly/trunk/src/Admin/Pages/DashboardPage.php

    r3184536 r3195809  
    77use Ambikly\Controllers\ReportController;
    88
    9 class DashboardPage
     9class DashboardPage extends BasePage
    1010{
    1111    public function __construct()
  • ambikly/trunk/src/Assets.php

    r3184536 r3195809  
    1313    public function register()
    1414    {
     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
    1525        wp_register_script(
    1626            'ambikly-common-js',
     
    6777            'ambikly-checkout-style',
    6878            AMBIKLY_ASSETS_URI . 'css/checkout-style.css',
    69             array('ambikly-common-style')
     79            array('ambikly-common-style', 'ambikly-select2-style')
    7080        );
    7181        wp_register_script(
    7282            'ambikly-checkout-js',
    7383            AMBIKLY_ASSETS_URI . 'js/checkout-script.js',
    74             array('ambikly-common-js'),
     84            array('ambikly-common-js', 'ambikly-select2-script'),
    7585            AMBIKLY_VERSION,
    7686            true
     
    101111            );
    102112        }
    103         wp_localize_script('ambikly-common-js', 'ambikly', [
     113
     114        $localize_data = [
    104115            '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);
    106124
    107125    }
  • ambikly/trunk/src/Controllers/CheckoutController.php

    r3186548 r3195809  
    9494            do_action('ambikly_process_' . $this->payment_method . '_payment', $order_id, $payment_method, $sanitized_data, $this);
    9595
    96             //$this->cart_controller->clear_cart();
     96            $this->cart_controller->clear_cart();
    9797        }
    9898
  • ambikly/trunk/src/Forms/CheckoutForm.php

    r3184536 r3195809  
    88    protected function initialize_fields()
    99    {
     10        $countries = ambikly_get_countries();
     11
     12        $countries = array_merge(['' => __('-- Select Country --', 'ambikly')], $countries);
     13
    1014        $this->fields = [
    1115
     
    3741                'required' => true,
    3842                'placeholder' => esc_html__('Enter your country', 'ambikly'),
    39                 'options' => ambikly_get_countries(),
     43                'options' => $countries,
    4044                'class' => 'half',
    4145                'attributes' => [
  • ambikly/trunk/src/Gateways/PayPal/PayPal.php

    r3184536 r3195809  
    191191
    192192
    193         $args['option_index_0'] = $args_index;
     193        $args['option_index_0'] = ($args_index-1);
    194194
    195195        $order_code = $order_details['order_code'] ?? '';
  • ambikly/trunk/src/Gateways/PayPal/Settings.php

    r3184536 r3195809  
    4040                    'label' => esc_html__('PayPal Email', 'ambikly'),
    4141                    'name' => $this->id . '_email',
    42                     'placeholder' => esc_html__('PayPal Email.', 'ambikly'),
     42                    'placeholder' => esc_html__('PayPal account email address', 'ambikly'),
    4343                ],
    4444
  • ambikly/trunk/src/Shortcodes/CheckoutShortcode.php

    r3184536 r3195809  
    1818
    1919        wp_enqueue_script('ambikly-checkout-js');
     20
    2021        /**
    2122         * @var $ambikly_cart Cart
Note: See TracChangeset for help on using the changeset viewer.