InXpress - Version 0.1.0

Version Notes

Start selling internationally. Get bulk discounted DHL Express rates, displayed in real-time to your customers

Download this release

Release Info

Developer Cedcoss
Extension InXpress
Version 0.1.0
Comparing to
See all releases


Version 0.1.0

app/code/local/Cedcoss/Inxpress/Model/Carrier/Inxpress.php ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Cedcoss_Inxpress_Model_Carrier_Inxpress extends Mage_Shipping_Model_Carrier_Abstract
3
+ {
4
+
5
+ protected $_code = 'inxpress';
6
+
7
+ public function collectRates(Mage_Shipping_Model_Rate_Request $request)
8
+ {
9
+
10
+ if (!$this->getConfigFlag('active')) {
11
+ return false;
12
+ }
13
+
14
+ $shippingPrice=0;
15
+ if ($request->getAllItems())
16
+ {
17
+ foreach ($request->getAllItems() as $item) {
18
+
19
+
20
+ if ($item->getProduct()->isVirtual()) {
21
+ continue;
22
+ }
23
+ else
24
+ {
25
+ $resource = Mage::getSingleton('core/resource');
26
+ $readConnection = $resource->getConnection('core_read');
27
+ if($item->getProduct()->getWeight()>=1) {
28
+
29
+ $code='P';
30
+ }
31
+ else
32
+ {
33
+ $code='X';
34
+ }
35
+ $price=$this->calcRate(Mage::getStoreConfig('carriers/inxpress/account'),$code,$request->getDestCountryId(),$item->getProduct()->getWeight());
36
+
37
+ if($price)
38
+ {
39
+
40
+ $shippingPrice=($shippingPrice+$price['price'])*$item->getQty();
41
+ }
42
+ else
43
+ {
44
+
45
+ return false;
46
+ }
47
+ }
48
+ }
49
+ }
50
+ $result = Mage::getModel('shipping/rate_result');
51
+ if ($shippingPrice != 0) {
52
+
53
+ $method = Mage::getModel('shipping/rate_result_method');
54
+
55
+
56
+
57
+
58
+ $method->setCarrier('inxpress');
59
+ $method->setCarrierTitle(Mage::getStoreConfig('carriers/inxpress/title'));
60
+
61
+ $method->setMethod('inxpress');
62
+ $method->setMethodTitle(Mage::getStoreConfig('carriers/inxpress/title').' ( Transit Days: '.$price['days'].' )');
63
+
64
+
65
+
66
+
67
+ $method->setPrice($shippingPrice);
68
+ $method->setCost($shippingPrice);
69
+
70
+ $result->append($method);
71
+
72
+
73
+ }
74
+
75
+ return $result;
76
+ }
77
+
78
+
79
+ public function calcRate($account,$code,$country,$weight)
80
+ {
81
+ $url = Mage::getStoreConfig('carriers/inxpress/gateway_url').'?acc='.$account.'&dst='.$country.'&prd='.$code.'&wgt='.$weight;
82
+
83
+ $ch = curl_init();
84
+ curl_setopt($ch, CURLOPT_URL,$url);
85
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
86
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,false);
87
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,false);
88
+ $data = curl_exec ($ch);
89
+ curl_close ($ch);
90
+ $xml = preg_replace("/(<\/?)(\w+):([^>]*>)/", "$1$2$3", $data);
91
+ $xml = simplexml_load_string($xml);
92
+ $json = json_encode($xml);
93
+ $responseArray = json_decode($json,true);
94
+ if(isset($responseArray['totalCharge']))
95
+ {
96
+ $response=array();
97
+ $response['price']=$responseArray['totalCharge'];
98
+ $response['days']=$responseArray['info']['baseCountryTransitDays'];
99
+ return $response;
100
+ }
101
+ else
102
+ {
103
+ return false;
104
+ }
105
+
106
+ }
107
+ }
app/code/local/Cedcoss/Inxpress/Model/Inxpress.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Cedcoss_Inxpress_Model_Inxpress extends Mage_Core_Model_Abstract
3
+ {
4
+ protected function _construct()
5
+ {
6
+ $this->_init('inxpress/inxpress');
7
+ }
8
+ }
app/code/local/Cedcoss/Inxpress/Model/Mysql4/Inxpress.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Cedcoss_Inxpress_Model_Mysql4_Inxpress extends Mage_Core_Model_Mysql4_Abstract
3
+ {
4
+ protected function _construct()
5
+ {
6
+ $resource = Mage::getSingleton('core/resource');
7
+
8
+ $this->setType('inxpress_inxpress');
9
+ $this->setConnection(
10
+ $resource->getConnection('inxpress_read'),
11
+ $resource->getConnection('inxpress_write')
12
+ );
13
+ }
14
+ }
app/code/local/Cedcoss/Inxpress/Model/Mysql4/Inxpress/Collection.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Cedcoss_Inxpress_Model_Mysql4_Inxpress_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
3
+ {
4
+ protected function _construct()
5
+ {
6
+ $this->_init('inxpress/inxpress');
7
+ }
8
+ }
app/code/local/Cedcoss/Inxpress/Model/Mysql4/Setup.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+ class Cedcoss_Inxpress_Model_Mysql4_Setup extends Mage_Core_Model_Resource_Setup
3
+ {
4
+
5
+ }
app/code/local/Cedcoss/Inxpress/controllers/ActivateController.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Cedcoss_Inxpress_ActivateController extends Mage_Core_Controller_Front_Action
3
+ {
4
+ public function indexAction()
5
+ {
6
+ try
7
+ {
8
+ if(isset($_POST['key']))
9
+ {
10
+ if($_POST['key']==Mage::getStoreConfig('carriers/inxpress/key'))
11
+ {
12
+ $inxpresskey = new Mage_Core_Model_Config();
13
+
14
+ $inxpresskey ->saveConfig('carriers/inxpress/active', 1, 'default', 0);
15
+ $inxpresskey ->saveConfig('carriers/inxpress/account', $_POST['account_no'], 'default', 0);
16
+ $inxpresskey ->saveConfig('carriers/inxpress/inexpressid', $_POST['inxpress_account_no'], 'default', 0);
17
+ $inxpresskey ->saveConfig('carriers/inxpress/gateway_url', 'http://www.ixpapi.com/ixpapp/rates.php', 'default', 0);
18
+ echo "Configuration Data Has Been Saved Successfully!!!!";die;
19
+ }
20
+ }
21
+ }
22
+ catch(Exception $e)
23
+ {
24
+ echo $e;die;
25
+ }
26
+ }
27
+
28
+
29
+ }
30
+
app/code/local/Cedcoss/Inxpress/etc/config.xml ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <default>
4
+ <carriers>
5
+ <inxpress>
6
+ <active>carriers/inxpress/active</active>
7
+ <sallowspecific>0</sallowspecific>
8
+ <model>inxpress/carrier_inxpress</model>
9
+ <name>InXpress</name>
10
+ <title>DHL Express</title>
11
+ <specificerrmsg>
12
+ This shipping method is currently unavailable.
13
+ If you would like to ship using this shipping
14
+ method, please contact us.
15
+ </specificerrmsg>
16
+ <handling_type>F</handling_type>
17
+ </inxpress>
18
+ </carriers>
19
+ </default>
20
+ <modules>
21
+ <Cedcoss_Inxpress>
22
+ <version>0.1.0</version>
23
+ </Cedcoss_Inxpress>
24
+ </modules>
25
+
26
+ <frontend>
27
+ <routers>
28
+ <inxpress>
29
+ <use>standard</use>
30
+ <args>
31
+ <module>Cedcoss_Inxpress</module>
32
+ <frontName>inxpress</frontName>
33
+ </args>
34
+ </inxpress>
35
+ </routers>
36
+ </frontend>
37
+ <global>
38
+ <models>
39
+ <inxpress>
40
+ <class>Cedcoss_Inxpress_Model</class>
41
+ <resourceModel>inxpress_mysql4</resourceModel>
42
+ </inxpress>
43
+ <inxpress_mysql4>
44
+ <class>Cedcoss_Inxpress_Model_Mysql4</class>
45
+ </inxpress_mysql4>
46
+ </models>
47
+ <resources>
48
+ <inxpress_setup>
49
+ <setup>
50
+ <module>Cedcoss_Inxpress</module>
51
+ <class>Cedcoss_Inxpress_Model_Mysql4_Setup</class>
52
+ </setup>
53
+ <connection>
54
+ <use>core_setup</use>
55
+ </connection>
56
+ </inxpress_setup>
57
+ </resources>
58
+ </global>
59
+ </config>
app/code/local/Cedcoss/Inxpress/etc/system.xml ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <sections>
4
+ <carriers>
5
+ <groups>
6
+ <inxpress translate="label" module="shipping">
7
+ <label>InXpress</label>
8
+ <frontend_type>text</frontend_type>
9
+ <sort_order>14</sort_order>
10
+ <show_in_default>1</show_in_default>
11
+ <show_in_website>1</show_in_website>
12
+ <show_in_store>1</show_in_store>
13
+ <fields>
14
+ <account translate="label">
15
+ <label>Account number</label>
16
+ <frontend_type>text</frontend_type>
17
+ <sort_order>7</sort_order>
18
+ <show_in_default>1</show_in_default>
19
+ <show_in_website>1</show_in_website>
20
+ <show_in_store>1</show_in_store>
21
+ </account>
22
+ <active translate="label">
23
+ <label>Enabled</label>
24
+ <frontend_type>select</frontend_type>
25
+ <source_model>adminhtml/system_config_source_yesno</source_model>
26
+ <sort_order>1</sort_order>
27
+ <show_in_default>1</show_in_default>
28
+ <show_in_website>1</show_in_website>
29
+ <show_in_store>1</show_in_store>
30
+ </active>
31
+
32
+ <inexpressid translate="label">
33
+ <label>InXpress Account number</label>
34
+ <frontend_type>text</frontend_type>
35
+ <sort_order>8</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
+ </inexpressid>
40
+
41
+ <title translate="label">
42
+ <label>Title</label>
43
+ <frontend_type>text</frontend_type>
44
+ <sort_order>2</sort_order>
45
+ <show_in_default>1</show_in_default>
46
+ <show_in_website>1</show_in_website>
47
+ <show_in_store>1</show_in_store>
48
+ </title>
49
+
50
+ </fields>
51
+ </inxpress>
52
+ </groups>
53
+ </carriers>
54
+ </sections>
55
+ </config>
app/code/local/Cedcoss/Inxpress/sql/inxpress_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,158 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ try
4
+
5
+ {
6
+
7
+ $installer = $this;
8
+
9
+ $installer->startSetup();
10
+
11
+ $owner_name=explode(' ',Mage::getStoreConfig('trans_email/ident_general/name'));
12
+
13
+
14
+
15
+ $company=Mage::getStoreConfig('general/store_information/name');
16
+
17
+ $firstname=$owner_name[0];
18
+
19
+ $lastname=$owner_name[1];
20
+
21
+ $countryModel = Mage::getModel('directory/country')->loadByCode(Mage::getStoreConfig('shipping/origin/country_id'));
22
+
23
+ $countryName = $countryModel->getName();
24
+
25
+ $region = Mage::getModel('directory/region')->load(Mage::getStoreConfig('shipping/origin/region_id'));
26
+
27
+ if($region->getName()!='')
28
+
29
+ {
30
+
31
+ $region_name=$region->getName();
32
+
33
+ }
34
+
35
+ else
36
+
37
+ {
38
+
39
+ $region_name=Mage::getStoreConfig('shipping/origin/region_id');
40
+
41
+ }
42
+
43
+ $city=Mage::getStoreConfig('shipping/origin/city');
44
+
45
+ $zip=Mage::getStoreConfig('shipping/origin/postcode');
46
+
47
+ $phone=Mage::getStoreConfig('general/store_information/phone');
48
+
49
+ $email=Mage::getStoreConfig('trans_email/ident_general/email');
50
+
51
+ $address=Mage::getStoreConfig('shipping/origin/street_line1').','.Mage::getStoreConfig('shipping/origin/street_line2');
52
+
53
+ $website=Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
54
+
55
+
56
+
57
+ Mage::log('Company Name: '.$company);
58
+
59
+ Mage::log('First Name: '.$firstname);
60
+
61
+ Mage::log('Last Name: '.$lastname);
62
+
63
+ Mage::log('Country: '.$countryName);
64
+
65
+ Mage::log('State: '.$region_name);
66
+
67
+ Mage::log('City: '.$city);
68
+
69
+ Mage::log('Zipcode: '.$zip);
70
+
71
+ Mage::log('Phone: '.$phone);
72
+
73
+ Mage::log('Email: '.$email);
74
+
75
+ Mage::log('Address: '.$address);
76
+
77
+ Mage::log('Website: '.$website);
78
+
79
+
80
+
81
+ $url = 'http://inxpressaz.force.com/leadcreation?cmp='.$company.'&fn='.$firstname.'&ln='.$lastname.'&add='.$address.'&ct='.$city.'&st='.$region_name.'&cnt='.$countryName.'&zp='.$zip.'&ph='.$phone.'&em='.$email.'&ws='.$website.'&ls=Magento';
82
+
83
+ Mage::log($url);
84
+
85
+ $ch = curl_init();
86
+
87
+ curl_setopt($ch, CURLOPT_URL,$url);
88
+
89
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
90
+
91
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,false);
92
+
93
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,false);
94
+
95
+ $data = curl_exec ($ch);
96
+
97
+ Mage::log($data);
98
+
99
+ $key1=md5(substr ($website,8,6)."_".time().substr ($email,2,5));
100
+
101
+
102
+
103
+
104
+ $post_string = '';
105
+ $params = array(
106
+ 'firstname'=>$firstname,
107
+ 'lastname'=>$lastname,
108
+ 'company'=>$company,
109
+ 'phone'=>$phone,
110
+ 'email'=>$email,
111
+ 'address'=>$address,
112
+ 'city'=>$city,
113
+ 'state'=>$region_name,
114
+ 'country'=>$countryName,
115
+ 'zipcode'=>$zip,
116
+ 'website'=>$website,
117
+ 'framework'=>1,
118
+ 'key'=>$key1,
119
+ );
120
+
121
+ Mage::log($key1);
122
+ Mage::log('======================');
123
+
124
+ $inxpresskey = new Mage_Core_Model_Config();
125
+
126
+ $inxpresskey ->saveConfig('carriers/inxpress/key', $key1, 'default', 0);
127
+
128
+ foreach($params as $key=>$value) { $post_string .= $key.'='.$value.'&'; }
129
+ $post_string = rtrim($post_string, '&');
130
+
131
+ $url="http://www.ixpapi.com/ixpadmin/control/index.php/downloadInfo/create";
132
+
133
+ $ch = curl_init($url);
134
+ curl_setopt($ch, CURLOPT_HEADER, 0);
135
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
136
+ curl_setopt($ch, CURLOPT_POST, 1);
137
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $post_string);
138
+
139
+
140
+ $result = curl_exec($ch);
141
+ curl_close($ch);
142
+ Mage::log($result);
143
+
144
+ Mage::log('setup executed');
145
+
146
+
147
+
148
+
149
+
150
+ }
151
+
152
+ catch(Exception $e)
153
+
154
+ {
155
+
156
+ Mage::log($e);
157
+
158
+ }
app/etc/modules/Cedcoss_Inxpress.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <modules>
4
+ <Cedcoss_Inxpress>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ </Cedcoss_Inxpress>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>InXpress</name>
4
+ <version>0.1.0</version>
5
+ <stability>stable</stability>
6
+ <license>0.3osl</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Get bulk discounted DHL Express rates, displayed in real-time to your customers.</summary>
10
+ <description>You&#x2019;ll receive your own DHL account with deep group volume international shipping discounts!&#xD;
11
+ DHL Picks up and Delivers your packages. It&#x2019;s That Simple!&#xD;
12
+ Reduce your Fraud Risk with Door-to-Door delivery/tracking to over 225+ Countries.&#xD;
13
+ Leverage the world&#x2019;s largest international shipping carrier and open new international markets.&#xD;
14
+ DHL&#x2019;s transit times are the fastest in the world.&#xD;
15
+ InXpress&#x2019;s group volume international shipping discounts on small parcel you will dramatically increase your international revenue streams.&#xD;
16
+ Fully Integrated Partner of ShipStation&#xD;
17
+ &#xD;
18
+ As the largest small business solution of DHL Express, we are an authorized reseller dramatically reducing international shipping costs by consolidating the shipping volume from thousands of small businesses under one umbrella. When you request your DHL account through InXpress, the DHL account belongs to you; you just pay much less. You will gain access to discounts you would never achieve on your own. DHL picks up and delivers your packages. It&#x2019;s that easy.&#xD;
19
+ ***Please note this is not for existing DHL Customers who have shipped on their account within the last 6 months.&#xD;
20
+ </description>
21
+ <notes>Start selling internationally. Get bulk discounted DHL Express rates, displayed in real-time to your customers</notes>
22
+ <authors><author><name>Cedcoss</name><user>Cedcoss</user><email>developer@cedcoss.com</email></author></authors>
23
+ <date>2014-07-24</date>
24
+ <time>12:29:18</time>
25
+ <contents><target name="magelocal"><dir name="Cedcoss"><dir name="Inxpress"><dir name="Model"><dir name="Carrier"><file name="Inxpress.php" hash="aa4127f3ec66caff79f838af84ff68b4"/></dir><file name="Inxpress.php" hash="c00b406b60986a41713219995929fe35"/><dir name="Mysql4"><dir name="Inxpress"><file name="Collection.php" hash="fac10a23aad024cd73ea5ec0f618a488"/></dir><file name="Inxpress.php" hash="7b61c380c27488dc8cd885f58fe541ed"/><file name="Setup.php" hash="1d62889c7eb878fab5538068a659ff5b"/></dir></dir><dir name="controllers"><file name="ActivateController.php" hash="a5e72af04c62b64ef2e09a358d6ed6f0"/></dir><dir name="etc"><file name="config.xml" hash="8d9dab285eb63b04d7947dabae870960"/><file name="system.xml" hash="a09af7686796dbe3f9c9a48339f0fc3d"/></dir><dir name="sql"><dir name="inxpress_setup"><file name="mysql4-install-0.1.0.php" hash="e32ac907fa1c315e1d719f6ea898a825"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Cedcoss_Inxpress.xml" hash="ce41d55e28a410c66676332f84947239"/></dir></target></contents>
26
+ <compatible/>
27
+ <dependencies><required><php><min>5.2.0</min><max>5.5.0</max></php></required></dependencies>
28
+ </package>