Version Notes
First stable release
Download this release
Release Info
Developer | Michael Teasdale |
Extension | Ship2Anywhere_oSync |
Version | 0.1.0 |
Comparing to | |
See all releases |
Version 0.1.0
- app/code/community/Ship2Anywhere/OrderSync/Block/Adminhtml/Sales/Order/View/Tab/Info.php +45 -0
- app/code/community/Ship2Anywhere/OrderSync/Block/Adminhtml/System/Config/Form/Field/TokenInfo.php +78 -0
- app/code/community/Ship2Anywhere/OrderSync/Helper/Data.php +31 -0
- app/code/community/Ship2Anywhere/OrderSync/Model/System/Config/Source.php +104 -0
- app/code/community/Ship2Anywhere/OrderSync/Model/System/Config/Source/Order/Statuses.php +41 -0
- app/code/community/Ship2Anywhere/OrderSync/Model/System/Config/Source/Stores.php +44 -0
- app/code/community/Ship2Anywhere/OrderSync/controllers/RestController.php +300 -0
- app/code/community/Ship2Anywhere/OrderSync/etc/adminhtml.xml +52 -0
- app/code/community/Ship2Anywhere/OrderSync/etc/config.xml +77 -0
- app/code/community/Ship2Anywhere/OrderSync/etc/system.xml +96 -0
- app/design/adminhtml/default/default/layout/osync.xml +11 -0
- app/design/adminhtml/default/default/template/osync/sales/order/view/tab/info.phtml +138 -0
- app/etc/modules/Ship2Anywhere_OrderSync.xml +26 -0
- package.xml +18 -0
app/code/community/Ship2Anywhere/OrderSync/Block/Adminhtml/Sales/Order/View/Tab/Info.php
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ship 2 Anywhere extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
*
|
12 |
+
* @category Ship2Anywhere
|
13 |
+
* @package Ship2Anywhere_OrderSync
|
14 |
+
* @copyright Copyright (C) 2014 Ship 2 Anywhere (https://www.ship2anywhere.com.au/)
|
15 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
16 |
+
*/
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Ship 2 Anywhere System Config Token Info Block
|
20 |
+
*
|
21 |
+
* @category Ship2Anywhere
|
22 |
+
* @package Ship2Anywhere_OrderSync
|
23 |
+
* @subpackage Block
|
24 |
+
* @author Michael Teasdale <michael@ship2anywhere.com.au>
|
25 |
+
*/
|
26 |
+
|
27 |
+
class Ship2Anywhere_OrderSync_Block_Adminhtml_Sales_Order_View_Tab_Info
|
28 |
+
extends Mage_Adminhtml_Block_Sales_Order_View_Tab_Info
|
29 |
+
{
|
30 |
+
public function getTrackingNumbers()
|
31 |
+
{
|
32 |
+
$trackNums = array();
|
33 |
+
$shipmentCollection = $this->getSource()->getShipmentsCollection();
|
34 |
+
foreach ($shipmentCollection as $_shipment) {
|
35 |
+
foreach ($_shipment->getAllTracks() as $tracknum) {
|
36 |
+
$trackNums[] = $tracknum->getNumber();
|
37 |
+
}
|
38 |
+
}
|
39 |
+
if (count($trackNums)) {
|
40 |
+
return implode(', ', $trackNums);
|
41 |
+
} else {
|
42 |
+
return false;
|
43 |
+
}
|
44 |
+
}
|
45 |
+
}
|
app/code/community/Ship2Anywhere/OrderSync/Block/Adminhtml/System/Config/Form/Field/TokenInfo.php
ADDED
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ship 2 Anywhere extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
*
|
12 |
+
* @category Ship2Anywhere
|
13 |
+
* @package Ship2Anywhere_OrderSync
|
14 |
+
* @copyright Copyright (C) 2014 Ship 2 Anywhere (https://www.ship2anywhere.com.au/)
|
15 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
16 |
+
*/
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Ship 2 Anywhere System Config Token Info Block
|
20 |
+
*
|
21 |
+
* @category Ship2Anywhere
|
22 |
+
* @package Ship2Anywhere_OrderSync
|
23 |
+
* @subpackage Block
|
24 |
+
* @author Michael Teasdale <michael@ship2anywhere.com.au>
|
25 |
+
*/
|
26 |
+
|
27 |
+
class Ship2Anywhere_OrderSync_Block_Adminhtml_System_Config_Form_Field_TokenInfo
|
28 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
29 |
+
{
|
30 |
+
const KEY_LENGTH = 32;
|
31 |
+
protected $_element;
|
32 |
+
|
33 |
+
protected function _getOsyncKey()
|
34 |
+
{
|
35 |
+
if (!Mage::getStoreConfig("s2a_osync/token")) {
|
36 |
+
$key = Mage::helper('core')->getRandomString(self::KEY_LENGTH);
|
37 |
+
$op = new Mage_Core_Model_Config();
|
38 |
+
$op->saveConfig('s2a_osync/token', $key, 'default', 0);
|
39 |
+
return $key;
|
40 |
+
}
|
41 |
+
|
42 |
+
return Mage::getStoreConfig("s2a_osync/token");
|
43 |
+
}
|
44 |
+
|
45 |
+
protected function _getOsyncUrl()
|
46 |
+
{
|
47 |
+
return Mage::getBaseUrl() . 'osync/rest/';
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* @see Mage_Adminhtml_Block_System_Config_Form_Field::render()
|
52 |
+
*
|
53 |
+
* Adds the "required" star to the form field.
|
54 |
+
*/
|
55 |
+
public function render(Varien_Data_Form_Element_Abstract $element)
|
56 |
+
{
|
57 |
+
$html = '<div style="margin:5px 5px; float:left;">';
|
58 |
+
$html .= '<strong>' . $this->__('Your Sync URL') . '</strong>';
|
59 |
+
$html .= '</div>';
|
60 |
+
|
61 |
+
$html .= '<div style="margin:5px 210px;">';
|
62 |
+
$html .= '<strong>' . $this->_getOsyncUrl() . '</strong>';
|
63 |
+
$html .= '</div>';
|
64 |
+
|
65 |
+
$html .= '<div style="margin:5px 5px 20px; float:left;">';
|
66 |
+
$html .= '<strong>' . $this->__('Your Sync Key') . '</strong>';
|
67 |
+
$html .= '</div>';
|
68 |
+
|
69 |
+
$html .= '<div style="margin:5px 210px 20px;">';
|
70 |
+
$html .= '<strong>' . $this->_getOsyncKey() . '</strong>';
|
71 |
+
$html .= '</div>';
|
72 |
+
|
73 |
+
$html .= '<div style="clear:both;"></div>';
|
74 |
+
|
75 |
+
|
76 |
+
return $html;
|
77 |
+
}
|
78 |
+
}
|
app/code/community/Ship2Anywhere/OrderSync/Helper/Data.php
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ship 2 Anywhere extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
*
|
12 |
+
* @category Ship2Anywhere
|
13 |
+
* @package Ship2Anywhere_OrderSync
|
14 |
+
* @copyright Copyright (C) 2014 Ship 2 Anywhere (https://www.ship2anywhere.com.au/)
|
15 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
16 |
+
*/
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Ship 2 Anywhere Data Helper
|
20 |
+
*
|
21 |
+
* @category Ship2Anywhere
|
22 |
+
* @package Ship2Anywhere_OrderSync
|
23 |
+
* @subpackage Helper
|
24 |
+
* @author Michael Teasdale <michael@ship2anywhere.com.au>
|
25 |
+
*/
|
26 |
+
|
27 |
+
class Ship2Anywhere_OrderSync_Helper_Data
|
28 |
+
extends Mage_Core_Helper_Abstract
|
29 |
+
{
|
30 |
+
|
31 |
+
}
|
app/code/community/Ship2Anywhere/OrderSync/Model/System/Config/Source.php
ADDED
@@ -0,0 +1,104 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ship 2 Anywhere extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
*
|
12 |
+
* @category Ship2Anywhere
|
13 |
+
* @package Ship2Anywhere_OrderSync
|
14 |
+
* @copyright Copyright (C) 2014 Ship 2 Anywhere (https://www.ship2anywhere.com.au/)
|
15 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
16 |
+
*/
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Ship 2 Anywhere Config Source Model
|
20 |
+
*
|
21 |
+
* @category Ship2Anywhere
|
22 |
+
* @package Ship2Anywhere_OrderSync
|
23 |
+
* @subpackage Model
|
24 |
+
* @author Michael Teasdale <michael@ship2anywhere.com.au>
|
25 |
+
*/
|
26 |
+
|
27 |
+
abstract class Ship2Anywhere_OrderSync_Model_System_Config_Source
|
28 |
+
{
|
29 |
+
/**
|
30 |
+
* The array of options in the configuration item.
|
31 |
+
*
|
32 |
+
* This array's keys are the values used in the database etc. and the
|
33 |
+
* values of this array are used as labels on the frontend.
|
34 |
+
*
|
35 |
+
* @var array
|
36 |
+
*/
|
37 |
+
protected $_options;
|
38 |
+
|
39 |
+
public function __construct()
|
40 |
+
{
|
41 |
+
$this->_setupOptions();
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Sets up the $_options array with the correct values.
|
46 |
+
*
|
47 |
+
* This function is called in the constructor.
|
48 |
+
*
|
49 |
+
* @return Ship2Anywhere_ShippingModule_Model_System_Config_Source
|
50 |
+
*/
|
51 |
+
protected abstract function _setupOptions();
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Gets all the options in the key => value type array.
|
55 |
+
*
|
56 |
+
* @return array
|
57 |
+
*/
|
58 |
+
public function getOptions($please_select = false)
|
59 |
+
{
|
60 |
+
$options = $this->_options;
|
61 |
+
if ($please_select) {
|
62 |
+
$options = array(null => '--Please Select--') + $options;
|
63 |
+
}
|
64 |
+
return $options;
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Converts the options into a format suitable for use in the admin area.
|
69 |
+
*
|
70 |
+
* @return array
|
71 |
+
*/
|
72 |
+
public function toOptionArray()
|
73 |
+
{
|
74 |
+
return $this->_toOptionArray($this->_options);
|
75 |
+
}
|
76 |
+
|
77 |
+
protected function _toOptionArray($input)
|
78 |
+
{
|
79 |
+
$array = array();
|
80 |
+
|
81 |
+
foreach ($input as $key => $value) {
|
82 |
+
$array[] = array(
|
83 |
+
'value' => $key,
|
84 |
+
'label' => $value,
|
85 |
+
);
|
86 |
+
}
|
87 |
+
|
88 |
+
return $array;
|
89 |
+
}
|
90 |
+
|
91 |
+
/**
|
92 |
+
* Looks up an option by key and gets the label.
|
93 |
+
*
|
94 |
+
* @param mixed $value
|
95 |
+
* @return mixed
|
96 |
+
*/
|
97 |
+
public function getOptionLabel($value)
|
98 |
+
{
|
99 |
+
if (array_key_exists($value, $this->_options)) {
|
100 |
+
return $this->_options[$value];
|
101 |
+
}
|
102 |
+
return null;
|
103 |
+
}
|
104 |
+
}
|
app/code/community/Ship2Anywhere/OrderSync/Model/System/Config/Source/Order/Statuses.php
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ship 2 Anywhere extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
*
|
12 |
+
* @category Ship2Anywhere
|
13 |
+
* @package Ship2Anywhere_OrderSync
|
14 |
+
* @copyright Copyright (C) 2014 Ship 2 Anywhere (https://www.ship2anywhere.com.au/)
|
15 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
16 |
+
*/
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Ship 2 Anywhere System Config Source Order Status Model
|
20 |
+
*
|
21 |
+
* @category Ship2Anywhere
|
22 |
+
* @package Ship2Anywhere_OrderSync
|
23 |
+
* @subpackage Model
|
24 |
+
* @author Michael Teasdale <michael@ship2anywhere.com.au>
|
25 |
+
*/
|
26 |
+
|
27 |
+
class Ship2Anywhere_OrderSync_Model_System_Config_Source_Order_Statuses
|
28 |
+
extends Ship2Anywhere_OrderSync_Model_System_Config_Source
|
29 |
+
{
|
30 |
+
protected function _setupOptions()
|
31 |
+
{
|
32 |
+
if (is_null($this->_options)) {
|
33 |
+
$this->_options = array();
|
34 |
+
$orderStatusCollection = Mage::getModel('sales/order_status')
|
35 |
+
->getResourceCollection();
|
36 |
+
foreach($orderStatusCollection as $_status) {
|
37 |
+
$this->_options[$_status->getStatus()] = $_status->getLabel();
|
38 |
+
}
|
39 |
+
}
|
40 |
+
}
|
41 |
+
}
|
app/code/community/Ship2Anywhere/OrderSync/Model/System/Config/Source/Stores.php
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ship 2 Anywhere extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
*
|
12 |
+
* @category Ship2Anywhere
|
13 |
+
* @package Ship2Anywhere_OrderSync
|
14 |
+
* @copyright Copyright (C) 2014 Ship 2 Anywhere (https://www.ship2anywhere.com.au/)
|
15 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
16 |
+
*/
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Ship 2 Anywhere System Config Source Stores Model
|
20 |
+
*
|
21 |
+
* @category Ship2Anywhere
|
22 |
+
* @package Ship2Anywhere_OrderSync
|
23 |
+
* @subpackage Model
|
24 |
+
* @author Michael Teasdale <michael@ship2anywhere.com.au>
|
25 |
+
*/
|
26 |
+
|
27 |
+
class Ship2Anywhere_OrderSync_Model_System_Config_Source_Stores
|
28 |
+
extends Ship2Anywhere_OrderSync_Model_System_Config_Source
|
29 |
+
{
|
30 |
+
protected function _setupOptions()
|
31 |
+
{
|
32 |
+
if (is_null($this->_options)) {
|
33 |
+
$this->_options = array();
|
34 |
+
foreach (Mage::app()->getWebsites() as $website) {
|
35 |
+
foreach ($website->getGroups() as $group) {
|
36 |
+
$stores = $group->getStores();
|
37 |
+
foreach ($stores as $store) {
|
38 |
+
$this->_options[$store->getStoreId()] = $store->getName();
|
39 |
+
}
|
40 |
+
}
|
41 |
+
}
|
42 |
+
}
|
43 |
+
}
|
44 |
+
}
|
app/code/community/Ship2Anywhere/OrderSync/controllers/RestController.php
ADDED
@@ -0,0 +1,300 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ship 2 Anywhere extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
*
|
12 |
+
* @category Ship2Anywhere
|
13 |
+
* @package Ship2Anywhere_OrderSync
|
14 |
+
* @copyright Copyright (C) 2014 Ship 2 Anywhere (https://www.ship2anywhere.com.au/)
|
15 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
16 |
+
*/
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Order sync rest controller
|
20 |
+
*
|
21 |
+
* @category Ship2Anywhere
|
22 |
+
* @package Ship2Anywhere_OrderSync
|
23 |
+
* @subpackage controllers
|
24 |
+
* @author Michael Teasdale <michael@ship2anywhere.com.au>
|
25 |
+
*/
|
26 |
+
|
27 |
+
class Ship2Anywhere_OrderSync_RestController
|
28 |
+
extends Mage_Core_Controller_Front_Action
|
29 |
+
{
|
30 |
+
protected function _checkKey()
|
31 |
+
{
|
32 |
+
$result = array('success' => false);
|
33 |
+
if ($key = $this->getRequest()->getParam('key')) {
|
34 |
+
$validKey = Mage::getStoreConfig("s2a_osync/token");
|
35 |
+
if ($key == $validKey)
|
36 |
+
$result['success'] = true;
|
37 |
+
else
|
38 |
+
$result['error'] = 'Your Sync Key is not valid';
|
39 |
+
} else
|
40 |
+
$result['error'] = 'Synk key was not found';
|
41 |
+
|
42 |
+
return $result;
|
43 |
+
}
|
44 |
+
|
45 |
+
protected function _prepareResponse($data)
|
46 |
+
{
|
47 |
+
$response = $this->getResponse();
|
48 |
+
if (isset($data['error']) && $data['error'])
|
49 |
+
$response->setHeader('HTTP/1.0','403',true);
|
50 |
+
else
|
51 |
+
$response->setHeader('HTTP/1.0','200',true);
|
52 |
+
|
53 |
+
$response->setBody(Mage::helper('core')->jsonEncode($data));
|
54 |
+
return;
|
55 |
+
}
|
56 |
+
|
57 |
+
public function authAction()
|
58 |
+
{
|
59 |
+
$this->_prepareResponse($this->_checkKey());
|
60 |
+
}
|
61 |
+
|
62 |
+
public function ordersAction()
|
63 |
+
{
|
64 |
+
if (!Mage::getStoreConfig('s2a_osync/general/enable')) {
|
65 |
+
$this->_prepareResponse(array(
|
66 |
+
'success' => false,
|
67 |
+
'error' => 'Order Synchronization is disabled')
|
68 |
+
);
|
69 |
+
return;
|
70 |
+
}
|
71 |
+
|
72 |
+
$authResult = $this->_checkKey();
|
73 |
+
if (isset($authResult['success']) AND !$authResult['success']) {
|
74 |
+
$this->_prepareResponse($authResult);
|
75 |
+
return;
|
76 |
+
}
|
77 |
+
|
78 |
+
switch ($this->getRequest()->getMethod()) {
|
79 |
+
case 'GET':
|
80 |
+
$this->_getOrders();
|
81 |
+
break;
|
82 |
+
|
83 |
+
case 'PUT':
|
84 |
+
case 'POST':
|
85 |
+
$this->_updateOrder($this->getRequest()->getParams());
|
86 |
+
break;
|
87 |
+
}
|
88 |
+
}
|
89 |
+
|
90 |
+
/**
|
91 |
+
* Prepare Invoice info
|
92 |
+
*/
|
93 |
+
public function documentsAction()
|
94 |
+
{
|
95 |
+
if (!Mage::getStoreConfig('s2a_osync/general/enable')) {
|
96 |
+
$this->_prepareResponse(array(
|
97 |
+
'success' => false,
|
98 |
+
'error' => 'Order Synchronization is disabled')
|
99 |
+
);
|
100 |
+
return;
|
101 |
+
}
|
102 |
+
|
103 |
+
$authResult = $this->_checkKey();
|
104 |
+
if (isset($authResult['success']) AND !$authResult['success']) {
|
105 |
+
$this->_prepareResponse($authResult);
|
106 |
+
return;
|
107 |
+
}
|
108 |
+
|
109 |
+
$result = array();
|
110 |
+
$params = $this->getRequest()->getParams();
|
111 |
+
if (!isset($params['order_id']) OR !$params['order_id'])
|
112 |
+
$result['error'] = "Order Id doesn't exist";
|
113 |
+
|
114 |
+
$order = Mage::getModel('sales/order')
|
115 |
+
->loadByIncrementId($params['order_id']);
|
116 |
+
|
117 |
+
if ($order->getId()) {
|
118 |
+
$result['store_logo'] = '';
|
119 |
+
if ($invoiceLogo = Mage::getStoreConfig('sales/identity/logo')) {
|
120 |
+
$invoiceLogoPath = Mage::getBaseDir('media')
|
121 |
+
. DS . 'sales' . DS . 'store' . DS . 'logo' . DS . $invoiceLogo;
|
122 |
+
if (file_exists($invoiceLogoPath))
|
123 |
+
$result['store_logo'] = base64_encode(file_get_contents($invoiceLogoPath));
|
124 |
+
}
|
125 |
+
|
126 |
+
$result['order_id'] = $order->getIncrementId();
|
127 |
+
$result['order_created_at'] = $order->getCreatedAt();
|
128 |
+
$result['destination'] = $this->_prepareDestination($order);
|
129 |
+
$result['items'] = $this->_prepareOrderItems($order);
|
130 |
+
$result['subtotal_amount'] = $order->getSubtotal();
|
131 |
+
$result['shipping_amount'] = $order->getShippingAmount();
|
132 |
+
$result['tax_amount'] = $order->getTaxAmount();
|
133 |
+
$result['discount_amount'] = $order->getDiscountAmount();
|
134 |
+
$result['total_amount'] = $order->getGrandTotal();
|
135 |
+
} else
|
136 |
+
$result['error'] = "Order with this ID doesn't exist";
|
137 |
+
|
138 |
+
$this->_prepareResponse($result);
|
139 |
+
}
|
140 |
+
|
141 |
+
protected function _getOrders()
|
142 |
+
{
|
143 |
+
$orderCollection = Mage::getModel('sales/order')
|
144 |
+
->getCollection();
|
145 |
+
|
146 |
+
if ($allowedStores = Mage::getStoreConfig('s2a_osync/general/allowed_stores')) {
|
147 |
+
$allowedStores = explode(',', $allowedStores);
|
148 |
+
if (count($allowedStores))
|
149 |
+
$orderCollection->addFieldToFilter('store_id', array('in' => $allowedStores));
|
150 |
+
}
|
151 |
+
|
152 |
+
if ($allowedStatuses = Mage::getStoreConfig('s2a_osync/general/allowed_order_statuses')) {
|
153 |
+
$allowedStatuses = explode(',', $allowedStatuses);
|
154 |
+
if (count($allowedStatuses))
|
155 |
+
$orderCollection->addFieldToFilter('status', array('in' => $allowedStatuses));
|
156 |
+
}
|
157 |
+
|
158 |
+
$result = array();
|
159 |
+
if ($orderCollection->count()) {
|
160 |
+
$i = 1;
|
161 |
+
foreach ($orderCollection as $_order) {
|
162 |
+
$result[$i]['order_id'] = $_order->getIncrementId();
|
163 |
+
$result[$i]['destination'] = $this->_prepareDestination($_order);
|
164 |
+
$result[$i]['items'] = $this->_prepareOrderItems($_order);
|
165 |
+
|
166 |
+
$i++;
|
167 |
+
}
|
168 |
+
}
|
169 |
+
if (count($result))
|
170 |
+
$this->_prepareResponse(array('orders' => $result));
|
171 |
+
else {
|
172 |
+
$this->_prepareResponse(array(
|
173 |
+
'success' => false,
|
174 |
+
'error' => 'There are no orders to import')
|
175 |
+
);
|
176 |
+
return;
|
177 |
+
}
|
178 |
+
}
|
179 |
+
|
180 |
+
protected function _updateOrder($params)
|
181 |
+
{
|
182 |
+
$result = array('success' => false);
|
183 |
+
if (!isset($params['order_id']) OR !$params['order_id'])
|
184 |
+
$result['error'] = "Order Id doesn't exist";
|
185 |
+
|
186 |
+
if (!isset($params['tracking_number']) OR !$params['tracking_number'])
|
187 |
+
$result['error'] = "Tracking Number doesn't exist";
|
188 |
+
|
189 |
+
$order = Mage::getModel('sales/order')
|
190 |
+
->loadByIncrementId($params['order_id']);
|
191 |
+
|
192 |
+
if ($order->getId()) {
|
193 |
+
if ($order->canShip()) {
|
194 |
+
$shipment = Mage::getModel('sales/service_order', $order)
|
195 |
+
->prepareShipment($this->_getItemQtys($order));
|
196 |
+
|
197 |
+
$shipment->addTrack(Mage::getModel('sales/order_shipment_track')
|
198 |
+
->addData(array(
|
199 |
+
'carrier_code' => $order->getShippingCarrier()->getCarrierCode(),
|
200 |
+
'title' => $order->getShippingDescription(),
|
201 |
+
'number' => $params['tracking_number'],
|
202 |
+
)));
|
203 |
+
|
204 |
+
$shipment->register();
|
205 |
+
$order->setIsInProcess(true);
|
206 |
+
|
207 |
+
Mage::getModel('core/resource_transaction')
|
208 |
+
->addObject($shipment)
|
209 |
+
->addObject($order)
|
210 |
+
->save();
|
211 |
+
|
212 |
+
if (!$shipment->getEmailSent()) {
|
213 |
+
$shipment->sendEmail(true);
|
214 |
+
$shipment->setEmailSent(1);
|
215 |
+
$shipment->save();
|
216 |
+
}
|
217 |
+
$result = array('success' => true);
|
218 |
+
} else
|
219 |
+
$result['error'] = "Order with this ID can't be shipped";
|
220 |
+
} else
|
221 |
+
$result['error'] = "Order with this ID doesn't exist";
|
222 |
+
|
223 |
+
$this->_prepareResponse($result);
|
224 |
+
}
|
225 |
+
|
226 |
+
/**
|
227 |
+
* Prepare Shipping address
|
228 |
+
*
|
229 |
+
* @param $order Mage_Sales_Model_Order
|
230 |
+
* @return array
|
231 |
+
*/
|
232 |
+
protected function _prepareDestination(Mage_Sales_Model_Order $order)
|
233 |
+
{
|
234 |
+
$destination = array();
|
235 |
+
$shippingAddress = $order->getShippingAddress();
|
236 |
+
$destination['firstname'] = $shippingAddress->getFirstname();
|
237 |
+
$destination['lastname'] = $shippingAddress->getLastname();
|
238 |
+
$destination['street'] = $shippingAddress->getStreet();
|
239 |
+
$destination['city'] = $shippingAddress->getCity();
|
240 |
+
$destination['postcode'] = $shippingAddress->getPostcode();
|
241 |
+
$destination['country'] = $shippingAddress->getCountryId();
|
242 |
+
$destination['phone'] = $shippingAddress->getTelephone();
|
243 |
+
$destination['email'] = $order->getCustomerEmail();
|
244 |
+
|
245 |
+
return $destination;
|
246 |
+
}
|
247 |
+
|
248 |
+
/**
|
249 |
+
* Prepare all Visible order items
|
250 |
+
*
|
251 |
+
* @param $order Mage_Sales_Model_Order
|
252 |
+
* @return array
|
253 |
+
*/
|
254 |
+
protected function _prepareOrderItems(Mage_Sales_Model_Order $order)
|
255 |
+
{
|
256 |
+
$orderItems = array();
|
257 |
+
foreach ($order->getAllVisibleItems() as $_orderItem) {
|
258 |
+
$orderItems[$_orderItem->getItemId()]['name'] = $_orderItem->getName();
|
259 |
+
$orderItems[$_orderItem->getItemId()]['sku'] = $_orderItem->getSku();
|
260 |
+
$orderItems[$_orderItem->getItemId()]['qty'] = $_orderItem->getQtyOrdered();
|
261 |
+
$orderItems[$_orderItem->getItemId()]['weight'] = $_orderItem->getRowWeight();
|
262 |
+
|
263 |
+
$qty = floatval($_orderItem->getQty());
|
264 |
+
if (!$qty)
|
265 |
+
$qty = floatval($_orderItem->getQtyOrdered());
|
266 |
+
|
267 |
+
$rowPrice = floatval($_orderItem->getValue()) * $qty;
|
268 |
+
if (!$rowPrice)
|
269 |
+
$rowPrice = floatval($_orderItem->getRowTotalInclTax());
|
270 |
+
if (!$rowPrice)
|
271 |
+
$rowPrice = floatval($_orderItem->getRowTotal());
|
272 |
+
if (!$rowPrice)
|
273 |
+
$rowPrice = floatval($_orderItem->getPrice()) * $qty;
|
274 |
+
|
275 |
+
$orderItems[$_orderItem->getItemId()]['price'] = $rowPrice;
|
276 |
+
}
|
277 |
+
|
278 |
+
return $orderItems;
|
279 |
+
}
|
280 |
+
|
281 |
+
/**
|
282 |
+
* Get the Quantities shipped for the Order, based on an item-level
|
283 |
+
* This method can also be modified, to have the Partial Shipment functionality in place
|
284 |
+
*
|
285 |
+
* @param $order Mage_Sales_Model_Order
|
286 |
+
* @return array
|
287 |
+
*/
|
288 |
+
protected function _getItemQtys(Mage_Sales_Model_Order $order)
|
289 |
+
{
|
290 |
+
$qty = array();
|
291 |
+
foreach ($order->getAllItems() as $_item) {
|
292 |
+
if ($_item->getParentItemId())
|
293 |
+
$qty[$_item->getParentItemId()] = $_item->getQtyOrdered();
|
294 |
+
else
|
295 |
+
$qty[$_item->getId()] = $_item->getQtyOrdered();
|
296 |
+
}
|
297 |
+
|
298 |
+
return $qty;
|
299 |
+
}
|
300 |
+
}
|
app/code/community/Ship2Anywhere/OrderSync/etc/adminhtml.xml
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* Ship 2 Anywhere extension
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
12 |
+
*
|
13 |
+
* @category Ship2Anywhere
|
14 |
+
* @package Ship2Anywhere_OrderSync
|
15 |
+
* @copyright Copyright (C) 2014 Ship 2 Anywhere (https://www.ship2anywhere.com.au/)
|
16 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
17 |
+
*/
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Adminhtml Layout Config
|
21 |
+
*
|
22 |
+
* @category Ship2Anywhere
|
23 |
+
* @package Ship2Anywhere_OrderSync
|
24 |
+
* @subpackage etc
|
25 |
+
* @author Michael Teasdale <michael@ship2anywhere.com.au>
|
26 |
+
*/
|
27 |
+
-->
|
28 |
+
|
29 |
+
<config>
|
30 |
+
<acl>
|
31 |
+
<resources>
|
32 |
+
<all>
|
33 |
+
<title>Allow Everything</title>
|
34 |
+
</all>
|
35 |
+
<admin>
|
36 |
+
<children>
|
37 |
+
<system>
|
38 |
+
<children>
|
39 |
+
<config>
|
40 |
+
<children>
|
41 |
+
<s2a_osync translate="title" module="s2a_osync">
|
42 |
+
<title>Ship 2 Anywhere Order Sync</title>
|
43 |
+
</s2a_osync>
|
44 |
+
</children>
|
45 |
+
</config>
|
46 |
+
</children>
|
47 |
+
</system>
|
48 |
+
</children>
|
49 |
+
</admin>
|
50 |
+
</resources>
|
51 |
+
</acl>
|
52 |
+
</config>
|
app/code/community/Ship2Anywhere/OrderSync/etc/config.xml
ADDED
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* Ship 2 Anywhere extension
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
12 |
+
*
|
13 |
+
* @category Ship2Anywhere
|
14 |
+
* @package Ship2Anywhere_OrderSync
|
15 |
+
* @copyright Copyright (C) 2014 Ship 2 Anywhere (https://www.ship2anywhere.com.au/)
|
16 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
17 |
+
*/
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Main Module Config
|
21 |
+
*
|
22 |
+
* @category Ship2Anywhere
|
23 |
+
* @package Ship2Anywhere_OrderSync
|
24 |
+
* @subpackage etc
|
25 |
+
* @author Michael Teasdale <michael@ship2anywhere.com.au>
|
26 |
+
*/
|
27 |
+
-->
|
28 |
+
|
29 |
+
<config>
|
30 |
+
<modules>
|
31 |
+
<Ship2Anywhere_OrderSync>
|
32 |
+
<version>0.1.0</version>
|
33 |
+
</Ship2Anywhere_OrderSync>
|
34 |
+
</modules>
|
35 |
+
<global>
|
36 |
+
<blocks>
|
37 |
+
<s2a_osync>
|
38 |
+
<class>Ship2Anywhere_OrderSync_Block</class>
|
39 |
+
</s2a_osync>
|
40 |
+
<adminhtml>
|
41 |
+
<rewrite>
|
42 |
+
<sales_order_view_tab_info>Ship2Anywhere_OrderSync_Block_Adminhtml_Sales_Order_View_Tab_Info</sales_order_view_tab_info>
|
43 |
+
</rewrite>
|
44 |
+
</adminhtml>
|
45 |
+
</blocks>
|
46 |
+
<models>
|
47 |
+
<s2a_osync>
|
48 |
+
<class>Ship2Anywhere_OrderSync_Model</class>
|
49 |
+
</s2a_osync>
|
50 |
+
</models>
|
51 |
+
<helpers>
|
52 |
+
<s2a_osync>
|
53 |
+
<class>Ship2Anywhere_OrderSync_Helper</class>
|
54 |
+
</s2a_osync>
|
55 |
+
</helpers>
|
56 |
+
</global>
|
57 |
+
<frontend>
|
58 |
+
<routers>
|
59 |
+
<osync>
|
60 |
+
<use>standard</use>
|
61 |
+
<args>
|
62 |
+
<module>Ship2Anywhere_OrderSync</module>
|
63 |
+
<frontName>osync</frontName>
|
64 |
+
</args>
|
65 |
+
</osync>
|
66 |
+
</routers>
|
67 |
+
</frontend>
|
68 |
+
<adminhtml>
|
69 |
+
<layout>
|
70 |
+
<updates>
|
71 |
+
<osync>
|
72 |
+
<file>osync.xml</file>
|
73 |
+
</osync>
|
74 |
+
</updates>
|
75 |
+
</layout>
|
76 |
+
</adminhtml>
|
77 |
+
</config>
|
app/code/community/Ship2Anywhere/OrderSync/etc/system.xml
ADDED
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* Ship 2 Anywhere extension
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
12 |
+
*
|
13 |
+
* @category Ship2Anywhere
|
14 |
+
* @package Ship2Anywhere_OrderSync
|
15 |
+
* @copyright Copyright (C) 2014 Ship 2 Anywhere (https://www.ship2anywhere.com.au/)
|
16 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
17 |
+
*/
|
18 |
+
|
19 |
+
/**
|
20 |
+
* System Config Layount
|
21 |
+
*
|
22 |
+
* @category Ship2Anywhere
|
23 |
+
* @package Ship2Anywhere_OrderSync
|
24 |
+
* @subpackage etc
|
25 |
+
* @author Michael Teasdale <michael@ship2anywhere.com.au>
|
26 |
+
*/
|
27 |
+
-->
|
28 |
+
|
29 |
+
<config>
|
30 |
+
<sections>
|
31 |
+
<s2a_osync translate="label">
|
32 |
+
<label>Ship2Anywhere Order Sync</label>
|
33 |
+
<tab>sales</tab>
|
34 |
+
<frontend_type>text</frontend_type>
|
35 |
+
<sort_order>322</sort_order>
|
36 |
+
<show_in_default>1</show_in_default>
|
37 |
+
<show_in_website>1</show_in_website>
|
38 |
+
<show_in_store>1</show_in_store>
|
39 |
+
<groups>
|
40 |
+
<general translate="label">
|
41 |
+
<label>General</label>
|
42 |
+
<sort_order>10</sort_order>
|
43 |
+
<show_in_default>1</show_in_default>
|
44 |
+
<show_in_website>1</show_in_website>
|
45 |
+
<show_in_store>1</show_in_store>
|
46 |
+
<fields>
|
47 |
+
<token_info>
|
48 |
+
<frontend_model>s2a_osync/adminhtml_system_config_form_field_tokenInfo</frontend_model>
|
49 |
+
<sort_order>10</sort_order>
|
50 |
+
<show_in_default>1</show_in_default>
|
51 |
+
<show_in_website>0</show_in_website>
|
52 |
+
<show_in_store>0</show_in_store>
|
53 |
+
</token_info>
|
54 |
+
<enable translate="label">
|
55 |
+
<label>Enable Synchronization</label>
|
56 |
+
<frontend_type>select</frontend_type>
|
57 |
+
<sort_order>10</sort_order>
|
58 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
59 |
+
<show_in_default>1</show_in_default>
|
60 |
+
<show_in_website>0</show_in_website>
|
61 |
+
<show_in_store>0</show_in_store>
|
62 |
+
</enable>
|
63 |
+
<allowed_stores translate="label">
|
64 |
+
<label>Allowed Stores</label>
|
65 |
+
<frontend_type>multiselect</frontend_type>
|
66 |
+
<source_model>s2a_osync/system_config_source_stores</source_model>
|
67 |
+
<frontend_class>required-entry</frontend_class>
|
68 |
+
<sort_order>20</sort_order>
|
69 |
+
<show_in_default>1</show_in_default>
|
70 |
+
<show_in_website>0</show_in_website>
|
71 |
+
<show_in_store>0</show_in_store>
|
72 |
+
<depends>
|
73 |
+
<enable>1</enable>
|
74 |
+
</depends>
|
75 |
+
<comment>Select here stores which order will be exported</comment>
|
76 |
+
</allowed_stores>
|
77 |
+
<allowed_order_statuses translate="label">
|
78 |
+
<label>Allowed Order Statuses</label>
|
79 |
+
<frontend_type>multiselect</frontend_type>
|
80 |
+
<source_model>s2a_osync/system_config_source_order_statuses</source_model>
|
81 |
+
<frontend_class>required-entry</frontend_class>
|
82 |
+
<sort_order>30</sort_order>
|
83 |
+
<show_in_default>1</show_in_default>
|
84 |
+
<show_in_website>0</show_in_website>
|
85 |
+
<show_in_store>0</show_in_store>
|
86 |
+
<depends>
|
87 |
+
<enable>1</enable>
|
88 |
+
</depends>
|
89 |
+
<comment>Select here stuses of orders which will be exported</comment>
|
90 |
+
</allowed_order_statuses>
|
91 |
+
</fields>
|
92 |
+
</general>
|
93 |
+
</groups>
|
94 |
+
</s2a_osync>
|
95 |
+
</sections>
|
96 |
+
</config>
|
app/design/adminhtml/default/default/layout/osync.xml
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
|
3 |
+
<layout>
|
4 |
+
<adminhtml_sales_order_view>
|
5 |
+
<reference name="order_tab_info">
|
6 |
+
<action method="setTemplate">
|
7 |
+
<template>osync/sales/order/view/tab/info.phtml</template>
|
8 |
+
</action>
|
9 |
+
</reference>
|
10 |
+
</adminhtml_sales_order_view>
|
11 |
+
</layout>
|
app/design/adminhtml/default/default/template/osync/sales/order/view/tab/info.phtml
ADDED
@@ -0,0 +1,138 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category design
|
22 |
+
* @package default_default
|
23 |
+
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
|
24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
25 |
+
*/
|
26 |
+
?>
|
27 |
+
<?php /** @var $this Mage_Adminhtml_Block_Sales_Order_View_Tab_Info */ ?>
|
28 |
+
<?php $_order = $this->getOrder() ?>
|
29 |
+
<div>
|
30 |
+
<div id="order-messages">
|
31 |
+
<?php echo $this->getChildHtml('order_messages') ?>
|
32 |
+
</div>
|
33 |
+
<?php echo $this->getChildHtml('order_info') ?>
|
34 |
+
<input type="hidden" name="order_id" value="<?php echo $_order->getId() ?>"/>
|
35 |
+
<?php if ($_order->getIsVirtual()): ?>
|
36 |
+
<div class="box-right">
|
37 |
+
<?php else: ?>
|
38 |
+
<div class="box-left">
|
39 |
+
<?php endif; ?>
|
40 |
+
<!--Payment Method-->
|
41 |
+
<div class="entry-edit">
|
42 |
+
<div class="entry-edit-head">
|
43 |
+
<h4 class="icon-head head-payment-method"><?php echo Mage::helper('sales')->__('Payment Information') ?></h4>
|
44 |
+
</div>
|
45 |
+
<fieldset>
|
46 |
+
<?php echo $this->getPaymentHtml() ?>
|
47 |
+
<div><?php echo Mage::helper('sales')->__('Order was placed using %s', $_order->getOrderCurrencyCode()) ?></div>
|
48 |
+
</fieldset>
|
49 |
+
</div>
|
50 |
+
</div>
|
51 |
+
<?php if (!$_order->getIsVirtual()): ?>
|
52 |
+
<div class="box-right">
|
53 |
+
<!--Shipping Method-->
|
54 |
+
<div class="entry-edit">
|
55 |
+
<div class="entry-edit-head">
|
56 |
+
<h4 class="icon-head head-shipping-method"><?php echo Mage::helper('sales')->__('Shipping & Handling Information') ?></h4>
|
57 |
+
</div>
|
58 |
+
<fieldset>
|
59 |
+
<?php if ($_order->getTracksCollection()->count()) : ?>
|
60 |
+
<a href="#" id="linkId" onclick="popWin('<?php echo $this->helper('shipping')->getTrackingPopupUrlBySalesModel($_order) ?>','trackorder','width=800,height=600,resizable=yes,scrollbars=yes')" title="<?php echo $this->__('Track Order') ?>"><?php echo $this->__('Track Order') ?></a>
|
61 |
+
<?php if ($this->getTrackingNumbers()): ?>
|
62 |
+
<strong><?php echo $this->getTrackingNumbers() ?></strong>
|
63 |
+
<?php endif ?>
|
64 |
+
<br/>
|
65 |
+
<?php endif; ?>
|
66 |
+
<?php if ($_order->getShippingDescription()): ?>
|
67 |
+
<strong><?php echo $this->escapeHtml($_order->getShippingDescription()) ?></strong>
|
68 |
+
|
69 |
+
<?php if ($this->helper('tax')->displayShippingPriceIncludingTax()): ?>
|
70 |
+
<?php $_excl = $this->displayShippingPriceInclTax($_order); ?>
|
71 |
+
<?php else: ?>
|
72 |
+
<?php $_excl = $this->displayPriceAttribute('shipping_amount', false, ' '); ?>
|
73 |
+
<?php endif; ?>
|
74 |
+
<?php $_incl = $this->displayShippingPriceInclTax($_order); ?>
|
75 |
+
|
76 |
+
<?php echo $_excl; ?>
|
77 |
+
<?php if ($this->helper('tax')->displayShippingBothPrices() && $_incl != $_excl): ?>
|
78 |
+
(<?php echo $this->__('Incl. Tax'); ?> <?php echo $_incl; ?>)
|
79 |
+
<?php endif; ?>
|
80 |
+
<?php else: ?>
|
81 |
+
<?php echo $this->helper('sales')->__('No shipping information available'); ?>
|
82 |
+
<?php endif; ?>
|
83 |
+
</fieldset>
|
84 |
+
</div>
|
85 |
+
</div>
|
86 |
+
<?php endif; ?>
|
87 |
+
<div class="clear"></div>
|
88 |
+
<?php echo $this->getGiftOptionsHtml() ?>
|
89 |
+
<div class="clear"></div>
|
90 |
+
<div class="entry-edit">
|
91 |
+
<div class="entry-edit-head">
|
92 |
+
<h4 class="icon-head head-products"><?php echo Mage::helper('sales')->__('Items Ordered') ?></h4>
|
93 |
+
</div>
|
94 |
+
</div>
|
95 |
+
<?php echo $this->getItemsHtml() ?>
|
96 |
+
<div class="clear"></div>
|
97 |
+
|
98 |
+
<div class="box-left">
|
99 |
+
<div class="entry-edit">
|
100 |
+
<div class="entry-edit-head">
|
101 |
+
<h4><?php echo Mage::helper('sales')->__('Comments History') ?></h4>
|
102 |
+
</div>
|
103 |
+
<fieldset><?php echo $this->getChildHtml('order_history') ?></fieldset>
|
104 |
+
</div>
|
105 |
+
</div>
|
106 |
+
<div class="box-right entry-edit">
|
107 |
+
<div class="entry-edit-head"><h4><?php echo Mage::helper('sales')->__('Order Totals') ?></h4></div>
|
108 |
+
<div class="order-totals"><?php echo $this->getChildHtml('order_totals') ?></div>
|
109 |
+
</div>
|
110 |
+
<div class="clear"></div>
|
111 |
+
</div>
|
112 |
+
|
113 |
+
<?php echo $this->getChildHtml('popup_window');?>
|
114 |
+
<script type="text/javascript">
|
115 |
+
//<![CDATA[
|
116 |
+
/**
|
117 |
+
* Retrieve gift options tooltip content
|
118 |
+
*/
|
119 |
+
function getGiftOptionsTooltipContent(itemId) {
|
120 |
+
var contentLines = [];
|
121 |
+
var headerLine = null;
|
122 |
+
var contentLine = null;
|
123 |
+
|
124 |
+
$$('#gift_options_data_' + itemId + ' .gift-options-tooltip-content').each(function (element) {
|
125 |
+
if (element.down(0)) {
|
126 |
+
headerLine = element.down(0).innerHTML;
|
127 |
+
contentLine = element.down(0).next().innerHTML;
|
128 |
+
if (contentLine.length > 30) {
|
129 |
+
contentLine = contentLine.slice(0,30) + '...';
|
130 |
+
}
|
131 |
+
contentLines.push(headerLine + ' ' + contentLine);
|
132 |
+
}
|
133 |
+
});
|
134 |
+
return contentLines.join('<br/>');
|
135 |
+
}
|
136 |
+
giftOptionsTooltip.setTooltipContentLoaderFunction(getGiftOptionsTooltipContent);
|
137 |
+
//]]>
|
138 |
+
</script>
|
app/etc/modules/Ship2Anywhere_OrderSync.xml
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* Ship 2 Anywhere extension
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
12 |
+
*
|
13 |
+
* @category Ship2Anywhere
|
14 |
+
* @package Ship2Anywhere_OrderSync
|
15 |
+
* @copyright Copyright (C) 2014 Ship 2 Anywhere (https://www.ship2anywhere.com.au/)
|
16 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
17 |
+
*/
|
18 |
+
-->
|
19 |
+
<config>
|
20 |
+
<modules>
|
21 |
+
<Ship2Anywhere_OrderSync>
|
22 |
+
<active>true</active>
|
23 |
+
<codePool>community</codePool>
|
24 |
+
</Ship2Anywhere_OrderSync>
|
25 |
+
</modules>
|
26 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Ship2Anywhere_oSync</name>
|
4 |
+
<version>0.1.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Ship2Anywhere Order Sync extension for Magento</summary>
|
10 |
+
<description>Ship2Anywhere Order Sync extension for Magento</description>
|
11 |
+
<notes>First stable release</notes>
|
12 |
+
<authors><author><name>Michael Teasdale</name><user>michaelgt</user><email>michael@ship2anywhere.com.au</email></author></authors>
|
13 |
+
<date>2015-02-11</date>
|
14 |
+
<time>18:36:40</time>
|
15 |
+
<contents><target name="magecommunity"><dir name="Ship2Anywhere"><dir name="OrderSync"><dir name="Block"><dir name="Adminhtml"><dir name="Sales"><dir name="Order"><dir name="View"><dir name="Tab"><file name="Info.php" hash="b7473499549cb67b41fb350c4e92af4a"/></dir></dir></dir></dir><dir name="System"><dir name="Config"><dir name="Form"><dir name="Field"><file name="TokenInfo.php" hash="c61fc639a02bb112766fe829e1663e0b"/></dir></dir></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="77e2d4c5a5fd16491a5e77321a243b20"/></dir><dir name="Model"><dir name="System"><dir name="Config"><dir name="Source"><dir name="Order"><file name="Statuses.php" hash="8f37725561d115b7d1a9caa22985a55a"/></dir><file name="Stores.php" hash="d4c894c2d087a64286cbe7dd655e638c"/></dir><file name="Source.php" hash="008a015bdd44aaf143b8a33b0c33b847"/></dir></dir></dir><dir name="controllers"><file name="RestController.php" hash="baf3237f710d915f88b91cc684776538"/></dir><dir name="etc"><file name="adminhtml.xml" hash="29db9046ce4ca384f06beb7f773d7d4f"/><file name="config.xml" hash="cf96431c22eff0fb68632853b6f78606"/><file name="system.xml" hash="d400b5cf1b0bbd9560c6aa8816089d1e"/></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="osync.xml" hash="0de314e11236e5b99dace09275d82075"/></dir><dir name="template"><dir name="osync"><dir name="sales"><dir name="order"><dir name="view"><dir name="tab"><file name="info.phtml" hash="c20a3a8584db83724688693117c99deb"/></dir></dir></dir></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Ship2Anywhere_OrderSync.xml" hash="b34be217fd9b0815dc120faee1b02211"/></dir></target></contents>
|
16 |
+
<compatible/>
|
17 |
+
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
18 |
+
</package>
|