From b664fb886799c35eb22f011b244347ed31f24da1 Mon Sep 17 00:00:00 2001 From: Gytautas Date: Thu, 14 Sep 2023 11:12:29 +0300 Subject: [PATCH 01/17] hide print label button in orders listing page --- .../admin/AdminDPDBalticsSettingsController.php | 15 +++++++++++++++ dpdbaltics.php | 8 ++++++++ src/Config/Config.php | 1 + src/Install/Installer.php | 1 + 4 files changed, 25 insertions(+) diff --git a/controllers/admin/AdminDPDBalticsSettingsController.php b/controllers/admin/AdminDPDBalticsSettingsController.php index be47f2bd..c37be6e9 100644 --- a/controllers/admin/AdminDPDBalticsSettingsController.php +++ b/controllers/admin/AdminDPDBalticsSettingsController.php @@ -114,6 +114,21 @@ protected function initOptions() 'title' => $this->l('Save'), ], ], + 'orders_page_configuration' => [ + 'title' => $this->l('Orders listing page configuration'), + 'icon' => 'dpd-icon-settings', + 'fields' => [ + Config::HIDE_ORDERS_LABEL_PRINT_BUTTON => [ + 'title' => $this->l('Hide print button in admin orders listing page'), + 'type' => 'bool', + 'validation' => 'isBool', + 'cast' => 'intval' + ], + ], + 'submit' => [ + 'title' => $this->l('Save'), + ], + ], 'log_configuration' => [ 'title' => $this->l('Log configuration'), 'icon' => 'dpd-icon-settings', diff --git a/dpdbaltics.php b/dpdbaltics.php index 0fe045a9..b1bf8260 100644 --- a/dpdbaltics.php +++ b/dpdbaltics.php @@ -1207,12 +1207,18 @@ public function hookDisplayOrderDetail($params) public function hookActionAdminOrdersListingFieldsModifier($params) { + if ((bool) Configuration::get(Config::HIDE_ORDERS_LABEL_PRINT_BUTTON)) { + return false; + } + if (isset($params['select'])) { $params['select'] .= ' ,ds.`id_order` AS id_order_shipment '; } + if (isset($params['join'])) { $params['join'] .= ' LEFT JOIN `' . _DB_PREFIX_ . 'dpd_shipment` ds ON ds.`id_order` = a.`id_order` '; } + $params['fields']['id_order_shipment'] = [ 'title' => $this->l('DPD Label'), 'align' => 'text-center', @@ -1267,6 +1273,7 @@ public function hookActionOrderGridDefinitionModifier(array $params) $definition = $params['definition']; + if (!(bool) Configuration::get(Config::HIDE_ORDERS_LABEL_PRINT_BUTTON)) { $definition->getColumns() ->addAfter( 'date_add', @@ -1276,6 +1283,7 @@ public function hookActionOrderGridDefinitionModifier(array $params) 'actions' => $this->getGridAction() ]) ); + } $definition->getBulkActions() ->add( diff --git a/src/Config/Config.php b/src/Config/Config.php index 0e633611..fe9a188a 100644 --- a/src/Config/Config.php +++ b/src/Config/Config.php @@ -115,6 +115,7 @@ class Config const DEFAULT_LABEL_POSITION = 'DPD_DEFAULT_LABEL_POSITION'; const SEND_EMAIL_ON_PARCEL_CREATION = 'DPD_SEND_EMAIL_TO_CUSTOMER'; const MULTIPLE_LABEL_NAME_MAX_SIZE = 44; + const HIDE_ORDERS_LABEL_PRINT_BUTTON = 'DPD_HIDE_ORDERS_LABEL_PRINT_BUTTON'; const PHONE_CODE_PREFIX = '+'; diff --git a/src/Install/Installer.php b/src/Install/Installer.php index 7943125b..2e806e4c 100644 --- a/src/Install/Installer.php +++ b/src/Install/Installer.php @@ -220,6 +220,7 @@ public function getDefaultConfiguration() Config::IMPORT_LINES_SKIP => 1, Config::IMPORT_FIELD_SEPARATOR => ';', Config::IMPORT_DELETE_OLD_DATA => 0, + Config::HIDE_ORDERS_LABEL_PRINT_BUTTON => 0, /** On-board */ Config::ON_BOARD_TURNED_ON => 1, From 4a0c404e942f3651da8cb864b4cf9659dd2cf1fe Mon Sep 17 00:00:00 2001 From: Gytautas Date: Thu, 14 Sep 2023 11:49:00 +0300 Subject: [PATCH 02/17] fix: translation domain added --- controllers/admin/AdminDPDBalticsSettingsController.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/controllers/admin/AdminDPDBalticsSettingsController.php b/controllers/admin/AdminDPDBalticsSettingsController.php index c37be6e9..820795ec 100644 --- a/controllers/admin/AdminDPDBalticsSettingsController.php +++ b/controllers/admin/AdminDPDBalticsSettingsController.php @@ -39,6 +39,8 @@ class AdminDPDBalticsSettingsController extends AbstractAdminController { + private const FILE_NAME = 'AdminDPDBalticsSettingsController'; + public function init() { $parentReturn = parent::init(); @@ -115,7 +117,7 @@ protected function initOptions() ], ], 'orders_page_configuration' => [ - 'title' => $this->l('Orders listing page configuration'), + 'title' => $this->l('Orders listing page configuration', self::FILE_NAME), 'icon' => 'dpd-icon-settings', 'fields' => [ Config::HIDE_ORDERS_LABEL_PRINT_BUTTON => [ From 71d2ed65aa19e642c38a7e07e115b496705939b3 Mon Sep 17 00:00:00 2001 From: Gytautas Date: Wed, 29 Nov 2023 16:58:03 +0200 Subject: [PATCH 03/17] fix: moved dev dependency from production ones --- composer.json | 8 +- composer.lock | 469 ++++++++++++++++++++++++++------------------------ 2 files changed, 246 insertions(+), 231 deletions(-) diff --git a/composer.json b/composer.json index 8fdb63d6..7be6b9e6 100644 --- a/composer.json +++ b/composer.json @@ -36,16 +36,16 @@ "invertus/dpdbaltics-api": "dev-developer", "invertus/psmoduletabs": "dev-develop", "symfony/console": "^3.4", - "prestashop/decimal": "^1.4", - "prestashop/autoindex": "1.0.0", - "prestashop/header-stamp": "1.7" + "prestashop/decimal": "^1.4" }, "require-dev": { "phpunit/phpunit": "*", "facebook/webdriver": "dev-master", "squizlabs/php_codesniffer": "*", "vlucas/phpdotenv": "^3.6", - "friendsofphp/php-cs-fixer": "^2.19" + "prestashop/autoindex": "1.0.0", + "friendsofphp/php-cs-fixer": "^2.19", + "prestashop/header-stamp": "1.7" }, "author": "PrestaShop", "license": "AFL-3.0" diff --git a/composer.lock b/composer.lock index fc7e496f..67c4085f 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": "9ff3d00c8c0f2f99a7cf13791049d534", + "content-hash": "d0adbb8ef686f675841e9929585eae6d", "packages": [ { "name": "apimatic/jsonmapper", @@ -271,61 +271,6 @@ ], "time": "2022-06-09T08:53:42+00:00" }, - { - "name": "nikic/php-parser", - "version": "v3.1.5", - "source": { - "type": "git", - "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "bb87e28e7d7b8d9a7fda231d37457c9210faf6ce" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/bb87e28e7d7b8d9a7fda231d37457c9210faf6ce", - "reference": "bb87e28e7d7b8d9a7fda231d37457c9210faf6ce", - "shasum": "" - }, - "require": { - "ext-tokenizer": "*", - "php": ">=5.5" - }, - "require-dev": { - "phpunit/phpunit": "~4.0|~5.0" - }, - "bin": [ - "bin/php-parse" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.0-dev" - } - }, - "autoload": { - "psr-4": { - "PhpParser\\": "lib/PhpParser" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Nikita Popov" - } - ], - "description": "A PHP parser written in PHP", - "keywords": [ - "parser", - "php" - ], - "support": { - "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v3.1.5" - }, - "time": "2018-02-28T20:30:58+00:00" - }, { "name": "paragonie/random_compat", "version": "v2.0.21", @@ -607,52 +552,6 @@ ], "time": "2020-07-20T17:29:33+00:00" }, - { - "name": "prestashop/autoindex", - "version": "v1.0.0", - "source": { - "type": "git", - "url": "https://github.com/PrestaShopCorp/autoindex.git", - "reference": "92e10242f94a99163dece280f6bd7b7c2b79c158" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/PrestaShopCorp/autoindex/zipball/92e10242f94a99163dece280f6bd7b7c2b79c158", - "reference": "92e10242f94a99163dece280f6bd7b7c2b79c158", - "shasum": "" - }, - "require": { - "nikic/php-parser": "^3.1", - "php": ">=5.6", - "symfony/console": "^3.4", - "symfony/finder": "^3.4" - }, - "bin": [ - "bin/autoindex" - ], - "type": "library", - "autoload": { - "psr-4": { - "PrestaShop\\AutoIndex\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "AFL-3.0" - ], - "authors": [ - { - "name": "PrestaShop SA", - "email": "contact@prestashop.com" - } - ], - "description": "Automatically add an 'index.php' in all the current or specified directories and all sub-directories.", - "homepage": "https://github.com/PrestaShopCorp/autoindex", - "support": { - "source": "https://github.com/PrestaShopCorp/autoindex/tree/v1.0.0" - }, - "time": "2020-03-11T13:37:03+00:00" - }, { "name": "prestashop/decimal", "version": "1.4.0", @@ -709,56 +608,6 @@ }, "time": "2020-10-08T07:14:07+00:00" }, - { - "name": "prestashop/header-stamp", - "version": "v1.7", - "source": { - "type": "git", - "url": "https://github.com/PrestaShopCorp/header-stamp.git", - "reference": "d77ce6d0a7f066670a4774be88f05e5f07b4b6fc" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/PrestaShopCorp/header-stamp/zipball/d77ce6d0a7f066670a4774be88f05e5f07b4b6fc", - "reference": "d77ce6d0a7f066670a4774be88f05e5f07b4b6fc", - "shasum": "" - }, - "require": { - "nikic/php-parser": "^3.1", - "php": ">=5.6", - "symfony/console": "^3.4 || ~4.0 || ~5.0", - "symfony/finder": "^3.4 || ~4.0 || ~5.0" - }, - "require-dev": { - "prestashop/php-dev-tools": "1.*" - }, - "bin": [ - "bin/header-stamp" - ], - "type": "library", - "autoload": { - "psr-4": { - "PrestaShop\\HeaderStamp\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "AFL-3.0" - ], - "authors": [ - { - "name": "PrestaShop SA", - "email": "contact@prestashop.com" - } - ], - "description": "Rewrite your file headers to add the license or to make them up-to-date", - "homepage": "https://github.com/PrestaShopCorp/header-stamp", - "support": { - "issues": "https://github.com/PrestaShopCorp/header-stamp/issues", - "source": "https://github.com/PrestaShopCorp/header-stamp/tree/v1.7" - }, - "time": "2020-12-09T16:40:38+00:00" - }, { "name": "psr/log", "version": "1.1.4", @@ -962,67 +811,6 @@ "abandoned": "symfony/error-handler", "time": "2020-10-24T10:57:07+00:00" }, - { - "name": "symfony/finder", - "version": "v3.4.47", - "source": { - "type": "git", - "url": "https://github.com/symfony/finder.git", - "reference": "b6b6ad3db3edb1b4b1c1896b1975fb684994de6e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/b6b6ad3db3edb1b4b1c1896b1975fb684994de6e", - "reference": "b6b6ad3db3edb1b4b1c1896b1975fb684994de6e", - "shasum": "" - }, - "require": { - "php": "^5.5.9|>=7.0.8" - }, - "type": "library", - "autoload": { - "psr-4": { - "Symfony\\Component\\Finder\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Finder Component", - "homepage": "https://symfony.com", - "support": { - "source": "https://github.com/symfony/finder/tree/v3.4.47" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2020-11-16T17:02:08+00:00" - }, { "name": "symfony/inflector", "version": "v3.4.47", @@ -1797,16 +1585,16 @@ }, { "name": "composer/semver", - "version": "3.3.2", + "version": "3.4.0", "source": { "type": "git", "url": "https://github.com/composer/semver.git", - "reference": "3953f23262f2bff1919fc82183ad9acb13ff62c9" + "reference": "35e8d0af4486141bc745f23a29cc2091eb624a32" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/semver/zipball/3953f23262f2bff1919fc82183ad9acb13ff62c9", - "reference": "3953f23262f2bff1919fc82183ad9acb13ff62c9", + "url": "https://api.github.com/repos/composer/semver/zipball/35e8d0af4486141bc745f23a29cc2091eb624a32", + "reference": "35e8d0af4486141bc745f23a29cc2091eb624a32", "shasum": "" }, "require": { @@ -1856,9 +1644,9 @@ "versioning" ], "support": { - "irc": "irc://irc.freenode.org/composer", + "irc": "ircs://irc.libera.chat:6697/composer", "issues": "https://github.com/composer/semver/issues", - "source": "https://github.com/composer/semver/tree/3.3.2" + "source": "https://github.com/composer/semver/tree/3.4.0" }, "funding": [ { @@ -1874,7 +1662,7 @@ "type": "tidelift" } ], - "time": "2022-04-01T19:23:25+00:00" + "time": "2023-08-31T09:50:34+00:00" }, { "name": "composer/xdebug-handler", @@ -2068,8 +1856,22 @@ ], "support": { "issues": "https://github.com/doctrine/instantiator/issues", - "source": "https://github.com/doctrine/instantiator/tree/master" + "source": "https://github.com/doctrine/instantiator/tree/1.0.5" }, + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Finstantiator", + "type": "tidelift" + } + ], "time": "2015-06-14T21:17:01+00:00" }, { @@ -2341,6 +2143,61 @@ }, "time": "2017-10-19T19:58:43+00:00" }, + { + "name": "nikic/php-parser", + "version": "v3.1.5", + "source": { + "type": "git", + "url": "https://github.com/nikic/PHP-Parser.git", + "reference": "bb87e28e7d7b8d9a7fda231d37457c9210faf6ce" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/bb87e28e7d7b8d9a7fda231d37457c9210faf6ce", + "reference": "bb87e28e7d7b8d9a7fda231d37457c9210faf6ce", + "shasum": "" + }, + "require": { + "ext-tokenizer": "*", + "php": ">=5.5" + }, + "require-dev": { + "phpunit/phpunit": "~4.0|~5.0" + }, + "bin": [ + "bin/php-parse" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "psr-4": { + "PhpParser\\": "lib/PhpParser" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Nikita Popov" + } + ], + "description": "A PHP parser written in PHP", + "keywords": [ + "parser", + "php" + ], + "support": { + "issues": "https://github.com/nikic/PHP-Parser/issues", + "source": "https://github.com/nikic/PHP-Parser/tree/v3.1.5" + }, + "time": "2018-02-28T20:30:58+00:00" + }, { "name": "php-cs-fixer/diff", "version": "v1.3.1", @@ -2887,6 +2744,102 @@ "abandoned": true, "time": "2017-06-30T09:13:00+00:00" }, + { + "name": "prestashop/autoindex", + "version": "v1.0.0", + "source": { + "type": "git", + "url": "https://github.com/PrestaShopCorp/autoindex.git", + "reference": "92e10242f94a99163dece280f6bd7b7c2b79c158" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PrestaShopCorp/autoindex/zipball/92e10242f94a99163dece280f6bd7b7c2b79c158", + "reference": "92e10242f94a99163dece280f6bd7b7c2b79c158", + "shasum": "" + }, + "require": { + "nikic/php-parser": "^3.1", + "php": ">=5.6", + "symfony/console": "^3.4", + "symfony/finder": "^3.4" + }, + "bin": [ + "bin/autoindex" + ], + "type": "library", + "autoload": { + "psr-4": { + "PrestaShop\\AutoIndex\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "AFL-3.0" + ], + "authors": [ + { + "name": "PrestaShop SA", + "email": "contact@prestashop.com" + } + ], + "description": "Automatically add an 'index.php' in all the current or specified directories and all sub-directories.", + "homepage": "https://github.com/PrestaShopCorp/autoindex", + "support": { + "source": "https://github.com/PrestaShopCorp/autoindex/tree/v1.0.0" + }, + "time": "2020-03-11T13:37:03+00:00" + }, + { + "name": "prestashop/header-stamp", + "version": "v1.7", + "source": { + "type": "git", + "url": "https://github.com/PrestaShopCorp/header-stamp.git", + "reference": "d77ce6d0a7f066670a4774be88f05e5f07b4b6fc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PrestaShopCorp/header-stamp/zipball/d77ce6d0a7f066670a4774be88f05e5f07b4b6fc", + "reference": "d77ce6d0a7f066670a4774be88f05e5f07b4b6fc", + "shasum": "" + }, + "require": { + "nikic/php-parser": "^3.1", + "php": ">=5.6", + "symfony/console": "^3.4 || ~4.0 || ~5.0", + "symfony/finder": "^3.4 || ~4.0 || ~5.0" + }, + "require-dev": { + "prestashop/php-dev-tools": "1.*" + }, + "bin": [ + "bin/header-stamp" + ], + "type": "library", + "autoload": { + "psr-4": { + "PrestaShop\\HeaderStamp\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "AFL-3.0" + ], + "authors": [ + { + "name": "PrestaShop SA", + "email": "contact@prestashop.com" + } + ], + "description": "Rewrite your file headers to add the license or to make them up-to-date", + "homepage": "https://github.com/PrestaShopCorp/header-stamp", + "support": { + "issues": "https://github.com/PrestaShopCorp/header-stamp/issues", + "source": "https://github.com/PrestaShopCorp/header-stamp/tree/v1.7" + }, + "time": "2020-12-09T16:40:38+00:00" + }, { "name": "sebastian/code-unit-reverse-lookup", "version": "1.0.2", @@ -3448,16 +3401,16 @@ }, { "name": "squizlabs/php_codesniffer", - "version": "3.7.1", + "version": "3.7.2", "source": { "type": "git", "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "1359e176e9307e906dc3d890bcc9603ff6d90619" + "reference": "ed8e00df0a83aa96acf703f8c2979ff33341f879" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/1359e176e9307e906dc3d890bcc9603ff6d90619", - "reference": "1359e176e9307e906dc3d890bcc9603ff6d90619", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/ed8e00df0a83aa96acf703f8c2979ff33341f879", + "reference": "ed8e00df0a83aa96acf703f8c2979ff33341f879", "shasum": "" }, "require": { @@ -3493,14 +3446,15 @@ "homepage": "https://github.com/squizlabs/PHP_CodeSniffer", "keywords": [ "phpcs", - "standards" + "standards", + "static analysis" ], "support": { "issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues", "source": "https://github.com/squizlabs/PHP_CodeSniffer", "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki" }, - "time": "2022-06-18T07:21:10+00:00" + "time": "2023-02-22T23:07:41+00:00" }, { "name": "symfony/event-dispatcher", @@ -3640,6 +3594,67 @@ ], "time": "2020-10-24T10:57:07+00:00" }, + { + "name": "symfony/finder", + "version": "v3.4.47", + "source": { + "type": "git", + "url": "https://github.com/symfony/finder.git", + "reference": "b6b6ad3db3edb1b4b1c1896b1975fb684994de6e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/finder/zipball/b6b6ad3db3edb1b4b1c1896b1975fb684994de6e", + "reference": "b6b6ad3db3edb1b4b1c1896b1975fb684994de6e", + "shasum": "" + }, + "require": { + "php": "^5.5.9|>=7.0.8" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Finder\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Finder Component", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/finder/tree/v3.4.47" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-11-16T17:02:08+00:00" + }, { "name": "symfony/options-resolver", "version": "v3.4.47", From e7115d2e7686fb81f1579fc087a22ac4754a0c77 Mon Sep 17 00:00:00 2001 From: Gytautas Date: Mon, 11 Dec 2023 13:54:46 +0200 Subject: [PATCH 04/17] added additional filtration for the price rules which includes check of the country --- src/Repository/PriceRuleRepository.php | 22 +++++++++++++++++-- .../ShippingPriceCalculationService.php | 3 ++- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/Repository/PriceRuleRepository.php b/src/Repository/PriceRuleRepository.php index ce71fdae..365ed6a6 100644 --- a/src/Repository/PriceRuleRepository.php +++ b/src/Repository/PriceRuleRepository.php @@ -73,12 +73,14 @@ public function getAllFlag($tableName, $idPriceRule) * * @param Address $deliveryAddress * @param int $carrierReferenceId + * @param bool $includeCountryCheck * @return array price rules IDs * @throws PrestaShopDatabaseException */ public function getByCarrierReference( Address $deliveryAddress, - $carrierReference + $carrierReference, + bool $includeCountryCheck = false ) { $query = new DbQuery(); $query->select('prc.`id_dpd_price_rule`'); @@ -89,11 +91,27 @@ public function getByCarrierReference( 'prs', 'prs.`id_dpd_price_rule` = prc.`id_dpd_price_rule`' ); + + /* param needed to filter out by countries to get specific price rules for that country address */ + if ($includeCountryCheck) { + $query->innerJoin( + 'dpd_price_rule_zone', + 'prz', + 'prc.`id_dpd_price_rule` = prz.`id_dpd_price_rule`' + ); + $query->innerJoin( + 'dpd_zone_range', + 'zr', + 'prz.`id_dpd_zone` = zr.`id_dpd_zone`' + ); + + $query->where('zr.`id_country`= ' . $deliveryAddress->id_country); + } + $query->where('prc.`id_reference`="' . (int)$carrierReference . '" OR prc.`all_carriers`="1"'); $query->where('pr.active = 1'); $query->orderBy('pr.position ASC'); - if (Validate::isLoadedObject($deliveryAddress)) { if ($deliveryAddress->company) { $query->where( diff --git a/src/Service/ShippingPriceCalculationService.php b/src/Service/ShippingPriceCalculationService.php index 2e696558..1bbc8e3f 100644 --- a/src/Service/ShippingPriceCalculationService.php +++ b/src/Service/ShippingPriceCalculationService.php @@ -56,7 +56,8 @@ public function calculate(Cart $cart, \Carrier $carrier, Address $deliveryAddres $priceRulesIds = $this->priceRuleRepository->getByCarrierReference( $deliveryAddress, - $carrier->id_reference + $carrier->id_reference, + true ); $shippingCosts += $this->priceRuleService->applyPriceRuleForCarrier( From 32bd71260bd01a5e975b4fa92cbfdb105e60f49a Mon Sep 17 00:00:00 2001 From: Gytautas Date: Mon, 11 Dec 2023 13:59:02 +0200 Subject: [PATCH 05/17] version increased and changelog updated --- CHANGELOG.md | 4 ++++ dpdbaltics.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b3168040..f57ac8eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -154,3 +154,7 @@ ## [3.2.17] - Label printing after changing shipment product bug fix + +## [3.2.18] +- Vulnerability fix with development dependencies +- Price rule bug fix to add additional filtration by country \ No newline at end of file diff --git a/dpdbaltics.php b/dpdbaltics.php index cb11ea4f..b1adf47e 100644 --- a/dpdbaltics.php +++ b/dpdbaltics.php @@ -92,7 +92,7 @@ public function __construct() $this->author = 'Invertus'; $this->tab = 'shipping_logistics'; $this->description = 'DPD Baltics shipping integration'; - $this->version = '3.2.17'; + $this->version = '3.2.18'; $this->ps_versions_compliancy = ['min' => '1.7.1.0', 'max' => _PS_VERSION_]; $this->need_instance = 0; parent::__construct(); From 6d3a4a45e460b600e7db2c908f17c78aef24b1c8 Mon Sep 17 00:00:00 2001 From: Gytautas Date: Tue, 12 Dec 2023 09:26:16 +0200 Subject: [PATCH 06/17] feat: upgrade method created to define value --- CHANGELOG.md | 3 +++ dpdbaltics.php | 2 +- upgrade/Upgrade-3.2.18.php | 29 +++++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 upgrade/Upgrade-3.2.18.php diff --git a/CHANGELOG.md b/CHANGELOG.md index b3168040..9f1ba11a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -154,3 +154,6 @@ ## [3.2.17] - Label printing after changing shipment product bug fix + +## [3.2.18] +- Ability to hide label print feature in orders list page \ No newline at end of file diff --git a/dpdbaltics.php b/dpdbaltics.php index b2f25446..86f43c38 100644 --- a/dpdbaltics.php +++ b/dpdbaltics.php @@ -92,7 +92,7 @@ public function __construct() $this->author = 'Invertus'; $this->tab = 'shipping_logistics'; $this->description = 'DPD Baltics shipping integration'; - $this->version = '3.2.17'; + $this->version = '3.2.18'; $this->ps_versions_compliancy = ['min' => '1.7.1.0', 'max' => _PS_VERSION_]; $this->need_instance = 0; parent::__construct(); diff --git a/upgrade/Upgrade-3.2.18.php b/upgrade/Upgrade-3.2.18.php new file mode 100644 index 00000000..8b111167 --- /dev/null +++ b/upgrade/Upgrade-3.2.18.php @@ -0,0 +1,29 @@ + + * @copyright Copyright (c) permanent, INVERTUS, UAB + * @license Addons PrestaShop license limitation + * @see /LICENSE + * + * International Registered Trademark & Property of INVERTUS, UAB + */ + +use Invertus\dpdBaltics\Config\Config; + +if (!defined('_PS_VERSION_')) { + exit; +} + +/** + * @return bool + * + * @throws PrestaShopDatabaseException + * @throws PrestaShopException + */ +function upgrade_module_3_2_18(DPDBaltics $module) +{ + return Configuration::updateValue(Config::HIDE_ORDERS_LABEL_PRINT_BUTTON, 0); +} + From f523bc4557ddf7e332074a54c7da0c9e0d3b4126 Mon Sep 17 00:00:00 2001 From: Gytautas Date: Wed, 20 Dec 2023 14:31:36 +0200 Subject: [PATCH 07/17] price rule and country fix --- src/Repository/PriceRuleRepository.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Repository/PriceRuleRepository.php b/src/Repository/PriceRuleRepository.php index 365ed6a6..c9572803 100644 --- a/src/Repository/PriceRuleRepository.php +++ b/src/Repository/PriceRuleRepository.php @@ -93,7 +93,7 @@ public function getByCarrierReference( ); /* param needed to filter out by countries to get specific price rules for that country address */ - if ($includeCountryCheck) { + if ($includeCountryCheck && $deliveryAddress->id_country) { $query->innerJoin( 'dpd_price_rule_zone', 'prz', @@ -105,10 +105,10 @@ public function getByCarrierReference( 'prz.`id_dpd_zone` = zr.`id_dpd_zone`' ); - $query->where('zr.`id_country`= ' . $deliveryAddress->id_country); + $query->where('zr.`id_country`= ' . (int) $deliveryAddress->id_country); } - $query->where('prc.`id_reference`="' . (int)$carrierReference . '" OR prc.`all_carriers`="1"'); + $query->where('prc.`id_reference`="' . (int) $carrierReference . '" OR prc.`all_carriers`="1"'); $query->where('pr.active = 1'); $query->orderBy('pr.position ASC'); From e4655f6d6a79dcee84d95bc4d74856a60a36d6b2 Mon Sep 17 00:00:00 2001 From: Gytautas Date: Thu, 11 Jan 2024 14:04:41 +0200 Subject: [PATCH 08/17] carrier availability in country fox --- dpdbaltics.php | 5 ++++ src/Repository/ProductRepository.php | 38 ++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/dpdbaltics.php b/dpdbaltics.php index 86f43c38..e22b3855 100644 --- a/dpdbaltics.php +++ b/dpdbaltics.php @@ -475,6 +475,11 @@ public function getOrderShippingCostExternal($cart) return false; } + if (!$productRepo->checkIfCarrierIsAvailableInCountry((int) $carrier->id_reference, (int) $deliveryAddress->id_country) + ) { + return false; + } + try { $isCarrierAvailableInShop = $productRepo->checkIfCarrierIsAvailableInShop($carrier->id_reference, $this->context->shop->id); if (empty($isCarrierAvailableInShop)) { diff --git a/src/Repository/ProductRepository.php b/src/Repository/ProductRepository.php index 611e1a82..fe488f29 100644 --- a/src/Repository/ProductRepository.php +++ b/src/Repository/ProductRepository.php @@ -28,6 +28,8 @@ use PDOStatement; use PrestaShopCollection; use PrestaShopDatabaseException; +use PrestaShopException; +use resource; class ProductRepository extends AbstractEntityRepository { @@ -252,4 +254,40 @@ public function findProductByProductReference($carrierReference) return $this->db->getRow($query) ?: null; } + + + /** + * @param int $carrierReference + * @param int $countryId + * + * @return array|bool|mysqli_result|PDOStatement|resource|null + * @throws PrestaShopDatabaseException + * @throws PrestaShopException + */ + public function checkIfCarrierIsAvailableInCountry(int $carrierReference, int $countryId) + { + $productId = $this->getProductIdByCarrierReference($carrierReference); + $product = new DPDProduct($productId); + + $query = new DbQuery(); + $query->select('dp.id_dpd_product'); + $query->from('dpd_product', 'dp'); + + $query->leftJoin( + 'dpd_product_zone', + 'dpz', + 'dp.`id_dpd_product` = dpz.`id_dpd_product`' + ); + + $query->leftJoin( + 'dpd_zone_range', + 'dzr', + 'dzr.`id_dpd_zone` = dpz.`id_dpd_zone`' + ); + + $query->where('dp.id_reference= '.(int) $product->id_reference); + $query->where('dzr.id_country = '.(int) $countryId); + + return $this->db->executeS($query); + } } From f9d11e3d5ce8f63ed9a6fd09d85f0c7b2dc8db6b Mon Sep 17 00:00:00 2001 From: Gytautas Date: Thu, 11 Jan 2024 14:06:31 +0200 Subject: [PATCH 09/17] not needed use statement removed --- src/Repository/ProductRepository.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/Repository/ProductRepository.php b/src/Repository/ProductRepository.php index fe488f29..a2592ced 100644 --- a/src/Repository/ProductRepository.php +++ b/src/Repository/ProductRepository.php @@ -28,8 +28,6 @@ use PDOStatement; use PrestaShopCollection; use PrestaShopDatabaseException; -use PrestaShopException; -use resource; class ProductRepository extends AbstractEntityRepository { @@ -255,14 +253,12 @@ public function findProductByProductReference($carrierReference) return $this->db->getRow($query) ?: null; } - /** * @param int $carrierReference * @param int $countryId * * @return array|bool|mysqli_result|PDOStatement|resource|null * @throws PrestaShopDatabaseException - * @throws PrestaShopException */ public function checkIfCarrierIsAvailableInCountry(int $carrierReference, int $countryId) { From 71ce134fe2c4598de73d3612566f603c6c3ca21e Mon Sep 17 00:00:00 2001 From: Gytautas Date: Fri, 19 Jan 2024 09:36:12 +0200 Subject: [PATCH 10/17] fix: fixed to check all countries too --- src/Repository/ProductRepository.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Repository/ProductRepository.php b/src/Repository/ProductRepository.php index a2592ced..35954d16 100644 --- a/src/Repository/ProductRepository.php +++ b/src/Repository/ProductRepository.php @@ -265,6 +265,10 @@ public function checkIfCarrierIsAvailableInCountry(int $carrierReference, int $c $productId = $this->getProductIdByCarrierReference($carrierReference); $product = new DPDProduct($productId); + if ($product->all_zones) { + return ['id_dpd_product' => $productId]; + } + $query = new DbQuery(); $query->select('dp.id_dpd_product'); $query->from('dpd_product', 'dp'); From ede5164043893163e2302488d93438b9af82a701 Mon Sep 17 00:00:00 2001 From: Gytautas Date: Fri, 19 Jan 2024 14:32:01 +0200 Subject: [PATCH 11/17] added additional filtration to filter active countries only --- src/Repository/PhonePrefixRepository.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Repository/PhonePrefixRepository.php b/src/Repository/PhonePrefixRepository.php index 2bec758f..097f511b 100644 --- a/src/Repository/PhonePrefixRepository.php +++ b/src/Repository/PhonePrefixRepository.php @@ -57,6 +57,8 @@ public function getCallPrefixesFrontOffice() $query = new DbQuery(); $query->select('c.`call_prefix`'); $query->from('country', 'c'); + $query->where('active=1'); + $resource = Db::getInstance()->query($query); $result = []; while ($row = Db::getInstance()->nextRow($resource)) { From c595738ef9b9e4d607890cac8e745181827efac6 Mon Sep 17 00:00:00 2001 From: Gytautas Date: Fri, 19 Jan 2024 14:45:02 +0200 Subject: [PATCH 12/17] modal fix for more information --- views/js/front/pudo-search.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/js/front/pudo-search.js b/views/js/front/pudo-search.js index ba3dc8be..ee43983b 100644 --- a/views/js/front/pudo-search.js +++ b/views/js/front/pudo-search.js @@ -137,7 +137,7 @@ function saveSelectedStreet(city, street) { var coordinates = response.coordinates; var $idReference = $parent.data('id'); $('.points-container').empty().append(response.template); - + reselectDataPopover(); initMap(coordinates, true, response.selectedPudoId, false, $idReference); isPudoPointSelected = true; } From 6dca1fbc885d65944299db211f8a111ad18e8fed Mon Sep 17 00:00:00 2001 From: Gytautas Date: Thu, 29 Feb 2024 16:20:16 +0200 Subject: [PATCH 13/17] fix: fixed post codes to check only numeric one --- src/Adapter/AddressAdapter.php | 7 ++++--- src/Repository/ZoneRepository.php | 7 +++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/Adapter/AddressAdapter.php b/src/Adapter/AddressAdapter.php index 6c8f47ea..27aec1d9 100644 --- a/src/Adapter/AddressAdapter.php +++ b/src/Adapter/AddressAdapter.php @@ -85,9 +85,10 @@ private function getFormattedZipCode(Country $country, $postCode) $postCode = preg_replace("/[^a-zA-Z0-9]+/", "", $postCode); // If C doesn't exist in zip code format - don't modify the zip code - if (false === $countryCodePosition) { - return $postCode; - } + //todo this check prevents from saving zip code to numeric not sure why c has to be checked +// if (false === $countryCodePosition) { +// return $postCode; +// } $countryCodeLength = Tools::strlen($country->iso_code); $countryCode = Tools::substr($postCode, $countryCodePosition, $countryCodeLength); diff --git a/src/Repository/ZoneRepository.php b/src/Repository/ZoneRepository.php index a26f3d77..c1cd4102 100644 --- a/src/Repository/ZoneRepository.php +++ b/src/Repository/ZoneRepository.php @@ -24,6 +24,7 @@ use Address; use Country; use DbQuery; +use Invertus\dpdBaltics\Adapter\AddressAdapter; use PrestaShopDatabaseException; class ZoneRepository extends AbstractEntityRepository @@ -101,14 +102,16 @@ public function addProductZonesFromArray(array $zones) public function findZoneInRangeByAddress(Address $address) { $idCountry = $address->id_country ?: (int)\Configuration::get('PS_COUNTRY_DEFAULT'); - $zipCode = $address->postcode; + $addressAdapter = new AddressAdapter(); + + $zipCode = $addressAdapter->getZipCodeByCountry($idCountry, $address->postcode); $query = new DbQuery(); $query->select('dz.id_dpd_zone'); $query->from('dpd_zone', 'dz'); $query->leftJoin('dpd_zone_range', 'dzr', 'dzr.id_dpd_zone = dz.id_dpd_zone'); $query->where('dzr.id_country = ' . (int)$idCountry); - $query->where('dzr.include_all_zip_codes = 1 OR (dzr.zip_code_from <= \'' . pSQL($zipCode) . '\' AND dzr.zip_code_to >= \'' . pSQL($zipCode) . '\')'); + $query->where('dzr.include_all_zip_codes = 1 OR (dzr.zip_code_from_numeric <= \'' . pSQL($zipCode) . '\' AND dzr.zip_code_to_numeric >= \'' . pSQL($zipCode) . '\')'); $result = $this->db->executeS($query); From 0f7f5b73dd7ee6a36588f70815184541f4f65046 Mon Sep 17 00:00:00 2001 From: Gytautas Date: Thu, 29 Feb 2024 17:20:01 +0200 Subject: [PATCH 14/17] restore country code check --- src/Adapter/AddressAdapter.php | 7 +++---- src/Repository/ZoneRepository.php | 5 ++--- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/Adapter/AddressAdapter.php b/src/Adapter/AddressAdapter.php index 27aec1d9..6c8f47ea 100644 --- a/src/Adapter/AddressAdapter.php +++ b/src/Adapter/AddressAdapter.php @@ -85,10 +85,9 @@ private function getFormattedZipCode(Country $country, $postCode) $postCode = preg_replace("/[^a-zA-Z0-9]+/", "", $postCode); // If C doesn't exist in zip code format - don't modify the zip code - //todo this check prevents from saving zip code to numeric not sure why c has to be checked -// if (false === $countryCodePosition) { -// return $postCode; -// } + if (false === $countryCodePosition) { + return $postCode; + } $countryCodeLength = Tools::strlen($country->iso_code); $countryCode = Tools::substr($postCode, $countryCodePosition, $countryCodeLength); diff --git a/src/Repository/ZoneRepository.php b/src/Repository/ZoneRepository.php index c1cd4102..b19169a2 100644 --- a/src/Repository/ZoneRepository.php +++ b/src/Repository/ZoneRepository.php @@ -25,6 +25,7 @@ use Country; use DbQuery; use Invertus\dpdBaltics\Adapter\AddressAdapter; +use Invertus\dpdBaltics\Validate\Zone\ZoneRangeValidate; use PrestaShopDatabaseException; class ZoneRepository extends AbstractEntityRepository @@ -102,9 +103,7 @@ public function addProductZonesFromArray(array $zones) public function findZoneInRangeByAddress(Address $address) { $idCountry = $address->id_country ?: (int)\Configuration::get('PS_COUNTRY_DEFAULT'); - $addressAdapter = new AddressAdapter(); - - $zipCode = $addressAdapter->getZipCodeByCountry($idCountry, $address->postcode); + $zipCode = ZoneRangeValidate::getNumericZipCode($address->postcode, $idCountry); $query = new DbQuery(); $query->select('dz.id_dpd_zone'); From 9f88532fa3e298db700a3433c0a1b9ff112f914e Mon Sep 17 00:00:00 2001 From: Gytautas Date: Thu, 14 Mar 2024 10:57:36 +0200 Subject: [PATCH 15/17] unused use statement deleted --- src/Repository/ZoneRepository.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Repository/ZoneRepository.php b/src/Repository/ZoneRepository.php index b19169a2..d0620df8 100644 --- a/src/Repository/ZoneRepository.php +++ b/src/Repository/ZoneRepository.php @@ -24,7 +24,6 @@ use Address; use Country; use DbQuery; -use Invertus\dpdBaltics\Adapter\AddressAdapter; use Invertus\dpdBaltics\Validate\Zone\ZoneRangeValidate; use PrestaShopDatabaseException; From 0be83918adcdb0ba8bf7eee9ffbc4d5ff0cdbb85 Mon Sep 17 00:00:00 2001 From: Gytautas Date: Thu, 14 Mar 2024 16:45:20 +0200 Subject: [PATCH 16/17] version bump and changelogs added --- CHANGELOG.md | 6 ++++++ dpdbaltics.php | 11 +++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 548b7aed..a1aeae13 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -159,3 +159,9 @@ - Ability to hide label print feature in orders list page - Vulnerability fix with development dependencies - Price rule bug fix to add additional filtration by country + +## [3.2.19] +- Carrier availability in country +- Phone input selections sorted by active countries in shop +- Work hours pop up fix +- Numeric post code improvements \ No newline at end of file diff --git a/dpdbaltics.php b/dpdbaltics.php index e22b3855..9043978f 100644 --- a/dpdbaltics.php +++ b/dpdbaltics.php @@ -92,7 +92,7 @@ public function __construct() $this->author = 'Invertus'; $this->tab = 'shipping_logistics'; $this->description = 'DPD Baltics shipping integration'; - $this->version = '3.2.18'; + $this->version = '3.2.19'; $this->ps_versions_compliancy = ['min' => '1.7.1.0', 'max' => _PS_VERSION_]; $this->need_instance = 0; parent::__construct(); @@ -203,7 +203,6 @@ public function hookActionFrontControllerSetMedia() 'priority' => 130 ] ); - } /** @var \Invertus\dpdBaltics\Provider\CurrentCountryProvider $currentCountryProvider */ @@ -278,7 +277,8 @@ public function hookActionFrontControllerSetMedia() $googleApiService = $this->getModuleContainer('invertus.dpdbaltics.service.google_api_service'); $this->context->controller->registerJavascript( 'dpdbaltics-google-api', - $googleApiService->getFormattedGoogleMapsUrl(), [ + $googleApiService->getFormattedGoogleMapsUrl(), + [ 'server' => 'remote' ] ); @@ -507,7 +507,7 @@ public function getOrderShippingCostExternal($cart) $parcelDistribution = \Configuration::get(Config::PARCEL_DISTRIBUTION); $maxAllowedWeight = Config::getDefaultServiceWeights($countryCode, $serviceCarrier['product_reference']); - if (!$cartWeightValidator->validate($cart, $parcelDistribution ,$maxAllowedWeight)) { + if (!$cartWeightValidator->validate($cart, $parcelDistribution, $maxAllowedWeight)) { return false; } @@ -1150,7 +1150,6 @@ private function updateOrderCarrier($shipmentId) public function hookDisplayOrderDetail($params) { - $isReturnServiceEnabled = Configuration::get(Config::PARCEL_RETURN); if (!$isReturnServiceEnabled) { return; @@ -1279,7 +1278,7 @@ public function hookActionOrderGridDefinitionModifier(array $params) $definition = $params['definition']; if (!(bool) Configuration::get(Config::HIDE_ORDERS_LABEL_PRINT_BUTTON)) { - $definition->getColumns() + $definition->getColumns() ->addAfter( 'date_add', (new ActionColumn('dpd_print_label')) From 48439b3a1ce2dae36c191299a9282711e79ce463 Mon Sep 17 00:00:00 2001 From: Gytautas Date: Thu, 18 Apr 2024 13:19:57 +0300 Subject: [PATCH 17/17] compatibility fix --- src/Repository/ProductRepository.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Repository/ProductRepository.php b/src/Repository/ProductRepository.php index 35954d16..e09e6ca2 100644 --- a/src/Repository/ProductRepository.php +++ b/src/Repository/ProductRepository.php @@ -260,7 +260,7 @@ public function findProductByProductReference($carrierReference) * @return array|bool|mysqli_result|PDOStatement|resource|null * @throws PrestaShopDatabaseException */ - public function checkIfCarrierIsAvailableInCountry(int $carrierReference, int $countryId) + public function checkIfCarrierIsAvailableInCountry($carrierReference, $countryId) { $productId = $this->getProductIdByCarrierReference($carrierReference); $product = new DPDProduct($productId);