diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..3fa69a7 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +*.* @seebeen @oblakbot diff --git a/.github/scripts/deploy.sh b/.github/scripts/deploy.sh deleted file mode 100644 index c1a9c09..0000000 --- a/.github/scripts/deploy.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -cp -p .wordpress-org/readme.txt ./ diff --git a/.github/scripts/release.sh b/.github/scripts/release.sh deleted file mode 100644 index b9ba5ca..0000000 --- a/.github/scripts/release.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash - -PROJECT_NAME="serbian-addons-for-woocommerce" -NEXT_VERSION=$1 -CURRENT_VERSION=$(cat $PROJECT_NAME.php | grep "Version" | head -1 | awk -F= "{ print $2 }" | sed 's/[* Version:,\",]//g' | tr -d '[[:space:]]') - -sed -i "s/Version: $CURRENT_VERSION/Version: $NEXT_VERSION/g" serbian-addons-for-woocommerce.php -sed -i "s/'$CURRENT_VERSION'/'$NEXT_VERSION'/g" lib/Serbian_WooCommerce.php -sed -i "s/Stable tag: $CURRENT_VERSION/Stable tag: $NEXT_VERSION/g" ./.wordpress-org/readme.txt - -rm -f /tmp/release.zip -mkdir /tmp/$PROJECT_NAME -cp -ar config dist languages lib vendor ./*.php loco.xml /tmp/$PROJECT_NAME 2>/dev/null -cp ./.wordpress-org/readme.txt /tmp/$PROJECT_NAME 2>/dev/null - -cd /tmp || exit -zip -qr /tmp/release.zip ./*.php $PROJECT_NAME diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5907971..092c4cd 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -15,6 +15,7 @@ on: - 'package.json' - 'package-lock.json' - 'serbian-addons-for-woocommerce.php' + - 'release.config.js' jobs: ci: diff --git a/.github/workflows/reusable_release.yml b/.github/workflows/reusable_release.yml index b2539a0..6054b4d 100644 --- a/.github/workflows/reusable_release.yml +++ b/.github/workflows/reusable_release.yml @@ -124,6 +124,7 @@ jobs: name: Publish runs-on: ubuntu-latest needs: release + if: ${{ inputs.dry_run == false }} steps: - name: Download Package uses: actions/download-artifact@v4 diff --git a/.github/workflows/wp-assets.yml b/.github/workflows/wp-assets.yml deleted file mode 100644 index 4304491..0000000 --- a/.github/workflows/wp-assets.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: Plugin asset/readme update -on: - workflow_call: - -jobs: - master: - name: Push to trunk - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Pre deploy scripts - run: 'sh ./.github/scripts/deploy.sh' - - name: WordPress.org plugin asset/readme update - uses: 10up/action-wordpress-plugin-asset-update@2.1.3 - env: - SVN_USERNAME: ${{ secrets.WP_ORG_SVN_USERNAME }} - SVN_PASSWORD: ${{ secrets.WP_ORG_SVN_PASSWORD }} - ASSETS_DIR: '.wordpress-org/assets' - README_NAME: 'readme.txt' diff --git a/.github/workflows/wp-deploy.yml b/.github/workflows/wp-deploy.yml deleted file mode 100644 index 0670fe8..0000000 --- a/.github/workflows/wp-deploy.yml +++ /dev/null @@ -1,46 +0,0 @@ -name: Deploy to WP.org svn -on: - workflow_call: - -jobs: - tag: - name: Tag deploy - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - node-version: 16 - cache: yarn - - name: Cache Composer dependencies - uses: actions/cache@v4 - with: - path: /tmp/composer-cache - key: ${{ runner.os }}-${{ hashFiles('**/composer.lock') }} - - name: Install composer dependencies - uses: php-actions/composer@v6 - with: - php_version: '8.0' - version: 2 - dev: no - quiet: yes - args: --optimize-autoloader --classmap-authoritative --prefer-dist - - name: Install Yarn dependencies - run: yarn install - - name: Build - run: 'yarn build:production' - - name: Pre deploy scripts - run: 'sh ./.github/scripts/deploy.sh' - - name: WordPress Plugin Deploy - id: deploy - uses: 10up/action-wordpress-plugin-deploy@2.2.2 - env: - SVN_USERNAME: ${{ secrets.WP_ORG_SVN_USERNAME }} - SVN_PASSWORD: ${{ secrets.WP_ORG_SVN_PASSWORD }} - ASSETS_DIR: '.wordpress-org/assets' - with: - generate-zip: false diff --git a/.gitignore b/.gitignore index 1cf49a2..9ffb3db 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .vscode dist languages/*backup* +languages/*.php node_modules vendor diff --git a/assets/scripts/@types/index.d.ts b/assets/scripts/@types/index.d.ts index 320c874..ae9d797 100644 --- a/assets/scripts/@types/index.d.ts +++ b/assets/scripts/@types/index.d.ts @@ -1,6 +1,13 @@ -// eslint-disable-next-line @typescript-eslint/no-unused-vars -import _ from 'lodash'; - declare global { - const _: typeof _; + const Backbone: typeof Backbone; + const _: _.UnderscoreStatic; + + interface Window { + wc_address_i18n_params: any; + wp: { + template: (id: string) => _.CompiledTemplate; + }; + } } + +export {}; diff --git a/assets/scripts/admin/controllers/company-settings.controller.ts b/assets/scripts/admin/controllers/company-settings.controller.ts index 3f1d85d..3788b93 100644 --- a/assets/scripts/admin/controllers/company-settings.controller.ts +++ b/assets/scripts/admin/controllers/company-settings.controller.ts @@ -1,42 +1,41 @@ -import { TemplateExecutor } from 'lodash'; - export class CompanySettingsController { - private templates: Record = {}; + private templates: Record = {}; init(): void { - document - .querySelectorAll('.repeater-tmpl') - .forEach((tmpl) => this.registerTemplate(tmpl)); + this.registerTemplates('woocommerce_store_bank_accounts'); } finalize(): void { document .querySelectorAll('.repeater-add-row') - .forEach((btn) => btn.addEventListener('click', (e) => this.addRow(e))); + .forEach((btn) => + btn.addEventListener('click', ({ target }) => + this.addRow(target as HTMLButtonElement), + ), + ); document .querySelector('.bank-accounts') - .addEventListener('click', (e) => this.removeRow(e)); + .addEventListener('click', ({ target }) => + this.removeRow(target as HTMLButtonElement), + ); } - private registerTemplate(tmpl: HTMLElement): void { - this.templates[tmpl.id] = _.template(tmpl.innerHTML); + private registerTemplates(...ids: string[]): void { + ids.forEach((id) => { + this.templates[id] = window.wp.template(id); + }); } - private addRow(event: Event): void { - const btn = event.target as HTMLButtonElement; - const { tmpl, ...template } = btn.dataset; - const id = tmpl.replace('-tmpl', ''); - - const wrapper = document.createElement('div'); - wrapper.innerHTML = this.templates[tmpl]({ data: template }); + private addRow(btn: HTMLButtonElement): void { + const { tmpl, ...data } = btn.dataset; - document.querySelector(`#${id}`).appendChild(wrapper.querySelector('div')); + document + .querySelector(`#${tmpl}`) + .insertAdjacentHTML('beforeend', this.templates[tmpl](data)); } - private removeRow(e: Event): void { - const btn = e.target as HTMLButtonElement; - + private removeRow(btn: HTMLButtonElement): void { if (!btn.classList.contains('repeater-remove-row')) { return; } diff --git a/assets/scripts/frontend/controllers/address-page.controller.ts b/assets/scripts/frontend/controllers/address-page.controller.ts index 1ed68fb..fdb4a35 100644 --- a/assets/scripts/frontend/controllers/address-page.controller.ts +++ b/assets/scripts/frontend/controllers/address-page.controller.ts @@ -1,25 +1,77 @@ const $ = jQuery; export default class AddressPageController { - private $inputs: JQuery; + private selector = '.entity-type-control input'; + private locale: Record; public init(): void { - this.$inputs = $('.entity-type-control input[type="radio"]'); + this.locale = JSON.parse(window.wc_address_i18n_params.locale_fields); } public finalize(): void { - this.$inputs.on('click', ({ currentTarget }) => - this.toggleFields($(currentTarget)), + $(document.body).on('change refresh', this.selector, (e) => { + console.log('change refresh'); + this.toggleEntityType($(e.target)); + }); + + $(document.body).on('country_to_state_changing', () => { + window.setTimeout( + () => this.toggleEntityType($(`${this.selector}:checked`)), + 100, + ); + console.log('country_to_state_changing'); + }); + } + + private toggleEntityType($input: JQuery): void { + const isCompany = $input.val() === 'company'; + + console.log($input.is(':checked'), $input.val()); + + this.isRequired($('.entity-type-toggle'), isCompany); + } + + private isRequired( + $field: JQuery, + required: boolean, + ): void { + $field.find('input').prop({ + 'aria-required': required, + disabled: !required, + }); + + if (required) { + $field.find('label .optional').remove(); + $field.addClass('shown validate-required'); + + if ($field.find('label .required').length === 0) { + $field + .find('label') + .append( + `*`, + ); + } + + return; + } + + $field.find('label .required').remove(); + $field.removeClass( + 'shown validate-required woocommerce-invalid woocommerce-invalid-required-field', ); - this.toggleFields(this.$inputs.filter(':checked')); + + if ($field.find('label .optional').length === 0) { + $field + .find('label') + .append( + `${window.wc_address_i18n_params.i18n_optional_text}`, + ); + } } private toggleFields($toggle: JQuery): void { const isPerson = $toggle.attr('value') === 'person'; - $('.hide-if-person').toggleClass('shown', !isPerson).find('input').prop({ - required: isPerson, - disabled: isPerson, - }); + $('.hide-if-person').toggleClass('shown', !isPerson); } } diff --git a/assets/styles/components/_billing_fields.scss b/assets/styles/components/_billing_fields.scss index 90296ca..285a6de 100644 --- a/assets/styles/components/_billing_fields.scss +++ b/assets/styles/components/_billing_fields.scss @@ -15,11 +15,11 @@ } } - .hide-if-person { - display: none; + .entity-type-toggle { + display: none !important; &.shown { - display: block; + display: block !important; } } } diff --git a/composer.json b/composer.json index 4695804..cb4c03b 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "type": "project", "require": { "php": "^8.0", - "automattic/jetpack-autoloader": "^3", + "automattic/jetpack-autoloader": "^3.1", "chillerlan/php-qrcode": "^5", "oblak/serbian-validators": "^1", "oblak/woocommerce-utils": "^1.27", @@ -10,6 +10,7 @@ "oblak/wp-plugin-installer": "^2", "x-wp/asset-loader": "^1.0", "x-wp/helper-functions": "^1.4", + "x-wp/helper-woocommerce": "^1.13", "x-wp/wc-template-customizer": "^1.0" }, "require-dev": { @@ -19,13 +20,19 @@ }, "autoload": { "psr-4": { - "Oblak\\WooCommerce\\Serbian_Addons\\": "lib" + "Oblak\\WCSRB\\": "lib/" }, + "classmap": [ + "lib/Admin/", + "lib/Gateway/", + "lib/QR/" + ], "files": [ - "lib/Utils/wcsrb-core.php", - "lib/Utils/wcsrb-helpers.php", - "lib/Utils/wcsrb-payment-slip.php", - "lib/Utils/wcsrb-settings.php" + "lib/Functions/wcsrb-address-field-fns.php", + "lib/Functions/wcsrb-core.php", + "lib/Functions/wcsrb-helpers.php", + "lib/Functions/wcsrb-payment-slip.php", + "lib/Functions/wcsrb-settings.php" ] }, "config": { diff --git a/composer.lock b/composer.lock index 00a5d85..b6062b8 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "818339a7921273dcd4c25b6a61e03072", + "content-hash": "927f847326d94c6a3659abdbf13afecb", "packages": [ { "name": "automattic/jetpack-autoloader", @@ -371,21 +371,22 @@ }, { "name": "oblak/woocommerce-utils", - "version": "v1.31.2", + "version": "v1.31.3", "source": { "type": "git", "url": "https://github.com/oblakstudio/woocommerce-utils.git", - "reference": "6c6043c43e3eb276da599f160aba7570831b8f88" + "reference": "5e8315c951455495f3e21a24a41958eb0a41d92b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/oblakstudio/woocommerce-utils/zipball/6c6043c43e3eb276da599f160aba7570831b8f88", - "reference": "6c6043c43e3eb276da599f160aba7570831b8f88", + "url": "https://api.github.com/repos/oblakstudio/woocommerce-utils/zipball/5e8315c951455495f3e21a24a41958eb0a41d92b", + "reference": "5e8315c951455495f3e21a24a41958eb0a41d92b", "shasum": "" }, "require": { - "oblak/wp-polyfills": "^1.1", - "php": ">= 8.0" + "php": ">= 8.0", + "x-wp/helper-functions": "^1.9", + "x-wp/helper-traits": "^1.9" }, "require-dev": { "ergebnis/composer-normalize": "^2.31", @@ -418,9 +419,9 @@ "description": "This module contains various utilities for WooCommerce.", "support": { "issues": "https://github.com/oblakstudio/woocommerce-utils/issues", - "source": "https://github.com/oblakstudio/woocommerce-utils/tree/v1.31.2" + "source": "https://github.com/oblakstudio/woocommerce-utils/tree/v1.31.3" }, - "time": "2024-02-09T22:27:39+00:00" + "time": "2024-09-22T03:30:34+00:00" }, { "name": "oblak/wp-hook-di", @@ -528,69 +529,6 @@ }, "time": "2024-02-09T21:39:23+00:00" }, - { - "name": "oblak/wp-polyfills", - "version": "v1.4.2", - "source": { - "type": "git", - "url": "https://github.com/oblakstudio/wp-polyfills.git", - "reference": "b5d433d81c97339abb6153bc8e1c3fe797815ae0" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/oblakstudio/wp-polyfills/zipball/b5d433d81c97339abb6153bc8e1c3fe797815ae0", - "reference": "b5d433d81c97339abb6153bc8e1c3fe797815ae0", - "shasum": "" - }, - "require": { - "php": ">= 8.0 < 8.2" - }, - "require-dev": { - "ergebnis/composer-normalize": "^2.31", - "oblak/wordpress-coding-standard": "^1" - }, - "suggest": { - "automattic/jetpack-autoloader": "Allow for better interoperability with other plugins that use this package." - }, - "type": "library", - "autoload": { - "files": [ - "src/oblak-polyfill-array.php", - "src/oblak-polyfill-block.php", - "src/oblak-polyfill-conditionals.php", - "src/oblak-polyfill-filter.php", - "src/oblak-polyfill-terms.php", - "src/oblak-polyfill-wpfs.php" - ], - "psr-4": { - "Oblak\\WP\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "GPL-2.0-only" - ], - "authors": [ - { - "name": "Sibin Grasic", - "email": "sibin.grasic@oblak.studio" - } - ], - "description": "Various polyfills for WordPress.", - "keywords": [ - "compat", - "compatibility", - "polyfill", - "shim", - "shims", - "wordpress" - ], - "support": { - "issues": "https://github.com/oblakstudio/wp-polyfills/issues", - "source": "https://github.com/oblakstudio/wp-polyfills/tree/v1.4.2" - }, - "time": "2024-01-24T06:00:19+00:00" - }, { "name": "woocommerce/action-scheduler", "version": "3.8.2", @@ -700,16 +638,16 @@ }, { "name": "x-wp/helper-functions", - "version": "v1.9.1", + "version": "v1.13.1", "source": { "type": "git", "url": "https://github.com/x-wp/helper-functions.git", - "reference": "2f9ed127f62f37e1c87ccfd3153d551a5bcd3839" + "reference": "93f6c928cd08192298e572a49873e3bd6b7aad49" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/x-wp/helper-functions/zipball/2f9ed127f62f37e1c87ccfd3153d551a5bcd3839", - "reference": "2f9ed127f62f37e1c87ccfd3153d551a5bcd3839", + "url": "https://api.github.com/repos/x-wp/helper-functions/zipball/93f6c928cd08192298e572a49873e3bd6b7aad49", + "reference": "93f6c928cd08192298e572a49873e3bd6b7aad49", "shasum": "" }, "require": { @@ -750,13 +688,13 @@ ], "support": { "issues": "https://github.com/x-wp/helper-functions/issues", - "source": "https://github.com/x-wp/helper-functions/tree/v1.9.1" + "source": "https://github.com/x-wp/helper-functions/tree/v1.13.1" }, - "time": "2024-09-18T12:43:44+00:00" + "time": "2024-09-23T14:26:03+00:00" }, { "name": "x-wp/helper-traits", - "version": "v1.9.1", + "version": "v1.13.1", "source": { "type": "git", "url": "https://github.com/x-wp/helper-traits.git", @@ -802,10 +740,60 @@ ], "support": { "issues": "https://github.com/x-wp/helper-traits/issues", - "source": "https://github.com/x-wp/helper-traits/tree/v1.9.1" + "source": "https://github.com/x-wp/helper-traits/tree/v1.13.1" }, "time": "2024-09-18T12:43:44+00:00" }, + { + "name": "x-wp/helper-woocommerce", + "version": "v1.13.1", + "source": { + "type": "git", + "url": "https://github.com/x-wp/helper-woocommerce.git", + "reference": "15d74e968ca875df0cdd5084337c7fed4a03c3cb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/x-wp/helper-woocommerce/zipball/15d74e968ca875df0cdd5084337c7fed4a03c3cb", + "reference": "15d74e968ca875df0cdd5084337c7fed4a03c3cb", + "shasum": "" + }, + "require": { + "php": ">=8.0" + }, + "suggest": { + "automattic/jetpack-autoloader": "Allow for better interoperability with other plugins that use this package." + }, + "type": "library", + "autoload": { + "psr-4": { + "XWC\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "GPL-2.0-only" + ], + "authors": [ + { + "name": "Sibin Grasic", + "email": "sibin.grasic@oblak.studio" + } + ], + "description": "Utilities and helpers for WooCommerce", + "keywords": [ + "abstractions", + "decoupling", + "extended-wp", + "interoperability", + "woocommerce" + ], + "support": { + "issues": "https://github.com/x-wp/helper-woocommerce/issues", + "source": "https://github.com/x-wp/helper-woocommerce/tree/v1.13.1" + }, + "time": "2024-09-25T09:23:08+00:00" + }, { "name": "x-wp/wc-template-customizer", "version": "v1.0.0", @@ -1412,16 +1400,16 @@ }, { "name": "phpstan/phpdoc-parser", - "version": "1.30.1", + "version": "1.31.0", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "51b95ec8670af41009e2b2b56873bad96682413e" + "reference": "249f15fb843bf240cf058372dad29e100cee6c17" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/51b95ec8670af41009e2b2b56873bad96682413e", - "reference": "51b95ec8670af41009e2b2b56873bad96682413e", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/249f15fb843bf240cf058372dad29e100cee6c17", + "reference": "249f15fb843bf240cf058372dad29e100cee6c17", "shasum": "" }, "require": { @@ -1453,9 +1441,9 @@ "description": "PHPDoc parser with support for nullable, intersection and generic types", "support": { "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/1.30.1" + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.31.0" }, - "time": "2024-09-07T20:13:05+00:00" + "time": "2024-09-22T11:32:18+00:00" }, { "name": "slevomat/coding-standard", diff --git a/config/assets.php b/config/assets.php index e0e6888..675e0eb 100644 --- a/config/assets.php +++ b/config/assets.php @@ -23,6 +23,6 @@ 'base_uri' => plugins_url( 'dist', WCRS_PLUGIN_BASE ), 'id' => 'wcrs', 'manifest' => 'assets.php', - 'priority' => 50, + 'priority' => 500, 'version' => WCRS_VERSION, ); diff --git a/config/company-settings.php b/config/company-settings.php new file mode 100644 index 0000000..b680df0 --- /dev/null +++ b/config/company-settings.php @@ -0,0 +1,70 @@ + \__( 'Company information', 'woocommerce' ), + 'type' => 'title', + 'desc' => \__( 'This is where your business is located. Tax rates and shipping rates will use this address.', 'woocommerce' ), + 'id' => 'store_address', + ), + + array( + 'title' => \__( 'Business name', 'serbian-addons-for-woocommerce' ), + 'desc' => \__( 'Name of your business', 'serbian-addons-for-woocommerce' ), + 'id' => 'woocommerce_store_name', + 'default' => '', + 'type' => 'text', + 'desc_tip' => true, + ), + + array( + 'title' => \__( 'Address line 1', 'woocommerce' ), + 'desc' => \__( 'The street address for your business location.', 'woocommerce' ), + 'id' => 'woocommerce_store_address', + 'default' => '', + 'type' => 'text', + 'desc_tip' => true, + ), + + array( + 'title' => \__( 'Address line 2', 'woocommerce' ), + 'desc' => \__( 'An additional, optional address line for your business location.', 'woocommerce' ), + 'id' => 'woocommerce_store_address_2', + 'default' => '', + 'type' => 'text', + 'desc_tip' => true, + ), + + array( + 'title' => \__( 'City', 'woocommerce' ), + 'desc' => \__( 'The city in which your business is located.', 'woocommerce' ), + 'id' => 'woocommerce_store_city', + 'default' => '', + 'type' => 'text', + 'desc_tip' => true, + ), + + array( + 'title' => \__( 'Country / State', 'woocommerce' ), + 'desc' => \__( 'The country and state or province, if any, in which your business is located.', 'woocommerce' ), + 'id' => 'woocommerce_default_country', + 'default' => 'US:CA', + 'type' => 'single_select_country', + 'desc_tip' => true, + ), + + array( + 'title' => \__( 'Postcode / ZIP', 'woocommerce' ), + 'desc' => \__( 'The postal code, if any, in which your business is located.', 'woocommerce' ), + 'id' => 'woocommerce_store_postcode', + 'css' => 'min-width:50px;', + 'default' => '', + 'type' => 'text', + 'desc_tip' => true, + ), +); diff --git a/languages/serbian-addons-for-woocommerce-sr_RS.mo b/languages/serbian-addons-for-woocommerce-sr_RS.mo new file mode 100644 index 0000000..650168b Binary files /dev/null and b/languages/serbian-addons-for-woocommerce-sr_RS.mo differ diff --git a/languages/serbian-addons-for-woocommerce-sr_RS.po b/languages/serbian-addons-for-woocommerce-sr_RS.po new file mode 100644 index 0000000..d8811d0 --- /dev/null +++ b/languages/serbian-addons-for-woocommerce-sr_RS.po @@ -0,0 +1,627 @@ +# Translation of Plugins - Serbian Addons for WooCommerce - Stable (latest release) in Serbian +# This file is distributed under the same license as the Plugins - Serbian Addons for WooCommerce - Stable (latest release) package. +msgid "" +msgstr "" +"PO-Revision-Date: 2024-09-25 10:40+0000\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=3; plural=(n % 10 == 1 && n % 100 != 11) ? 0 : ((n % " +"10 >= 2 && n % 10 <= 4 && (n % 100 < 12 || n % 100 > 14)) ? 1 : 2);\n" +"X-Generator: Loco https://localise.biz/\n" +"Language: sr_RS\n" +"Project-Id-Version: Plugins - Serbian Addons for WooCommerce - Stable " +"(latest release)\n" +"Language-Team: Српски језик" + +#: woocommerce/checkout/payment-slip-qr-code.php:40 +msgid "" +" Security is guaranteed by the standards of the National Bank of Serbia." +msgstr " Безбедност гарантују стандарди и прописи Народне Банке Србије" + +#. Translators: %d is the payment code. +#: lib/Utils/wcsrb-settings.php:52 +msgid "%d - Final expenses" +msgstr "%d - Финална потрошња" + +#. Translators: %d is the payment code. +#: lib/Utils/wcsrb-settings.php:50 +msgid "%d - Interim expenses" +msgstr "%d - Међуфазна потрошња" + +#. Translators: %d is the payment code. +#: lib/Utils/wcsrb-settings.php:61 +msgid "%d - Other transactions" +msgstr "%d - Остале трансакције" + +#. Translators: %d is the payment code. +#: lib/Utils/wcsrb-settings.php:57 +msgid "%d - Transactions on behalf of a person" +msgstr "%d - Трансакције по налогу грађана" + +#. Translators: %s is the bank name. +#: lib/Utils/wcsrb-helpers.php:37 +msgid "%s Bank" +msgstr "%s Банка" + +#: woocommerce/checkout/payment-slip.php:144 +msgid "Account payable" +msgstr "Рачун примаоца" + +#: config/pg-slip-settings.php:40 +msgid "Add to e-mail" +msgstr "" + +#: lib/Utils/wcsrb-helpers.php:46 +msgid "Addiko" +msgstr "Адико" + +#: lib/Order/Field_Display.php:134 +msgctxt "Address display" +msgid "Company Number" +msgstr "МБ" + +#: lib/Order/Field_Display.php:140 +msgctxt "Address display" +msgid "Tax Identification Number" +msgstr "ПИБ" + +#: config/pg-slip-settings.php:169 +msgid "Advanced Settings" +msgstr "Напредна подешавања" + +#: lib/Utils/wcsrb-helpers.php:40 +msgid "AIK" +msgstr "АИК" + +#: lib/Utils/wcsrb-helpers.php:48 +msgid "Alta" +msgstr "Алта" + +#: woocommerce/checkout/payment-slip.php:114 +msgid "Amount" +msgstr "Износ" + +#: lib/Utils/wcsrb-helpers.php:63 +msgid "API" +msgstr "АПИ" + +#: lib/Utils/wcsrb-payment-slip.php:40 lib/Utils/wcsrb-settings.php:44 +msgid "Automatic" +msgstr "Аутоматски" + +#: lib/Utils/wcsrb-helpers.php:45 +msgid "Banca Intesa" +msgstr "Банка Интеза" + +#: config/pg-slip-settings.php:57 +msgid "Bank account" +msgstr "Жиро рачун" + +#: config/pg-slip-settings.php:60 +msgid "Bank account number" +msgstr "Број рачуна" + +#: config/settings.php:63 +msgid "Bank accounts" +msgstr "Жиро рачуни" + +#: config/settings.php:65 +msgid "Bank accounts of your business." +msgstr "Жиро рачуни ваше фирме." + +#: lib/Utils/wcsrb-helpers.php:65 +msgid "Bank of China" +msgstr "Кинеска банка" + +#: config/company-settings.php:17 +msgid "Business name" +msgstr "Име фирме" + +#: config/settings.php:47 +msgid "" +"By default, currency is displayed in cyrillic. This will transliterate it" +msgstr "" +"Динарска валута ће се подразумевано приказати на ћирилици. Активирање ове " +"опције ће пресловити валуту" + +#. translators: %1$s line break. +#: config/pg-slip-settings.php:89 +msgid "" +"Choosing the model 97 will automatically set the payment reference.%1$sWe " +"recommend using model 97 because payment processor guarantees verbatim " +"reference transfer only if it is done via model 97 " +msgstr "" +"Уколико одаберете Модел 97, позив на број ће бити подешен аутоматски и не " +"може бити промењен.%1$sПрепоручујемо коришћење модела 97 с обзиром на то да " +"пружалац платних услуга у складу са прописима одговара за пренети садржај " +"позива на број одобрења само ако је позив на број уписан у складу са моделом " +"97 " + +#: config/pg-slip-settings.php:49 +msgid "Classic" +msgstr "Класични" + +#: config/pg-slip-settings.php:143 +msgid "Color of the corner dots on the QR code" +msgstr "Боја тачака у углу QR кôда" + +#: config/pg-slip-settings.php:135 +msgid "Color of the dots on the QR code" +msgstr "Боја тачака QR кôда" + +#: config/settings.php:28 +msgid "Companies and persons" +msgstr "Физичка и правна лица" + +#: lib/Utils/wcsrb-helpers.php:17 lib/Utils/wcsrb-settings.php:48 +#: lib/Utils/wcsrb-settings.php:67 lib/Utils/wcsrb-settings.php:71 +msgid "Company" +msgstr "Правно лице" + +#: config/settings.php:58 +msgid "Company information" +msgstr "Подаци о фирми" + +#: lib/Checkout/Field_Validator.php:117 +msgid "Company name is required" +msgstr "Морате унети име фирме" + +#: lib/Checkout/Field_Customizer.php:183 lib/Order/Field_Display.php:186 +msgid "Company Number" +msgstr "Матични број" + +#: lib/Checkout/Field_Validator.php:122 +msgid "Company number is invalid" +msgstr "Матични број фирме није валидан" + +#: lib/Checkout/Field_Validator.php:127 +msgid "Company Tax Number is invalid" +msgstr "ПИБ није валидан" + +#: woocommerce/checkout/payment-slip-qr-code.php:53 +msgid "Confirm with your PIN or fingerprint" +msgstr "Потврдите плаћање ПИН кодом или отиском прста" + +#: config/pg-slip-settings.php:140 +msgid "Corner dot color" +msgstr "Боја тачака у угловима" + +#: lib/Utils/wcsrb-helpers.php:59 +msgid "Credit Agricole" +msgstr "Кредит агриколе" + +#: lib/Utils/wcsrb-payment-slip.php:64 +msgid "Customer ID" +msgstr "Идентификатор купца" + +#: lib/Checkout/Field_Customizer.php:149 lib/Order/Field_Display.php:178 +msgid "Customer type" +msgstr "Купујем као" + +#: config/pg-slip-settings.php:174 +msgid "Debug log" +msgstr "Лог за дебаговање" + +#: config/pg-slip-settings.php:53 +msgid "Defines the style of the payment slip" +msgstr "Изглед опште уплатнице" + +#: config/pg-slip-settings.php:26 +msgid "Description" +msgstr "Опис" + +#: lib/Utils/wcsrb-helpers.php:43 +msgid "Direct" +msgstr "Директна" + +#: config/pg-slip-settings.php:132 +msgid "Dot color" +msgstr "Боја тачака" + +#: config/pg-slip-settings.php:176 +msgid "Enable logging" +msgstr "Омогући логовање" + +#: config/pg-slip-settings.php:14 +msgid "Enable Payment Slip" +msgstr "Активирај плаћање општом уплатницом" + +#: config/pg-slip-settings.php:13 +msgid "Enable/Disable" +msgstr "Активирај/Деактивирај" + +#: config/settings.php:23 +msgid "Enabled customer types" +msgstr "Дозвољени типови купаца" + +#: config/settings.php:67 +msgid "Enter bank account" +msgstr "Унесите жиро рачун" + +#: lib/Checkout/Field_Customizer.php:184 +msgid "Enter MB" +msgstr "" + +#: lib/Checkout/Field_Customizer.php:193 +msgid "Enter PIB" +msgstr "" + +#: lib/Utils/wcsrb-helpers.php:60 +msgid "Erste" +msgstr "Ерсте" + +#: lib/Utils/wcsrb-helpers.php:52 +msgid "Eurobank Direct" +msgstr "Еуробанк Директна" + +#: lib/Utils/wcsrb-helpers.php:42 +msgid "Expobank" +msgstr "Експобанк" + +#: config/settings.php:35 +msgid "Field removal" +msgstr "Сакривање поља" + +#: config/settings.php:16 +msgid "General settings" +msgstr "Општа подешавања" + +#: config/settings.php:18 +msgid "General settings for Serbian Addons for WooCommerce" +msgstr "Општа подешавања српских додатака за WooCommerce" + +#: lib/Utils/wcsrb-helpers.php:44 +msgid "Halkbank" +msgstr "Халкбанк" + +#: lib/Gateway/Gateway_Payment_Slip.php:151 +msgid "Have your customers pay you by sending you money via wire transfer." +msgstr "" +"Плаћање општом уплатницом у поштама и банкама србије са опцијом генерисања " +"НБС ИПС QR кôда" + +#: lib/Admin/Plugin_Settings_Page.php:63 +msgid "here" +msgstr "овде" + +#: woocommerce/checkout/payment-slip-qr-code.php:43 +msgid "How to pay" +msgstr "Како извршити уплату" + +#. Author URI of the plugin +#: serbian-addons-for-woocommerce.php +msgid "https://oblak.studio" +msgstr "https://oblak.studio" + +#. Plugin URI of the plugin +#: serbian-addons-for-woocommerce.php +msgid "https://oblak.studio/open-source/srpski-woocommerce" +msgstr "https://oblak.studio/open-source/srpski-woocommerce" + +#: config/pg-slip-settings.php:152 +msgid "Image that will be shown on the QR code. " +msgstr "Слика која ће бити приказана у средини QR кôда " + +#: woocommerce/checkout/payment-slip-qr-code.php:26 +msgid "Instant payment" +msgstr "Инстант плаћање" + +#. Translators: %s is the invalid bank account number. +#: lib/Admin/Plugin_Settings_Page.php:153 +msgid "Invalid bank account number: %s" +msgstr "" + +#: lib/Gateway/Gateway_Payment_Slip_IPS_Handler.php:328 +msgid "IPS QR Code" +msgstr "ИПС QR кôд" + +#. translators: %1$s log file path, %2$s line break. +#: config/pg-slip-settings.php:180 +msgid "" +"Log Payment Slip events, inside %1$s %2$sNote: this may log personal " +"information. We recommend using this for debugging purposes only and " +"deleting the logs when finished." +msgstr "" +"Логуј догађаје Опште Уплатнице унутар %1$s %2$s Напомена: Лог датотека може " +"садржати личне информације. Препоручујемо Вам да користите ово само у сврху " +"дебаговања, као и да обришете логове након завршетка." + +#: lib/Utils/wcsrb-helpers.php:64 +msgid "Mirabank" +msgstr "Мирабанк" + +#: lib/Utils/wcsrb-helpers.php:41 +msgid "Mobi" +msgstr "Моби" + +#: woocommerce/checkout/payment-slip.php:159 +msgid "Model" +msgstr "Модел" + +#: lib/Utils/wcsrb-payment-slip.php:41 +msgid "Model 97" +msgstr "Модел 97" + +#: config/pg-slip-settings.php:50 +msgid "Modern" +msgstr "Модеран" + +#: lib/Utils/wcsrb-helpers.php:61 +msgid "MTS" +msgstr "МТС" + +#: config/company-settings.php:18 +msgid "Name of your business" +msgstr "Име ваше фирме" + +#: lib/Utils/wcsrb-helpers.php:57 +msgid "NLB" +msgstr "НЛБ" + +#: lib/Utils/wcsrb-helpers.php:50 +msgid "NLB Commercial" +msgstr "НЛБ Комерцијална" + +#. Author of the plugin +#: serbian-addons-for-woocommerce.php +msgid "Oblak Studio" +msgstr "Облак Студио" + +#: lib/Utils/wcsrb-helpers.php:62 +msgid "Opportunity" +msgstr "Опортунити" + +#: lib/Utils/wcsrb-payment-slip.php:67 +msgid "Order date" +msgstr "Датум наруџбине" + +#: lib/Utils/wcsrb-payment-slip.php:68 +msgid "Order ID" +msgstr "Идентификатор наруџбине" + +#: lib/Utils/wcsrb-payment-slip.php:69 +msgid "Order number" +msgstr "Број наруџбине" + +#: config/pg-slip-settings.php:108 +msgid "Order payment" +msgstr "Плаћање наруџбине" + +#: lib/Utils/wcsrb-helpers.php:54 +msgid "OTP" +msgstr "ОТП" + +#: config/pg-slip-settings.php:29 +msgid "Pay by sending us money via wire transfer" +msgstr "Платите наруџбину општом уплатницом" + +#: config/pg-slip-settings.php:69 woocommerce/checkout/payment-slip.php:98 +msgid "Payment code" +msgstr "Шифра плаћања" + +#: config/pg-slip-settings.php:74 +msgid "Payment code on the payment slip" +msgstr "Шифра плаћања која ће бити приказана на општој уплатници" + +#: woocommerce/checkout/payment-slip.php:28 +msgid "Payment instructions" +msgstr "Инструкције за уплату" + +#: woocommerce/checkout/payment-slip-qr-code.php:56 +msgid "Payment is complete" +msgstr "Плаћање је извршено" + +#: config/pg-slip-settings.php:82 +msgid "Payment model" +msgstr "Модел плаћања" + +#: config/pg-slip-settings.php:86 +msgid "Payment model for the payment reference" +msgstr "Модел за позив на број" + +#: config/pg-slip-settings.php:106 woocommerce/checkout/payment-slip.php:58 +msgid "Payment purpose" +msgstr "Сврха уплате" + +#: config/pg-slip-settings.php:95 woocommerce/checkout/payment-slip.php:167 +msgid "Payment reference" +msgstr "Позив на број" + +#: lib/Gateway/Gateway_Payment_Slip.php:155 +msgid "Payment Slip" +msgstr "Општа уплатница" + +#: lib/Utils/wcsrb-helpers.php:16 lib/Utils/wcsrb-settings.php:54 +#: lib/Utils/wcsrb-settings.php:68 lib/Utils/wcsrb-settings.php:74 +msgid "Person" +msgstr "Физичко лице" + +#: lib/Utils/wcsrb-helpers.php:49 +msgid "Postal Savings" +msgstr "Поштанска штедионица" + +#: lib/Utils/wcsrb-helpers.php:51 +msgid "ProCredit" +msgstr "ПроКредит" + +#: config/pg-slip-settings.php:112 +msgid "QR Code" +msgstr "QR кôд" + +#: lib/Utils/wcsrb-helpers.php:53 +msgid "Raiffeisen" +msgstr "Рајфајзен" + +#: woocommerce/checkout/payment-slip.php:73 +msgid "Reciever" +msgstr "Прималац" + +#: config/settings.php:38 +msgid "Remove unneeded fields from the checkout page" +msgstr "Уклоните непотребна поља на страници за куповину" + +#: config/settings.php:39 +msgid "Removes Address 2 and State fields" +msgstr "Активирање ове опције ће сакрити поља Адреса 2 и Округ" + +#: lib/Utils/wcsrb-helpers.php:55 +msgid "Sberbank" +msgstr "Сбербанк" + +#: woocommerce/checkout/payment-slip-qr-code.php:50 +msgid "Scan the QR code" +msgstr "Скенирајте QR кôд" + +#: lib/Utils/wcsrb-settings.php:20 +msgid "Select bank account" +msgstr "Одаберите жиро рачун" + +#: woocommerce/checkout/payment-slip-qr-code.php:47 +msgid "Select IPS SCAN in the m-banking app" +msgstr "Одаберите ИПС Скенирај у м-банкинг апликацији" + +#: woocommerce/checkout/payment-slip.php:42 +msgid "Sender" +msgstr "Пошиљаоц" + +#: lib/Utils/wcsrb-helpers.php:56 +msgid "Serbian" +msgstr "Српски" + +#: lib/Admin/Plugin_Settings_Page.php:24 +msgid "Serbian Addons" +msgstr "Српски додаци" + +#. Plugin Name of the plugin +#: serbian-addons-for-woocommerce.php lib/Core/Installer.php:28 +msgid "Serbian Addons for WooCommerce" +msgstr "Српски додаци за WooCommerce" + +#: lib/Gateway/Gateway_Payment_Slip.php:184 +msgid "Serbian Payment Slip does not support your store currency." +msgstr "Плаћање општом уплатницом није подржано за вашу валуту." + +#: lib/Gateway/Gateway_Payment_Slip.php:194 +msgid "Serbian Payment Slip requires at least one bank account." +msgstr "Плаћање општом уплатницом захтева бар један унет жиро рачун" + +#: lib/Core/Installer.php:45 lib/Core/Installer.php:46 +msgid "Settings" +msgstr "Подешавања" + +#: config/pg-slip-settings.php:114 +msgid "Settings for NBS IPS QR Code" +msgstr "Подешавања за НБС ИПС QR кôд" + +#: config/pg-slip-settings.php:148 +msgid "Show image" +msgstr "Прикажи слику" + +#: config/pg-slip-settings.php:150 +msgid "Show image on QR code" +msgstr "Прикажи слику на QR кôду" + +#: config/pg-slip-settings.php:42 +msgid "Show payment slip in the order confirmation e-mail" +msgstr "" + +#: config/pg-slip-settings.php:118 +msgid "Show QR code" +msgstr "Прикажи QR кôд" + +#: config/pg-slip-settings.php:125 +msgid "Show QR code in emails" +msgstr "" + +#: config/pg-slip-settings.php:127 +msgid "Show QR code in order confirmation emails" +msgstr "" + +#: config/pg-slip-settings.php:120 +msgid "Show QR code on the payment slip" +msgstr "Прикажи QR кôд на општој уплатници" + +#: config/pg-slip-settings.php:35 +msgid "Slip settings" +msgstr "Подешавања уплатнице" + +#. Translators: %s is a link to the company settings page. +#: lib/Admin/Plugin_Settings_Page.php:59 +msgid "Store settings have been moved %s" +msgstr "Подешавања продавнице су премештена %s" + +#: config/pg-slip-settings.php:46 +msgid "Style" +msgstr "Изглед" + +#: lib/Checkout/Field_Customizer.php:192 lib/Order/Field_Display.php:191 +msgid "Tax Number" +msgstr "ПИБ" + +#: woocommerce/checkout/payment-slip-qr-code.php:37 +msgid "" +"The NBS IPS QR code is an innovative way to perform instant payments using " +"mobile devices." +msgstr "" +"НБС ИПС QR кôд је иновативни начин за инстант плаћање коришћењем мобилних " +"уређаја" + +#: config/pg-slip-settings.php:28 +msgid "This controls the description which the user sees during checkout." +msgstr "Опис који ће купац видети приликом куповине" + +#: config/pg-slip-settings.php:21 +msgid "This controls the title which the user sees during checkout." +msgstr "Назив који ће купац видети приликом куповине" + +#: config/pg-slip-settings.php:19 +msgid "Title" +msgstr "Назив" + +#: config/settings.php:43 +msgid "Transliterate currency symbol" +msgstr "Преслови валуту" + +#: config/settings.php:46 +msgid "Transliterate currency symbol to latin script" +msgstr "Пресловљава валуту у латиницу" + +#: lib/Utils/wcsrb-helpers.php:47 +msgid "UniCredit" +msgstr "УниКредит" + +#. Description of the plugin +#: serbian-addons-for-woocommerce.php +msgid "" +"Various addons and tweaks that make WooCommerce compatible with Serbian " +"bureaucracy." +msgstr "" +"Raзни додаци и подешавања која ће ускладити вашу продавницу са српским " +"књиговодстевним прописима." + +#: lib/Utils/wcsrb-helpers.php:58 +msgid "Vojvodjanska" +msgstr "Војвођанска" + +#: config/settings.php:26 +msgid "Which customer types can shop on the store" +msgstr "Дефинише који типови купаца могу да праве наруџбине" + +#. translators: %1$s opening link tag, %2$s closing link tag. +#: config/pg-slip-settings.php:63 +msgid "You can add your bank account details in the %1$sCompany settings%2$s ." +msgstr "Можете додати ваш банковни рачун у %1$sПодешвањима компаније%2$s" + +#: config/pg-slip-settings.php:73 +msgid "" +"You can choose a payment code only if you limit checkout to a single " +"customer type." +msgstr "" +"Можете одабрати шифру плаћања само ако ограничите куповину на одређени тип " +"купца" + +#. translators: %1$s opening link tag, %2$s Customizer title, %3$s closing link tag, %3$s current image HTML. +#: config/pg-slip-settings.php:155 +msgid "You can set it in %1$s%2$s%3$s. Current image is: %4$s" +msgstr "Слику можете подесити овде: %1$s%2$s%3$s. Тренутна слика: %4$s" diff --git a/languages/serbian-addons-for-woocommerce.pot b/languages/serbian-addons-for-woocommerce.pot index 2fa6f58..7cf9b7d 100644 --- a/languages/serbian-addons-for-woocommerce.pot +++ b/languages/serbian-addons-for-woocommerce.pot @@ -2,263 +2,292 @@ # This file is distributed under the GPLv2 or later. msgid "" msgstr "" -"Project-Id-Version: Serbian Addons for WooCommerce 3.5.5\n" +"Project-Id-Version: Serbian Addons for WooCommerce 0.0.0\n" "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/serbian-addons-for-woocommerce\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"POT-Creation-Date: 2024-02-02T17:25:16+01:00\n" +"POT-Creation-Date: 2024-09-25T12:39:15+02:00\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"X-Generator: WP-CLI 2.9.0\n" +"X-Generator: WP-CLI 2.10.0\n" "X-Domain: serbian-addons-for-woocommerce\n" #. Plugin Name of the plugin +#: serbian-addons-for-woocommerce.php #: lib/Core/Installer.php:28 msgid "Serbian Addons for WooCommerce" msgstr "" #. Plugin URI of the plugin +#: serbian-addons-for-woocommerce.php msgid "https://oblak.studio/open-source/srpski-woocommerce" msgstr "" #. Description of the plugin +#: serbian-addons-for-woocommerce.php msgid "Various addons and tweaks that make WooCommerce compatible with Serbian bureaucracy." msgstr "" #. Author of the plugin +#: serbian-addons-for-woocommerce.php msgid "Oblak Studio" msgstr "" #. Author URI of the plugin +#: serbian-addons-for-woocommerce.php msgid "https://oblak.studio" msgstr "" -#: config/pg-slip-settings.php:18 +#: config/company-settings.php:17 +msgid "Business name" +msgstr "" + +#: config/company-settings.php:18 +msgid "Name of your business" +msgstr "" + +#: config/pg-slip-settings.php:13 msgid "Enable/Disable" msgstr "" -#: config/pg-slip-settings.php:19 +#: config/pg-slip-settings.php:14 msgid "Enable Payment Slip" msgstr "" -#: config/pg-slip-settings.php:24 +#: config/pg-slip-settings.php:19 msgid "Title" msgstr "" -#: config/pg-slip-settings.php:26 +#: config/pg-slip-settings.php:21 msgid "This controls the title which the user sees during checkout." msgstr "" -#: config/pg-slip-settings.php:31 +#: config/pg-slip-settings.php:26 msgid "Description" msgstr "" -#: config/pg-slip-settings.php:33 +#: config/pg-slip-settings.php:28 msgid "This controls the description which the user sees during checkout." msgstr "" -#: config/pg-slip-settings.php:34 +#: config/pg-slip-settings.php:29 msgid "Pay by sending us money via wire transfer" msgstr "" -#: config/pg-slip-settings.php:40 +#: config/pg-slip-settings.php:35 msgid "Slip settings" msgstr "" -#: config/pg-slip-settings.php:45 +#: config/pg-slip-settings.php:40 +msgid "Add to e-mail" +msgstr "" + +#: config/pg-slip-settings.php:42 +msgid "Show payment slip in the order confirmation e-mail" +msgstr "" + +#: config/pg-slip-settings.php:46 msgid "Style" msgstr "" -#: config/pg-slip-settings.php:48 +#: config/pg-slip-settings.php:49 msgid "Classic" msgstr "" -#: config/pg-slip-settings.php:49 +#: config/pg-slip-settings.php:50 msgid "Modern" msgstr "" -#: config/pg-slip-settings.php:52 +#: config/pg-slip-settings.php:53 msgid "Defines the style of the payment slip" msgstr "" -#: config/pg-slip-settings.php:56 +#: config/pg-slip-settings.php:57 msgid "Bank account" msgstr "" -#: config/pg-slip-settings.php:59 +#: config/pg-slip-settings.php:60 msgid "Bank account number" msgstr "" #. translators: %1$s opening link tag, %2$s closing link tag. -#: config/pg-slip-settings.php:62 +#: config/pg-slip-settings.php:63 msgid "You can add your bank account details in the %1$sCompany settings%2$s ." msgstr "" -#: config/pg-slip-settings.php:68 +#: config/pg-slip-settings.php:69 #: woocommerce/checkout/payment-slip.php:98 msgid "Payment code" msgstr "" -#: config/pg-slip-settings.php:72 +#: config/pg-slip-settings.php:73 msgid "You can choose a payment code only if you limit checkout to a single customer type." msgstr "" -#: config/pg-slip-settings.php:73 +#: config/pg-slip-settings.php:74 msgid "Payment code on the payment slip" msgstr "" -#: config/pg-slip-settings.php:81 +#: config/pg-slip-settings.php:82 msgid "Payment model" msgstr "" -#: config/pg-slip-settings.php:85 +#: config/pg-slip-settings.php:86 msgid "Payment model for the payment reference" msgstr "" #. translators: %1$s line break. -#: config/pg-slip-settings.php:88 +#: config/pg-slip-settings.php:89 msgid "Choosing the model 97 will automatically set the payment reference.%1$sWe recommend using model 97 because payment processor guarantees verbatim reference transfer only if it is done via model 97 " msgstr "" -#: config/pg-slip-settings.php:94 +#: config/pg-slip-settings.php:95 #: woocommerce/checkout/payment-slip.php:167 msgid "Payment reference" msgstr "" -#: config/pg-slip-settings.php:105 +#: config/pg-slip-settings.php:106 #: woocommerce/checkout/payment-slip.php:58 msgid "Payment purpose" msgstr "" -#: config/pg-slip-settings.php:107 +#: config/pg-slip-settings.php:108 msgid "Order payment" msgstr "" -#: config/pg-slip-settings.php:111 +#: config/pg-slip-settings.php:112 msgid "QR Code" msgstr "" -#: config/pg-slip-settings.php:113 +#: config/pg-slip-settings.php:114 msgid "Settings for NBS IPS QR Code" msgstr "" -#: config/pg-slip-settings.php:117 +#: config/pg-slip-settings.php:118 msgid "Show QR code" msgstr "" -#: config/pg-slip-settings.php:119 +#: config/pg-slip-settings.php:120 msgid "Show QR code on the payment slip" msgstr "" -#: config/pg-slip-settings.php:124 -msgid "Dot color" +#: config/pg-slip-settings.php:125 +msgid "Show QR code in emails" msgstr "" #: config/pg-slip-settings.php:127 -msgid "Color of the dots on the QR code" +msgid "Show QR code in order confirmation emails" msgstr "" #: config/pg-slip-settings.php:132 -msgid "Corner dot color" +msgid "Dot color" msgstr "" #: config/pg-slip-settings.php:135 -msgid "Color of the corner dots on the QR code" +msgid "Color of the dots on the QR code" msgstr "" #: config/pg-slip-settings.php:140 +msgid "Corner dot color" +msgstr "" + +#: config/pg-slip-settings.php:143 +msgid "Color of the corner dots on the QR code" +msgstr "" + +#: config/pg-slip-settings.php:148 msgid "Show image" msgstr "" -#: config/pg-slip-settings.php:142 +#: config/pg-slip-settings.php:150 msgid "Show image on QR code" msgstr "" -#: config/pg-slip-settings.php:144 +#: config/pg-slip-settings.php:152 msgid "Image that will be shown on the QR code. " msgstr "" #. translators: %1$s opening link tag, %2$s Customizer title, %3$s closing link tag, %3$s current image HTML. -#: config/pg-slip-settings.php:147 +#: config/pg-slip-settings.php:155 msgid "You can set it in %1$s%2$s%3$s. Current image is: %4$s" msgstr "" -#: config/pg-slip-settings.php:161 +#: config/pg-slip-settings.php:169 msgid "Advanced Settings" msgstr "" -#: config/pg-slip-settings.php:166 +#: config/pg-slip-settings.php:174 msgid "Debug log" msgstr "" -#: config/pg-slip-settings.php:168 +#: config/pg-slip-settings.php:176 msgid "Enable logging" msgstr "" #. translators: %1$s log file path, %2$s line break. -#: config/pg-slip-settings.php:172 +#: config/pg-slip-settings.php:180 msgid "Log Payment Slip events, inside %1$s %2$sNote: this may log personal information. We recommend using this for debugging purposes only and deleting the logs when finished." msgstr "" -#: config/settings.php:17 +#: config/settings.php:16 msgid "General settings" msgstr "" -#: config/settings.php:19 +#: config/settings.php:18 msgid "General settings for Serbian Addons for WooCommerce" msgstr "" -#: config/settings.php:24 +#: config/settings.php:23 msgid "Enabled customer types" msgstr "" -#: config/settings.php:27 +#: config/settings.php:26 msgid "Which customer types can shop on the store" msgstr "" -#: config/settings.php:29 +#: config/settings.php:28 msgid "Companies and persons" msgstr "" -#: config/settings.php:36 +#: config/settings.php:35 msgid "Field removal" msgstr "" -#: config/settings.php:39 +#: config/settings.php:38 msgid "Remove unneeded fields from the checkout page" msgstr "" -#: config/settings.php:40 +#: config/settings.php:39 msgid "Removes Address 2 and State fields" msgstr "" -#: config/settings.php:44 +#: config/settings.php:43 msgid "Transliterate currency symbol" msgstr "" -#: config/settings.php:47 +#: config/settings.php:46 msgid "Transliterate currency symbol to latin script" msgstr "" -#: config/settings.php:48 +#: config/settings.php:47 msgid "By default, currency is displayed in cyrillic. This will transliterate it" msgstr "" -#: config/settings.php:59 +#: config/settings.php:58 msgid "Company information" msgstr "" -#: config/settings.php:64 +#: config/settings.php:63 msgid "Bank accounts" msgstr "" -#: config/settings.php:66 +#: config/settings.php:65 msgid "Bank accounts of your business." msgstr "" -#: config/settings.php:68 +#: config/settings.php:67 msgid "Enter bank account" msgstr "" @@ -267,54 +296,52 @@ msgid "Serbian Addons" msgstr "" #. Translators: %s is a link to the company settings page. -#: lib/Admin/Plugin_Settings_Page.php:54 +#: lib/Admin/Plugin_Settings_Page.php:59 msgid "Store settings have been moved %s" msgstr "" -#: lib/Admin/Plugin_Settings_Page.php:58 +#: lib/Admin/Plugin_Settings_Page.php:63 msgid "here" msgstr "" -#: lib/Admin/Plugin_Settings_Page.php:91 -msgid "Business name" +#. Translators: %s is the invalid bank account number. +#: lib/Admin/Plugin_Settings_Page.php:153 +msgid "Invalid bank account number: %s" msgstr "" -#: lib/Admin/Plugin_Settings_Page.php:92 -msgid "Name of your business" -msgstr "" - -#: lib/Checkout/Field_Customizer.php:144 +#: lib/Checkout/Field_Customizer.php:149 +#: lib/Order/Field_Display.php:178 msgid "Customer type" msgstr "" -#: lib/Checkout/Field_Customizer.php:178 +#: lib/Checkout/Field_Customizer.php:183 +#: lib/Order/Field_Display.php:186 msgid "Company Number" msgstr "" -#: lib/Checkout/Field_Customizer.php:179 +#: lib/Checkout/Field_Customizer.php:184 msgid "Enter MB" msgstr "" -#: lib/Checkout/Field_Customizer.php:187 +#: lib/Checkout/Field_Customizer.php:192 +#: lib/Order/Field_Display.php:191 msgid "Tax Number" msgstr "" -#: lib/Checkout/Field_Customizer.php:188 +#: lib/Checkout/Field_Customizer.php:193 msgid "Enter PIB" msgstr "" -#: lib/Checkout/Field_Validator.php:73 -#: lib/Checkout/Field_Validator.php:115 -msgid "Company number is invalid" +#: lib/Checkout/Field_Validator.php:117 +msgid "Company name is required" msgstr "" -#: lib/Checkout/Field_Validator.php:82 -#: lib/Checkout/Field_Validator.php:119 -msgid "Company Tax Number is invalid" +#: lib/Checkout/Field_Validator.php:122 +msgid "Company number is invalid" msgstr "" -#: lib/Checkout/Field_Validator.php:112 -msgid "Company name is required" +#: lib/Checkout/Field_Validator.php:127 +msgid "Company Tax Number is invalid" msgstr "" #: lib/Core/Installer.php:45 @@ -322,206 +349,206 @@ msgstr "" msgid "Settings" msgstr "" -#: lib/Gateway/Gateway_Payment_Slip.php:138 -msgid "Payment Slip" +#: lib/Gateway/Gateway_Payment_Slip.php:151 +msgid "Have your customers pay you by sending you money via wire transfer." msgstr "" -#: lib/Gateway/Gateway_Payment_Slip.php:139 -msgid "Have your customers pay you by sending you money via wire transfer." +#: lib/Gateway/Gateway_Payment_Slip.php:155 +msgid "Payment Slip" msgstr "" -#: lib/Gateway/Gateway_Payment_Slip.php:165 +#: lib/Gateway/Gateway_Payment_Slip.php:184 msgid "Serbian Payment Slip does not support your store currency." msgstr "" -#: lib/Gateway/Gateway_Payment_Slip.php:167 +#: lib/Gateway/Gateway_Payment_Slip.php:194 msgid "Serbian Payment Slip requires at least one bank account." msgstr "" -#: lib/Gateway/Gateway_Payment_Slip_IPS_Handler.php:318 +#: lib/Gateway/Gateway_Payment_Slip_IPS_Handler.php:328 msgid "IPS QR Code" msgstr "" -#: lib/Order/Field_Display.php:149 +#: lib/Order/Field_Display.php:134 msgctxt "Address display" msgid "Company Number" msgstr "" -#: lib/Order/Field_Display.php:154 +#: lib/Order/Field_Display.php:140 msgctxt "Address display" msgid "Tax Identification Number" msgstr "" -#: lib/Utils/wcsrb-helpers.php:18 -#: lib/Utils/wcsrb-settings.php:47 -#: lib/Utils/wcsrb-settings.php:64 -#: lib/Utils/wcsrb-settings.php:70 +#: lib/Utils/wcsrb-helpers.php:16 +#: lib/Utils/wcsrb-settings.php:54 +#: lib/Utils/wcsrb-settings.php:68 +#: lib/Utils/wcsrb-settings.php:74 msgid "Person" msgstr "" -#: lib/Utils/wcsrb-helpers.php:19 -#: lib/Utils/wcsrb-settings.php:53 -#: lib/Utils/wcsrb-settings.php:63 +#: lib/Utils/wcsrb-helpers.php:17 +#: lib/Utils/wcsrb-settings.php:48 #: lib/Utils/wcsrb-settings.php:67 +#: lib/Utils/wcsrb-settings.php:71 msgid "Company" msgstr "" #. Translators: %s is the bank name. -#: lib/Utils/wcsrb-helpers.php:39 +#: lib/Utils/wcsrb-helpers.php:37 msgid "%s Bank" msgstr "" -#: lib/Utils/wcsrb-helpers.php:42 +#: lib/Utils/wcsrb-helpers.php:40 msgid "AIK" msgstr "" -#: lib/Utils/wcsrb-helpers.php:43 +#: lib/Utils/wcsrb-helpers.php:41 msgid "Mobi" msgstr "" -#: lib/Utils/wcsrb-helpers.php:44 +#: lib/Utils/wcsrb-helpers.php:42 msgid "Expobank" msgstr "" -#: lib/Utils/wcsrb-helpers.php:45 +#: lib/Utils/wcsrb-helpers.php:43 msgid "Direct" msgstr "" -#: lib/Utils/wcsrb-helpers.php:46 +#: lib/Utils/wcsrb-helpers.php:44 msgid "Halkbank" msgstr "" -#: lib/Utils/wcsrb-helpers.php:47 +#: lib/Utils/wcsrb-helpers.php:45 msgid "Banca Intesa" msgstr "" -#: lib/Utils/wcsrb-helpers.php:48 +#: lib/Utils/wcsrb-helpers.php:46 msgid "Addiko" msgstr "" -#: lib/Utils/wcsrb-helpers.php:49 +#: lib/Utils/wcsrb-helpers.php:47 msgid "UniCredit" msgstr "" -#: lib/Utils/wcsrb-helpers.php:50 +#: lib/Utils/wcsrb-helpers.php:48 msgid "Alta" msgstr "" -#: lib/Utils/wcsrb-helpers.php:51 +#: lib/Utils/wcsrb-helpers.php:49 msgid "Postal Savings" msgstr "" -#: lib/Utils/wcsrb-helpers.php:52 +#: lib/Utils/wcsrb-helpers.php:50 msgid "NLB Commercial" msgstr "" -#: lib/Utils/wcsrb-helpers.php:53 +#: lib/Utils/wcsrb-helpers.php:51 msgid "ProCredit" msgstr "" -#: lib/Utils/wcsrb-helpers.php:54 +#: lib/Utils/wcsrb-helpers.php:52 msgid "Eurobank Direct" msgstr "" -#: lib/Utils/wcsrb-helpers.php:55 +#: lib/Utils/wcsrb-helpers.php:53 msgid "Raiffeisen" msgstr "" -#: lib/Utils/wcsrb-helpers.php:56 +#: lib/Utils/wcsrb-helpers.php:54 msgid "OTP" msgstr "" -#: lib/Utils/wcsrb-helpers.php:57 +#: lib/Utils/wcsrb-helpers.php:55 msgid "Sberbank" msgstr "" -#: lib/Utils/wcsrb-helpers.php:58 +#: lib/Utils/wcsrb-helpers.php:56 msgid "Serbian" msgstr "" -#: lib/Utils/wcsrb-helpers.php:59 +#: lib/Utils/wcsrb-helpers.php:57 msgid "NLB" msgstr "" -#: lib/Utils/wcsrb-helpers.php:60 +#: lib/Utils/wcsrb-helpers.php:58 msgid "Vojvodjanska" msgstr "" -#: lib/Utils/wcsrb-helpers.php:61 +#: lib/Utils/wcsrb-helpers.php:59 msgid "Credit Agricole" msgstr "" -#: lib/Utils/wcsrb-helpers.php:62 +#: lib/Utils/wcsrb-helpers.php:60 msgid "Erste" msgstr "" -#: lib/Utils/wcsrb-helpers.php:63 +#: lib/Utils/wcsrb-helpers.php:61 msgid "MTS" msgstr "" -#: lib/Utils/wcsrb-helpers.php:64 +#: lib/Utils/wcsrb-helpers.php:62 msgid "Opportunity" msgstr "" -#: lib/Utils/wcsrb-helpers.php:65 +#: lib/Utils/wcsrb-helpers.php:63 msgid "API" msgstr "" -#: lib/Utils/wcsrb-helpers.php:66 +#: lib/Utils/wcsrb-helpers.php:64 msgid "Mirabank" msgstr "" -#: lib/Utils/wcsrb-helpers.php:67 +#: lib/Utils/wcsrb-helpers.php:65 msgid "Bank of China" msgstr "" -#: lib/Utils/wcsrb-payment-slip.php:44 -#: lib/Utils/wcsrb-settings.php:46 +#: lib/Utils/wcsrb-payment-slip.php:40 +#: lib/Utils/wcsrb-settings.php:44 msgid "Automatic" msgstr "" -#: lib/Utils/wcsrb-payment-slip.php:45 +#: lib/Utils/wcsrb-payment-slip.php:41 msgid "Model 97" msgstr "" -#: lib/Utils/wcsrb-payment-slip.php:68 -msgid "Order ID" +#: lib/Utils/wcsrb-payment-slip.php:64 +msgid "Customer ID" msgstr "" -#: lib/Utils/wcsrb-payment-slip.php:69 -msgid "Order number" +#: lib/Utils/wcsrb-payment-slip.php:67 +msgid "Order date" msgstr "" -#: lib/Utils/wcsrb-payment-slip.php:70 -msgid "Order date" +#: lib/Utils/wcsrb-payment-slip.php:68 +msgid "Order ID" msgstr "" -#: lib/Utils/wcsrb-payment-slip.php:74 -msgid "Customer ID" +#: lib/Utils/wcsrb-payment-slip.php:69 +msgid "Order number" msgstr "" -#: lib/Utils/wcsrb-settings.php:22 +#: lib/Utils/wcsrb-settings.php:20 msgid "Select bank account" msgstr "" #. Translators: %d is the payment code. -#: lib/Utils/wcsrb-settings.php:49 -msgid "%d - Transactions on behalf of a person" +#: lib/Utils/wcsrb-settings.php:50 +msgid "%d - Interim expenses" msgstr "" #. Translators: %d is the payment code. -#: lib/Utils/wcsrb-settings.php:51 -msgid "%d - Other transactions" +#: lib/Utils/wcsrb-settings.php:52 +msgid "%d - Final expenses" msgstr "" #. Translators: %d is the payment code. -#: lib/Utils/wcsrb-settings.php:55 -msgid "%d - Interim expenses" +#: lib/Utils/wcsrb-settings.php:57 +msgid "%d - Transactions on behalf of a person" msgstr "" #. Translators: %d is the payment code. -#: lib/Utils/wcsrb-settings.php:57 -msgid "%d - Final expenses" +#: lib/Utils/wcsrb-settings.php:61 +msgid "%d - Other transactions" msgstr "" #: woocommerce/checkout/payment-slip-qr-code.php:26 diff --git a/lib/Admin/Edit_User_Controller.php b/lib/Admin/Edit_User_Controller.php new file mode 100644 index 0000000..24bec75 --- /dev/null +++ b/lib/Admin/Edit_User_Controller.php @@ -0,0 +1,60 @@ + array( + 'description' => '', + 'label' => \__( 'Customer type', 'serbian-addons-for-woocommerce' ), + 'options' => \wcsrb_get_entity_types(), + 'type' => 'select', + ), + 'billing_company' => $fields['billing']['fields']['billing_company'], + 'billing_mb' => array( + 'description' => '', + 'label' => \__( 'Company Number', 'serbian-addons-for-woocommerce' ), + 'type' => 'text', + ), + 'billing_pib' => array( + 'description' => '', + 'label' => \__( 'Tax Number', 'serbian-addons-for-woocommerce' ), + 'type' => 'text', + ), + + ), + \array_slice( $fields['billing']['fields'], $company ), + ); + //phpcs:enable SlevomatCodingStandard.Arrays.AlphabeticallySortedByKeys.IncorrectKeyOrder + + return $fields; + } +} diff --git a/lib/Admin/Plugin_Settings_Page.php b/lib/Admin/Plugin_Settings_Page.php index e8b31ff..5b0907d 100644 --- a/lib/Admin/Plugin_Settings_Page.php +++ b/lib/Admin/Plugin_Settings_Page.php @@ -6,30 +6,36 @@ */ namespace Oblak\WooCommerce\Serbian_Addons\Admin; -use Oblak\WooCommerce\Admin\Extended_Settings_Page; use Oblak\WP\Decorators\Action; use Oblak\WP\Decorators\Filter; -use WC_Admin_Settings; /** * Adds the settings for the plugin to the WooCommerce settings page * * @since 2.2.0 */ -class Plugin_Settings_Page extends Extended_Settings_Page { +class Plugin_Settings_Page extends \XWC\Admin\Settings_Page_Base { /** - * Class Constructor + * Constructor */ public function __construct() { parent::__construct( 'wcsrb', \__( 'Serbian Addons', 'serbian-addons-for-woocommerce' ), - include WCRS_PLUGIN_PATH . 'config/settings.php', - ); + ); \xwp_invoke_hooked_methods( $this ); } + /** + * Returns the settings array + * + * @return array[] Settings array + */ + protected function get_settings_array(): array { + return include WCRS_PLUGIN_PATH . 'config/settings.php'; + } + /** * Modifies the general settings * @@ -72,76 +78,14 @@ public function modify_general_settings( $settings, $section ) { * @param string $section Section name. * @return array[] Modified settings fields */ - #[Filter( tag: 'woocommerce_formatted_settings_wcsrb', priority: 99 )] + #[Filter( tag: 'woocommerce_get_settings_wcsrb', priority: 99 )] public function modify_company_settings( $settings, $section ) { if ( 'company' !== $section ) { return $settings; } return \array_merge( - array( - array( - 'title' => \__( 'Company information', 'woocommerce' ), - 'type' => 'title', - 'desc' => \__( 'This is where your business is located. Tax rates and shipping rates will use this address.', 'woocommerce' ), - 'id' => 'store_address', - ), - - array( - 'title' => \__( 'Business name', 'serbian-addons-for-woocommerce' ), - 'desc' => \__( 'Name of your business', 'serbian-addons-for-woocommerce' ), - 'id' => 'woocommerce_store_name', - 'default' => '', - 'type' => 'text', - 'desc_tip' => true, - ), - - array( - 'title' => \__( 'Address line 1', 'woocommerce' ), - 'desc' => \__( 'The street address for your business location.', 'woocommerce' ), - 'id' => 'woocommerce_store_address', - 'default' => '', - 'type' => 'text', - 'desc_tip' => true, - ), - - array( - 'title' => \__( 'Address line 2', 'woocommerce' ), - 'desc' => \__( 'An additional, optional address line for your business location.', 'woocommerce' ), - 'id' => 'woocommerce_store_address_2', - 'default' => '', - 'type' => 'text', - 'desc_tip' => true, - ), - - array( - 'title' => \__( 'City', 'woocommerce' ), - 'desc' => \__( 'The city in which your business is located.', 'woocommerce' ), - 'id' => 'woocommerce_store_city', - 'default' => '', - 'type' => 'text', - 'desc_tip' => true, - ), - - array( - 'title' => \__( 'Country / State', 'woocommerce' ), - 'desc' => \__( 'The country and state or province, if any, in which your business is located.', 'woocommerce' ), - 'id' => 'woocommerce_default_country', - 'default' => 'US:CA', - 'type' => 'single_select_country', - 'desc_tip' => true, - ), - - array( - 'title' => \__( 'Postcode / ZIP', 'woocommerce' ), - 'desc' => \__( 'The postal code, if any, in which your business is located.', 'woocommerce' ), - 'id' => 'woocommerce_store_postcode', - 'css' => 'min-width:50px;', - 'default' => '', - 'type' => 'text', - 'desc_tip' => true, - ), - ), + include WCRS_PLUGIN_PATH . 'config/company-settings.php', $settings, array( array( @@ -159,11 +103,8 @@ public function modify_company_settings( $settings, $section ) { */ #[Action( tag: 'woocommerce_admin_field_repeater_text', priority: 10 )] public function output_bank_accounts_field( $value ) { - $option_value = \wc_string_to_array( $value['value'] ?? '' ); - $field_name = "{$value['field_name']}[]"; - $field_description = WC_Admin_Settings::get_field_description( $value ); - $description = $field_description['description']; - $tooltip_html = $field_description['tooltip_html']; + $option_value = $value['value']['acct'] ?? $value['value'] ?? ''; + $option_value = \wc_string_to_array( $option_value ); $custom_attributes = array(); if ( isset( $value['custom_attributes'] ) && \is_array( $value['custom_attributes'] ) ) { @@ -171,63 +112,9 @@ public function output_bank_accounts_field( $value ) { $custom_attributes[] = \sprintf( '%s="%s"', \esc_attr( $att_key ), \esc_attr( $att_val ) ); } } - ?> - - - - - -
- -
- - /> - - -
- -
- - - - - $value Field value. + * @var string $field_name Field name. + */ + +defined( 'ABSPATH' ) || exit; + + +$field_name = "{$value['field_name']}[]"; +$field_desc = WC_Admin_Settings::get_field_description( $value ); + +?> + + + + + +
+ +
+ + /> + + +
+ +
+ + + diff --git a/lib/Admin/Views/admin-html-bank-account-template.php b/lib/Admin/Views/admin-html-bank-account-template.php new file mode 100644 index 0000000..678785e --- /dev/null +++ b/lib/Admin/Views/admin-html-bank-account-template.php @@ -0,0 +1,28 @@ + $value Field value. + */ + +defined( 'ABSPATH' ) || exit; + +?> + diff --git a/lib/Serbian_WooCommerce.php b/lib/App.php similarity index 68% rename from lib/Serbian_WooCommerce.php rename to lib/App.php index 51bd1d9..129bbc1 100644 --- a/lib/Serbian_WooCommerce.php +++ b/lib/App.php @@ -5,23 +5,23 @@ * @package Serbian Addons for WooCommerce */ -namespace Oblak\WooCommerce\Serbian_Addons; +namespace Oblak\WCSRB; -use Oblak\WooCommerce\Core\Settings_Helper; +use Oblak\WCSRB\Services\Field_Validator; +use Oblak\WooCommerce\Serbian_Addons as Legacy; use Oblak\WP\Decorators\Action; use Oblak\WP\Decorators\Filter; use Oblak\WP\Traits\Hook_Processor_Trait; -use Oblak\WP\Traits\Singleton; +use XWC\Traits\Settings_API_Methods; +use XWP\Helper\Traits\Singleton; /** * Main plugin class */ -class Serbian_WooCommerce { +class App { use Hook_Processor_Trait; + use Settings_API_Methods; use Singleton; - use Settings_Helper { - Settings_Helper::load_settings as load_settings_helper; - } use \XWP_Asset_Retriever; /** @@ -31,6 +31,13 @@ class Serbian_WooCommerce { */ public string $version = WCRS_VERSION; + /** + * Field validator instance. + * + * @var Field_Validator + */ + protected Field_Validator $validator; + /** * Private constructor */ @@ -45,11 +52,12 @@ protected function __construct() { */ protected function get_dependencies(): array { return array( - Admin\Admin_Core::class, - Core\Template_Extender::class, - Checkout\Field_Customizer::class, - Checkout\Field_Validator::class, - Order\Field_Display::class, + Admin\Edit_User_Controller::class, + Core\Address_Display_Controller::class, + Core\Address_Field_Controller::class, + Core\Address_Validate_Controller::class, + Utils\Template_Extender::class, + Legacy\Admin\Admin_Core::class, ); } @@ -60,40 +68,17 @@ public function run_hooks() { \xwp_invoke_hooked_methods( $this ); } - /** - * Get the settings array from the database - * - * We use the helper settings loader to load the settings, and then we add the company info - * because it is a mix of our settings and WooCommerce settings. - * - * @param string $prefix The settings prefix. - * @param array $raw_settings The settings fields. - * @param mixed $default_value The default value for the settings. - * @return array The settings array. - */ - protected function load_settings( string $prefix, array $raw_settings, $default_value ): array { - $settings = $this->load_settings_helper( $prefix, $raw_settings, $default_value ); - - $settings['company'] = array( - 'accounts' => \wcsrb_get_bank_accounts(), - 'address' => \get_option( 'woocommerce_store_address', '' ), - 'address_2' => \get_option( 'woocommerce_store_address_2', '' ), - 'city' => \get_option( 'woocommerce_store_city', '' ), - 'country' => \wc_get_base_location()['country'], - 'logo' => \get_option( 'site_icon', 0 ), - 'name' => \get_option( 'woocommerce_store_name', '' ), - 'postcode' => \get_option( 'woocommerce_store_postcode', '' ), - ); - - return $settings; - } - /** * Initializes the installer */ #[Action( tag: 'plugins_loaded', priority: 1000 )] public function on_plugins_loaded() { - Core\Installer::instance()->init(); + Utils\Installer::instance()->init(); + + \load_plugin_textdomain( + domain: 'serbian-addons-for-woocommerce', + plugin_rel_path: \dirname( WCRS_PLUGIN_BASE ) . '/languages', + ); } /** @@ -101,10 +86,36 @@ public function on_plugins_loaded() { */ #[Action( tag: 'woocommerce_loaded', priority: 99 )] public function load_plugin_settings() { - $this->settings = $this->load_settings( - 'wcsrb', - require WCRS_PLUGIN_PATH . 'config/settings.php', - false, + try { + $this->load_options( 'wcsrb_settings' ); + } catch ( \Exception | \Error ) { + \wc_get_logger()->critical( + 'Failed to load plugin settings', + array( + 'source' => 'serbian-addons-for-woocommerce', + ), + ); + $this->settings = array(); + } + + $this->settings['core'] = \wp_parse_args( + \array_filter( $this->settings['core'] ?? array() ), + array( + 'enabled_customer_types' => 'both', + 'fix_currency_symbol' => true, + 'remove_unneeded_fields' => false, + ), + ); + + $this->settings['company'] = array( + 'accounts' => \wcsrb_get_bank_accounts(), + 'address' => \get_option( 'woocommerce_store_address', '' ), + 'address_2' => \get_option( 'woocommerce_store_address_2', '' ), + 'city' => \get_option( 'woocommerce_store_city', '' ), + 'country' => \wc_get_base_location()['country'], + 'logo' => \get_option( 'site_icon', 0 ), + 'name' => \get_option( 'woocommerce_store_name', '' ), + 'postcode' => \get_option( 'woocommerce_store_postcode', '' ), ); } @@ -132,7 +143,7 @@ public function declare_hpos_compatibility() { */ #[Filter( tag: 'woocommerce_payment_gateways', priority: 50 )] public function add_payment_gateways( $gateways ) { - $gateways[] = Gateway\Gateway_Payment_Slip::class; + $gateways[] = Legacy\Gateway\Gateway_Payment_Slip::class; return $gateways; } @@ -145,7 +156,7 @@ public function add_payment_gateways( $gateways ) { */ #[Filter( tag: 'woocommerce_currency_symbol', priority: 99 )] public function change_currency_symbol( string $symbol, string $currency ): string { - if ( ! $this->get_settings( 'general', 'fix_currency_symbol' ) ) { + if ( ! $this->get_settings( 'core', 'fix_currency_symbol' ) ) { return $symbol; } @@ -172,4 +183,13 @@ public function check_asset_necessity( bool $load, string $script ) { default => $load, }; } + + /** + * Gets the field validator instance. + * + * @return Field_Validator + */ + public function validator(): Field_Validator { + return $this->validator ??= new Field_Validator(); + } } diff --git a/lib/Checkout/Field_Customizer.php b/lib/Checkout/Field_Customizer.php deleted file mode 100644 index 4fe05dc..0000000 --- a/lib/Checkout/Field_Customizer.php +++ /dev/null @@ -1,208 +0,0 @@ -get_settings( 'general', 'enabled_customer_types' ); - - $fields = $this->maybe_remove_fields( $fields ); - - $fields['billing_type'] = $this->add_billing_type_field( $enabled_type ); - - $fields = \array_merge( - $fields, - $this->maybe_add_company_fields( $enabled_type ), - ); - - // If the billing type is not both or company, remove the company field. - if ( ! \in_array( $enabled_type, array( 'both', 'company' ), true ) ) { - unset( $fields['billing_company'] ); - } else { // Else, addin some extra data. - $fields['billing_company']['class'][] = 'hide-if-person'; - $fields['billing_company']['required'] = true; - } - - return $fields; - } - - /** - * Modifies shipping fields to remove the unneded fields. - * - * @param array $fields Shipping fields. - * @return array Modified shipping fields - */ - #[Filter( tag: 'woocommerce_shipping_fields', priority: 'woocommerce_serbian_checkout_fields_priority' )] - public function modify_shipping_fields( $fields ) { - $fields = $this->maybe_remove_fields( $fields, 'shipping' ); - - return $fields; - } - - /** - * Removes unnecessary fields from the checkout ajax request - * - * @param array $fields Fields to modify. - * @return array Modified fields - */ - #[Filter( tag: 'woocommerce_shipping_fields', priority: 'woocommerce_serbian_checkout_fields_priority' )] - public function modify_ajax_checkout_fields( $fields ) { - if ( ! \wp_doing_ajax() ) { - return $fields; - } - - $checkout_customer_type = \xwp_fetch_post_var( 'billing_type', 'person' ); - - if ( 'person' === $checkout_customer_type ) { - unset( $fields['billing']['billing_company'] ); - unset( $fields['billing']['billing_mb'] ); - unset( $fields['billing']['billing_pib'] ); - } - - return $fields; - } - - /** - * Removes the fields that are not needed, and changes fields priority. - * - * @param array $fields Fields. - * @param string $type Field type - billing or shipping. - * @return array Modified fields - */ - private function maybe_remove_fields( $fields, $type = 'billing' ) { - $fields[ "{$type}_postcode" ]['priority'] = 81; - $fields[ "{$type}_city" ]['priority'] = 91; - $fields[ "{$type}_country" ]['priority'] = 91; - - $to_remove = \WCSRB()->get_settings( - 'general', - 'remove_unneeded_fields', - ) ? array( 'address_2', 'state' ) : array(); - - /** - * Filters the fields that should be removed from the checkout page - * - * @param array $to_remove Fields to remove - * @return array - * @since 1.3.0 - */ - $to_remove = \apply_filters( 'woocommerce_serbian_checkout_fields_to_remove', $to_remove ); - - foreach ( $to_remove as $field_name ) { - unset( $fields[ "{$type}_{$field_name}" ] ); - } - - return $fields; - } - - /** - * Adds the billing type field to the checkout page. - * - * Depending on the plugin settings, field can be a radio button or a hidden input - * - * @param string $enabled_type Enabled customer type. - * @return array Billing type field data. - * - * @since 1.3.0 - */ - private function add_billing_type_field( $enabled_type ) { - $billing_type = array( - 'class' => array( 'form-row-wide', 'entity-type-control', 'update_totals_on_change' ), - 'default' => 'person', - 'label' => \__( 'Customer type', 'serbian-addons-for-woocommerce' ), - 'options' => \wcsrb_get_entity_types(), - 'priority' => 21, - 'required' => true, - 'type' => 'radio', - ); - - if ( 'both' !== $enabled_type ) { - - $billing_type['type'] = 'hidden'; - $billing_type['default'] = $enabled_type; - $billing_type['description'] = \wcsrb_get_entity_types()[ $enabled_type ]; - - unset( $billing_type['options'] ); - - } - - return $billing_type; - } - - /** - * Add needed company fields if the customer can checkout as a company - * - * @param string $enabled_type Enabled customer type. - * @return array Company fields data. - */ - private function maybe_add_company_fields( $enabled_type ) { - if ( ! \in_array( $enabled_type, array( 'both', 'company' ), true ) ) { - return array(); - } - - $extra_fields = array( - 'billing_mb' => array( - 'class' => array( 'form-row-first', 'hide-if-person' ), - 'label' => \__( 'Company Number', 'serbian-addons-for-woocommerce' ), - 'placeholder' => \__( 'Enter MB', 'serbian-addons-for-woocommerce' ), - 'priority' => 31, - 'required' => true, - 'type' => 'text', - 'validate' => array( 'mb' ), - ), - 'billing_pib' => array( - 'class' => array( 'form-row-last', 'hide-if-person' ), - 'label' => \__( 'Tax Number', 'serbian-addons-for-woocommerce' ), - 'placeholder' => \__( 'Enter PIB', 'serbian-addons-for-woocommerce' ), - 'priority' => 32, - 'required' => true, - 'type' => 'text', - 'validate' => array( 'pib' ), - ), - ); - - if ( 'company' !== $enabled_type ) { - $extra_fields['billing_pib']['custom_attributes']['disabled'] = 'disabled'; - $extra_fields['billing_mb']['custom_attributes']['disabled'] = 'disabled'; - } - - return $extra_fields; - } -} diff --git a/lib/Checkout/Field_Validator.php b/lib/Checkout/Field_Validator.php deleted file mode 100644 index becf97a..0000000 --- a/lib/Checkout/Field_Validator.php +++ /dev/null @@ -1,159 +0,0 @@ -can_validate( $posted, $type ) ) { - return; - } - - $validators = $this->get_field_validators( \current_filter() ); - $notices = $this->filter_notices( \array_keys( $validators ) ); - - foreach ( $validators as $field => $args ) { - if ( $args['validator']( $posted[ $field ] ) ) { - continue; - } - - $notices['error'][] = array( - 'data' => array( - 'id' => $field, - ), - 'notice' => $args['message'], - ); - } - \WC()->session->set( 'wc_notices', $notices ); - } - - - /** - * Adds custom validation to billing address field saving - * - * @param array $data Posted data. - * @param \WP_Error $error Error object. - */ - #[Action( 'woocommerce_after_checkout_validation', 0 )] - public function validate_checkout_fields( $data, $error ) { - $fields = $this->get_field_validators( \current_filter() ); - - foreach ( \array_keys( $fields ) as $field ) { - $error->remove( $field . '_required' ); - } - - if ( ! $this->can_validate( $data ) ) { - return; - } - - foreach ( $fields as $field => $args ) { - if ( $args['validator']( $data[ $field ] ) ) { - continue; - } - - $error->add( $args['code'], $args['message'], array( 'id' => $field ) ); - } - } - - /** - * Checks if the current address can be validated. - * - * @param array $fields Address fields. - * @param string $addr_type Address type being validated. - * @return bool - */ - protected function can_validate( array $fields, string $addr_type = 'billing' ): bool { - $type = $fields['billing_type'] ??= ''; - $country = $fields['billing_country'] ??= ''; - - return 'billing' === $addr_type && 'company' === $type && 'RS' === $country; - } - - /** - * Returns the field validators for the given action. - * - * @param string $action Action being performed. - * @return array - */ - protected function get_field_validators( string $action ) { - $args = array( - 'billing_company' => array( - 'code' => 'billing_company_required', - 'message' => \__( 'Company name is required', 'serbian-addons-for-woocommerce' ), - 'validator' => static fn( $val ) => '' !== $val, - ), - 'billing_mb' => array( - 'code' => 'billing_mb_validation', - 'message' => \__( 'Company number is invalid', 'serbian-addons-for-woocommerce' ), - 'validator' => '\Oblak\validateMB', - ), - 'billing_pib' => array( - 'code' => 'billing_pib_validation', - 'message' => \__( 'Company Tax Number is invalid', 'serbian-addons-for-woocommerce' ), - 'validator' => '\Oblak\validatePIB', - ), - ); - - /** - * Returns the validation arguments for the given action. - * - * @param array $args Validation arguments. - * @param string $action Action being performed. - * - * @return array - * - * @since 3.6.0 - */ - return \apply_filters( 'wcrs_field_validators', $args, $action ); - } - - /** - * Filters out notices for fields that have been validated. - * - * @param array $fields Fields that have been validated. - * @return array - */ - protected function filter_notices( array $fields ): array { - $notices = \WC()->session->get( 'wc_notices', array() ); - - $notices['error'] = \array_filter( - $notices['error'] ?? array(), - static fn( $e ) => ! \in_array( $e['data']['id'] ?? '', $fields, true ) - ); - - return $notices; - } -} diff --git a/lib/Core/Address_Display_Controller.php b/lib/Core/Address_Display_Controller.php new file mode 100644 index 0000000..450ede2 --- /dev/null +++ b/lib/Core/Address_Display_Controller.php @@ -0,0 +1,145 @@ + $formats Address formats. + * @return array + */ + #[Filter( 'woocommerce_localisation_address_formats', 'wcrs_localization_address_priority' )] + public function modify_address_format( $formats ) { + \add_filter( 'woocommerce_formatted_address_force_country_display', '__return_true' ); + + $formats['RS'] = "{name}\n{company}\n{mb}\n{pib}\n{address_1}\n{address_2}\n{postcode} {city}, {state} {country}"; + + if ( \WCSRB()->get_settings( 'core', 'remove_unneeded_fields' ) ) { + $formats['RS'] = \str_replace( array( '{state}', '{address_2}' ), '', $formats['RS'] ); + } + + return $formats; + } + + /** + * Adds custom replacements to the replacements array. + * + * Custom fields added are: + * - Type + * - Company Number + * - Tax Identification Number + * + * @param string[] $replacements Replacements array. + * @param array $args Address data. + * @return string[] Modified replacements array + */ + #[Filter( 'woocommerce_formatted_address_replacements', 99 )] + public function modify_address_replacements( $replacements, $args ) { + $replacements['{mb}'] = $args['mb'] ?? "\n"; + $replacements['{pib}'] = $args['pib'] ?? "\n"; + + return $replacements; + } + + /** + * Modifies the address data array to include neccecary company information. + * + * This is used in the My Account > Addresses page. + * + * @param array $fmtd Address data array. + * @param int $uid Customer ID. + * @param 'billing'|'shipping' $type Address type (billing or shipping). + * @return array + */ + #[Filter( 'woocommerce_my_account_my_address_formatted_address', 99 )] + public function modify_account_formatted_address( array $fmtd, int $uid, $type ) { + if ( 'billing' !== $type ) { + return $fmtd; + } + + return \array_merge( + $fmtd, + $this->get_replacement_values( new WC_Customer( $uid ) ), + ); + } + + /** + * Modifies the address data array to include neccecary company information. + * + * This is used for the order addresses. + * + * @param array $address Address data array. + * @param WC_Order $order Order object. + * @return array Modified address data array + */ + #[Filter( 'woocommerce_order_formatted_billing_address', 99 )] + public function modify_order_formatted_address( $address, $order ) { + return \array_merge( + $address, + $this->get_replacement_values( $order ), + ); + } + + /** + * Modifies the buyer name in the admin order page to include necessary company information + * + * @param string $buyer Buyer name. + * @param WC_Order $order Order object. + * @return string Modified Buyer name + */ + #[Filter( 'woocommerce_admin_order_buyer_name', 99 )] + public function modify_order_buyer_name( string $buyer, WC_Order $order ): string { + $data = \wcsrb_get_company_data( $order ); + + if ( 'RS' === $order->get_billing_country() && 'company' === $data['type'] ) { + $buyer = $order->get_billing_company(); + } + + return $buyer; + } + + /** + * Billing address modifier function + * + * Depending on the customer(user) type we add the needed rows to the address. + * If the customer is a company we prepend the number type before the number itself + * + * @param WC_Customer|WC_Order $target Customer or Order object. + * @return array + */ + protected function get_replacement_values( WC_Customer|WC_Order $target ): array { + $data = \wcsrb_get_company_data( $target ); + if ( 'company' !== $data['type'] ) { + return array(); + } + + return array( + 'first_name' => "\n", + 'last_name' => "\n", + 'mb' => \sprintf( + '%s: %s', + \_x( 'Company Number', 'Address display', 'serbian-addons-for-woocommerce' ), + $data['mb'] ?: "\n", + ), + 'pib' => \sprintf( + '%s: %s', + \_x( 'Tax Identification Number', 'Address display', 'serbian-addons-for-woocommerce' ), + $data['pib'] ?: "\n", + ), + + ); + } +} diff --git a/lib/Core/Address_Field_Controller.php b/lib/Core/Address_Field_Controller.php new file mode 100644 index 0000000..a7b3354 --- /dev/null +++ b/lib/Core/Address_Field_Controller.php @@ -0,0 +1,194 @@ + $fields Default address fields. + * @return array + */ + #[Filter( tag: 'woocommerce_default_address_fields', priority: 999999 )] + public function add_customer_type_field( array $fields ): array { + $enabled_type = \WCSRB()->get_settings( 'core', 'enabled_customer_types' ); + $type_field = array( + 'class' => array( 'form-row-wide', 'entity-type-control', 'update_totals_on_change', 'address-field' ), + 'default' => 'person', + 'label' => \__( 'Customer type', 'serbian-addons-for-woocommerce' ), + 'options' => \wcsrb_get_entity_types(), + 'priority' => 21, + 'required' => true, + 'type' => 'radio', + ); + + if ( 'both' !== $enabled_type ) { + + $type_field = \array_merge( + $type_field, + array( + 'default' => $enabled_type, + 'description' => \wcsrb_get_entity_types()[ $enabled_type ], + 'type' => 'hidden', + 'value' => $enabled_type, + ), + ); + + unset( $type_field['options'] ); + } + + $fields['type'] = $type_field; + + return $fields; + } + + /** + * Adds the extra fields to the default address fields + * + * @param array $fields Default address fields. + * @return array + */ + #[Filter( tag: 'woocommerce_default_address_fields', priority: 'wcsrb_address_fields_priority' )] + public function add_company_fields( array $fields ): array { + if ( \WCSRB()->get_settings( 'core', 'remove_unneeded_fields' ) ) { + unset( $fields['address_2'], $fields['state'] ); + } + + $fields['company']['class'][] = 'entity-type-toggle'; + + return \array_merge( $fields, \wcsrb_get_company_fields() ); + } + + /** + * Unsets I18n label for the customer type field. + * + * @param array $fields Default country locale fields. + * @return array + */ + #[Filter( tag: 'woocommerce_get_country_locale_default', priority: 999999 )] + public function modify_default_locale_field_data( array $fields ): array { + unset( $fields['type']['label'] ); + + return $fields; + } + + /** + * Set the JS locale fields data. + * + * Adds the hidden and required properties for all countries. + * All are set to be hidden and NOT required by default. + * + * @param array $locale Default locale fields data. + * @return array + */ + #[Filter( tag: 'woocommerce_get_country_locale', priority: 1000 )] + public function add_default_locale_field_data( array $locale ): array { + foreach ( $locale as &$fields ) { + $fields['company']['required'] = false; + $fields['type'] = array( + 'hidden' => true, + 'required' => false, + ); + $fields['mb'] = array( + 'hidden' => true, + 'required' => false, + ); + $fields['pib'] = array( + 'hidden' => true, + 'required' => false, + ); + } + + return $locale; + } + + /** + * Adds the custom locale field data + * + * We unhide the fields and enable them only if the company type is active. + * + * @param array $locale Default locale fields data. + * @return array + */ + #[Filter( tag: 'woocommerce_get_country_locale', priority: 1000 )] + public function add_custom_locale_field_data( array $locale ): array { + $company_active = \wcsrb_can_checkout_as( 'company' ); + $company_props = array( 'hidden' => ! $company_active ); + + // phpcs:disable SlevomatCodingStandard.Arrays.AlphabeticallySortedByKeys.IncorrectKeyOrder + $locale['RS'] = array( + 'type' => array( + 'required' => true, + 'hidden' => false, + ), + 'company' => \array_merge( + array( 'class' => array( 'form-row-wide', 'entity-type-toggle', 'shown' ) ), + $company_props, + ), + 'mb' => $company_props, + 'pib' => $company_props, + 'postcode' => array( + 'priority' => 81, + ), + 'city' => array( + 'priority' => 82, + ), + 'country' => array( + 'priority' => 91, + ), + ); + // phpcs:enable SlevomatCodingStandard.Arrays.AlphabeticallySortedByKeys.IncorrectKeyOrder + + return $locale; + } + + /** + * Modifies the locale field selectors + * + * @param array $selectors Field selectors. + * @return array + */ + #[Filter( tag: 'woocommerce_country_locale_field_selectors', priority: 99999 )] + public function locale_field_selectors( array $selectors ): array { + return \array_merge( + $selectors, + array( + 'company' => '#billing_company_field', + 'mb' => '#billing_mb_field', + 'pib' => '#billing_pib_field', + 'type' => '#billing_type_field', + ), + ); + } + + /** + * Modifies the billing fields to add the customer type and additional company fields + * + * @param array $fields Billing fields. + * @return array Modified billing fields + */ + #[Filter( tag: 'woocommerce_shipping_fields', priority: 'woocommerce_serbian_checkout_fields_priority' )] + public function modify_shipping_fields( array $fields ) { + $to_remove = array( 'company', 'mb', 'pib', 'type' ); + + return \xwp_array_diff_assoc( + $fields, + ...\array_map( static fn( $f ) => "shipping_{$f}", $to_remove ), + ); + } +} diff --git a/lib/Core/Address_Validate_Controller.php b/lib/Core/Address_Validate_Controller.php new file mode 100644 index 0000000..b5bc13b --- /dev/null +++ b/lib/Core/Address_Validate_Controller.php @@ -0,0 +1,47 @@ +validator()->validate_fields( \xwp_post_arr(), $type ) as $error ) { + \wc_add_notice( $error['message'], 'error', array( 'id' => $error['id'] ) ); + } + } + + + /** + * Validates the checkout fields. + * + * @param array $fields Address fields. + * @param \WP_Error $error Error object. + */ + #[Action( 'woocommerce_after_checkout_validation', 0 )] + public function validate_checkout( array $fields, \WP_Error $error ) { + foreach ( \WCSRB()->validator()->validate_fields( $fields, 'billing' ) as $err ) { + $error->add( $err['code'], $err['message'], array( 'id' => $err['id'] ) ); + } + } +} diff --git a/lib/Core/Installer.php b/lib/Core/Installer.php deleted file mode 100644 index 31df4f1..0000000 --- a/lib/Core/Installer.php +++ /dev/null @@ -1,100 +0,0 @@ -name = __( 'Serbian Addons for WooCommerce', 'serbian-addons-for-woocommerce' ); - $this->slug = 'serbian_woocommerce'; - $this->version = WCRS_VERSION; - $this->db_version = WCRS_VERSION; - } - - /** - * Show action links on the plugin screen - * - * @param array $links Plugin Action links. - * @return array Modified action links - */ - public static function plugin_action_links( $links ) { - $action_links = array( - 'settings' => sprintf( - '%s', - admin_url( 'admin.php?page=wc-settings' ), - esc_attr__( 'Settings', 'serbian-addons-for-woocommerce' ), - esc_html__( 'Settings', 'serbian-addons-for-woocommerce' ), - ), - ); - - return array_merge( $action_links, $links ); - } - - /** - * {@inheritDoc} - */ - public function setup_environment() { - $this->create_files(); - } - - /** - * Create files and folders - * - * @return void - */ - protected function create_files() { - /** - * Bypass if filesystem is read-only and/or non-standard upload system is used. - * - * @return bool - * @since 3.4.0 - */ - if ( apply_filters( 'woocommerce_serbian_install_skip_create_files', false ) ) { - return; - } - - // Install files and folders for uploading files and prevent hotlinking. - $files = array( - array( - 'base' => WCRS_IPS_DIR, - 'file' => 'index.html', - 'content' => '', - ), - array( - 'base' => WCRS_IPS_DIR, - 'file' => '.htaccess', - 'content' => 'deny from all', - ), - ); - - foreach ( $files as $file ) { - if ( wp_mkdir_p( $file['base'] ) && ! file_exists( trailingslashit( $file['base'] ) . $file['file'] ) ) { - $file_handle = @fopen( trailingslashit( $file['base'] ) . $file['file'], 'wb' ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged, WordPress.WP.AlternativeFunctions.file_system_operations_fopen - if ( $file_handle ) { - fwrite( $file_handle, $file['content'] ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_fwrite - fclose( $file_handle ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_fclose - } - } - } - } -} diff --git a/lib/Functions/wcsrb-address-field-fns.php b/lib/Functions/wcsrb-address-field-fns.php new file mode 100644 index 0000000..0cca998 --- /dev/null +++ b/lib/Functions/wcsrb-address-field-fns.php @@ -0,0 +1,96 @@ + array( + 'class' => array( 'form-row-first', 'address-field', 'entity-type-toggle', 'shown' ), + 'label' => \__( 'Company Number', 'serbian-addons-for-woocommerce' ), + 'placeholder' => \__( 'Enter MB', 'serbian-addons-for-woocommerce' ), + 'priority' => 31, + 'type' => 'text', + 'validate' => array( 'mb' ), + ), + 'pib' => array( + 'class' => array( 'form-row-last', 'address-field', 'entity-type-toggle', 'shown' ), + 'label' => \__( 'Tax Number', 'serbian-addons-for-woocommerce' ), + 'placeholder' => \__( 'Enter PIB', 'serbian-addons-for-woocommerce' ), + 'priority' => 32, + 'type' => 'text', + 'validate' => array( 'pib' ), + ), + ); + + /** + * Filters the company address fields. + * + * @param array $fields Company address fields. + * @return array + * + * @since 3.8.0 + */ + return apply_filters( 'wcsrb_company_address_fields', $fields ); +} + +/** + * Checks if the customer can checkout as a given type. + * + * @param 'person'|'company'|'both' $type Customer type. + * @return bool + */ +function wcsrb_can_checkout_as( string $type ): bool { + static $types; + + $types ??= WCSRB()->get_settings( 'core', 'enabled_customer_types' ); + + return 'both' === $types || $type === $types; +} + + +/** + * Get the customer type for the given customer. + * + * @param WC_Order|WC_Customer $target Customer ID or object. + * @return 'person'|'company' + */ +function wcsrb_get_customer_type( WC_Order|WC_Customer $target ): string { + $key = $target instanceof WC_Order ? '_billing_type' : 'billing_type'; + + // phpcs:ignore Universal + return $target->get_meta( $key, true ) ?: 'person'; +} + +/** + * Get the company data for the given customer. + * + * @param WC_Order|WC_Customer $target Customer ID or object. + * @return false|array{mb: string, pib: string, type: 'company'|'person'} + */ +function wcsrb_get_company_data( WC_Order|WC_Customer $target ): bool|array { + if ( 'company' !== wcsrb_get_customer_type( $target ) ) { + return array( + 'mb' => '', + 'pib' => '', + 'type' => 'person', + ); + } + + $key = $target instanceof WC_Order ? '_billing' : 'billing'; + + return array( + 'mb' => $target->get_meta( "{$key}_mb", true ), + 'pib' => $target->get_meta( "{$key}_pib", true ), + 'type' => 'company', + ); +} diff --git a/lib/Utils/wcsrb-core.php b/lib/Functions/wcsrb-core.php similarity index 89% rename from lib/Utils/wcsrb-core.php rename to lib/Functions/wcsrb-core.php index d7c583f..2ead635 100644 --- a/lib/Utils/wcsrb-core.php +++ b/lib/Functions/wcsrb-core.php @@ -6,15 +6,13 @@ * @subpackage Utils */ -use Oblak\WooCommerce\Serbian_Addons\Serbian_WooCommerce; - /** * Main Plugin Instance * - * @return Serbian_WooCommerce + * @return Oblak\WCSRB\App */ function WCSRB() { - return Serbian_WooCommerce::instance(); + return Oblak\WCSRB\App::instance(); } /** diff --git a/lib/Utils/wcsrb-helpers.php b/lib/Functions/wcsrb-helpers.php similarity index 96% rename from lib/Utils/wcsrb-helpers.php rename to lib/Functions/wcsrb-helpers.php index 0b625db..992d1b9 100644 --- a/lib/Utils/wcsrb-helpers.php +++ b/lib/Functions/wcsrb-helpers.php @@ -1,4 +1,4 @@ - __( 'Company', 'serbian-addons-for-woocommerce' ), 'person' => __( 'Person', 'serbian-addons-for-woocommerce' ), + 'company' => __( 'Company', 'serbian-addons-for-woocommerce' ), ); /** diff --git a/lib/Utils/wcsrb-payment-slip.php b/lib/Functions/wcsrb-payment-slip.php similarity index 100% rename from lib/Utils/wcsrb-payment-slip.php rename to lib/Functions/wcsrb-payment-slip.php diff --git a/lib/Utils/wcsrb-settings.php b/lib/Functions/wcsrb-settings.php similarity index 97% rename from lib/Utils/wcsrb-settings.php rename to lib/Functions/wcsrb-settings.php index b7564e3..3e249ea 100644 --- a/lib/Utils/wcsrb-settings.php +++ b/lib/Functions/wcsrb-settings.php @@ -62,7 +62,7 @@ function wcsrb_format_payment_code_select() { ), ); - switch ( WCSRB()->get_settings( 'general', 'enabled_customer_types' ) ) { + switch ( WCSRB()->get_settings( 'core', 'enabled_customer_types' ) ) { case 'both': unset( $options[ __( 'Company', 'serbian-addons-for-woocommerce' ) ] ); unset( $options[ __( 'Person', 'serbian-addons-for-woocommerce' ) ] ); diff --git a/lib/Order/Field_Display.php b/lib/Order/Field_Display.php deleted file mode 100644 index 6a38eda..0000000 --- a/lib/Order/Field_Display.php +++ /dev/null @@ -1,200 +0,0 @@ -get_settings( 'general', 'remove_unneeded_fields' ) ) { - $formats['RS'] = \str_replace( array( '{state}', '{address_2}' ), '', $formats['RS'] ); - } - - return $formats; - } - - /** - * Adds custom replacements to the replacements array. - * - * Custom fields added are: - * - Type - * - Company Number - * - Tax Identification Number - * - * @param string[] $replacements Replacements array. - * @param array $args Address data. - * @return string[] Modified replacements array - */ - #[Filter( 'woocommerce_formatted_address_replacements', 99 )] - public function modify_address_replacements( $replacements, $args ) { - $replacements['{type}'] = $args['type'] ?? "\n"; - $replacements['{mb}'] = $args['mb'] ?? "\n"; - $replacements['{pib}'] = $args['pib'] ?? "\n"; - - return $replacements; - } - - /** - * Modifies the address data array to include neccecary company information. - * - * This is used in the My Account > Addresses page. - * - * @param array $address Address data array. - * @param int $customer_id Customer ID. - * @param string $address_type Address type (billing or shipping). - * @return array Modified address data array - */ - #[Filter( 'woocommerce_my_account_my_address_formatted_address', 99 )] - public function modify_account_formatted_address( $address, $customer_id, $address_type ) { - if ( 'billing' !== $address_type ) { - return $address; - } - - $customer = new WC_Customer( $customer_id ); - - // phpcs:ignore Universal.Operators.DisallowShortTernary.Found - $user_type = $customer->get_meta( 'billing_type', true ) ?: 'person'; - $company_num = $customer->get_meta( 'billing_mb', true ); - $company_tax = $customer->get_meta( 'billing_pib', true ); - - return $this->address_modifier( $address, $user_type, $company_num, $company_tax ); - } - - /** - * Modifies the address data array to include neccecary company information. - * - * This is used for the order addresses. - * - * @param array $address Address data array. - * @param WC_Order $order Order object. - * @return array Modified address data array - */ - #[Filter( 'woocommerce_order_formatted_billing_address', 99 )] - public function modify_order_formatted_address( $address, $order ) { - return $this->address_modifier( - $address, - $order->get_meta( '_billing_type', true ), - $order->get_meta( '_billing_mb', true ), - $order->get_meta( '_billing_pib', true ), - ); - } - - /** - * Billing address modifier function - * - * Depending on the customer(user) type we add the needed rows to the address. - * If the customer is a company we prepend the number type before the number itself - * - * @param array $address Billing address data array. - * @param string $type User type (person or company). - * @param string $company_number Company number. - * @param string $tax_number Company tax number. - * @return array Modified billing address data array. - */ - private function address_modifier( $address, $type, $company_number, $tax_number ) { - $address['type'] = $type; - $address['mb'] = "\n"; - $address['pib'] = "\n"; - - if ( 'company' !== $type ) { - return $address; - } - - $address['first_name'] = "\n"; - $address['last_name'] = "\n"; - - if ( $company_number ) { - $address['mb'] = \sprintf( - '%s: %s', - \_x( 'Company Number', 'Address display', 'serbian-addons-for-woocommerce' ), - $company_number, - ); - } - $address['pib'] = \sprintf( - '%s: %s', - \_x( 'Tax Identification Number', 'Address display', 'serbian-addons-for-woocommerce' ), - $tax_number, - ); - - return $address; - } - - /** - * Modifies the buyer name in the admin order page to include necessary company information - * - * @param string $buyer Buyer name. - * @param WC_Order $order Order object. - * @return string Modified Buyer name - */ - #[Filter( 'woocommerce_admin_order_buyer_name', 99 )] - public function modify_order_buyer_name( $buyer, $order ) { - return 'RS' === $order->get_billing_country() && 'company' === $order->get_meta( '_billing_type', true ) - ? $order->get_billing_company() - : $buyer; - } - - /** - * Adds the company information to the customer meta fields. - * - * @param array $fields Customer meta fields. - * @return array Modified customer meta fields - */ - #[Filter( 'woocommerce_customer_meta_fields' )] - public function modify_customer_meta_fields( array $fields ): array { - $billing = array(); - - foreach ( $fields['billing']['fields'] as $field => $args ) { - if ( 'billing_company' !== $field ) { - $billing[ $field ] = $args; - continue; - } - - $billing['billing_type'] = array( - 'label' => \__( 'Customer type', 'serbian-addons-for-woocommerce' ), - 'options' => \wcsrb_get_entity_types(), - 'type' => 'select', - ); - - $billing[ $field ] = $args; - - $billing['billing_mb'] = array( - 'label' => \__( 'Company Number', 'serbian-addons-for-woocommerce' ), - 'type' => 'text', - ); - - $billing['billing_pib'] = array( - 'label' => \__( 'Tax Number', 'serbian-addons-for-woocommerce' ), - 'type' => 'text', - ); - } - - $fields['billing']['fields'] = $billing; - - return $fields; - } -} diff --git a/lib/QR/QR_Code_Handler.php b/lib/QR/QR_Code_Handler.php index 9d5ebab..1345051 100644 --- a/lib/QR/QR_Code_Handler.php +++ b/lib/QR/QR_Code_Handler.php @@ -10,8 +10,8 @@ use chillerlan\QRCode\Data\QRMatrix; use chillerlan\QRCode\Output\QROutputInterface; use chillerlan\QRCode\QRCode; -use Oblak\WP\Traits\Singleton; use WC_Order; +use XWP\Helper\Traits\Singleton; /** * Handles the creation and rendering of QR Codes. diff --git a/lib/Services/Field_Validator.php b/lib/Services/Field_Validator.php new file mode 100644 index 0000000..63dca2a --- /dev/null +++ b/lib/Services/Field_Validator.php @@ -0,0 +1,141 @@ +company_active = \wcsrb_can_checkout_as( 'company' ); + } + + /** + * Validates the address fields. + * + * @param array $fields Address fields. + * @param 'billing'|'shipping' $type Address type being validated. + * @param array $address Address fields. + * @return null|array + */ + public function validate_fields( array $fields, string $type, ?array $address = null ): array { + if ( ! $this->needs_validation( $fields ) ) { + return array(); + } + + $address ??= \WC()->countries->get_address_fields( $fields[ "{$type}_country" ], $type . '_' ); + $errors = array(); + + foreach ( $this->get_field_validators() as $key => $args ) { + $errors[] = $this->validate_field( $fields[ $key ] ?? '', $key, $args, $address[ $key ] ); + + } + + //phpcs:ignore Universal.Operators.DisallowShortTernary.Found + return \array_filter( $errors ); + } + + /** + * Validates the given field. + * + * @param mixed $value Field value. + * @param string $key Field key. + * @param array $args Validation arguments. + * @param array $field Field data. + * @return ?array Error data if validation fails, null otherwise. + */ + protected function validate_field( mixed $value, string $key, array $args, array $field ): ?array { + if ( ! $value ) { + return array( + 'code' => "{$key}_required", + 'id' => $key, + // Translators: %s: Field label. + 'message' => \sprintf( \__( '%s is a required field.', 'woocommerce' ), $field['label'] ), + ); + } + + if ( ! $args['callback']( $value ) ) { + return array( + 'code' => $args['code'], + 'id' => $key, + 'message' => $args['message'], + ); + } + + return null; + } + + /** + * Returns the field validators for the given action. + * + * @return array + */ + protected function get_field_validators(): array { + $args = array( + 'billing_company' => array( + 'callback' => '__return_true', + 'code' => 'billing_company_required', + 'message' => \__( 'Company name is required', 'serbian-addons-for-woocommerce' ), + ), + 'billing_mb' => array( + 'callback' => '\Oblak\validateMB', + 'code' => 'billing_mb_validation', + 'message' => \__( 'Company number is invalid', 'serbian-addons-for-woocommerce' ), + ), + 'billing_pib' => array( + 'callback' => '\Oblak\validatePIB', + 'code' => 'billing_pib_validation', + 'message' => \__( 'Company Tax Number is invalid', 'serbian-addons-for-woocommerce' ), + ), + ); + + /** + * Returns the validation arguments for the given action. + * + * @param array $args Validation arguments. + * @return array + * + * @since 3.6.0 + */ + return \apply_filters( 'wcrs_field_validators', $args ); + } + + /** + * Checks if the current address can be validated. + * + * @param array $fields Address fields. + * @param 'billing'|'shipping' $address Address type being validated. + * @return bool + */ + protected function needs_validation( array $fields, string $address = 'billing' ): bool { + return $this->company_active && + 'billing' === $address && + 'company' === ( $fields['billing_type'] ?? '' ) && + 'RS' === ( $fields['billing_country'] ?? '' ); + } +} diff --git a/lib/Utils/Installer.php b/lib/Utils/Installer.php new file mode 100644 index 0000000..54a607d --- /dev/null +++ b/lib/Utils/Installer.php @@ -0,0 +1,120 @@ +name = \__( 'Serbian Addons for WooCommerce', 'serbian-addons-for-woocommerce' ); + $this->slug = 'serbian_woocommerce'; + $this->version = WCRS_VERSION; + $this->db_version = WCRS_VERSION; + } + + /** + * Show action links on the plugin screen + * + * @param array $links Plugin Action links. + * @return array Modified action links + */ + public static function plugin_action_links( $links ) { + $action_links = array( + 'settings' => \sprintf( + '%s', + \admin_url( 'admin.php?page=wc-settings&tab=wcsrb' ), + \esc_attr__( 'Settings', 'serbian-addons-for-woocommerce' ), + \esc_html__( 'Settings', 'serbian-addons-for-woocommerce' ), + ), + ); + + return \array_merge( $action_links, $links ); + } + + /** + * {@inheritDoc} + */ + public function setup_environment() { + $this->create_files(); + } + + /** + * Create files and folders + * + * @return void + */ + protected function create_files() { + /** + * Bypass if filesystem is read-only and/or non-standard upload system is used. + * + * @param bool $skip_create_files Whether to skip creating files. Default is false. + * @return bool + * @since 3.4.0 + */ + if ( \apply_filters( 'woocommerce_serbian_install_skip_create_files', false ) ) { + return; + } + + // Install files and folders for uploading files and prevent hotlinking. + $files = array( + array( + 'base' => WCRS_IPS_DIR, + 'content' => '', + 'file' => 'index.html', + ), + array( + 'base' => WCRS_IPS_DIR, + 'content' => 'deny from all', + 'file' => '.htaccess', + ), + ); + + foreach ( $files as $file ) { + $this->create_file( $file ); + } + } + + /** + * Creates a file. + * + * @param array $file File data. + */ + private function create_file( array $file ) { + if ( + ! \wp_mkdir_p( $file['base'] ) || + \file_exists( \trailingslashit( $file['base'] ) . $file['file'] ) + ) { + return; + } + + // phpcs:disable WordPress.PHP.NoSilencedErrors.Discouraged, WordPress.WP.AlternativeFunctions + $file_handle = @\fopen( \trailingslashit( $file['base'] ) . $file['file'], 'wb' ); + + if ( ! $file_handle ) { + return; + } + + \fwrite( $file_handle, $file['content'] ); + \fclose( $file_handle ); + // phpcs:enable WordPress.PHP.NoSilencedErrors.Discouraged, WordPress.WP.AlternativeFunctions + } +} diff --git a/lib/Core/Template_Extender.php b/lib/Utils/Template_Extender.php similarity index 89% rename from lib/Core/Template_Extender.php rename to lib/Utils/Template_Extender.php index e8d5b34..0610699 100644 --- a/lib/Core/Template_Extender.php +++ b/lib/Utils/Template_Extender.php @@ -5,9 +5,8 @@ * @package Serbian Addons for WooCommerce */ -namespace Oblak\WooCommerce\Serbian_Addons\Core; +namespace Oblak\WCSRB\Utils; -use Oblak\WooCommerce\Core\Base_Template_Extender; use Oblak\WP\Decorators\Hookable; use XWC\Template\Customizer_Base; @@ -15,6 +14,7 @@ * Adds custom templates to WooCommerce. * * @since 2.3.0 + * @since 3.8.0 Moved from the `Core` namespace. */ #[Hookable( 'before_woocommerce_init', 99 )] class Template_Extender extends Customizer_Base { diff --git a/loco.xml b/loco.xml index 7983ebe..89970a3 100644 --- a/loco.xml +++ b/loco.xml @@ -1,21 +1,20 @@ - - - - - - . - - - languages - - - - - - node_modules - vendor - languages - - + + + + + + . + + + languages + + + + + + node_modules + vendor + + diff --git a/package-lock.json b/package-lock.json index 290d664..975af7c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,8 +13,9 @@ "sass-mq": "^5.0" }, "devDependencies": { + "@types/backbone": "^1.4.19", "@types/jquery": "^3.5.5", - "@types/lodash": "^4.17.0", + "@types/wordpress__admin": "^5.8.4", "@typescript-eslint/eslint-plugin": "^7.8.0", "@typescript-eslint/parser": "^7.8.0", "@x-wp/semantic-release-config": "^1", @@ -27,7 +28,7 @@ "stylelint": "^15.10.1", "stylelint-config-standard": "^34.0.0", "stylelint-config-standard-scss": "^10.0.0", - "typescript": "5", + "typescript": "^5.6.2", "webpack": "^5", "webpack-cli": "^5" }, @@ -3731,6 +3732,16 @@ "integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==", "dev": true }, + "node_modules/@types/backbone": { + "version": "1.4.20", + "resolved": "https://registry.npmjs.org/@types/backbone/-/backbone-1.4.20.tgz", + "integrity": "sha512-SVzEWyos+awvuu3lUJdfhFEUuksiRvXOFK6aJy1cA8Dmbf+BbCvIve7LSsW3XPOd9d0urB7eo3Y+xP8YtPOoIg==", + "dev": true, + "dependencies": { + "@types/jquery": "*", + "@types/underscore": "*" + } + }, "node_modules/@types/estree": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.6.tgz", @@ -3782,12 +3793,6 @@ "integrity": "sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==", "dev": true }, - "node_modules/@types/lodash": { - "version": "4.17.7", - "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.17.7.tgz", - "integrity": "sha512-8wTvZawATi/lsmNu10/j2hk1KEP0IvjubqPE3cu1Xz7xfXXt5oCq3SNUz4fMIP4XGF9Ky+Ue2tBA3hcS7LSBlA==", - "dev": true - }, "node_modules/@types/minimist": { "version": "1.2.5", "resolved": "https://registry.npmjs.org/@types/minimist/-/minimist-1.2.5.tgz", @@ -3815,12 +3820,34 @@ "integrity": "sha512-0vWLNK2D5MT9dg0iOo8GlKguPAU02QjmZitPEsXRuJXU/OGIOt9vT9Fc26wtYuavLxtO45v9PGleoL9Z0k1LHg==", "dev": true }, + "node_modules/@types/underscore": { + "version": "1.11.15", + "resolved": "https://registry.npmjs.org/@types/underscore/-/underscore-1.11.15.tgz", + "integrity": "sha512-HP38xE+GuWGlbSRq9WrZkousaQ7dragtZCruBVMi0oX1migFZavZ3OROKHSkNp/9ouq82zrWtZpg18jFnVN96g==", + "dev": true + }, "node_modules/@types/validator": { "version": "13.12.2", "resolved": "https://registry.npmjs.org/@types/validator/-/validator-13.12.2.tgz", "integrity": "sha512-6SlHBzUW8Jhf3liqrGGXyTJSIFe4nqlJ5A5KaMZ2l/vbM3Wh3KSybots/wfWVzNLK4D1NZluDlSQIbIEPx6oyA==", "dev": true }, + "node_modules/@types/wordpress__admin": { + "version": "5.8.4", + "resolved": "https://registry.npmjs.org/@types/wordpress__admin/-/wordpress__admin-5.8.4.tgz", + "integrity": "sha512-Fi9nEQWXTLe0MSwuzMnJW/sGZNgkw5eV7WNbvp+DIMO1Zly+9c8zWgsQuG0Wzkc4F1T3dPvkgyrFjADStfiHRA==", + "dev": true, + "dependencies": { + "@types/backbone": "*", + "@types/lodash": "^3" + } + }, + "node_modules/@types/wordpress__admin/node_modules/@types/lodash": { + "version": "3.10.9", + "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-3.10.9.tgz", + "integrity": "sha512-BqzpDcDNIj0D15QezYF2C8OhOZVsm3g9Y6bLfXC6jO+wgxDGdCJlzge9OqnI0RezYJNsfsGXovhb3zTZjHpiCA==", + "dev": true + }, "node_modules/@types/yargs": { "version": "17.0.33", "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.33.tgz", diff --git a/package.json b/package.json index 5847faa..6d7d849 100644 --- a/package.json +++ b/package.json @@ -19,8 +19,9 @@ "sass-mq": "^5.0" }, "devDependencies": { + "@types/backbone": "^1.4.19", "@types/jquery": "^3.5.5", - "@types/lodash": "^4.17.0", + "@types/wordpress__admin": "^5.8.4", "@typescript-eslint/eslint-plugin": "^7.8.0", "@typescript-eslint/parser": "^7.8.0", "@x-wp/semantic-release-config": "^1", @@ -33,7 +34,7 @@ "stylelint": "^15.10.1", "stylelint-config-standard": "^34.0.0", "stylelint-config-standard-scss": "^10.0.0", - "typescript": "5", + "typescript": "^5.6.2", "webpack": "^5", "webpack-cli": "^5" }, diff --git a/release.config.js b/release.config.js index 9edefa5..0c02756 100644 --- a/release.config.js +++ b/release.config.js @@ -18,6 +18,7 @@ config.plugins.push([ { preset: 'angular', releaseRules: [ + { type: 'compat', release: 'patch' }, { type: 'refactor', release: 'patch' }, { type: 'style', release: 'patch' }, ], diff --git a/serbian-addons-for-woocommerce.php b/serbian-addons-for-woocommerce.php index 0200b88..0716d26 100644 --- a/serbian-addons-for-woocommerce.php +++ b/serbian-addons-for-woocommerce.php @@ -13,6 +13,8 @@ * License: GPLv2 or later * License URI: https://www.gnu.org/licenses/gpl-2.0.html * Text Domain: serbian-addons-for-woocommerce + * Domain Path: /languages + * Requires Plugins: woocommerce * * @package Serbian Addons for WooCommerce */ diff --git a/tsconfig.json b/tsconfig.json index 28d0c6f..9e4bb0c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,9 +3,14 @@ "esModuleInterop": true, "moduleResolution": "node", "allowSyntheticDefaultImports": true, - "target": "ES2019" + "target": "ES2021", + "typeRoots": [ + "./node_modules/@types", + "./assets/scripts/@types" + ] }, - "include": [ - "assets/scripts/**/*" + "exclude": [ + "node_modules", + "dist" ] -} +} \ No newline at end of file