From bbc05b222c8e56dc6f3a73d7f024f728904143f7 Mon Sep 17 00:00:00 2001 From: magenizr Date: Tue, 25 Oct 2022 22:04:05 +1100 Subject: [PATCH] Version 1.0.2 --- .../System/Config/Field/DatePicker.php | 13 ++++--- Helper/Config.php | 24 +++++++----- .../Shipping/Config/Source/AllMethods.php | 13 +++++-- .../System/Config/Source/Availability.php | 7 ++-- .../System/Config/Source/Weekdays.php | 7 ++-- Model/Carrier/Custom.php | 7 ++-- .../Shipping/Rate/Result/FilteredRates.php | 7 ++-- Model/Plugin/Shipping/Rate/Result/Remove.php | 7 ++-- README.md | 39 ++++++++++++++++--- composer.json | 5 +-- etc/adminhtml/system.xml | 7 ++-- etc/config.xml | 7 ++-- etc/di.xml | 7 ++-- etc/module.xml | 9 ++--- .../system/config/field/datepicker.phtml | 4 +- 15 files changed, 96 insertions(+), 67 deletions(-) diff --git a/Block/Adminhtml/System/Config/Field/DatePicker.php b/Block/Adminhtml/System/Config/Field/DatePicker.php index 09c5b2f..c2bf1b8 100644 --- a/Block/Adminhtml/System/Config/Field/DatePicker.php +++ b/Block/Adminhtml/System/Config/Field/DatePicker.php @@ -2,10 +2,9 @@ /** * Magenizr CustomShipping * - * @category Magenizr - * @package Magenizr_CustomShipping - * @copyright Copyright (c) 2018 Magenizr (http://www.magenizr.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @category Magenizr + * @copyright Copyright (c) 2018 - 2022 Magenizr (https://agency.magenizr.com) + * @license https://www.magenizr.com/license Magenizr EULA */ namespace Magenizr\CustomShipping\Block\Adminhtml\System\Config\Field; @@ -13,10 +12,12 @@ class DatePicker extends \Magento\Config\Block\System\Config\Form\Field { - const TEMPLATE_DATEPICKER = 'system/config/field/datepicker.phtml'; + private const TEMPLATE_DATEPICKER = 'system/config/field/datepicker.phtml'; /** - * @Override Title + * Set template + * + * @return mixed */ protected function _prepareLayout() { diff --git a/Helper/Config.php b/Helper/Config.php index 114c7d7..27ac4f9 100644 --- a/Helper/Config.php +++ b/Helper/Config.php @@ -2,10 +2,9 @@ /** * Magenizr CustomShipping * - * @category Magenizr - * @package Magenizr_CustomShipping - * @copyright Copyright (c) 2018 Magenizr (http://www.magenizr.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @category Magenizr + * @copyright Copyright (c) 2018 - 2022 Magenizr (https://agency.magenizr.com) + * @license https://www.magenizr.com/license Magenizr EULA */ namespace Magenizr\CustomShipping\Helper; @@ -30,7 +29,8 @@ class Config extends \Magento\Framework\App\Helper\AbstractHelper private $tab = 'carriers'; /** - * Config constructor. + * Init Constructor + * * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $timezone * @param \Magento\Customer\Model\Session $session * @param \Magento\Framework\App\Helper\Context $context @@ -50,7 +50,7 @@ public function __construct( /** * Get module configuration values from core_config_data * - * @param $setting + * @param string $setting * @return mixed */ public function getConfig($setting) @@ -68,9 +68,15 @@ public function getConfig($setting) */ public function isAvailable() { - $date_current = strtotime($this->timezone->formatDate()); - $date_start = strtotime($this->getConfig('date_start')); - $date_end = strtotime($this->getConfig('date_end')); + $timezone = $this->timezone->getConfigTimezone(); + + $date_current = date_create('now', new \DateTimeZone($timezone)) + ->getTimestamp(); + $date_start = date_create($this->getConfig('date_start'), new \DateTimeZone($timezone)) + ->getTimestamp(); + $date_end = date_create($this->getConfig('date_end'), new \DateTimeZone($timezone)) + ->getTimestamp(); + $frequency = $this->getConfig('frequency'); $day = strtolower(date('D', $date_current)); diff --git a/Model/Adminhtml/Shipping/Config/Source/AllMethods.php b/Model/Adminhtml/Shipping/Config/Source/AllMethods.php index 15c6f48..cd1c639 100644 --- a/Model/Adminhtml/Shipping/Config/Source/AllMethods.php +++ b/Model/Adminhtml/Shipping/Config/Source/AllMethods.php @@ -2,10 +2,9 @@ /** * Magenizr CustomShipping * - * @category Magenizr - * @package Magenizr_CustomShipping - * @copyright Copyright (c) 2018 Magenizr (http://www.magenizr.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @category Magenizr + * @copyright Copyright (c) 2018 - 2022 Magenizr (https://agency.magenizr.com) + * @license https://www.magenizr.com/license Magenizr EULA */ namespace Magenizr\CustomShipping\Model\Adminhtml\Shipping\Config\Source; @@ -22,6 +21,12 @@ class AllMethods implements \Magento\Framework\Option\ArrayInterface */ private $scopeConfig; + /** + * Init Constructor + * + * @param \Magento\Framework\App\Config $scopeConfig + * @param \Magento\Shipping\Model\Config $shippingConfig + */ public function __construct( \Magento\Framework\App\Config $scopeConfig, \Magento\Shipping\Model\Config $shippingConfig diff --git a/Model/Adminhtml/System/Config/Source/Availability.php b/Model/Adminhtml/System/Config/Source/Availability.php index 98ce68a..736de88 100644 --- a/Model/Adminhtml/System/Config/Source/Availability.php +++ b/Model/Adminhtml/System/Config/Source/Availability.php @@ -2,10 +2,9 @@ /** * Magenizr CustomShipping * - * @category Magenizr - * @package Magenizr_CustomShipping - * @copyright Copyright (c) 2018 Magenizr (http://www.magenizr.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @category Magenizr + * @copyright Copyright (c) 2018 - 2022 Magenizr (https://agency.magenizr.com) + * @license https://www.magenizr.com/license Magenizr EULA */ namespace Magenizr\CustomShipping\Model\Adminhtml\System\Config\Source; diff --git a/Model/Adminhtml/System/Config/Source/Weekdays.php b/Model/Adminhtml/System/Config/Source/Weekdays.php index db28a22..27e222b 100644 --- a/Model/Adminhtml/System/Config/Source/Weekdays.php +++ b/Model/Adminhtml/System/Config/Source/Weekdays.php @@ -2,10 +2,9 @@ /** * Magenizr CustomShipping * - * @category Magenizr - * @package Magenizr_CustomShipping - * @copyright Copyright (c) 2018 Magenizr (http://www.magenizr.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @category Magenizr + * @copyright Copyright (c) 2018 - 2022 Magenizr (https://agency.magenizr.com) + * @license https://www.magenizr.com/license Magenizr EULA */ namespace Magenizr\CustomShipping\Model\Adminhtml\System\Config\Source; diff --git a/Model/Carrier/Custom.php b/Model/Carrier/Custom.php index 5b65d8b..bfc2b4a 100755 --- a/Model/Carrier/Custom.php +++ b/Model/Carrier/Custom.php @@ -2,10 +2,9 @@ /** * Magenizr CustomShipping * - * @category Magenizr - * @package Magenizr_CustomShipping - * @copyright Copyright (c) 2018 Magenizr (http://www.magenizr.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @category Magenizr + * @copyright Copyright (c) 2018 - 2022 Magenizr (https://agency.magenizr.com) + * @license https://www.magenizr.com/license Magenizr EULA */ namespace Magenizr\CustomShipping\Model\Carrier; diff --git a/Model/Plugin/Shipping/Rate/Result/FilteredRates.php b/Model/Plugin/Shipping/Rate/Result/FilteredRates.php index dcc2099..04b16d6 100644 --- a/Model/Plugin/Shipping/Rate/Result/FilteredRates.php +++ b/Model/Plugin/Shipping/Rate/Result/FilteredRates.php @@ -2,10 +2,9 @@ /** * Magenizr CustomShipping * - * @category Magenizr - * @package Magenizr_CustomShipping - * @copyright Copyright (c) 2018 Magenizr (http://www.magenizr.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @category Magenizr + * @copyright Copyright (c) 2018 - 2022 Magenizr (https://agency.magenizr.com) + * @license https://www.magenizr.com/license Magenizr EULA */ namespace Magenizr\CustomShipping\Model\Plugin\Shipping\Rate\Result; diff --git a/Model/Plugin/Shipping/Rate/Result/Remove.php b/Model/Plugin/Shipping/Rate/Result/Remove.php index 2602e95..496f795 100644 --- a/Model/Plugin/Shipping/Rate/Result/Remove.php +++ b/Model/Plugin/Shipping/Rate/Result/Remove.php @@ -2,10 +2,9 @@ /** * Magenizr CustomShipping * - * @category Magenizr - * @package Magenizr_CustomShipping - * @copyright Copyright (c) 2018 Magenizr (http://www.magenizr.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @category Magenizr + * @copyright Copyright (c) 2018 - 2022 Magenizr (https://agency.magenizr.com) + * @license https://www.magenizr.com/license Magenizr EULA */ namespace Magenizr\CustomShipping\Model\Plugin\Shipping\Rate\Result; diff --git a/README.md b/README.md index bbbc43c..c9b94d6 100755 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ This Magento 2 module allows you to provide a custom shipping method in backend ## Installation (Composer) -1. Update your composer.json `composer require "magenizr/magento2-customshipping":"1.0.1" --no-update` +1. Update your composer.json `composer require "magenizr/magento2-customshipping":"1.0.2" --no-update` 2. Install dependencies and update your composer.lock `composer update --lock` ``` @@ -13,7 +13,7 @@ This Magento 2 module allows you to provide a custom shipping method in backend Loading composer repositories with package information Updating dependencies (including require-dev) Package operations: 1 install, 0 updates, 0 removals - - Installing magenizr/magento2-customshipping (1.0.1): Downloading (100%) + - Installing magenizr/magento2-customshipping (1.0.2): Downloading (100%) Writing lock file Generating autoload files ``` @@ -25,15 +25,40 @@ php bin/magento module:enable Magenizr_CustomShipping --clear-static-content php bin/magento setup:upgrade ``` -# Installation (Manually) +## Installation (Composer 2) + +1. Update your composer.json `composer require "magenizr/magento2-customshipping":"1.0.2" --no-update` +2. Use `composer update magenizr/magento2-customshipping --no-install` to update your composer.lock file. + +``` +Updating dependencies +Lock file operations: 1 install, 1 update, 0 removals + - Locking magenizr/magento2-customshipping (1.0.2) +``` + +3. And then `composer install` to install the package. + +``` +Installing dependencies from lock file (including require-dev) +Verifying lock file contents can be installed on current platform. +Package operations: 1 install, 0 update, 0 removals + - Installing magenizr/magento2-customshipping (1.0.2): Extracting archive +``` + +4. Enable the module and clear static content. + +``` +php bin/magento module:enable Magenizr_CustomShipping --clear-static-content +``` + +## Installation (Manually) 1. Download the latest version of the source code. -2. Extract the downloaded tar.gz file. Example: `tar -xzf Magenizr_CustomShipping_1.0.1.tar.gz`. +2. Extract the downloaded tar.gz file. Example: `tar -xzf Magenizr_CustomShipping_1.0.2.tar.gz`. 3. Copy the code into `./app/code/Magenizr/CustomShipping/`. 4. Enable the module and clear static content. ``` php bin/magento module:enable Magenizr_CustomShipping --clear-static-content -php bin/magento setup:upgrade ``` ## Features @@ -52,6 +77,10 @@ The functionality can be used in the backend section `Stores > Configuration > S If you have any issues with this extension, open an issue on [Github](https://github.com/magenizr/Magenizr_CustomShipping/issues). For a custom build, don't hesitate to contact us on [Magento Marketplace](https://marketplace.magento.com/partner/magenizr). ## History +===== 1.0.2 ===== +* Cleanup to meet coding standards (EQP, ECG) +* Remove framework constraints in composer.json + ===== 1.0.1 ===== * Magento 2.4.x compatibility added * i18n added diff --git a/composer.json b/composer.json index 6b9a50f..9fd3242 100755 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "magenizr/magento2-customshipping", "description": "This Magento 2 module allows you to provide a custom shipping method in backend only, frontend only or both. With the Scheduler feature you can manage the availability automatically.", "type": "magento2-module", - "version": "1.0.1", + "version": "1.0.2", "license": [ "OSL-3.0" ], @@ -13,9 +13,6 @@ "homepage": "https://www.magenizr.com" } ], - "require": { - "magento/framework": "^100|^101|^102|^103" - }, "repositories": [ { "type": "composer", diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml index 2539f98..4cb77eb 100755 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -3,10 +3,9 @@ /** * Magenizr CustomShipping * - * @category Magenizr - * @package Magenizr_CustomShipping - * @copyright Copyright (c) 2018 Magenizr (http://www.magenizr.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @category Magenizr + * @copyright Copyright (c) 2018 - 2022 Magenizr (https://agency.magenizr.com) + * @license https://www.magenizr.com/license Magenizr EULA */ --> diff --git a/etc/config.xml b/etc/config.xml index eebf59f..4986507 100755 --- a/etc/config.xml +++ b/etc/config.xml @@ -3,10 +3,9 @@ /** * Magenizr CustomShipping * - * @category Magenizr - * @package Magenizr_CustomShipping - * @copyright Copyright (c) 2018 Magenizr (http://www.magenizr.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @category Magenizr + * @copyright Copyright (c) 2018 - 2022 Magenizr (https://agency.magenizr.com) + * @license https://www.magenizr.com/license Magenizr EULA */ --> diff --git a/etc/di.xml b/etc/di.xml index c4fcbed..e352f2b 100644 --- a/etc/di.xml +++ b/etc/di.xml @@ -3,10 +3,9 @@ /** * Magenizr CustomShipping * - * @category Magenizr - * @package Magenizr_CustomShipping - * @copyright Copyright (c) 2018 Magenizr (http://www.magenizr.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @category Magenizr + * @copyright Copyright (c) 2018 - 2022 Magenizr (https://agency.magenizr.com) + * @license https://www.magenizr.com/license Magenizr EULA */ --> diff --git a/etc/module.xml b/etc/module.xml index 1d62fd8..97388dd 100755 --- a/etc/module.xml +++ b/etc/module.xml @@ -3,12 +3,11 @@ /** * Magenizr CustomShipping * - * @category Magenizr - * @package Magenizr_CustomShipping - * @copyright Copyright (c) 2018 Magenizr (http://www.magenizr.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @category Magenizr + * @copyright Copyright (c) 2018 - 2022 Magenizr (https://agency.magenizr.com) + * @license https://www.magenizr.com/license Magenizr EULA */ --> - + diff --git a/view/adminhtml/templates/system/config/field/datepicker.phtml b/view/adminhtml/templates/system/config/field/datepicker.phtml index db896de..9bf29b1 100644 --- a/view/adminhtml/templates/system/config/field/datepicker.phtml +++ b/view/adminhtml/templates/system/config/field/datepicker.phtml @@ -2,10 +2,10 @@