diff --git a/Block/Adminhtml/System/Config/Form/Composer/Version.php b/Block/Adminhtml/System/Config/Form/Composer/Version.php index ccbfb8d..c0a09ba 100644 --- a/Block/Adminhtml/System/Config/Form/Composer/Version.php +++ b/Block/Adminhtml/System/Config/Form/Composer/Version.php @@ -2,39 +2,56 @@ /** * Copyright © MagePal LLC. All rights reserved. * See COPYING.txt for license details. - * http://www.magepal.com | support@magepal.com + * https://www.magepal.com | support@magepal.com */ namespace MagePal\PreviewCheckoutSuccessPage\Block\Adminhtml\System\Config\Form\Composer; -class Version extends \Magento\Config\Block\System\Config\Form\Field +use Exception; +use Magento\Backend\Block\Template\Context; +use Magento\Config\Block\System\Config\Form\Field; +use Magento\Framework\App\DeploymentConfig; +use Magento\Framework\Component\ComponentRegistrar; +use Magento\Framework\Component\ComponentRegistrarInterface; +use Magento\Framework\Data\Form\Element\AbstractElement; +use Magento\Framework\Exception\LocalizedException; +use Magento\Framework\Filesystem\Directory\ReadFactory; +use Magento\Framework\Phrase; + +/** + * Class Version + * @package MagePal\PreviewCheckoutSuccessPage\Block\Adminhtml\System\Config\Form\Composer + */ +class Version extends Field { /** - * @var \Magento\Framework\App\DeploymentConfig + * @var DeploymentConfig */ protected $deploymentConfig; /** - * @var \Magento\Framework\Component\ComponentRegistrarInterface + * @var ComponentRegistrarInterface */ protected $componentRegistrar; /** - * @var \Magento\Framework\Filesystem\Directory\ReadFactory + * @var ReadFactory */ protected $readFactory; /** - * @param \Magento\Framework\App\DeploymentConfig $deploymentConfig - * @param \Magento\Framework\Component\ComponentRegistrarInterface $componentRegistrar - * @param \Magento\Framework\Filesystem\Directory\ReadFactory $readFactory + * @param Context $context + * @param DeploymentConfig $deploymentConfig + * @param ComponentRegistrarInterface $componentRegistrar + * @param ReadFactory $readFactory + * @param array $data */ public function __construct( - \Magento\Backend\Block\Template\Context $context, - \Magento\Framework\App\DeploymentConfig $deploymentConfig, - \Magento\Framework\Component\ComponentRegistrarInterface $componentRegistrar, - \Magento\Framework\Filesystem\Directory\ReadFactory $readFactory, + Context $context, + DeploymentConfig $deploymentConfig, + ComponentRegistrarInterface $componentRegistrar, + ReadFactory $readFactory, array $data = [] ) { $this->deploymentConfig = $deploymentConfig; @@ -46,11 +63,11 @@ public function __construct( /** * Render button * - * @param \Magento\Framework\Data\Form\Element\AbstractElement $element + * @param AbstractElement $element * @return string - * @throws \Magento\Framework\Exception\LocalizedException + * @throws LocalizedException */ - public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element) + public function render(AbstractElement $element) { // Remove scope label $element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue(); @@ -60,11 +77,11 @@ public function render(\Magento\Framework\Data\Form\Element\AbstractElement $ele /** * Return element html * - * @param \Magento\Framework\Data\Form\Element\AbstractElement $element + * @param AbstractElement $element * @return string * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element) + protected function _getElementHtml(AbstractElement $element) { return 'v' . $this->getVersion(); } @@ -93,12 +110,12 @@ public function getModuleName() * Get module composer version * * @param $moduleName - * @return \Magento\Framework\Phrase|string|void + * @return Phrase|string|void */ public function getComposerVersion($moduleName) { $path = $this->componentRegistrar->getPath( - \Magento\Framework\Component\ComponentRegistrar::MODULE, + ComponentRegistrar::MODULE, $moduleName ); @@ -110,7 +127,7 @@ public function getComposerVersion($moduleName) $data = json_decode($composerJsonData); return !empty($data->version) ? $data->version : __('Unknown'); } - } catch (\Exception $e) { + } catch (Exception $e) { // } diff --git a/Block/Adminhtml/System/Config/Form/Field/OrderIncrement.php b/Block/Adminhtml/System/Config/Form/Field/OrderIncrement.php index 79cf987..e7d8507 100644 --- a/Block/Adminhtml/System/Config/Form/Field/OrderIncrement.php +++ b/Block/Adminhtml/System/Config/Form/Field/OrderIncrement.php @@ -2,7 +2,7 @@ /** * Copyright © MagePal LLC. All rights reserved. * See COPYING.txt for license details. - * http://www.magepal.com | support@magepal.com + * https://www.magepal.com | support@magepal.com */ /** @@ -12,17 +12,35 @@ */ namespace MagePal\PreviewCheckoutSuccessPage\Block\Adminhtml\System\Config\Form\Field; -class OrderIncrement extends \Magento\Config\Block\System\Config\Form\Field +use Magento\Backend\Block\Template\Context; +use Magento\Config\Block\System\Config\Form\Field; +use Magento\Framework\Data\Form\Element\AbstractElement; +use Magento\Framework\DataObject; +use Magento\Sales\Model\Order; +use Magento\Sales\Model\ResourceModel\Order\CollectionFactory; +use Magento\Store\Api\Data\StoreInterface; + +/** + * Class OrderIncrement + * @package MagePal\PreviewCheckoutSuccessPage\Block\Adminhtml\System\Config\Form\Field + */ +class OrderIncrement extends Field { /** - * @var \Magento\Sales\Model\ResourceModel\Order\CollectionFactory + * @var CollectionFactory */ protected $orderCollectionFactory; + /** + * OrderIncrement constructor. + * @param Context $context + * @param CollectionFactory $orderCollectionFactory + * @param array $data + */ public function __construct( - \Magento\Backend\Block\Template\Context $context, - \Magento\Sales\Model\ResourceModel\Order\CollectionFactory $orderCollectionFactory, + Context $context, + CollectionFactory $orderCollectionFactory, array $data = [] ) { parent::__construct($context, $data); @@ -32,16 +50,16 @@ public function __construct( /** * Get the grid and scripts contents * - * @param \Magento\Framework\Data\Form\Element\AbstractElement $element + * @param AbstractElement $element * @return string */ - protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element) + protected function _getElementHtml(AbstractElement $element) { $this->setElement($element); if (!$element->getEscapedValue()) { - /** @var \Magento\Sales\Model\Order $order */ + /** @var Order $order */ $order = $this->getLastOrder(); if ($order->getId()) { @@ -53,7 +71,7 @@ protected function _getElementHtml(\Magento\Framework\Data\Form\Element\Abstract } /** - * @return \Magento\Store\Api\Data\StoreInterface|null + * @return StoreInterface|null */ public function getCurrentStore() { @@ -70,7 +88,7 @@ public function getCurrentStore() } /** - * @return \Magento\Framework\DataObject + * @return DataObject */ public function getLastOrder() { diff --git a/Block/Adminhtml/System/Config/Form/Field/Preview.php b/Block/Adminhtml/System/Config/Form/Field/Preview.php index a22d972..ed1bf71 100644 --- a/Block/Adminhtml/System/Config/Form/Field/Preview.php +++ b/Block/Adminhtml/System/Config/Form/Field/Preview.php @@ -2,15 +2,20 @@ /** * Copyright © MagePal LLC. All rights reserved. * See COPYING.txt for license details. - * http://www.magepal.com | support@magepal.com + * https://www.magepal.com | support@magepal.com */ namespace MagePal\PreviewCheckoutSuccessPage\Block\Adminhtml\System\Config\Form\Field; +use Magento\Backend\Block\Template\Context; use Magento\Config\Block\System\Config\Form\Field; +use Magento\Framework\Data\Form\Element\AbstractElement; +use Magento\Framework\Url; +use Magento\Store\Api\Data\StoreInterface; /** - * Class Locations Backend system config array field renderer + * Class Preview + * @package MagePal\PreviewCheckoutSuccessPage\Block\Adminhtml\System\Config\Form\Field */ class Preview extends Field { @@ -20,19 +25,19 @@ class Preview extends Field protected $_template = 'MagePal_PreviewCheckoutSuccessPage::system/config/form/field/preview.phtml'; /** - * @var \Magento\Framework\Url + * @var Url */ protected $urlHelper; /** * Preview constructor. - * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Framework\Url $urlHelper + * @param Context $context + * @param Url $urlHelper * @param array $data */ public function __construct( - \Magento\Backend\Block\Template\Context $context, - \Magento\Framework\Url $urlHelper, + Context $context, + Url $urlHelper, array $data = [] ) { $this->urlHelper = $urlHelper; @@ -41,10 +46,10 @@ public function __construct( /** - * @param \Magento\Framework\Data\Form\Element\AbstractElement $element + * @param AbstractElement $element * @return string */ - public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element) + public function render(AbstractElement $element) { $element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue(); @@ -54,10 +59,10 @@ public function render(\Magento\Framework\Data\Form\Element\AbstractElement $ele } /** - * @param \Magento\Framework\Data\Form\Element\AbstractElement $element + * @param AbstractElement $element * @return string */ - protected function _renderValue(\Magento\Framework\Data\Form\Element\AbstractElement $element) + protected function _renderValue(AbstractElement $element) { return $this->_getElementHtml($element); } @@ -65,10 +70,10 @@ protected function _renderValue(\Magento\Framework\Data\Form\Element\AbstractEle /** * Get the grid and scripts contents * - * @param \Magento\Framework\Data\Form\Element\AbstractElement $element + * @param AbstractElement $element * @return string */ - protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element) + protected function _getElementHtml(AbstractElement $element) { $this->setElement($element); @@ -76,7 +81,7 @@ protected function _getElementHtml(\Magento\Framework\Data\Form\Element\Abstract } /** - * @return \Magento\Store\Api\Data\StoreInterface|null + * @return StoreInterface|null */ public function getCurrentStore() { diff --git a/Block/Adminhtml/System/Config/Form/Module/Version.php b/Block/Adminhtml/System/Config/Form/Module/Version.php index fa2313c..8d71178 100644 --- a/Block/Adminhtml/System/Config/Form/Module/Version.php +++ b/Block/Adminhtml/System/Config/Form/Module/Version.php @@ -2,27 +2,37 @@ /** * Copyright © MagePal LLC. All rights reserved. * See COPYING.txt for license details. - * http://www.magepal.com | support@magepal.com + * https://www.magepal.com | support@magepal.com */ namespace MagePal\PreviewCheckoutSuccessPage\Block\Adminhtml\System\Config\Form\Module; -class Version extends \Magento\Config\Block\System\Config\Form\Field +use Magento\Backend\Block\Template\Context; +use Magento\Config\Block\System\Config\Form\Field; +use Magento\Framework\Data\Form\Element\AbstractElement; +use Magento\Framework\Exception\LocalizedException; +use Magento\Framework\Module\ModuleListInterface; + +/** + * Class Version + * @package MagePal\PreviewCheckoutSuccessPage\Block\Adminhtml\System\Config\Form\Module + */ +class Version extends Field { /** - * @var \Magento\Framework\Module\ModuleListInterface + * @var ModuleListInterface */ protected $_moduleList; /** - * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Framework\Module\ModuleListInterface $moduleList + * @param Context $context + * @param ModuleListInterface $moduleList * @param array $data */ public function __construct( - \Magento\Backend\Block\Template\Context $context, - \Magento\Framework\Module\ModuleListInterface $moduleList, + Context $context, + ModuleListInterface $moduleList, array $data = [] ) { parent::__construct($context, $data); @@ -32,11 +42,11 @@ public function __construct( /** * Render button * - * @param \Magento\Framework\Data\Form\Element\AbstractElement $element + * @param AbstractElement $element * @return string - * @throws \Magento\Framework\Exception\LocalizedException + * @throws LocalizedException */ - public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element) + public function render(AbstractElement $element) { // Remove scope label $element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue(); @@ -46,11 +56,11 @@ public function render(\Magento\Framework\Data\Form\Element\AbstractElement $ele /** * Return element html * - * @param \Magento\Framework\Data\Form\Element\AbstractElement $element + * @param AbstractElement $element * @return string * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element) + protected function _getElementHtml(AbstractElement $element) { return 'v' . $this->getVersion(); } diff --git a/Helper/Data.php b/Helper/Data.php index 1aa04ad..bd920d2 100755 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -2,22 +2,29 @@ /** * Copyright © MagePal LLC. All rights reserved. * See COPYING.txt for license details. - * http://www.magepal.com | support@magepal.com + * https://www.magepal.com | support@magepal.com */ namespace MagePal\PreviewCheckoutSuccessPage\Helper; +use Magento\Framework\App\Helper\AbstractHelper; +use Magento\Framework\App\Helper\Context; +use Magento\Store\Model\ScopeInterface; use MagePal\PreviewCheckoutSuccessPage\Model\Config\Backend\ValidFor; -class Data extends \Magento\Framework\App\Helper\AbstractHelper +/** + * Class Data + * @package MagePal\PreviewCheckoutSuccessPage\Helper + */ +class Data extends AbstractHelper { const XML_PATH_ACTIVE = 'magepal_checkout/preview_success_page/active'; /** - * @param \Magento\Framework\App\Helper\Context $context + * @param Context $context */ public function __construct( - \Magento\Framework\App\Helper\Context $context + Context $context ) { parent::__construct($context); } @@ -31,7 +38,7 @@ public function isEnabled() { return $this->scopeConfig->isSetFlag( self::XML_PATH_ACTIVE, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ScopeInterface::SCOPE_STORE ); } @@ -43,7 +50,7 @@ public function getAccessCode() { return $this->scopeConfig->getValue( 'magepal_checkout/preview_success_page/access_code', - \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ScopeInterface::SCOPE_STORE ); } @@ -55,7 +62,7 @@ public function getOrderIncrement() { return $this->scopeConfig->getValue( 'magepal_checkout/preview_success_page/order_increment', - \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ScopeInterface::SCOPE_STORE ); } @@ -67,7 +74,7 @@ public function getValidFor() { $value = $this->scopeConfig->getValue( 'magepal_checkout/preview_success_page/valid_for', - \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ScopeInterface::SCOPE_STORE ); if ($value < ValidFor::MIN_ACCESS_TIME) { @@ -79,11 +86,14 @@ public function getValidFor() return $value; } + /** + * @return mixed + */ public function getModifyTimestamp() { return $this->scopeConfig->getValue( 'magepal_checkout/preview_success_page/modify_timestamp', - \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ScopeInterface::SCOPE_STORE ); } } diff --git a/Model/Config/Backend/AccessCode.php b/Model/Config/Backend/AccessCode.php index 3746312..4dc3dc1 100644 --- a/Model/Config/Backend/AccessCode.php +++ b/Model/Config/Backend/AccessCode.php @@ -2,38 +2,51 @@ /** * Copyright © MagePal LLC. All rights reserved. * See COPYING.txt for license details. - * http://www.magepal.com | support@magepal.com + * https://www.magepal.com | support@magepal.com */ namespace MagePal\PreviewCheckoutSuccessPage\Model\Config\Backend; -class AccessCode extends \Magento\Framework\App\Config\Value +use Magento\Framework\App\Cache\TypeListInterface; +use Magento\Framework\App\Config\ScopeConfigInterface; +use Magento\Framework\App\Config\Value; +use Magento\Framework\Data\Collection\AbstractDb; +use Magento\Framework\Math\Random; +use Magento\Framework\Model\Context; +use Magento\Framework\Model\ResourceModel\AbstractResource; +use Magento\Framework\Registry; + +/** + * Class AccessCode + * @package MagePal\PreviewCheckoutSuccessPage\Model\Config\Backend + */ +class AccessCode extends Value { /** - * @var \Magento\Framework\Math\Random + * @var Random */ private $random; /** * Serialized constructor * - * @param \Magento\Framework\Model\Context $context - * @param \Magento\Framework\Registry $registry - * @param \Magento\Framework\App\Config\ScopeConfigInterface $config - * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList - * @param \Magento\Framework\Model\ResourceModel\AbstractResource|null $resource - * @param \Magento\Framework\Data\Collection\AbstractDb|null $resourceCollection - * @param \Magento\Framework\Math\Random $random + * @param Context $context + * @param Registry $registry + * @param ScopeConfigInterface $config + * @param TypeListInterface $cacheTypeList + * @param AbstractResource|null $resource + * @param AbstractDb|null $resourceCollection + * @param Random $random * @param array $data */ public function __construct( - \Magento\Framework\Model\Context $context, - \Magento\Framework\Registry $registry, - \Magento\Framework\App\Config\ScopeConfigInterface $config, - \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, - \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, - \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, - \Magento\Framework\Math\Random $random, + Context $context, + Registry $registry, + ScopeConfigInterface $config, + TypeListInterface $cacheTypeList, + AbstractResource $resource = null, + AbstractDb $resourceCollection = null, + Random $random, array $data = [] ) { @@ -46,8 +59,7 @@ public function __construct( */ public function beforeSave() { - $code = $this->random->getRandomString(7) . $this->random->getUniqueHash($prefix = '-'); - $this->setValue($code); + $this->setValue($this->random->getRandomString(7) . $this->random->getUniqueHash('-')); parent::beforeSave(); return $this; diff --git a/Model/Config/Backend/ModifyTimestamp.php b/Model/Config/Backend/ModifyTimestamp.php index a530aa9..26eada3 100644 --- a/Model/Config/Backend/ModifyTimestamp.php +++ b/Model/Config/Backend/ModifyTimestamp.php @@ -2,40 +2,51 @@ /** * Copyright © MagePal LLC. All rights reserved. * See COPYING.txt for license details. - * http://www.magepal.com | support@magepal.com + * https://www.magepal.com | support@magepal.com */ namespace MagePal\PreviewCheckoutSuccessPage\Model\Config\Backend; +use Magento\Framework\App\Cache\TypeListInterface; use Magento\Framework\App\Config\ScopeConfigInterface; +use Magento\Framework\App\Config\Value; +use Magento\Framework\Data\Collection\AbstractDb; +use Magento\Framework\Model\Context; +use Magento\Framework\Model\ResourceModel\AbstractResource; +use Magento\Framework\Registry; +use Magento\Framework\Stdlib\DateTime\TimezoneInterface; -class ModifyTimestamp extends \Magento\Framework\App\Config\Value +/** + * Class ModifyTimestamp + * @package MagePal\PreviewCheckoutSuccessPage\Model\Config\Backend + */ +class ModifyTimestamp extends Value { /** - * @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface + * @var TimezoneInterface */ private $localeDate; /** * Serialized constructor * - * @param \Magento\Framework\Model\Context $context - * @param \Magento\Framework\Registry $registry - * @param \Magento\Framework\App\Config\ScopeConfigInterface $config - * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList - * @param \Magento\Framework\Model\ResourceModel\AbstractResource|null $resource - * @param \Magento\Framework\Data\Collection\AbstractDb|null $resourceCollection + * @param Context $context + * @param Registry $registry + * @param ScopeConfigInterface $config + * @param TypeListInterface $cacheTypeList + * @param AbstractResource|null $resource + * @param AbstractDb|null $resourceCollection * @param array $data - * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate + * @param TimezoneInterface $localeDate */ public function __construct( - \Magento\Framework\Model\Context $context, - \Magento\Framework\Registry $registry, - \Magento\Framework\App\Config\ScopeConfigInterface $config, - \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, - \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, - \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, - \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, + Context $context, + Registry $registry, + ScopeConfigInterface $config, + TypeListInterface $cacheTypeList, + AbstractResource $resource = null, + AbstractDb $resourceCollection = null, + TimezoneInterface $localeDate, array $data = [] ) { diff --git a/Model/Config/Backend/ValidFor.php b/Model/Config/Backend/ValidFor.php index c1109e1..23cd365 100644 --- a/Model/Config/Backend/ValidFor.php +++ b/Model/Config/Backend/ValidFor.php @@ -2,11 +2,17 @@ /** * Copyright © MagePal LLC. All rights reserved. * See COPYING.txt for license details. - * http://www.magepal.com | support@magepal.com + * https://www.magepal.com | support@magepal.com */ namespace MagePal\PreviewCheckoutSuccessPage\Model\Config\Backend; -class ValidFor extends \Magento\Framework\App\Config\Value +use Magento\Framework\App\Config\Value; + +/** + * Class ValidFor + * @package MagePal\PreviewCheckoutSuccessPage\Model\Config\Backend + */ +class ValidFor extends Value { const MAX_ACCESS_TIME = 15; const MIN_ACCESS_TIME = 3; diff --git a/Plugin/Model/Session/SuccessValidatorPlugin.php b/Plugin/Model/Session/SuccessValidatorPlugin.php index 39a7b8f..19742d5 100644 --- a/Plugin/Model/Session/SuccessValidatorPlugin.php +++ b/Plugin/Model/Session/SuccessValidatorPlugin.php @@ -2,45 +2,61 @@ /** * Copyright © MagePal LLC. All rights reserved. * See COPYING.txt for license details. - * http://www.magepal.com | support@magepal.com + * https://www.magepal.com | support@magepal.com */ namespace MagePal\PreviewCheckoutSuccessPage\Plugin\Model\Session; +use Magento\Checkout\Model\Session; +use Magento\Checkout\Model\Session\SuccessValidator; use Magento\Framework\App\Config\ScopeConfigInterface; +use Magento\Framework\App\RequestInterface; +use Magento\Framework\DataObject; +use Magento\Framework\Stdlib\DateTime\TimezoneInterface; +use Magento\Sales\Model\Order; +use Magento\Sales\Model\ResourceModel\Order\CollectionFactory; +use MagePal\PreviewCheckoutSuccessPage\Helper\Data; +/** + * Class SuccessValidatorPlugin + * @package MagePal\PreviewCheckoutSuccessPage\Plugin\Model\Session + */ class SuccessValidatorPlugin { - /** @var \MagePal\PreviewCheckoutSuccessPage\Helper\Data */ + /** @var Data */ protected $dataHelper; - /** @var \Magento\Framework\App\RequestInterface */ + /** @var RequestInterface */ protected $request; /** - * @var \Magento\Checkout\Model\Session + * @var Session */ protected $checkoutSession; /** - * @var \Magento\Sales\Model\ResourceModel\Order\CollectionFactory + * @var CollectionFactory */ protected $orderCollectionFactory; /** - * @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface + * @var TimezoneInterface */ private $localeDate; /** - * @param \MagePal\PreviewCheckoutSuccessPage\Helper\Data $dataHelper + * @param Data $dataHelper + * @param RequestInterface $request + * @param Session $checkoutSession + * @param CollectionFactory $orderCollectionFactory + * @param TimezoneInterface $localeDate */ public function __construct( - \MagePal\PreviewCheckoutSuccessPage\Helper\Data $dataHelper, - \Magento\Framework\App\RequestInterface $request, - \Magento\Checkout\Model\Session $checkoutSession, - \Magento\Sales\Model\ResourceModel\Order\CollectionFactory $orderCollectionFactory, - \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate + Data $dataHelper, + RequestInterface $request, + Session $checkoutSession, + CollectionFactory $orderCollectionFactory, + TimezoneInterface $localeDate ) { $this->dataHelper = $dataHelper; $this->request = $request; @@ -49,13 +65,18 @@ public function __construct( $this->localeDate = $localeDate; } - public function afterIsValid(\Magento\Checkout\Model\Session\SuccessValidator $subject, $result) + /** + * @param SuccessValidator $subject + * @param $result + * @return bool + */ + public function afterIsValid(SuccessValidator $subject, $result) { if ($this->dataHelper->isEnabled() && $this->isValidAccessCode() && $this->dataHelper->getOrderIncrement() ) { - /** @var \Magento\Sales\Model\Order $order */ + /** @var Order $order */ $order = $this->getOrderByIncrementId($this->dataHelper->getOrderIncrement()); if ($order->getId()) { @@ -71,6 +92,10 @@ public function afterIsValid(\Magento\Checkout\Model\Session\SuccessValidator $s return $result; } + /** + * @param $increment_id + * @return DataObject + */ public function getOrderByIncrementId($increment_id) { $collection = $this->orderCollectionFactory->create(); @@ -80,6 +105,9 @@ public function getOrderByIncrementId($increment_id) return $collection->getFirstItem(); } + /** + * @return bool + */ protected function isValidAccessCode() { $accessCode = $this->request->getParam('previewAccessCode', null); diff --git a/README.md b/README.md index 9785101..19556fc 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ - + ## Preview Order Confirmation Page for Magento 2 @@ -7,12 +7,13 @@ Styling and testing Magento's order confirmation page can be a very difficult and time-consuming process since the order success page display is only displayed once after completing the lengthy checkout process. Changing your page content or testing a new CSS style will automatically redirect you to an empty shopping cart page on page refresh. -Our free magento2 extension allows you to quickly test [Google Universal Analytics (gtag.js)](https://www.magepal.com/magento2/extensions/google-universal-analytics-enhanced-ecommerce.html), [Google Tag Manager](https://www.magepal.com/magento2/extensions/google-tag-manager.html), [Enhanced Ecommerce](https://www.magepal.com/magento2/extensions/enhanced-ecommerce-for-google-tag-manager.html) or other [miscellaneous HTML, scripts and code snippets](https://www.magepal.com/magento2/extensions/order-confirmation-miscellaneous-scripts-for-magento-2.html). Easily preview and make changes to your success page without placing a new order or modifying Magento's core code, perfect for Magento frontend developers. After installing our extension you can navigate to the module preference in store configuration section and specify an order number and then preview the success page for that order, view HTML source and search for specific javascript snippet or share a link to preview on other devices. For security, the generated link is only valid for a short period of time which can be changed base on your needs. +Our free magento2 extension allows you to quickly test [Google Tag Manager](https://www.magepal.com/magento2/extensions/google-tag-manager.html), [Enhanced Ecommerce](https://www.magepal.com/magento2/extensions/enhanced-ecommerce-for-google-tag-manager.html) or other [miscellaneous HTML, scripts and code snippets](https://www.magepal.com/magento2/extensions/order-confirmation-miscellaneous-scripts-for-magento-2.html). Easily preview and make changes to your success page without placing a new order or modifying Magento's core code, perfect for Magento frontend developers. After installing our extension you can navigate to the module preference in store configuration section and specify an order number and then preview the success page for that order, view HTML source and search for specific javascript snippet or share a link to preview on other devices. For security, the generated link is only valid for a short period of time which can be changed base on your needs. To avoid tracking of duplicate order information on your live site, you may want to limit usage and testing of our extension to your development environment with [Google Analytics](https://www.magepal.com/magento2/extensions/enhanced-ecommerce-for-google-tag-manager.html) and order tracking script disabled. ![How to test or style the order success page](https://image.ibb.co/h9ssDH/Preview_Checkout_Success_Page_for_Magento.gif) +Design beautiful order confirmation page with our new [Enhanced Success Page](https://www.magepal.com/magento2/extensions/enhanced-success-page.html) extension. ### Features - Configure any order number you want to preview from admin. diff --git a/composer.json b/composer.json index 141793e..b0c09fb 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ "license": [ "proprietary" ], - "homepage": "http://www.magepal.com/", + "homepage": "https://www.magepal.com/", "support": { "email": "support@magepal.com", "issues": "https://github.com/magepal/magento2-preview-checkout-success-page/issues/" @@ -25,20 +25,20 @@ { "name": "Renon Stewart", "email": "renon@magepal.com", - "homepage": "http://www.magepal.com/", + "homepage": "https://www.magepal.com/", "role": "Leader" } ], "require": { "php": "~5.6.0|7.0.2|7.0.4|~7.0.6|~7.1.0|~7.1.3|~7.2.0", - "magento/module-backend": "100.0.*|100.1.*|100.2.*|101.0.0", + "magento/module-backend": "100.0.*|100.1.*|100.2.*|101.0.*", "magento/framework": "100.0.*|100.1.*|101.0.*|102.0.*" }, "suggest": { "magepal/magento2-checkout-success-misc-script":"Add miscellaneous HTML and scripts to your checkout success page" }, "type": "magento2-module", - "version": "1.0.4", + "version": "1.0.5", "autoload": { "files": [ "registration.php" diff --git a/etc/acl.xml b/etc/acl.xml index 3edd9a8..2031ff6 100644 --- a/etc/acl.xml +++ b/etc/acl.xml @@ -3,7 +3,7 @@ /** * Copyright © MagePal LLC. All rights reserved. * See COPYING.txt for license details. - * http://www.magepal.com | support@magepal.com + * https://www.magepal.com | support@magepal.com */ --> diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml index 3b1dbdb..a050815 100644 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -3,7 +3,7 @@ /** * Copyright © MagePal LLC. All rights reserved. * See COPYING.txt for license details. - * http://www.magepal.com | support@magepal.com + * https://www.magepal.com | support@magepal.com */ --> @@ -20,7 +20,9 @@ Copyright © 2018 www.magepal.com / support@magepal.com
- Discover other must have extensions at www.magepal.com. Thanks for choosing MagePal Extensions.

+ Design beautiful order confirmation page with our new + [Enhanced Success Page](https://www.magepal.com/magento2/extensions/enhanced-success-page.html) extension. + Thanks for choosing MagePal Extensions.


]]>
diff --git a/etc/frontend/di.xml b/etc/frontend/di.xml index 92fb647..a218f4e 100644 --- a/etc/frontend/di.xml +++ b/etc/frontend/di.xml @@ -3,7 +3,7 @@ /** * Copyright © MagePal LLC. All rights reserved. * See COPYING.txt for license details. - * http://www.magepal.com | support@magepal.com + * https://www.magepal.com | support@magepal.com */ --> diff --git a/view/adminhtml/layout/adminhtml_system_config_edit.xml b/view/adminhtml/layout/adminhtml_system_config_edit.xml index ff30dca..f1bc1bc 100644 --- a/view/adminhtml/layout/adminhtml_system_config_edit.xml +++ b/view/adminhtml/layout/adminhtml_system_config_edit.xml @@ -3,7 +3,7 @@ /** * Copyright © MagePal LLC. All rights reserved. * See COPYING.txt for license details. - * http://www.magepal.com | support@magepal.com + * https://www.magepal.com | support@magepal.com */ --> diff --git a/view/adminhtml/templates/system/config/form/field/preview.phtml b/view/adminhtml/templates/system/config/form/field/preview.phtml index d7e30b1..7a8865b 100644 --- a/view/adminhtml/templates/system/config/form/field/preview.phtml +++ b/view/adminhtml/templates/system/config/form/field/preview.phtml @@ -2,7 +2,7 @@ /** * Copyright © MagePal LLC. All rights reserved. * See COPYING.txt for license details. - * http://www.magepal.com | support@magepal.com + * https://www.magepal.com | support@magepal.com */ /**