PostmanPlugin - Version 1.0.0

Version Notes

Initial Release

Download this release

Release Info

Developer Paloma
Extension PostmanPlugin
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

app/code/local/PostmanPlugin/OrderExport/Helper/Data.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PostmanPlugin_OrderExport_Helper_Data extends Mage_Core_Helper_Abstract
4
+ {
5
+ }
6
+ ?>
app/code/local/PostmanPlugin/OrderExport/Model/Export.php ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PostmanPlugin_OrderExport_Model_Export
4
+ {
5
+
6
+ public function exportOrder($order)
7
+ {
8
+ try {
9
+
10
+ $ActivatePostmanPlugin = Mage::app()->getStore()->getConfig('PostmanPlugin_OrderExport_options/PostmanPlugin_group_id/PostmanPlugin_Activate');
11
+ if($ActivatePostmanPlugin==0){return;}
12
+
13
+ $client = new SoapClient("https://api.paloma.se/PalomaWebService.asmx?WSDL");
14
+ $timezone = new DateTimeZone('Europe/Stockholm');
15
+ $time = date("Y-m-dTH:i:s");
16
+ $date = new DateTime($time, $timezone);
17
+ $subscriber = new Subscriber($order->getCustomerEmail(), str_replace($date->format('P'), '', $date->format('c')), true, $order->getBillingAddress()->getData('street'), $order->getCustomerFirstname(), $order->getCustomerLastname(), '', $order->getBillingAddress()->getCompany(), $order->getBillingAddress()->getTelephone(), $order->getBillingAddress()->getTelephone(), $order->getBillingAddress()->getFax(), $order->getBillingAddress()->getPostcode(), $order->getBillingAddress()->getCity(), $order->getBillingAddress()->getCountry());
18
+
19
+ $customerID = Mage::app()->getStore()->getConfig('PostmanPlugin_OrderExport_options/PostmanPlugin_group_id/PostmanPlugin_customer_ID');
20
+ $customerHash = Mage::app()->getStore()->getConfig('PostmanPlugin_OrderExport_options/PostmanPlugin_group_id/PostmanPlugin_customer_Hash');
21
+ $addressListID = Mage::app()->getStore()->getConfig('PostmanPlugin_OrderExport_options/PostmanPlugin_group_id/PostmanPlugin_addressList_ID');
22
+
23
+ $params = array(
24
+ "subscribers" => array($subscriber),
25
+ "customerID" => $customerID,
26
+ "customerHash" => $customerHash,
27
+ "addressListID" => $addressListID
28
+ );
29
+
30
+ $response = $client->__soapCall("InsertSubscribers", array($params));
31
+ return true;
32
+
33
+
34
+ } catch (Exception $e) {
35
+ echo 'Caught exception: ', $e->getMessage(), "\n";
36
+ }
37
+
38
+ }
39
+ }
40
+
41
+
42
+ class Subscriber
43
+ {
44
+ function Subscriber($Email, $TimeStamp, $Registered, $Address, $Firstname, $Lastname, $Title, $Company, $Phone, $MobilePhone, $Fax, $ZipCode, $City, $State)
45
+ {
46
+ $this->Email = $Email;
47
+ $this->TimeStamp = $TimeStamp;
48
+ $this->Registered = $Registered;
49
+ $this->Address = $Address;
50
+ $this->Firstname = $Firstname;
51
+ $this->Lastname = $Lastname;
52
+ $this->Title = $Title;
53
+ $this->Company = $Company;
54
+ $this->Phone = $Phone;
55
+ $this->MobilePhone = $MobilePhone;
56
+ $this->Fax = $Fax;
57
+ $this->ZipCode = $ZipCode;
58
+ $this->City = $City;
59
+ $this->State = $State;
60
+ }
61
+ }
62
+
63
+
64
+
app/code/local/PostmanPlugin/OrderExport/Model/Observer.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PostmanPlugin_OrderExport_Model_Observer
4
+ {
5
+
6
+
7
+ public function exportOrder(Varien_Event_Observer $observer)
8
+ {
9
+ $order = $observer->getEvent()->getOrder();
10
+
11
+ Mage::getModel('PostmanPlugin_orderexport/export')
12
+ ->exportOrder($order);
13
+
14
+ return true;
15
+
16
+ }
17
+ }
app/code/local/PostmanPlugin/OrderExport/Model/ValidateCredential.php ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PostmanPlugin_OrderExport_Model_ValidateCredential
4
+ {
5
+ public function ValidatePalomaCredential($ovserver)
6
+ {
7
+
8
+
9
+ try {
10
+
11
+
12
+ $config_onecheckout = $_POST;
13
+ $config = $config_onecheckout['groups']['PostmanPlugin_group_id']['fields'];
14
+
15
+ $ActivatePostmanPlugin = $config['PostmanPlugin_Activate']['value'];
16
+ if($ActivatePostmanPlugin==0){return;}
17
+
18
+
19
+ $client = new SoapClient("https://api.paloma.se/PalomaWebService.asmx?WSDL");
20
+
21
+
22
+ $customerID = $config['PostmanPlugin_customer_ID']['value'];
23
+ $customerHash = $config['PostmanPlugin_customer_Hash']['value'];
24
+
25
+ $addressListID = $config['PostmanPlugin_addressList_ID']['value'];
26
+
27
+
28
+ $results = $client->ListAddressLists(array('customerID' => $customerID,
29
+ 'customerHash' => $customerHash));
30
+
31
+ if (is_array($results->ListAddressListsResult->AddressLists->AddressList)) {
32
+ $listnum = count($results->ListAddressListsResult->AddressLists->AddressList);
33
+
34
+
35
+ $IsValidCredential = FALSE;
36
+
37
+ $newarray = array();
38
+
39
+ for ($i = 0; $i < $listnum; $i++) {
40
+
41
+ $myarray[$i]['ListID'] = $results->ListAddressListsResult->AddressLists->AddressList[$i]->ListID;
42
+ $myarray[$i]['ListTitle'] = $results->ListAddressListsResult->AddressLists->AddressList[$i]->ListTitle;
43
+
44
+ if ($addressListID == $results->ListAddressListsResult->AddressLists->AddressList[$i]->ListID) {
45
+ $IsValidCredential = TRUE;
46
+ }
47
+
48
+ array_push($newarray, array('value' => $myarray[$i]['ListID'], 'label' => $myarray[$i]['ListTitle']));
49
+ }
50
+
51
+ if ($IsValidCredential == FALSE) {
52
+ Mage::throwException("Could not find an address list with this id.");
53
+ }
54
+
55
+
56
+ } else {
57
+ Mage::throwException("Could not validate customer id and customer hash, Please check your credentials.");
58
+
59
+ }
60
+
61
+
62
+
63
+ } catch (Exception $e) {
64
+ Mage::throwException($e->getMessage());
65
+ echo 'Caught exception: ', $e->getMessage(), "\n";
66
+
67
+
68
+ }
69
+
70
+
71
+ }
72
+
73
+
74
+ }
75
+
76
+ ?>
app/code/local/PostmanPlugin/OrderExport/etc/config.xml ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <modules>
4
+ <PostmanPlugin_OrderExport>
5
+ <version>0.1.0</version>
6
+ </PostmanPlugin_OrderExport>
7
+ </modules>
8
+ <global>
9
+ <helpers>
10
+ <orderexport>
11
+ <class>PostmanPlugin_OrderExport_Helper</class>
12
+ </orderexport>
13
+ </helpers>
14
+ <models>
15
+ <PostmanPlugin_orderexport>
16
+ <class>PostmanPlugin_OrderExport_Model</class>
17
+ </PostmanPlugin_orderexport>
18
+ </models>
19
+ <resources>
20
+ <PostmanPlugin_orderexport_setup>
21
+ <setup>
22
+ <module>PostmanPlugin_OrderExport</module>
23
+ <class>Mage_Core_Model_Resource_Setup</class>
24
+ </setup>
25
+ </PostmanPlugin_orderexport_setup>
26
+ </resources>
27
+ <events>
28
+ <sales_order_place_after>
29
+ <observers>
30
+ <PostmanPlugin_orderexport>
31
+ <class>PostmanPlugin_orderexport/observer</class>
32
+ <method>exportOrder</method>
33
+ </PostmanPlugin_orderexport>
34
+ </observers>
35
+ </sales_order_place_after>
36
+
37
+
38
+
39
+
40
+ <model_config_data_save_before>
41
+ <observers>
42
+ <onstepcheckout>
43
+ <type>singleton</type>
44
+ <class>PostmanPlugin_OrderExport_Model_ValidateCredential</class>
45
+ <method>ValidatePalomaCredential</method>
46
+ </onstepcheckout>
47
+ </observers>
48
+ </model_config_data_save_before>
49
+
50
+
51
+
52
+ </events>
53
+ </global>
54
+ <frontend>
55
+ <events>
56
+ <checkout_onepage_controller_success_action>
57
+ <observers>
58
+ <PostmanPlugin_orderexport>
59
+ <class>PostmanPlugin_orderexport/observer</class>
60
+ <method>newCustomer</method>
61
+ </PostmanPlugin_orderexport>
62
+ </observers>
63
+ </checkout_onepage_controller_success_action>
64
+ </events>
65
+ </frontend>
66
+
67
+
68
+
69
+ <!-- ... -->
70
+ <adminhtml>
71
+ <acl>
72
+ <resources>
73
+ <admin>
74
+ <children>
75
+ <system>
76
+ <children>
77
+ <config>
78
+ <children>
79
+ <PostmanPlugin_OrderExport_options>
80
+ <title>Orderexport Module Section</title>
81
+ </PostmanPlugin_OrderExport_options>
82
+ </children>
83
+ </config>
84
+ </children>
85
+ </system>
86
+ </children>
87
+ </admin>
88
+ </resources>
89
+ </acl>
90
+ </adminhtml>
91
+ <!-- ... -->
92
+
93
+ </config>
app/code/local/PostmanPlugin/OrderExport/etc/system.xml ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+
4
+
5
+ <tabs>
6
+ <PostmanPlugin_OrderExport translate="label">
7
+ <label>Postman Plugin</label>
8
+ <sort_order>99999</sort_order>
9
+ </PostmanPlugin_OrderExport>
10
+ </tabs>
11
+
12
+
13
+
14
+ <sections>
15
+
16
+ <PostmanPlugin_OrderExport_options translate="label">
17
+ <label>Order Export</label>
18
+ <tab>PostmanPlugin_OrderExport</tab>
19
+ <frontend_type>text</frontend_type>
20
+ <sort_order>1000</sort_order>
21
+ <show_in_default>1</show_in_default>
22
+ <show_in_website>1</show_in_website>
23
+ <show_in_store>1</show_in_store>
24
+
25
+
26
+ <groups>
27
+ <PostmanPlugin_group_id translate="label">
28
+ <label>Settings</label>
29
+ <frontend_type>text</frontend_type>
30
+ <sort_order>200</sort_order>
31
+ <show_in_default>1</show_in_default>
32
+ <show_in_website>1</show_in_website>
33
+ <show_in_store>1</show_in_store>
34
+ <fields>
35
+
36
+ <PostmanPlugin_Activate translate="label">
37
+ <label>Activate</label>
38
+ <frontend_type>select</frontend_type>
39
+ <source_model>adminhtml/system_config_source_yesno</source_model>
40
+ <sort_order>10</sort_order>
41
+ <show_in_default>1</show_in_default>
42
+ <show_in_website>1</show_in_website>
43
+ <show_in_store>1</show_in_store>
44
+ </PostmanPlugin_Activate>
45
+
46
+ <PostmanPlugin_customer_ID translate="label">
47
+ <label>Customer Id</label>
48
+ <frontend_type>text</frontend_type>
49
+ <sort_order>11</sort_order>
50
+ <show_in_default>1</show_in_default>
51
+ <show_in_website>1</show_in_website>
52
+ <show_in_store>1</show_in_store>
53
+ </PostmanPlugin_customer_ID>
54
+
55
+ <PostmanPlugin_customer_Hash translate="label">
56
+ <label>Customer Hash</label>
57
+ <frontend_type>password</frontend_type>
58
+ <sort_order>12</sort_order>
59
+ <show_in_default>1</show_in_default>
60
+ <show_in_website>1</show_in_website>
61
+ <show_in_store>1</show_in_store>
62
+ </PostmanPlugin_customer_Hash>
63
+
64
+
65
+
66
+ <PostmanPlugin_addressList_ID translate="label">
67
+ <label>Address List Id</label>
68
+ <frontend_type>text</frontend_type>
69
+ <sort_order>13</sort_order>
70
+ <show_in_default>1</show_in_default>
71
+ <show_in_website>1</show_in_website>
72
+ <show_in_store>1</show_in_store>
73
+ </PostmanPlugin_addressList_ID>
74
+
75
+
76
+
77
+ </fields>
78
+ </PostmanPlugin_group_id>
79
+ </groups>
80
+
81
+
82
+ </PostmanPlugin_OrderExport_options>
83
+
84
+
85
+
86
+
87
+ </sections>
88
+
89
+
90
+
91
+ </config>
app/etc/modules/PostmanPlugin_OrderExport.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <PostmanPlugin_OrderExport>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ </PostmanPlugin_OrderExport>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>PostmanPlugin</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">OSL</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Automatically send your customer to an address list in Postman, Paloma&#x2019;s tool for email marketing and newsletters.</summary>
10
+ <description>When an order is processed this plugin is automatically going to send the customer information over to Postman and create a subscriber in the selected address list.</description>
11
+ <notes>Initial Release</notes>
12
+ <authors><author><name>Paloma</name><user>Zakaria</user><email>teknik@paloma.se</email></author></authors>
13
+ <date>2015-10-14</date>
14
+ <time>10:01:21</time>
15
+ <contents><target name="magelocal"><dir name="PostmanPlugin"><dir name="OrderExport"><dir name="Helper"><file name="Data.php" hash="acfd235d6f1752564c04aea8c9847c88"/></dir><dir name="Model"><file name="Export.php" hash="9c51cdf365759f368ee599ebcc0a94a7"/><file name="Observer.php" hash="6c795942647c530786c7acc2f65aba58"/><file name="ValidateCredential.php" hash="5018a3e4c427aad27984032a1f871d98"/></dir><dir name="etc"><file name="config.xml" hash="486756157cb1761f7d69159be39be05b"/><file name="system.xml" hash="393b603a8b8680c6ca66414511167e99"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="PostmanPlugin_OrderExport.xml" hash="06cb77846399ddd9aca47f2c2144252b"/></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
18
+ </package>