├── .github ├── FUNDING.yml ├── issue_template.md └── workflows │ └── php.yml ├── Block └── Adminhtml │ └── System │ └── Config │ └── Form │ └── Field │ ├── OrderIncrement.php │ └── Preview.php ├── Helper └── Data.php ├── Model └── Config │ └── Backend │ ├── AccessCode.php │ ├── ModifyTimestamp.php │ └── ValidFor.php ├── Plugin └── Model │ └── Session │ └── SuccessValidatorPlugin.php ├── README.md ├── composer.json ├── etc ├── acl.xml ├── adminhtml │ └── system.xml ├── config.xml ├── frontend │ └── di.xml └── module.xml ├── i18n └── en_US.csv ├── registration.php └── view └── adminhtml ├── layout └── adminhtml_system_config_edit.xml ├── requirejs-config.js ├── templates └── system │ └── config │ └── form │ └── field │ └── preview.phtml └── web ├── css └── styles.css └── js └── preview.js /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | #github: [srenon] 4 | custom: ['https://paypal.me/magepal'] 5 | -------------------------------------------------------------------------------- /.github/issue_template.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | #### Magento version #: 7 | 8 | #### Edition (EE, CE, OS, etc): 9 | 10 | #### Expected behavior: 11 | 12 | #### Actual behavior: 13 | 14 | #### Steps to reproduce: 15 | 16 | #### Preconditions 17 | 18 | 19 | 20 | 21 | 37 | -------------------------------------------------------------------------------- /.github/workflows/php.yml: -------------------------------------------------------------------------------- 1 | name: PHPCS 2 | on: [push] 3 | jobs: 4 | build: 5 | runs-on: ubuntu-latest 6 | steps: 7 | - uses: actions/checkout@master 8 | - name: PHPCS 9 | run: docker run --rm -v $PWD:/code:ro domw/phpcs phpcs --colors --standard=Magento2 --report=full,summary,gitblame --extensions=php,phtml ./ 10 | - name: compatibility 11 | run: docker run --rm -v $PWD:/code:ro domw/phpcompatibility phpcs --standard=PHPCompatibility --runtime-set testVersion 5.6-7.4 --colors --warning-severity=0 --report=full,summary --extensions=php,phtml ./ 12 | -------------------------------------------------------------------------------- /Block/Adminhtml/System/Config/Form/Field/OrderIncrement.php: -------------------------------------------------------------------------------- 1 | 12 | */ 13 | namespace MagePal\PreviewCheckoutSuccessPage\Block\Adminhtml\System\Config\Form\Field; 14 | 15 | use Magento\Backend\Block\Template\Context; 16 | use Magento\Config\Block\System\Config\Form\Field; 17 | use Magento\Framework\Data\Form\Element\AbstractElement; 18 | use Magento\Framework\DataObject; 19 | use Magento\Framework\Exception\LocalizedException; 20 | use Magento\Framework\Exception\NoSuchEntityException; 21 | use Magento\Sales\Model\Order; 22 | use Magento\Sales\Model\ResourceModel\Order\CollectionFactory; 23 | use Magento\Store\Api\Data\StoreInterface; 24 | 25 | /** 26 | * @method setElement($element) 27 | * @method getElement() 28 | * @method getForm() 29 | */ 30 | class OrderIncrement extends Field 31 | { 32 | /** 33 | * @var CollectionFactory 34 | */ 35 | protected $orderCollectionFactory; 36 | 37 | /** 38 | * OrderIncrement constructor. 39 | * @param Context $context 40 | * @param CollectionFactory $orderCollectionFactory 41 | * @param array $data 42 | */ 43 | public function __construct( 44 | Context $context, 45 | CollectionFactory $orderCollectionFactory, 46 | array $data = [] 47 | ) { 48 | parent::__construct($context, $data); 49 | $this->orderCollectionFactory = $orderCollectionFactory; 50 | } 51 | 52 | /** 53 | * Get the grid and scripts contents 54 | * 55 | * @param AbstractElement $element 56 | * @return string 57 | */ 58 | protected function _getElementHtml(AbstractElement $element) 59 | { 60 | $this->setElement($element); 61 | 62 | try { 63 | if (!$element->getEscapedValue()) { 64 | 65 | /** @var Order $order */ 66 | $order = $this->getLastOrder(); 67 | 68 | if ($order->getId()) { 69 | $element->setValue($order->getIncrementId()); 70 | } 71 | } 72 | } catch (\Exception $e) { 73 | return parent::_getElementHtml($element); 74 | } 75 | 76 | return parent::_getElementHtml($element); 77 | } 78 | 79 | /** 80 | * @return StoreInterface|null 81 | * @throws LocalizedException 82 | * @throws NoSuchEntityException 83 | * @return \Magento\Store\Api\Data\StoreInterface|null 84 | */ 85 | public function getCurrentStore() 86 | { 87 | $form = $this->getElement()->getForm(); 88 | if ($form->getStoreCode()) { 89 | $store = $this->_storeManager->getStore($form->getStoreCode()); 90 | } elseif ($form->getWebsiteCode()) { 91 | $store = $this->_storeManager->getWebsite($form->getWebsiteCode())->getDefaultStore(); 92 | } else { 93 | $store = $this->_storeManager->getDefaultStoreView(); 94 | } 95 | 96 | return $store; 97 | } 98 | 99 | /** 100 | * @return DataObject 101 | * @throws LocalizedException 102 | * @throws NoSuchEntityException 103 | * @return Order 104 | */ 105 | public function getLastOrder() 106 | { 107 | $store = $this->getCurrentStore(); 108 | $collection = $this->orderCollectionFactory->create(); 109 | $collection->addFieldToFilter('store_id', $store->getId()) 110 | ->setOrder('entity_id', 'DESC') 111 | ->setPageSize(1) 112 | ->setCurPage(1); 113 | 114 | return $collection->getFirstItem(); 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /Block/Adminhtml/System/Config/Form/Field/Preview.php: -------------------------------------------------------------------------------- 1 | urlHelper = $urlHelper; 40 | parent::__construct($context, $data); 41 | } 42 | 43 | /** 44 | * @param AbstractElement $element 45 | * @return string 46 | */ 47 | public function render(AbstractElement $element) 48 | { 49 | $element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue(); 50 | 51 | $html = '' . $this->_renderValue($element) . ''; 52 | 53 | return $this->_decorateRowHtml($element, $html); 54 | } 55 | 56 | /** 57 | * @param AbstractElement $element 58 | * @return string 59 | */ 60 | protected function _renderValue(AbstractElement $element) 61 | { 62 | return $this->_getElementHtml($element); 63 | } 64 | 65 | /** 66 | * Get the grid and scripts contents 67 | * 68 | * @param AbstractElement $element 69 | * @return string 70 | */ 71 | protected function _getElementHtml(AbstractElement $element) 72 | { 73 | $this->setElement($element); 74 | 75 | return $this->_toHtml(); 76 | } 77 | 78 | /** 79 | * @return StoreInterface|null 80 | */ 81 | public function getCurrentStore() 82 | { 83 | $form = $this->getElement()->getForm(); 84 | if ($form->getStoreCode()) { 85 | $store = $this->_storeManager->getStore($form->getStoreCode()); 86 | } elseif ($form->getWebsiteCode()) { 87 | $store = $this->_storeManager->getWebsite($form->getWebsiteCode())->getDefaultStore(); 88 | } else { 89 | $store = $this->_storeManager->getDefaultStoreView(); 90 | } 91 | 92 | return $store; 93 | } 94 | 95 | /** 96 | * @return string 97 | */ 98 | public function getSuccessPageUrl() 99 | { 100 | $store = $this->getCurrentStore(); 101 | $storeCode = $store->getCode(); 102 | 103 | $routeParams = [ 104 | '_nosid' => true, 105 | '_query' => [ 106 | '___store' => $storeCode 107 | ], 108 | 'previewAccessCode' => '--previewAccessCode--' 109 | ]; 110 | 111 | return $this->urlHelper->setScope($store->getId())->getUrl('checkout/onepage/success', $routeParams); 112 | } 113 | 114 | /** 115 | * @return string 116 | */ 117 | public function getSpinnerTemplate() 118 | { 119 | $value = '
'; 120 | $value .= '
'; 121 | return $value; 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /Helper/Data.php: -------------------------------------------------------------------------------- 1 | dateTime = $dateTime; 34 | } 35 | 36 | /** 37 | * Whether is active 38 | * 39 | * @return bool 40 | */ 41 | public function isEnabled() 42 | { 43 | return $this->scopeConfig->isSetFlag( 44 | self::XML_PATH_ACTIVE, 45 | ScopeInterface::SCOPE_STORE 46 | ); 47 | } 48 | 49 | /** 50 | * 51 | * @return string 52 | */ 53 | public function getAccessCode() 54 | { 55 | return $this->scopeConfig->getValue( 56 | 'magepal_checkout/preview_success_page/access_code', 57 | ScopeInterface::SCOPE_STORE 58 | ); 59 | } 60 | 61 | /** 62 | * 63 | * @return string 64 | */ 65 | public function getOrderIncrement() 66 | { 67 | return $this->scopeConfig->getValue( 68 | 'magepal_checkout/preview_success_page/order_increment', 69 | ScopeInterface::SCOPE_STORE 70 | ); 71 | } 72 | 73 | /** 74 | * 75 | * @return integer 76 | */ 77 | public function getValidFor() 78 | { 79 | $value = $this->scopeConfig->getValue( 80 | 'magepal_checkout/preview_success_page/valid_for', 81 | ScopeInterface::SCOPE_STORE 82 | ); 83 | 84 | if ($value < ValidFor::MIN_ACCESS_TIME) { 85 | $value = ValidFor::MIN_ACCESS_TIME; 86 | } elseif ($value > ValidFor::MAX_ACCESS_TIME) { 87 | $value = ValidFor::MAX_ACCESS_TIME; 88 | } 89 | 90 | return $value; 91 | } 92 | 93 | /** 94 | * @return mixed 95 | */ 96 | public function getModifyTimestamp() 97 | { 98 | return $this->scopeConfig->getValue( 99 | 'magepal_checkout/preview_success_page/modify_timestamp', 100 | ScopeInterface::SCOPE_STORE 101 | ); 102 | } 103 | 104 | /** 105 | * @return false|int 106 | */ 107 | public function getTimeStamp() 108 | { 109 | return strtotime($this->dateTime->gmtDate()); 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /Model/Config/Backend/AccessCode.php: -------------------------------------------------------------------------------- 1 | random = $random; 50 | parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data); 51 | } 52 | 53 | /** 54 | * @return $this 55 | * @throws LocalizedException 56 | */ 57 | public function beforeSave() 58 | { 59 | $this->setValue($this->random->getRandomString(7) . $this->random->getUniqueHash('-')); 60 | 61 | parent::beforeSave(); 62 | return $this; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /Model/Config/Backend/ModifyTimestamp.php: -------------------------------------------------------------------------------- 1 | dataHelper = $dataHelper; 49 | parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data); 50 | } 51 | 52 | /** 53 | * @return $this 54 | */ 55 | public function beforeSave() 56 | { 57 | $this->setValue($this->dataHelper->getTimeStamp()); 58 | return parent::beforeSave(); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /Model/Config/Backend/ValidFor.php: -------------------------------------------------------------------------------- 1 | getValue(); 22 | 23 | if ($value < self::MIN_ACCESS_TIME) { 24 | $value = self::MIN_ACCESS_TIME; 25 | } elseif ($value > self::MAX_ACCESS_TIME) { 26 | $value = self::MAX_ACCESS_TIME; 27 | } 28 | 29 | $this->setValue($value); 30 | 31 | parent::beforeSave(); 32 | return $this; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Plugin/Model/Session/SuccessValidatorPlugin.php: -------------------------------------------------------------------------------- 1 | dataHelper = $dataHelper; 55 | $this->request = $request; 56 | $this->checkoutSession = $checkoutSession; 57 | $this->orderCollectionFactory = $orderCollectionFactory; 58 | } 59 | 60 | /** 61 | * @param SuccessValidator $subject 62 | * @param $result 63 | * @return bool 64 | */ 65 | public function afterIsValid(SuccessValidator $subject, $result) 66 | { 67 | if ($this->dataHelper->isEnabled() 68 | && $this->isValidAccessCode() 69 | && $this->dataHelper->getOrderIncrement() 70 | ) { 71 | /** @var Order $order */ 72 | $order = $this->getOrderByIncrementId($this->dataHelper->getOrderIncrement()); 73 | 74 | if ($order->getId()) { 75 | $this->checkoutSession 76 | ->setLastOrderId($order->getId()) 77 | ->setLastRealOrderId($order->getIncrementId()) 78 | ->setLastOrderStatus($order->getStatus()); 79 | 80 | return true; 81 | } 82 | } 83 | 84 | return $result; 85 | } 86 | 87 | /** 88 | * @param $increment_id 89 | * @return DataObject 90 | */ 91 | public function getOrderByIncrementId($increment_id) 92 | { 93 | $collection = $this->orderCollectionFactory->create(); 94 | $collection->addFieldToFilter('increment_id', $increment_id) 95 | ->setPageSize(1) 96 | ->setCurPage(1); 97 | return $collection->getFirstItem(); 98 | } 99 | 100 | /** 101 | * @return bool 102 | */ 103 | protected function isValidAccessCode() 104 | { 105 | $accessCode = $this->request->getParam('previewAccessCode', null); 106 | $validUntil = $this->dataHelper->getModifyTimestamp() + 60 * $this->dataHelper->getValidFor(); 107 | 108 | if ($accessCode 109 | && $accessCode === $this->dataHelper->getAccessCode() 110 | && $validUntil > $this->dataHelper->getTimeStamp() 111 | ) { 112 | return true; 113 | } 114 | 115 | return false; 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Preview Order Confirmation Page for Magento 2 4 | 5 | 6 | [![Total Downloads](https://poser.pugx.org/magepal/magento2-preview-checkout-success-page/downloads)](https://www.magepal.com/preview-order-confirmation-page-for-magento-2.html) 7 | [![Latest Stable Version](https://poser.pugx.org/magepal/magento2-preview-checkout-success-page/v/stable)](https://www.magepal.com/preview-order-confirmation-page-for-magento-2.html) 8 | 9 | For Magento 2.0.x, 2.1.x, 2.2.x and 2.3.x 10 | 11 | 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. 12 | 13 | Design beautiful order confirmation page with our new [Enhanced Success Page](https://www.magepal.com/magento2/extensions/enhanced-success-page.html) extension. 14 | 15 | 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. 16 | 17 | 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. 18 | 19 | ![How to test or style the order success page](https://image.ibb.co/h9ssDH/Preview_Checkout_Success_Page_for_Magento.gif) 20 | 21 | ### Features 22 | - Configure any order number you want to preview from admin. 23 | - Quick and easily view checkout page source, in line within admin or within a new browser window. 24 | - Zero core hacks. 25 | - Created for testing sites but work perfectly on live/production environment. 26 | - Save time when style checkout success page. 27 | 28 | ### Production usage 29 | 30 | This module was intended for development, testing, and staging environment. Please consider carefully before using in a production environment because it may affect your analytics/conversion data. 31 | 32 | ## Documentation 33 | 34 | - [How to Installing Order Success Page Previewer](https://www.magepal.com/help/docs/preview-order-confirmation-page-magento-2/#installation) 35 | 36 | - [How to Configure Order Confirmation Page Preview](https://www.magepal.com/help/docs/preview-order-confirmation-page-magento-2/#configuration) 37 | 38 | ## Installation 39 | 40 | ``` 41 | composer require magepal/magento2-preview-checkout-success-page 42 | ``` 43 | 44 | Contribution 45 | --- 46 | Want to contribute to this extension? The quickest way is to open a [pull request on GitHub](https://help.github.com/articles/using-pull-requests). 47 | 48 | 49 | Support 50 | --- 51 | If you encounter any problems or bugs, please open an issue on [GitHub](https://github.com/magepal/magento2-preview-checkout-success-page/issues). 52 | 53 | Need help setting up or want to customize this extension to meet your business needs? Please email support@magepal.com and if we like your idea we will add this feature for free or at a discounted rate. 54 | 55 | Magento 2 Extensions 56 | --- 57 | - [Custom SMTP](https://www.magepal.com/magento2/extensions/custom-smtp.html) 58 | - [Catalog Hover Image for Magento](https://www.magepal.com/magento2/extensions/catalog-hover-image-for-magento.html) 59 | - [Enhanced Success Page for Magento 2](https://www.magepal.com/magento2/extensions/enhanced-success-page.html) 60 | - [Enhanced Transactional Emails for Magento 2](https://www.magepal.com/magento2/extensions/enhanced-transactional-emails.html) 61 | - [Google Tag Manager](https://www.magepal.com/magento2/extensions/google-tag-manager.html) 62 | - [Enhanced E-commerce](https://www.magepal.com/magento2/extensions/enhanced-ecommerce-for-google-tag-manager.html) 63 | - [Reindex](https://www.magepal.com/magento2/extensions/reindex.html) 64 | - [Custom Shipping Method](https://www.magepal.com/magento2/extensions/custom-shipping-rates-for-magento-2.html) 65 | - [Preview Order Confirmation](https://www.magepal.com/magento2/extensions/preview-order-confirmation-page-for-magento-2.html) 66 | - [Guest to Customer](https://www.magepal.com/magento2/extensions/guest-to-customer.html) 67 | - [Admin Form Fields Manager](https://www.magepal.com/magento2/extensions/admin-form-fields-manager-for-magento-2.html) 68 | - [Customer Dashboard Links Manager](https://www.magepal.com/magento2/extensions/customer-dashboard-links-manager-for-magento-2.html) 69 | - [Lazy Loader](https://www.magepal.com/magento2/extensions/lazy-load.html) 70 | - [Order Confirmation Page Miscellaneous Scripts](https://www.magepal.com/magento2/extensions/order-confirmation-miscellaneous-scripts-for-magento-2.html) 71 | - [HTML Minifier for Magento2](https://www.magepal.com/magento2/extensions/html-minifier.html) 72 | 73 | © MagePal LLC. | [www.magepal.com](https://www.magepal.com) 74 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "magepal/magento2-preview-checkout-success-page", 3 | "description": "Quickly and easily preview and test your Magento2 checkout success page, without placing a new order each time", 4 | "keywords": [ 5 | "magento 2", 6 | "magento2", 7 | "How to test or style the order success page", 8 | "checkout success page", 9 | "style checkout", 10 | "one step checkout previewer", 11 | "order confirmation page preview", 12 | "magento order confirmation styling", 13 | "magento checkout tester", 14 | "magento reload success page", 15 | "preview order success page", 16 | "checkout tester magento" 17 | ], 18 | "license": [ 19 | "proprietary" 20 | ], 21 | "homepage": "https://www.magepal.com/", 22 | "support": { 23 | "email": "support@magepal.com", 24 | "issues": "https://github.com/magepal/magento2-preview-checkout-success-page/issues/" 25 | }, 26 | "authors": [ 27 | { 28 | "name": "Renon Stewart", 29 | "email": "renon@magepal.com", 30 | "homepage": "https://www.magepal.com/", 31 | "role": "Leader" 32 | } 33 | ], 34 | "require": { 35 | "php": "~7.2.0|~7.3.0|~7.4.0|~8.1.0|~8.2.0|~8.3.0|~8.4.0", 36 | "magento/module-backend": "100.0.*|100.1.*|100.2.*|101.0.*|102.0.*", 37 | "magento/framework": "100.0.*|100.1.*|101.0.*|102.0.*|103.0.*", 38 | "magepal/magento2-core": ">=1.1.11" 39 | }, 40 | "suggest": { 41 | "magepal/magento2-checkout-success-misc-script":"Add miscellaneous HTML and scripts to your checkout success page" 42 | }, 43 | "type": "magento2-module", 44 | "version": "1.1.4", 45 | "autoload": { 46 | "files": [ 47 | "registration.php" 48 | ], 49 | "psr-4": { 50 | "MagePal\\PreviewCheckoutSuccessPage\\": "" 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /etc/acl.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /etc/adminhtml/system.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | magepal 17 | MagePal_PreviewCheckoutSuccessPage::config_magepal_previewcheckoutsuccesspage 18 | 19 | 1 20 | 21 | 23 | Copyright © 2024 MagePal, LLC 24 | Documentation 25 | Support 26 | Latest Version 27 | Extension Detail 28 | More Extensions 29 | 30 |
31 | Design beautiful order confirmation page with our new Enhanced Success Page extension. 32 |
33 |
34 | ]]> 35 |
36 | 37 | 38 | MagePal\Core\Block\Adminhtml\System\Config\Composer\Version 39 | 40 | 41 | 42 | Magento\Config\Model\Config\Source\Yesno 43 | 44 | 45 | 46 | Minimum of 3 minutes and Maximum of 15 minutes 47 | validate-zero-or-greater required-entry validate-number-range-3-15 validate-digits required-entry 48 | MagePal\PreviewCheckoutSuccessPage\Model\Config\Backend\ValidFor 49 | 50 | 1 51 | 52 | 53 | 54 | 55 | 56 | 57 | 1 58 | 59 | MagePal\PreviewCheckoutSuccessPage\Block\Adminhtml\System\Config\Form\Field\OrderIncrement 60 | 61 | 62 | 63 | 64 | MagePal\PreviewCheckoutSuccessPage\Model\Config\Backend\ModifyTimestamp 65 | 66 | 1 67 | 68 | 69 | 70 | 71 | 72 | MagePal\PreviewCheckoutSuccessPage\Model\Config\Backend\AccessCode 73 | 74 | 1 75 | 76 | 77 | 78 | 79 | MagePal\PreviewCheckoutSuccessPage\Block\Adminhtml\System\Config\Form\Field\Preview 80 | 81 | 1 82 | 83 | 84 |
85 |
86 |
87 |
88 | -------------------------------------------------------------------------------- /etc/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 15 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /etc/frontend/di.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 13 | 14 | -------------------------------------------------------------------------------- /etc/module.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /i18n/en_US.csv: -------------------------------------------------------------------------------- 1 | "Module Version","Module Version" 2 | "Composer Version","Composer Version" 3 | "Version","Version" 4 | "Enable","Enable" 5 | "Valid for","Valid for" 6 | "Minimum of 3 minutes and Maximum of 15 minutes","Minimum of 3 minutes and Maximum of 15 minutes" 7 | "Order ID","Order ID" 8 | "Save Config & Preview","Save Config & Preview" 9 | "Save Config & View Source","Save Config & View Source" 10 | "Save Config & Open New Window","Save Config & Open New Window" -------------------------------------------------------------------------------- /registration.php: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /view/adminhtml/requirejs-config.js: -------------------------------------------------------------------------------- 1 | var config = { 2 | map: { 3 | '*': { 4 | previewCheckoutSuccessPage: 'MagePal_PreviewCheckoutSuccessPage/js/preview' 5 | } 6 | } 7 | }; 8 | -------------------------------------------------------------------------------- /view/adminhtml/templates/system/config/form/field/preview.phtml: -------------------------------------------------------------------------------- 1 | 13 | 14 |
15 | 16 | 17 | 18 |
19 | 20 |
22 | 23 |
24 | 25 | 34 | -------------------------------------------------------------------------------- /view/adminhtml/web/css/styles.css: -------------------------------------------------------------------------------- 1 | #row_magepal_checkout_preview_success_page_modify_timestamp, #row_magepal_checkout_preview_success_page_access_code{ 2 | position: absolute; 3 | top: -9999px; 4 | left: -9999px; 5 | } -------------------------------------------------------------------------------- /view/adminhtml/web/js/preview.js: -------------------------------------------------------------------------------- 1 | define([ 2 | 'jquery', 3 | 'Magento_Ui/js/modal/alert' 4 | ], function ($, alert) { 5 | 6 | var saveConfig = function (urlTemplate, processCallback) { 7 | if (configForm.validation('isValid')) { 8 | $.ajax({ 9 | method: 'POST', 10 | url: configForm.attr('action'), 11 | data: configForm.serialize(), 12 | context: this 13 | }).done(function (response) { 14 | if (typeof response === 'object') { 15 | if (response.error) { 16 | alert({ title: 'Error', content: response.message }); 17 | } else if (response.ajaxExpired) { 18 | window.location.href = response.ajaxRedirect; 19 | } 20 | } else { 21 | var url = null; 22 | var $result = $(response); 23 | var $accessCode = $result.find('#magepal_checkout_preview_success_page_access_code'); 24 | var $orderIncrement = $result.find('#magepal_checkout_preview_success_page_order_increment'); 25 | 26 | if ($accessCode.length && $accessCode.val() 27 | && $orderIncrement.length && $orderIncrement.val() 28 | ) { 29 | url = urlTemplate.replace("--previewAccessCode--", $accessCode.val()); 30 | } 31 | 32 | processCallback(url); 33 | } 34 | }); 35 | 36 | return true; 37 | } else { 38 | return false; 39 | } 40 | }; 41 | 42 | return function (config) { 43 | var $iframe = $('[data-role="iframe-preview-panel"] iframe'); 44 | var $iframePreviewPanel = $('[data-role="iframe-preview-panel"]'); 45 | var urlTemplate = config.urlTemplate; 46 | 47 | $('#inline-preview').on('click', function () { 48 | $iframe.hide(); 49 | $iframePreviewPanel.css({"min-height": "500px"}).trigger('processStart'); 50 | 51 | $iframe.on('load', function () { 52 | $iframePreviewPanel.trigger('processStop'); 53 | $(this).show() 54 | }); 55 | 56 | saveConfig(urlTemplate, function (url) { 57 | if (url) { 58 | $iframe.attr('src', url); 59 | } 60 | 61 | }); 62 | }); 63 | 64 | $('#view-source').on('click', function () { 65 | $('body').trigger('processStart'); 66 | $iframePreviewPanel.css({"min-height": "0px"}); 67 | $iframe.hide(); 68 | 69 | saveConfig(urlTemplate, function (url) { 70 | if (url) { 71 | $.ajax({ 72 | method: 'GET', 73 | url: url, 74 | context: this 75 | }).done(function (response) { 76 | 77 | alert({ 78 | title: 'HTML Source', 79 | content: '' 80 | }); 81 | 82 | $('body').trigger('processStop'); 83 | }); 84 | } 85 | }); 86 | }); 87 | 88 | $('#new-window').on('click', function () { 89 | $('body').trigger('processStart'); 90 | $iframePreviewPanel.css({"min-height": "0px"}); 91 | $iframe.hide(); 92 | 93 | saveConfig(urlTemplate, function (url) { 94 | if (url) { 95 | window.open(url); 96 | } 97 | 98 | $('body').trigger('processStop'); 99 | }); 100 | }); 101 | }; 102 | }); 103 | --------------------------------------------------------------------------------