Version Notes
No notes
Download this release
Release Info
| Developer | Yireo |
| Extension | Yireo_CheckoutTester |
| Version | 0.1.8 |
| Comparing to | |
| See all releases | |
Code changes from version 0.1.4 to 0.1.8
- app/code/community/Yireo/CheckoutTester/Block/Field/Link.php +38 -4
- app/code/community/Yireo/CheckoutTester/Block/Success.php +5 -2
- app/code/community/Yireo/CheckoutTester/Helper/Data.php +65 -25
- app/code/community/Yireo/CheckoutTester/Model/Feed.php +4 -4
- app/code/community/Yireo/CheckoutTester/Model/Observer.php +3 -4
- app/code/community/Yireo/CheckoutTester/controllers/IndexController.php +91 -34
- app/code/community/Yireo/CheckoutTester/etc/adminhtml.xml +1 -1
- app/code/community/Yireo/CheckoutTester/etc/config.xml +2 -2
- app/code/community/Yireo/CheckoutTester/etc/system.xml +3 -3
- app/design/adminhtml/default/default/template/checkouttester/field/link.phtml +0 -1
- app/design/frontend/base/default/layout/checkouttester.xml +4 -1
- app/etc/modules/Yireo_CheckoutTester.xml +1 -1
- package.xml +1 -1
app/code/community/Yireo/CheckoutTester/Block/Field/Link.php
CHANGED
|
@@ -1,27 +1,61 @@
|
|
| 1 |
<?php
|
| 2 |
/**
|
| 3 |
-
* Yireo CheckoutTester for Magento
|
| 4 |
*
|
| 5 |
* @package Yireo_CheckoutTester
|
| 6 |
* @author Yireo (http://www.yireo.com/)
|
| 7 |
-
* @copyright Copyright
|
| 8 |
* @license Open Source License (OSL v3)
|
| 9 |
*/
|
| 10 |
|
|
|
|
|
|
|
|
|
|
| 11 |
class Yireo_CheckoutTester_Block_Field_Link extends Mage_Adminhtml_Block_System_Config_Form_Field
|
| 12 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
| 14 |
{
|
| 15 |
$link = $this->getFrontendLink();
|
| 16 |
-
$html = '<a href="'
|
| 17 |
. $this->__('Open success page in new window')
|
| 18 |
. '</a>';
|
|
|
|
| 19 |
return $html;
|
| 20 |
}
|
| 21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
public function getFrontendLink()
|
| 23 |
{
|
| 24 |
-
$storeId =
|
| 25 |
return Mage::app()->getStore($storeId)->getUrl('checkouttester/index/success');
|
| 26 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
}
|
| 1 |
<?php
|
| 2 |
/**
|
| 3 |
+
* Yireo CheckoutTester for Magento
|
| 4 |
*
|
| 5 |
* @package Yireo_CheckoutTester
|
| 6 |
* @author Yireo (http://www.yireo.com/)
|
| 7 |
+
* @copyright Copyright 2015 Yireo (http://www.yireo.com/)
|
| 8 |
* @license Open Source License (OSL v3)
|
| 9 |
*/
|
| 10 |
|
| 11 |
+
/**
|
| 12 |
+
* Class Yireo_CheckoutTester_Block_Field_Link
|
| 13 |
+
*/
|
| 14 |
class Yireo_CheckoutTester_Block_Field_Link extends Mage_Adminhtml_Block_System_Config_Form_Field
|
| 15 |
{
|
| 16 |
+
/**
|
| 17 |
+
* Return the elements HTML value
|
| 18 |
+
*
|
| 19 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
| 20 |
+
*
|
| 21 |
+
* @return string
|
| 22 |
+
*/
|
| 23 |
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
| 24 |
{
|
| 25 |
$link = $this->getFrontendLink();
|
| 26 |
+
$html = '<a href="' . $link . '" target="_new">'
|
| 27 |
. $this->__('Open success page in new window')
|
| 28 |
. '</a>';
|
| 29 |
+
|
| 30 |
return $html;
|
| 31 |
}
|
| 32 |
|
| 33 |
+
/**
|
| 34 |
+
* Return the frontend link
|
| 35 |
+
*
|
| 36 |
+
* @return string
|
| 37 |
+
*/
|
| 38 |
public function getFrontendLink()
|
| 39 |
{
|
| 40 |
+
$storeId = $this->_getStoreId();
|
| 41 |
return Mage::app()->getStore($storeId)->getUrl('checkouttester/index/success');
|
| 42 |
}
|
| 43 |
+
|
| 44 |
+
/**
|
| 45 |
+
* Return store id of current configuration scope
|
| 46 |
+
*
|
| 47 |
+
* @return int
|
| 48 |
+
*/
|
| 49 |
+
protected function _getStoreId()
|
| 50 |
+
{
|
| 51 |
+
$storeId = Mage::getSingleton('adminhtml/config_data')->getStore();
|
| 52 |
+
if ($storeId) {
|
| 53 |
+
return $storeId;
|
| 54 |
+
}
|
| 55 |
+
$websiteId = Mage::getSingleton('adminhtml/config_data')->getWebsite();
|
| 56 |
+
if ($websiteId) {
|
| 57 |
+
return Mage::app()->getWebsite($websiteId)->getDefaultStore()->getId();
|
| 58 |
+
}
|
| 59 |
+
return Mage::app()->getWebsite(true)->getDefaultGroup()->getDefaultStoreId();
|
| 60 |
+
}
|
| 61 |
}
|
app/code/community/Yireo/CheckoutTester/Block/Success.php
CHANGED
|
@@ -1,13 +1,16 @@
|
|
| 1 |
<?php
|
| 2 |
/**
|
| 3 |
-
* Yireo CheckoutTester for Magento
|
| 4 |
*
|
| 5 |
* @package Yireo_CheckoutTester
|
| 6 |
* @author Yireo (http://www.yireo.com/)
|
| 7 |
-
* @copyright Copyright
|
| 8 |
* @license Open Source License (OSL v3)
|
| 9 |
*/
|
| 10 |
|
|
|
|
|
|
|
|
|
|
| 11 |
class Yireo_CheckoutTester_Block_Success extends Mage_Checkout_Block_Onepage_Success
|
| 12 |
{
|
| 13 |
}
|
| 1 |
<?php
|
| 2 |
/**
|
| 3 |
+
* Yireo CheckoutTester for Magento
|
| 4 |
*
|
| 5 |
* @package Yireo_CheckoutTester
|
| 6 |
* @author Yireo (http://www.yireo.com/)
|
| 7 |
+
* @copyright Copyright 2015 Yireo (http://www.yireo.com/)
|
| 8 |
* @license Open Source License (OSL v3)
|
| 9 |
*/
|
| 10 |
|
| 11 |
+
/**
|
| 12 |
+
* Class Yireo_CheckoutTester_Block_Success
|
| 13 |
+
*/
|
| 14 |
class Yireo_CheckoutTester_Block_Success extends Mage_Checkout_Block_Onepage_Success
|
| 15 |
{
|
| 16 |
}
|
app/code/community/Yireo/CheckoutTester/Helper/Data.php
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
<?php
|
| 2 |
/**
|
| 3 |
-
* Yireo CheckoutTester for Magento
|
| 4 |
*
|
| 5 |
* @package Yireo_CheckoutTester
|
| 6 |
* @author Yireo (http://www.yireo.com/)
|
|
@@ -13,35 +13,43 @@
|
|
| 13 |
*/
|
| 14 |
class Yireo_CheckoutTester_Helper_Data extends Mage_Core_Helper_Abstract
|
| 15 |
{
|
| 16 |
-
|
| 17 |
* Switch to determine whether this extension is enabled or not
|
| 18 |
-
*
|
| 19 |
-
* @
|
| 20 |
-
* @param null
|
| 21 |
-
* @return string
|
| 22 |
*/
|
| 23 |
public function enabled()
|
| 24 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
return true;
|
| 26 |
}
|
| 27 |
|
| 28 |
-
|
| 29 |
* Method to determine whether the current user has access to this page
|
| 30 |
-
*
|
| 31 |
-
* @
|
| 32 |
-
* @param null
|
| 33 |
-
* @return string
|
| 34 |
*/
|
| 35 |
public function hasAccess()
|
| 36 |
{
|
| 37 |
$ip = Mage::getStoreConfig('checkouttester/settings/ip');
|
| 38 |
$ip = trim($ip);
|
| 39 |
-
|
|
|
|
|
|
|
|
|
|
| 40 |
$ips = explode(',', $ip);
|
| 41 |
-
|
|
|
|
| 42 |
$ip = trim($ip);
|
| 43 |
-
|
| 44 |
-
if($ip
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
return true;
|
| 46 |
}
|
| 47 |
}
|
|
@@ -51,25 +59,57 @@ class Yireo_CheckoutTester_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 51 |
return true;
|
| 52 |
}
|
| 53 |
|
| 54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
* Return the order ID
|
| 56 |
-
*
|
| 57 |
-
* @access public
|
| 58 |
-
* @param null
|
| 59 |
* @return string
|
| 60 |
*/
|
| 61 |
-
public function
|
| 62 |
{
|
| 63 |
-
return (int)Mage::getStoreConfig('checkouttester/settings/order_id');
|
| 64 |
}
|
| 65 |
|
| 66 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
{
|
| 68 |
$orders = Mage::getModel('sales/order')->getCollection()
|
| 69 |
-
->setOrder('created_at','DESC')
|
| 70 |
->setPageSize(1)
|
| 71 |
->setCurPage(1);
|
| 72 |
-
|
| 73 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
}
|
| 75 |
}
|
| 1 |
<?php
|
| 2 |
/**
|
| 3 |
+
* Yireo CheckoutTester for Magento
|
| 4 |
*
|
| 5 |
* @package Yireo_CheckoutTester
|
| 6 |
* @author Yireo (http://www.yireo.com/)
|
| 13 |
*/
|
| 14 |
class Yireo_CheckoutTester_Helper_Data extends Mage_Core_Helper_Abstract
|
| 15 |
{
|
| 16 |
+
/**
|
| 17 |
* Switch to determine whether this extension is enabled or not
|
| 18 |
+
*
|
| 19 |
+
* @return bool
|
|
|
|
|
|
|
| 20 |
*/
|
| 21 |
public function enabled()
|
| 22 |
{
|
| 23 |
+
if ((bool)Mage::getStoreConfig('advanced/modules_disable_output/Yireo_CheckoutTester')) {
|
| 24 |
+
return false;
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
return true;
|
| 28 |
}
|
| 29 |
|
| 30 |
+
/**
|
| 31 |
* Method to determine whether the current user has access to this page
|
| 32 |
+
*
|
| 33 |
+
* @return bool
|
|
|
|
|
|
|
| 34 |
*/
|
| 35 |
public function hasAccess()
|
| 36 |
{
|
| 37 |
$ip = Mage::getStoreConfig('checkouttester/settings/ip');
|
| 38 |
$ip = trim($ip);
|
| 39 |
+
|
| 40 |
+
$realIp = $this->getIpAddress();
|
| 41 |
+
|
| 42 |
+
if (!empty($ip) && $realIp) {
|
| 43 |
$ips = explode(',', $ip);
|
| 44 |
+
|
| 45 |
+
foreach ($ips as $ip) {
|
| 46 |
$ip = trim($ip);
|
| 47 |
+
|
| 48 |
+
if (empty($ip)) {
|
| 49 |
+
continue;
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
if ($ip == $realIp) {
|
| 53 |
return true;
|
| 54 |
}
|
| 55 |
}
|
| 59 |
return true;
|
| 60 |
}
|
| 61 |
|
| 62 |
+
/**
|
| 63 |
+
* Get the current IP address
|
| 64 |
+
*
|
| 65 |
+
* @return mixed
|
| 66 |
+
*/
|
| 67 |
+
public function getIpAddress()
|
| 68 |
+
{
|
| 69 |
+
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
|
| 70 |
+
$ip = $_SERVER['HTTP_CLIENT_IP'];
|
| 71 |
+
|
| 72 |
+
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
|
| 73 |
+
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
|
| 74 |
+
|
| 75 |
+
} else {
|
| 76 |
+
$ip = $_SERVER['REMOTE_ADDR'];
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
return $ip;
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
/**
|
| 83 |
* Return the order ID
|
| 84 |
+
*
|
|
|
|
|
|
|
| 85 |
* @return string
|
| 86 |
*/
|
| 87 |
+
public function getOrderIdFromConfig()
|
| 88 |
{
|
| 89 |
+
return (int) Mage::getStoreConfig('checkouttester/settings/order_id');
|
| 90 |
}
|
| 91 |
|
| 92 |
+
/**
|
| 93 |
+
* Return the last order ID in this database
|
| 94 |
+
*
|
| 95 |
+
* @return int
|
| 96 |
+
*/
|
| 97 |
+
public function getLastInsertedOrderId()
|
| 98 |
{
|
| 99 |
$orders = Mage::getModel('sales/order')->getCollection()
|
| 100 |
+
->setOrder('created_at', 'DESC')
|
| 101 |
->setPageSize(1)
|
| 102 |
->setCurPage(1);
|
| 103 |
+
|
| 104 |
+
if (empty($orders)) {
|
| 105 |
+
return 0;
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
$firstOrder = $orders->getFirstItem();
|
| 109 |
+
if (empty($firstOrder)) {
|
| 110 |
+
return 0;
|
| 111 |
+
}
|
| 112 |
+
|
| 113 |
+
return (int) $firstOrder->getEntityId();
|
| 114 |
}
|
| 115 |
}
|
app/code/community/Yireo/CheckoutTester/Model/Feed.php
CHANGED
|
@@ -4,12 +4,12 @@
|
|
| 4 |
*
|
| 5 |
* @author Yireo
|
| 6 |
* @package Yireo_Common
|
| 7 |
-
* @copyright Copyright
|
| 8 |
* @license Open Source License (OSL v3) (OSL)
|
| 9 |
* @link http://www.yireo.com
|
| 10 |
*/
|
| 11 |
|
| 12 |
-
|
| 13 |
* Feed Model
|
| 14 |
*/
|
| 15 |
class Yireo_CheckoutTester_Model_Feed extends Mage_AdminNotification_Model_Feed
|
|
@@ -17,7 +17,7 @@ class Yireo_CheckoutTester_Model_Feed extends Mage_AdminNotification_Model_Feed
|
|
| 17 |
/**
|
| 18 |
* Return the feed URL
|
| 19 |
*/
|
| 20 |
-
protected $customFeedUrl = 'www.yireo.com/extfeed?format=feed&platform=magento&extension=checkouttester';
|
| 21 |
|
| 22 |
/**
|
| 23 |
* Return the feed URL
|
|
@@ -26,7 +26,7 @@ class Yireo_CheckoutTester_Model_Feed extends Mage_AdminNotification_Model_Feed
|
|
| 26 |
*/
|
| 27 |
public function getFeedUrl()
|
| 28 |
{
|
| 29 |
-
return
|
| 30 |
}
|
| 31 |
|
| 32 |
/**
|
| 4 |
*
|
| 5 |
* @author Yireo
|
| 6 |
* @package Yireo_Common
|
| 7 |
+
* @copyright Copyright 2015
|
| 8 |
* @license Open Source License (OSL v3) (OSL)
|
| 9 |
* @link http://www.yireo.com
|
| 10 |
*/
|
| 11 |
|
| 12 |
+
/**
|
| 13 |
* Feed Model
|
| 14 |
*/
|
| 15 |
class Yireo_CheckoutTester_Model_Feed extends Mage_AdminNotification_Model_Feed
|
| 17 |
/**
|
| 18 |
* Return the feed URL
|
| 19 |
*/
|
| 20 |
+
protected $customFeedUrl = 'https://www.yireo.com/extfeed?format=feed&platform=magento&extension=checkouttester';
|
| 21 |
|
| 22 |
/**
|
| 23 |
* Return the feed URL
|
| 26 |
*/
|
| 27 |
public function getFeedUrl()
|
| 28 |
{
|
| 29 |
+
return $this->customFeedUrl;
|
| 30 |
}
|
| 31 |
|
| 32 |
/**
|
app/code/community/Yireo/CheckoutTester/Model/Observer.php
CHANGED
|
@@ -4,20 +4,19 @@
|
|
| 4 |
*
|
| 5 |
* @author Yireo
|
| 6 |
* @package CheckoutTester
|
| 7 |
-
* @copyright Copyright
|
| 8 |
* @license Open Source License (OSL v3)
|
| 9 |
* @link http://www.yireo.com
|
| 10 |
*/
|
| 11 |
|
| 12 |
-
|
| 13 |
* CheckoutTester observer to various Magento events
|
| 14 |
*/
|
| 15 |
class Yireo_CheckoutTester_Model_Observer extends Mage_Core_Model_Abstract
|
| 16 |
{
|
| 17 |
-
|
| 18 |
* Method fired on the event <controller_action_predispatch>
|
| 19 |
*
|
| 20 |
-
* @access public
|
| 21 |
* @param Varien_Event_Observer $observer
|
| 22 |
* @return Yireo_CheckoutTester_Model_Observer
|
| 23 |
*/
|
| 4 |
*
|
| 5 |
* @author Yireo
|
| 6 |
* @package CheckoutTester
|
| 7 |
+
* @copyright Copyright 2015
|
| 8 |
* @license Open Source License (OSL v3)
|
| 9 |
* @link http://www.yireo.com
|
| 10 |
*/
|
| 11 |
|
| 12 |
+
/**
|
| 13 |
* CheckoutTester observer to various Magento events
|
| 14 |
*/
|
| 15 |
class Yireo_CheckoutTester_Model_Observer extends Mage_Core_Model_Abstract
|
| 16 |
{
|
| 17 |
+
/**
|
| 18 |
* Method fired on the event <controller_action_predispatch>
|
| 19 |
*
|
|
|
|
| 20 |
* @param Varien_Event_Observer $observer
|
| 21 |
* @return Yireo_CheckoutTester_Model_Observer
|
| 22 |
*/
|
app/code/community/Yireo/CheckoutTester/controllers/IndexController.php
CHANGED
|
@@ -1,10 +1,10 @@
|
|
| 1 |
<?php
|
| 2 |
/**
|
| 3 |
-
* Yireo CheckoutTester for Magento
|
| 4 |
*
|
| 5 |
* @package Yireo_CheckoutTester
|
| 6 |
* @author Yireo (http://www.yireo.com/)
|
| 7 |
-
* @copyright Copyright
|
| 8 |
* @license Open Source License (OSL v3)
|
| 9 |
*/
|
| 10 |
|
|
@@ -17,64 +17,121 @@
|
|
| 17 |
class Yireo_CheckoutTester_IndexController extends Mage_Core_Controller_Front_Action
|
| 18 |
{
|
| 19 |
/**
|
| 20 |
-
* Empty page
|
| 21 |
-
*
|
| 22 |
*/
|
| 23 |
public function indexAction()
|
| 24 |
{
|
| 25 |
-
|
| 26 |
}
|
| 27 |
|
| 28 |
/**
|
| 29 |
-
* Success page
|
| 30 |
-
*
|
| 31 |
*/
|
| 32 |
public function successAction()
|
| 33 |
{
|
| 34 |
// Check access
|
| 35 |
-
if(Mage::helper('checkouttester')->hasAccess() == false) {
|
| 36 |
die('Access denied');
|
| 37 |
}
|
| 38 |
|
| 39 |
-
// Fetch
|
| 40 |
-
$
|
| 41 |
-
$urlId = (int)$this->getRequest()->getParam('order_id');
|
| 42 |
|
| 43 |
-
//
|
| 44 |
-
$
|
| 45 |
-
|
| 46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
}
|
| 52 |
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
|
|
|
| 56 |
}
|
| 57 |
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
|
|
|
| 61 |
}
|
| 62 |
|
| 63 |
-
|
|
|
|
| 64 |
|
| 65 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
Mage::getModel('checkout/session')->setLastOrderId($order->getId())
|
| 67 |
->setLastRealOrderId($order->getIncrementId());
|
| 68 |
|
| 69 |
-
// Load the layout
|
| 70 |
-
$this->loadLayout();
|
| 71 |
-
|
| 72 |
// Optionally dispatch an event
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
}
|
| 76 |
|
| 77 |
-
|
| 78 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
}
|
| 80 |
}
|
| 1 |
<?php
|
| 2 |
/**
|
| 3 |
+
* Yireo CheckoutTester for Magento
|
| 4 |
*
|
| 5 |
* @package Yireo_CheckoutTester
|
| 6 |
* @author Yireo (http://www.yireo.com/)
|
| 7 |
+
* @copyright Copyright 2015 Yireo (http://www.yireo.com/)
|
| 8 |
* @license Open Source License (OSL v3)
|
| 9 |
*/
|
| 10 |
|
| 17 |
class Yireo_CheckoutTester_IndexController extends Mage_Core_Controller_Front_Action
|
| 18 |
{
|
| 19 |
/**
|
| 20 |
+
* Empty page action
|
|
|
|
| 21 |
*/
|
| 22 |
public function indexAction()
|
| 23 |
{
|
| 24 |
+
// Not implemented
|
| 25 |
}
|
| 26 |
|
| 27 |
/**
|
| 28 |
+
* Success page action
|
|
|
|
| 29 |
*/
|
| 30 |
public function successAction()
|
| 31 |
{
|
| 32 |
// Check access
|
| 33 |
+
if (Mage::helper('checkouttester')->hasAccess() == false) {
|
| 34 |
die('Access denied');
|
| 35 |
}
|
| 36 |
|
| 37 |
+
// Fetch the order
|
| 38 |
+
$order = $this->getOrder();
|
|
|
|
| 39 |
|
| 40 |
+
// Fail when there is no valid order
|
| 41 |
+
if ($order == false) {
|
| 42 |
+
die('Invalid order ID');
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
// Load the layout
|
| 46 |
+
$this->loadLayout();
|
| 47 |
+
|
| 48 |
+
// Register this order
|
| 49 |
+
$this->registerOrder($order);
|
| 50 |
+
|
| 51 |
+
// Render the layout
|
| 52 |
+
$this->renderLayout();
|
| 53 |
+
}
|
| 54 |
|
| 55 |
+
/**
|
| 56 |
+
* Method to fetch the current order
|
| 57 |
+
*
|
| 58 |
+
* @return Mage_Sales_Model_Order | false
|
| 59 |
+
*/
|
| 60 |
+
protected function getOrder()
|
| 61 |
+
{
|
| 62 |
+
$orderIdFromUrl = (int)$this->getRequest()->getParam('order_id');
|
| 63 |
+
$order = $this->loadOrder($orderIdFromUrl);
|
| 64 |
+
if ($order) {
|
| 65 |
+
return $order;
|
| 66 |
}
|
| 67 |
|
| 68 |
+
$orderIdFromConfig = (int)Mage::helper('checkouttester')->getOrderIdFromConfig();
|
| 69 |
+
$order = $this->loadOrder($orderIdFromConfig);
|
| 70 |
+
if ($order) {
|
| 71 |
+
return $order;
|
| 72 |
}
|
| 73 |
|
| 74 |
+
$lastOrderId = Mage::helper('checkouttester')->getLastInsertedOrderId();
|
| 75 |
+
$order = $this->loadOrder($lastOrderId);
|
| 76 |
+
if ($order) {
|
| 77 |
+
return $order;
|
| 78 |
}
|
| 79 |
|
| 80 |
+
return false;
|
| 81 |
+
}
|
| 82 |
|
| 83 |
+
/**
|
| 84 |
+
* Method to try to load an order from an unvalidated ID
|
| 85 |
+
*
|
| 86 |
+
* @param int $orderId
|
| 87 |
+
*
|
| 88 |
+
* @return Mage_Sales_Model_Order | false
|
| 89 |
+
*/
|
| 90 |
+
protected function loadOrder($orderId)
|
| 91 |
+
{
|
| 92 |
+
$order = Mage::getModel('sales/order')->load($orderId);
|
| 93 |
+
if ($order->getId() > 0) {
|
| 94 |
+
return $order;
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($orderId);
|
| 98 |
+
if ($order->getId() > 0) {
|
| 99 |
+
return $order;
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
return false;
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
/**
|
| 106 |
+
* Method to register the order in this session
|
| 107 |
+
*
|
| 108 |
+
* @param Mage_Sales_Model_Order $order
|
| 109 |
+
*/
|
| 110 |
+
protected function registerOrder($order)
|
| 111 |
+
{
|
| 112 |
+
// Register this order as the current order
|
| 113 |
+
$currentOrder = Mage::registry('current_order');
|
| 114 |
+
if (empty($currentOrder)) {
|
| 115 |
+
Mage::register('current_order', $order);
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
// Load the session with this order
|
| 119 |
Mage::getModel('checkout/session')->setLastOrderId($order->getId())
|
| 120 |
->setLastRealOrderId($order->getIncrementId());
|
| 121 |
|
|
|
|
|
|
|
|
|
|
| 122 |
// Optionally dispatch an event
|
| 123 |
+
$this->dispatchEvents($order);
|
| 124 |
+
}
|
|
|
|
| 125 |
|
| 126 |
+
/**
|
| 127 |
+
* Method to optionally dispatch order-related events
|
| 128 |
+
*
|
| 129 |
+
* @param Mage_Sales_Model_Order $order
|
| 130 |
+
*/
|
| 131 |
+
public function dispatchEvents($order)
|
| 132 |
+
{
|
| 133 |
+
if ((bool)Mage::getStoreConfig('checkouttester/settings/checkout_onepage_controller_success_action')) {
|
| 134 |
+
Mage::dispatchEvent('checkout_onepage_controller_success_action', array('order_ids' => array($order->getId())));
|
| 135 |
+
}
|
| 136 |
}
|
| 137 |
}
|
app/code/community/Yireo/CheckoutTester/etc/adminhtml.xml
CHANGED
|
@@ -5,7 +5,7 @@
|
|
| 5 |
*
|
| 6 |
* @package Yireo_CheckoutTester
|
| 7 |
* @author Yireo (http://www.yireo.com/)
|
| 8 |
-
* @copyright Copyright
|
| 9 |
* @license Open Source License (OSL v3)
|
| 10 |
*/
|
| 11 |
-->
|
| 5 |
*
|
| 6 |
* @package Yireo_CheckoutTester
|
| 7 |
* @author Yireo (http://www.yireo.com/)
|
| 8 |
+
* @copyright Copyright 2015 Yireo (http://www.yireo.com/)
|
| 9 |
* @license Open Source License (OSL v3)
|
| 10 |
*/
|
| 11 |
-->
|
app/code/community/Yireo/CheckoutTester/etc/config.xml
CHANGED
|
@@ -5,7 +5,7 @@
|
|
| 5 |
*
|
| 6 |
* @package Yireo_CheckoutTester
|
| 7 |
* @author Yireo (http://www.yireo.com/)
|
| 8 |
-
* @copyright Copyright
|
| 9 |
* @license Open Source License (OSL v3)
|
| 10 |
*/
|
| 11 |
-->
|
|
@@ -13,7 +13,7 @@
|
|
| 13 |
|
| 14 |
<modules>
|
| 15 |
<Yireo_CheckoutTester>
|
| 16 |
-
<version>0.1.
|
| 17 |
</Yireo_CheckoutTester>
|
| 18 |
</modules>
|
| 19 |
|
| 5 |
*
|
| 6 |
* @package Yireo_CheckoutTester
|
| 7 |
* @author Yireo (http://www.yireo.com/)
|
| 8 |
+
* @copyright Copyright 2015 Yireo (http://www.yireo.com/)
|
| 9 |
* @license Open Source License (OSL v3)
|
| 10 |
*/
|
| 11 |
-->
|
| 13 |
|
| 14 |
<modules>
|
| 15 |
<Yireo_CheckoutTester>
|
| 16 |
+
<version>0.1.8</version>
|
| 17 |
</Yireo_CheckoutTester>
|
| 18 |
</modules>
|
| 19 |
|
app/code/community/Yireo/CheckoutTester/etc/system.xml
CHANGED
|
@@ -5,7 +5,7 @@
|
|
| 5 |
*
|
| 6 |
* @package Yireo_CheckoutTester
|
| 7 |
* @author Yireo (http://www.yireo.com/)
|
| 8 |
-
* @copyright Copyright
|
| 9 |
* @license Open Source License (OSL v3)
|
| 10 |
*/
|
| 11 |
-->
|
|
@@ -31,8 +31,8 @@
|
|
| 31 |
<frontend_type>text</frontend_type>
|
| 32 |
<sort_order>1</sort_order>
|
| 33 |
<show_in_default>1</show_in_default>
|
| 34 |
-
<show_in_website>
|
| 35 |
-
<show_in_store>
|
| 36 |
<fields>
|
| 37 |
<order_id translate="label">
|
| 38 |
<label>Sales Order ID</label>
|
| 5 |
*
|
| 6 |
* @package Yireo_CheckoutTester
|
| 7 |
* @author Yireo (http://www.yireo.com/)
|
| 8 |
+
* @copyright Copyright 2015 Yireo (http://www.yireo.com/)
|
| 9 |
* @license Open Source License (OSL v3)
|
| 10 |
*/
|
| 11 |
-->
|
| 31 |
<frontend_type>text</frontend_type>
|
| 32 |
<sort_order>1</sort_order>
|
| 33 |
<show_in_default>1</show_in_default>
|
| 34 |
+
<show_in_website>1</show_in_website>
|
| 35 |
+
<show_in_store>1</show_in_store>
|
| 36 |
<fields>
|
| 37 |
<order_id translate="label">
|
| 38 |
<label>Sales Order ID</label>
|
app/design/adminhtml/default/default/template/checkouttester/field/link.phtml
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
test
|
|
|
app/design/frontend/base/default/layout/checkouttester.xml
CHANGED
|
@@ -4,12 +4,15 @@
|
|
| 4 |
*
|
| 5 |
* @package Yireo_CheckoutTester
|
| 6 |
* @author Yireo (http://www.yireo.com/)
|
| 7 |
-
* @copyright Copyright
|
| 8 |
* @license Open Software License
|
| 9 |
*/
|
| 10 |
-->
|
| 11 |
<layout version="0.1.0">
|
| 12 |
<checkouttester_index_success translate="label">
|
| 13 |
<update handle="checkout_onepage_success" />
|
|
|
|
|
|
|
|
|
|
| 14 |
</checkouttester_index_success>
|
| 15 |
</layout>
|
| 4 |
*
|
| 5 |
* @package Yireo_CheckoutTester
|
| 6 |
* @author Yireo (http://www.yireo.com/)
|
| 7 |
+
* @copyright Copyright 2015 Yireo (http://www.yireo.com/)
|
| 8 |
* @license Open Software License
|
| 9 |
*/
|
| 10 |
-->
|
| 11 |
<layout version="0.1.0">
|
| 12 |
<checkouttester_index_success translate="label">
|
| 13 |
<update handle="checkout_onepage_success" />
|
| 14 |
+
<reference name="root">
|
| 15 |
+
<action method="addBodyClass"><value>checkout_onepage_success</value></action>
|
| 16 |
+
</reference>
|
| 17 |
</checkouttester_index_success>
|
| 18 |
</layout>
|
app/etc/modules/Yireo_CheckoutTester.xml
CHANGED
|
@@ -5,7 +5,7 @@
|
|
| 5 |
*
|
| 6 |
* @package Yireo_CheckoutTester
|
| 7 |
* @author Yireo (http://www.yireo.com/)
|
| 8 |
-
* @copyright Copyright
|
| 9 |
* @license Open Software License
|
| 10 |
*/
|
| 11 |
-->
|
| 5 |
*
|
| 6 |
* @package Yireo_CheckoutTester
|
| 7 |
* @author Yireo (http://www.yireo.com/)
|
| 8 |
+
* @copyright Copyright 2015 Yireo (http://www.yireo.com/)
|
| 9 |
* @license Open Software License
|
| 10 |
*/
|
| 11 |
-->
|
package.xml
CHANGED
|
@@ -1,2 +1,2 @@
|
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
-
<package><name>Yireo_CheckoutTester</name><version>0.1.
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
+
<package><name>Yireo_CheckoutTester</name><version>0.1.8</version><stability>stable</stability><license>Open Source License</license><channel>community</channel><extends></extends><summary>No summary</summary><description>No description</description><notes>No notes</notes><authors><author><name>Yireo</name><user>yireo</user><email>info@yireo.com</email></author></authors><date>2015-10-20</date><time>9:33:48</time><compatible></compatible><dependencies><required><php><min>5.4.0</min><max>6.0.0</max></php></required></dependencies><contents><target name="mage"><dir name="app"><dir name="etc"><dir name="modules"><file name="Yireo_CheckoutTester.xml" hash="6ec7061fee4f6da6fde57f268c35c7b3"/></dir></dir><dir name="design"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="checkouttester.xml" hash="666e53357dff060a51a5817791379460"/></dir></dir></dir></dir></dir><dir name="code"><dir name="community"><dir name="Yireo"><dir name="CheckoutTester"><dir name="etc"><file name="adminhtml.xml" hash="68ffa5d1b30fb7775db4e9998b4b1173"/><file name="config.xml" hash="9829c4b7de3d8d4ecb8a4c6c40639fa5"/><file name="system.xml" hash="48e7515fe90d68eea546f519b104650e"/></dir><dir name="controllers"><file name="IndexController.php" hash="fb829985f3070ceafb7cdc0ef2a37667"/></dir><dir name="Model"><file name="Feed.php" hash="6f83270f34cc549657e295b463d44a34"/><file name="Observer.php" hash="738effabd6971a0bacc7bee0b329f0a8"/></dir><dir name="Helper"><file name="Data.php" hash="74a58be38d3243c238c734b80ad4c418"/></dir><dir name="Block"><file name="Success.php" hash="37c45fc07ab77076671bdff4a22f01a2"/><dir name="Field"><file name="Link.php" hash="ad102571ae914b6f876ec46976f3136f"/></dir></dir></dir></dir></dir></dir></dir></target></contents></package>
|
