Version Notes
- Updated rates at checkout API for all carriers
- Added support for recent PHP releases
Download this release
Release Info
Developer | George Plummer |
Extension | Rvtech_Starshipit |
Version | 1.6.5.0 |
Comparing to | |
See all releases |
Code changes from version 1.6.4.0 to 1.6.5.0
- app/code/community/Rvtech/Starshipit/Model/Carrier/Auspost.php +172 -104
- app/code/community/Rvtech/Starshipit/Model/Carrier/Courierpost.php +173 -103
- app/code/community/Rvtech/Starshipit/Model/Carrier/Couriersplease.php +165 -151
- app/code/community/Rvtech/Starshipit/Model/Carrier/Dhlexpress.php +173 -119
- app/code/community/Rvtech/Starshipit/Model/Carrier/Fastway.php +174 -99
- app/code/community/Rvtech/Starshipit/Model/Carrier/Nzpost.php +172 -103
- app/code/community/Rvtech/Starshipit/Model/Carrier/Pace.php +165 -151
- app/code/community/Rvtech/Starshipit/Model/Carrier/Shipit.php +164 -150
- app/code/community/Rvtech/Starshipit/Model/Carrier/Startrack.php +165 -151
- app/code/community/Rvtech/Starshipit/Model/Carrier/Startrackexpress.php +165 -151
- package.xml +7 -7
app/code/community/Rvtech/Starshipit/Model/Carrier/Auspost.php
CHANGED
@@ -1,113 +1,181 @@
|
|
1 |
<?php
|
2 |
class Rvtech_Starshipit_Model_Carrier_Auspost extends Mage_Shipping_Model_Carrier_Abstract
|
3 |
implements Mage_Shipping_Model_Carrier_Interface {
|
4 |
-
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
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 |
}
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
$method->setCost($price);
|
80 |
-
$result->append($method);
|
81 |
-
|
82 |
-
}else{
|
83 |
-
$error = Mage::getModel('shipping/rate_result_error');
|
84 |
-
$error->setCarrier($this->_code);
|
85 |
-
$error->setCarrierTitle($this->getConfigData('name'));
|
86 |
-
$error->setErrorMessage($this->getConfigData('specificerrmsg'));
|
87 |
-
$result->append($error);
|
88 |
-
}
|
89 |
-
return $result;
|
90 |
-
}
|
91 |
-
public function getAllowedMethods()
|
92 |
-
{
|
93 |
-
return array('auspost'=>$this->getConfigData('name'));
|
94 |
-
}
|
95 |
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
|
|
|
|
100 |
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
|
|
113 |
}
|
1 |
<?php
|
2 |
class Rvtech_Starshipit_Model_Carrier_Auspost extends Mage_Shipping_Model_Carrier_Abstract
|
3 |
implements Mage_Shipping_Model_Carrier_Interface {
|
4 |
+
protected $_code = 'auspost';
|
5 |
|
6 |
+
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
|
7 |
+
{
|
8 |
+
if (!Mage::getStoreConfig('carriers/'.$this->_code.'/active')) {
|
9 |
+
return false;
|
10 |
+
}
|
11 |
+
|
12 |
+
$show = false;
|
13 |
+
$price = 0;
|
14 |
+
$doCalulate = $this->getConfigData('calculate');
|
15 |
+
if ($doCalulate==0) {
|
16 |
+
$show = true;
|
17 |
+
$price = $this->getConfigData('price');
|
18 |
+
|
19 |
+
$result = Mage::getModel('shipping/rate_result');
|
20 |
+
$method = Mage::getModel('shipping/rate_result_method');
|
21 |
+
$method->setCarrier($this->_code);
|
22 |
+
$method->setMethod($this->_code);
|
23 |
+
$method->setCarrierTitle($this->getConfigData('title'));
|
24 |
+
$method->setMethodTitle($this->getConfigData('name'));
|
25 |
+
$method->setPrice($price);
|
26 |
+
$method->setCost($price);
|
27 |
+
$result->append($method);
|
28 |
+
}
|
29 |
+
else {
|
30 |
+
try {
|
31 |
+
$shipItApiKey = Mage::helper('shipnote')->getShipItApiKey();
|
32 |
+
if ($shipItApiKey == "") {
|
33 |
+
return false;
|
34 |
+
}
|
35 |
+
|
36 |
+
$origCountryId = $request->getCountryId(); //Package Source Country ID
|
37 |
+
$origRegionId = $request->getRegionId(); //Package Source Region ID
|
38 |
+
$origRegionCode = $request->getRegion(); //Package Source Region Code
|
39 |
+
$origCity = $request->getCity(); //Package Source City
|
40 |
+
$origPostcode = $request->getPostcode(); //Package Source Post Code
|
41 |
+
|
42 |
+
$destCountryId = $request->getDestCountryId();
|
43 |
+
$destCountry = $request->getDestCountry();
|
44 |
+
$destRegion = $request->getDestRegionId();
|
45 |
+
$destRegionCode = $request->getDestRegionCode();
|
46 |
+
$destFullStreet = $request->getDestStreet();
|
47 |
+
$destStreet = "";
|
48 |
+
$destSuburb = "";
|
49 |
+
$destCity = $request->getDestCity();
|
50 |
+
$destPostcode = $request->getDestPostcode();
|
51 |
+
|
52 |
+
$destFullStreetArray = explode("\n", $destFullStreet);
|
53 |
+
if ($destFullStreetArray[0] !== false)
|
54 |
+
$destStreet = $destFullStreetArray[0];
|
55 |
+
if ($destFullStreetArray[1] !== false)
|
56 |
+
$destSuburb = $destFullStreetArray[1];
|
57 |
+
|
58 |
+
$packageValue = $request->getPackageValue(); //Dest Package Value
|
59 |
+
$packageValueDiscout = $request->getPackageValueWithDiscount(); //Dest Package Value After Discount
|
60 |
+
$packageWeight = $request->getPackageWeight() * 1000; //Package Weight (grams)
|
61 |
+
$packageCurrency = $request->getPackageCurrency();
|
62 |
+
|
63 |
+
$url = 'https://api.shipit.click/rate?apiKey=' . $shipItApiKey . '&integration=magento&format=json';
|
64 |
+
$post_data = '{
|
65 |
+
"rate": {
|
66 |
+
"origin": {
|
67 |
+
"country": "' . $origCountryId . '",
|
68 |
+
"postal_code": "' . $origPostcode . '",
|
69 |
+
"province": "' . $origRegionCode . '",
|
70 |
+
"city": "' . $origCity . '",
|
71 |
+
"name": null,
|
72 |
+
"address1": null,
|
73 |
+
"address2": null,
|
74 |
+
"address3": null,
|
75 |
+
"phone": null,
|
76 |
+
"fax": null,
|
77 |
+
"address_type": null,
|
78 |
+
"company_name": null
|
79 |
+
},
|
80 |
+
"destination":{
|
81 |
+
"country": "' . $destCountryId . '",
|
82 |
+
"postal_code": "' . $destPostcode . '",
|
83 |
+
"province": "' . $destRegionCode . '",
|
84 |
+
"city": "' . $destCity . '",
|
85 |
+
"name": null,
|
86 |
+
"address1": "' . $destStreet . '",
|
87 |
+
"address2": "' . $destSuburb . '",
|
88 |
+
"address3": null,
|
89 |
+
"phone": null,
|
90 |
+
"fax": null,
|
91 |
+
"address_type": null,
|
92 |
+
"company_name": null
|
93 |
+
},
|
94 |
+
"items":[
|
95 |
+
{
|
96 |
+
"name": "Total Items",
|
97 |
+
"sku": null,
|
98 |
+
"quantity": 1,
|
99 |
+
"grams": ' . $packageWeight . ' ,
|
100 |
+
"price": ' . $packageValue . ',
|
101 |
+
"vendor": null,
|
102 |
+
"requires_shipping": true,
|
103 |
+
"taxable": true,
|
104 |
+
"fulfillment_service": "manual"
|
105 |
+
}
|
106 |
+
],
|
107 |
+
"currency": "' . $packageCurrency->getCurrencyCode() . '",
|
108 |
+
"carrierid": "10"
|
109 |
+
}
|
110 |
+
}';
|
111 |
+
$contentLength = strlen($post_data);
|
112 |
+
|
113 |
+
$ch = curl_init();
|
114 |
+
curl_setopt($ch, CURLOPT_URL, $url);
|
115 |
+
curl_setopt($ch, CURLOPT_HEADER, false);
|
116 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
117 |
+
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
|
118 |
+
curl_setopt($ch, CURLOPT_POST, true);
|
119 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
|
120 |
+
$response = curl_exec($ch);
|
121 |
+
curl_close($ch);
|
122 |
+
|
123 |
+
$json_obj = json_decode($response);
|
124 |
+
$rates_obj = $json_obj->{'rates'};
|
125 |
+
|
126 |
+
$handling = Mage::getStoreConfig('carriers/'.$this->_code.'/handling');
|
127 |
+
$result = Mage::getModel('shipping/rate_result');
|
128 |
+
|
129 |
+
if (sizeof($rates_obj) > 0) {
|
130 |
+
$show = true;
|
131 |
+
}
|
132 |
+
|
133 |
+
if ($show) {
|
134 |
+
foreach ($rates_obj as $rate) {
|
135 |
+
if (is_object($rate)) {
|
136 |
+
// Add shipping option with shipping price
|
137 |
+
$method = Mage::getModel('shipping/rate_result_method');
|
138 |
+
$method->setCarrier($this->_code);
|
139 |
+
$method->setMethod($this->_code . $rate->{'service_code'});
|
140 |
+
$method->setCarrierTitle($this->getConfigData('title'));
|
141 |
+
$method->setMethodTitle($rate->{'service_name'});
|
142 |
+
$method->setPrice($rate->{'total_price'});
|
143 |
+
$method->setCost(0);
|
144 |
+
$result->append($method);
|
145 |
}
|
146 |
+
}
|
147 |
}
|
148 |
+
else {
|
149 |
+
$error = Mage::getModel('shipping/rate_result_error');
|
150 |
+
$error->setCarrier($this->_code);
|
151 |
+
$error->setCarrierTitle($this->getConfigData('name'));
|
152 |
+
$error->setErrorMessage($this->getConfigData('specificerrmsg'));
|
153 |
+
$result->append($error);
|
154 |
+
}
|
155 |
+
}
|
156 |
+
catch (Exception $e) {
|
157 |
+
Mage::log($e->getMessage());
|
158 |
+
}
|
159 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
160 |
|
161 |
+
return $result;
|
162 |
+
}
|
163 |
+
|
164 |
+
public function getAllowedMethods() {
|
165 |
+
return array('auspost'=>$this->getConfigData('name'));
|
166 |
+
}
|
167 |
|
168 |
+
public function isTrackingAvailable() {
|
169 |
+
return true;
|
170 |
+
}
|
171 |
+
|
172 |
+
public function getTrackingInfo($tracking) {
|
173 |
+
$status = Mage::getModel('shipping/tracking_result_status');
|
174 |
+
$status->setCarrier($this->_code);
|
175 |
+
$status->setCarrierTitle($this->getConfigData('title'));
|
176 |
+
$status->setTracking($tracking);
|
177 |
+
$status->setPopup(1);
|
178 |
+
$status->setUrl("http://auspost.com.au/track/track.html?id=".$tracking);
|
179 |
+
return $status;
|
180 |
+
}
|
181 |
}
|
app/code/community/Rvtech/Starshipit/Model/Carrier/Courierpost.php
CHANGED
@@ -1,111 +1,181 @@
|
|
1 |
<?php
|
2 |
-
class
|
3 |
implements Mage_Shipping_Model_Carrier_Interface {
|
4 |
-
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
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 |
}
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
$method->setCost($price);
|
80 |
-
$result->append($method);
|
81 |
-
|
82 |
-
}else{
|
83 |
-
$error = Mage::getModel('shipping/rate_result_error');
|
84 |
-
$error->setCarrier($this->_code);
|
85 |
-
$error->setCarrierTitle($this->getConfigData('name'));
|
86 |
-
$error->setErrorMessage($this->getConfigData('specificerrmsg'));
|
87 |
-
$result->append($error);
|
88 |
-
}
|
89 |
-
return $result;
|
90 |
-
}
|
91 |
-
public function getAllowedMethods()
|
92 |
-
{
|
93 |
-
return array('courierpost'=>$this->getConfigData('name'));
|
94 |
-
}
|
95 |
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
|
|
|
|
100 |
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
|
|
|
|
|
|
111 |
}
|
1 |
<?php
|
2 |
+
class Rvtech_Starshipit_Model_Carrier_Courierpost extends Mage_Shipping_Model_Carrier_Abstract
|
3 |
implements Mage_Shipping_Model_Carrier_Interface {
|
4 |
+
protected $_code = 'courierpost';
|
5 |
|
6 |
+
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
|
7 |
+
{
|
8 |
+
if (!Mage::getStoreConfig('carriers/'.$this->_code.'/active')) {
|
9 |
+
return false;
|
10 |
+
}
|
11 |
+
|
12 |
+
$show = false;
|
13 |
+
$price = 0;
|
14 |
+
$doCalulate = $this->getConfigData('calculate');
|
15 |
+
if ($doCalulate==0) {
|
16 |
+
$show = true;
|
17 |
+
$price = $this->getConfigData('price');
|
18 |
+
|
19 |
+
$result = Mage::getModel('shipping/rate_result');
|
20 |
+
$method = Mage::getModel('shipping/rate_result_method');
|
21 |
+
$method->setCarrier($this->_code);
|
22 |
+
$method->setMethod($this->_code);
|
23 |
+
$method->setCarrierTitle($this->getConfigData('title'));
|
24 |
+
$method->setMethodTitle($this->getConfigData('name'));
|
25 |
+
$method->setPrice($price);
|
26 |
+
$method->setCost($price);
|
27 |
+
$result->append($method);
|
28 |
+
}
|
29 |
+
else {
|
30 |
+
try {
|
31 |
+
$shipItApiKey = Mage::helper('shipnote')->getShipItApiKey();
|
32 |
+
if ($shipItApiKey == "") {
|
33 |
+
return false;
|
34 |
+
}
|
35 |
+
|
36 |
+
$origCountryId = $request->getCountryId(); //Package Source Country ID
|
37 |
+
$origRegionId = $request->getRegionId(); //Package Source Region ID
|
38 |
+
$origRegionCode = $request->getRegion(); //Package Source Region Code
|
39 |
+
$origCity = $request->getCity(); //Package Source City
|
40 |
+
$origPostcode = $request->getPostcode(); //Package Source Post Code
|
41 |
+
|
42 |
+
$destCountryId = $request->getDestCountryId();
|
43 |
+
$destCountry = $request->getDestCountry();
|
44 |
+
$destRegion = $request->getDestRegionId();
|
45 |
+
$destRegionCode = $request->getDestRegionCode();
|
46 |
+
$destFullStreet = $request->getDestStreet();
|
47 |
+
$destStreet = "";
|
48 |
+
$destSuburb = "";
|
49 |
+
$destCity = $request->getDestCity();
|
50 |
+
$destPostcode = $request->getDestPostcode();
|
51 |
+
|
52 |
+
$destFullStreetArray = explode("\n", $destFullStreet);
|
53 |
+
if ($destFullStreetArray[0] !== false)
|
54 |
+
$destStreet = $destFullStreetArray[0];
|
55 |
+
if ($destFullStreetArray[1] !== false)
|
56 |
+
$destSuburb = $destFullStreetArray[1];
|
57 |
+
|
58 |
+
$packageValue = $request->getPackageValue(); //Dest Package Value
|
59 |
+
$packageValueDiscout = $request->getPackageValueWithDiscount(); //Dest Package Value After Discount
|
60 |
+
$packageWeight = $request->getPackageWeight() * 1000; //Package Weight (grams)
|
61 |
+
$packageCurrency = $request->getPackageCurrency();
|
62 |
+
|
63 |
+
$url = 'https://api.shipit.click/rate?apiKey=' . $shipItApiKey . '&integration=magento&format=json';
|
64 |
+
$post_data = '{
|
65 |
+
"rate": {
|
66 |
+
"origin": {
|
67 |
+
"country": "' . $origCountryId . '",
|
68 |
+
"postal_code": "' . $origPostcode . '",
|
69 |
+
"province": "' . $origRegionCode . '",
|
70 |
+
"city": "' . $origCity . '",
|
71 |
+
"name": null,
|
72 |
+
"address1": null,
|
73 |
+
"address2": null,
|
74 |
+
"address3": null,
|
75 |
+
"phone": null,
|
76 |
+
"fax": null,
|
77 |
+
"address_type": null,
|
78 |
+
"company_name": null
|
79 |
+
},
|
80 |
+
"destination":{
|
81 |
+
"country": "' . $destCountryId . '",
|
82 |
+
"postal_code": "' . $destPostcode . '",
|
83 |
+
"province": "' . $destRegionCode . '",
|
84 |
+
"city": "' . $destCity . '",
|
85 |
+
"name": null,
|
86 |
+
"address1": "' . $destStreet . '",
|
87 |
+
"address2": "' . $destSuburb . '",
|
88 |
+
"address3": null,
|
89 |
+
"phone": null,
|
90 |
+
"fax": null,
|
91 |
+
"address_type": null,
|
92 |
+
"company_name": null
|
93 |
+
},
|
94 |
+
"items":[
|
95 |
+
{
|
96 |
+
"name": "Total Items",
|
97 |
+
"sku": null,
|
98 |
+
"quantity": 1,
|
99 |
+
"grams": ' . $packageWeight . ' ,
|
100 |
+
"price": ' . $packageValue . ',
|
101 |
+
"vendor": null,
|
102 |
+
"requires_shipping": true,
|
103 |
+
"taxable": true,
|
104 |
+
"fulfillment_service": "manual"
|
105 |
+
}
|
106 |
+
],
|
107 |
+
"currency": "' . $packageCurrency->getCurrencyCode() . '",
|
108 |
+
"carrierid": "0"
|
109 |
+
}
|
110 |
+
}';
|
111 |
+
$contentLength = strlen($post_data);
|
112 |
+
|
113 |
+
$ch = curl_init();
|
114 |
+
curl_setopt($ch, CURLOPT_URL, $url);
|
115 |
+
curl_setopt($ch, CURLOPT_HEADER, false);
|
116 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
117 |
+
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
|
118 |
+
curl_setopt($ch, CURLOPT_POST, true);
|
119 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
|
120 |
+
$response = curl_exec($ch);
|
121 |
+
curl_close($ch);
|
122 |
+
|
123 |
+
$json_obj = json_decode($response);
|
124 |
+
$rates_obj = $json_obj->{'rates'};
|
125 |
+
|
126 |
+
$handling = Mage::getStoreConfig('carriers/'.$this->_code.'/handling');
|
127 |
+
$result = Mage::getModel('shipping/rate_result');
|
128 |
+
|
129 |
+
if (sizeof($rates_obj) > 0) {
|
130 |
+
$show = true;
|
131 |
+
}
|
132 |
+
|
133 |
+
if ($show) {
|
134 |
+
foreach ($rates_obj as $rate) {
|
135 |
+
if (is_object($rate)) {
|
136 |
+
// Add shipping option with shipping price
|
137 |
+
$method = Mage::getModel('shipping/rate_result_method');
|
138 |
+
$method->setCarrier($this->_code);
|
139 |
+
$method->setMethod($this->_code . $rate->{'service_code'});
|
140 |
+
$method->setCarrierTitle($this->getConfigData('title'));
|
141 |
+
$method->setMethodTitle($rate->{'service_name'});
|
142 |
+
$method->setPrice($rate->{'total_price'});
|
143 |
+
$method->setCost(0);
|
144 |
+
$result->append($method);
|
145 |
}
|
146 |
+
}
|
147 |
}
|
148 |
+
else {
|
149 |
+
$error = Mage::getModel('shipping/rate_result_error');
|
150 |
+
$error->setCarrier($this->_code);
|
151 |
+
$error->setCarrierTitle($this->getConfigData('name'));
|
152 |
+
$error->setErrorMessage($this->getConfigData('specificerrmsg'));
|
153 |
+
$result->append($error);
|
154 |
+
}
|
155 |
+
}
|
156 |
+
catch (Exception $e) {
|
157 |
+
Mage::log($e->getMessage());
|
158 |
+
}
|
159 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
160 |
|
161 |
+
return $result;
|
162 |
+
}
|
163 |
+
|
164 |
+
public function getAllowedMethods() {
|
165 |
+
return array('courierpost'=>$this->getConfigData('name'));
|
166 |
+
}
|
167 |
|
168 |
+
public function isTrackingAvailable() {
|
169 |
+
return true;
|
170 |
+
}
|
171 |
+
|
172 |
+
public function getTrackingInfo($tracking) {
|
173 |
+
$status = Mage::getModel('shipping/tracking_result_status');
|
174 |
+
$status->setCarrier($this->_code);
|
175 |
+
$status->setCarrierTitle($this->getConfigData('title'));
|
176 |
+
$status->setTracking($tracking);
|
177 |
+
$status->setPopup(1);
|
178 |
+
$status->setUrl("https://www.nzpost.co.nz/tools/tracking/item/".$tracking);
|
179 |
+
return $status;
|
180 |
+
}
|
181 |
}
|
app/code/community/Rvtech/Starshipit/Model/Carrier/Couriersplease.php
CHANGED
@@ -1,167 +1,181 @@
|
|
1 |
<?php
|
2 |
class Rvtech_Starshipit_Model_Carrier_Couriersplease extends Mage_Shipping_Model_Carrier_Abstract
|
3 |
implements Mage_Shipping_Model_Carrier_Interface {
|
4 |
-
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
|
|
|
|
11 |
$price = 0;
|
12 |
$doCalulate = $this->getConfigData('calculate');
|
13 |
-
if ($doCalulate==0)
|
14 |
-
|
15 |
$price = $this->getConfigData('price');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
}
|
17 |
-
else{
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
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 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
],
|
94 |
-
"currency": "' . $packageCurrency->getCurrencyCode() . '",
|
95 |
-
"carrierid": "17"
|
96 |
}
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
$method->setCarrierTitle($this->getConfigData('title'));
|
125 |
-
$method->setMethodTitle($rate->{'service_name'});
|
126 |
-
$method->setPrice($rate->{'total_price'});
|
127 |
-
$method->setCost(0);
|
128 |
-
$result->append($method);
|
129 |
-
}
|
130 |
-
}
|
131 |
-
}
|
132 |
-
}else{
|
133 |
-
$error = Mage::getModel('shipping/rate_result_error');
|
134 |
-
$error->setCarrier($this->_code);
|
135 |
-
$error->setCarrierTitle($this->getConfigData('name'));
|
136 |
-
$error->setErrorMessage($this->getConfigData('specificerrmsg'));
|
137 |
-
$result->append($error);
|
138 |
-
}
|
139 |
}
|
140 |
-
|
141 |
-
|
|
|
|
|
|
|
|
|
142 |
}
|
|
|
|
|
|
|
|
|
143 |
}
|
144 |
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
public function isTrackingAvailable()
|
153 |
-
{
|
154 |
-
return true;
|
155 |
-
}
|
156 |
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
|
|
|
|
|
|
167 |
}
|
1 |
<?php
|
2 |
class Rvtech_Starshipit_Model_Carrier_Couriersplease extends Mage_Shipping_Model_Carrier_Abstract
|
3 |
implements Mage_Shipping_Model_Carrier_Interface {
|
4 |
+
protected $_code = 'couriersplease';
|
5 |
|
6 |
+
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
|
7 |
+
{
|
8 |
+
if (!Mage::getStoreConfig('carriers/'.$this->_code.'/active')) {
|
9 |
+
return false;
|
10 |
+
}
|
11 |
+
|
12 |
+
$show = false;
|
13 |
$price = 0;
|
14 |
$doCalulate = $this->getConfigData('calculate');
|
15 |
+
if ($doCalulate==0) {
|
16 |
+
$show = true;
|
17 |
$price = $this->getConfigData('price');
|
18 |
+
|
19 |
+
$result = Mage::getModel('shipping/rate_result');
|
20 |
+
$method = Mage::getModel('shipping/rate_result_method');
|
21 |
+
$method->setCarrier($this->_code);
|
22 |
+
$method->setMethod($this->_code);
|
23 |
+
$method->setCarrierTitle($this->getConfigData('title'));
|
24 |
+
$method->setMethodTitle($this->getConfigData('name'));
|
25 |
+
$method->setPrice($price);
|
26 |
+
$method->setCost($price);
|
27 |
+
$result->append($method);
|
28 |
}
|
29 |
+
else {
|
30 |
+
try {
|
31 |
+
$shipItApiKey = Mage::helper('shipnote')->getShipItApiKey();
|
32 |
+
if ($shipItApiKey == "") {
|
33 |
+
return false;
|
34 |
+
}
|
35 |
+
|
36 |
+
$origCountryId = $request->getCountryId(); //Package Source Country ID
|
37 |
+
$origRegionId = $request->getRegionId(); //Package Source Region ID
|
38 |
+
$origRegionCode = $request->getRegion(); //Package Source Region Code
|
39 |
+
$origCity = $request->getCity(); //Package Source City
|
40 |
+
$origPostcode = $request->getPostcode(); //Package Source Post Code
|
41 |
+
|
42 |
+
$destCountryId = $request->getDestCountryId();
|
43 |
+
$destCountry = $request->getDestCountry();
|
44 |
+
$destRegion = $request->getDestRegionId();
|
45 |
+
$destRegionCode = $request->getDestRegionCode();
|
46 |
+
$destFullStreet = $request->getDestStreet();
|
47 |
+
$destStreet = "";
|
48 |
+
$destSuburb = "";
|
49 |
+
$destCity = $request->getDestCity();
|
50 |
+
$destPostcode = $request->getDestPostcode();
|
51 |
+
|
52 |
+
$destFullStreetArray = explode("\n", $destFullStreet);
|
53 |
+
if ($destFullStreetArray[0] !== false)
|
54 |
+
$destStreet = $destFullStreetArray[0];
|
55 |
+
if ($destFullStreetArray[1] !== false)
|
56 |
+
$destSuburb = $destFullStreetArray[1];
|
57 |
+
|
58 |
+
$packageValue = $request->getPackageValue(); //Dest Package Value
|
59 |
+
$packageValueDiscout = $request->getPackageValueWithDiscount(); //Dest Package Value After Discount
|
60 |
+
$packageWeight = $request->getPackageWeight() * 1000; //Package Weight (grams)
|
61 |
+
$packageCurrency = $request->getPackageCurrency();
|
62 |
+
|
63 |
+
$url = 'https://api.shipit.click/rate?apiKey=' . $shipItApiKey . '&integration=magento&format=json';
|
64 |
+
$post_data = '{
|
65 |
+
"rate": {
|
66 |
+
"origin": {
|
67 |
+
"country": "' . $origCountryId . '",
|
68 |
+
"postal_code": "' . $origPostcode . '",
|
69 |
+
"province": "' . $origRegionCode . '",
|
70 |
+
"city": "' . $origCity . '",
|
71 |
+
"name": null,
|
72 |
+
"address1": null,
|
73 |
+
"address2": null,
|
74 |
+
"address3": null,
|
75 |
+
"phone": null,
|
76 |
+
"fax": null,
|
77 |
+
"address_type": null,
|
78 |
+
"company_name": null
|
79 |
+
},
|
80 |
+
"destination":{
|
81 |
+
"country": "' . $destCountryId . '",
|
82 |
+
"postal_code": "' . $destPostcode . '",
|
83 |
+
"province": "' . $destRegionCode . '",
|
84 |
+
"city": "' . $destCity . '",
|
85 |
+
"name": null,
|
86 |
+
"address1": "' . $destStreet . '",
|
87 |
+
"address2": "' . $destSuburb . '",
|
88 |
+
"address3": null,
|
89 |
+
"phone": null,
|
90 |
+
"fax": null,
|
91 |
+
"address_type": null,
|
92 |
+
"company_name": null
|
93 |
+
},
|
94 |
+
"items":[
|
95 |
+
{
|
96 |
+
"name": "Total Items",
|
97 |
+
"sku": null,
|
98 |
+
"quantity": 1,
|
99 |
+
"grams": ' . $packageWeight . ' ,
|
100 |
+
"price": ' . $packageValue . ',
|
101 |
+
"vendor": null,
|
102 |
+
"requires_shipping": true,
|
103 |
+
"taxable": true,
|
104 |
+
"fulfillment_service": "manual"
|
|
|
|
|
|
|
105 |
}
|
106 |
+
],
|
107 |
+
"currency": "' . $packageCurrency->getCurrencyCode() . '",
|
108 |
+
"carrierid": "17"
|
109 |
+
}
|
110 |
+
}';
|
111 |
+
$contentLength = strlen($post_data);
|
112 |
+
|
113 |
+
$ch = curl_init();
|
114 |
+
curl_setopt($ch, CURLOPT_URL, $url);
|
115 |
+
curl_setopt($ch, CURLOPT_HEADER, false);
|
116 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
117 |
+
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
|
118 |
+
curl_setopt($ch, CURLOPT_POST, true);
|
119 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
|
120 |
+
$response = curl_exec($ch);
|
121 |
+
curl_close($ch);
|
122 |
+
|
123 |
+
$json_obj = json_decode($response);
|
124 |
+
$rates_obj = $json_obj->{'rates'};
|
125 |
+
|
126 |
+
$handling = Mage::getStoreConfig('carriers/'.$this->_code.'/handling');
|
127 |
+
$result = Mage::getModel('shipping/rate_result');
|
128 |
+
|
129 |
+
if (sizeof($rates_obj) > 0) {
|
130 |
+
$show = true;
|
131 |
+
}
|
132 |
|
133 |
+
if ($show) {
|
134 |
+
foreach ($rates_obj as $rate) {
|
135 |
+
if (is_object($rate)) {
|
136 |
+
// Add shipping option with shipping price
|
137 |
+
$method = Mage::getModel('shipping/rate_result_method');
|
138 |
+
$method->setCarrier($this->_code);
|
139 |
+
$method->setMethod($this->_code . $rate->{'service_code'});
|
140 |
+
$method->setCarrierTitle($this->getConfigData('title'));
|
141 |
+
$method->setMethodTitle($rate->{'service_name'});
|
142 |
+
$method->setPrice($rate->{'total_price'});
|
143 |
+
$method->setCost(0);
|
144 |
+
$result->append($method);
|
145 |
+
}
|
146 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
147 |
}
|
148 |
+
else {
|
149 |
+
$error = Mage::getModel('shipping/rate_result_error');
|
150 |
+
$error->setCarrier($this->_code);
|
151 |
+
$error->setCarrierTitle($this->getConfigData('name'));
|
152 |
+
$error->setErrorMessage($this->getConfigData('specificerrmsg'));
|
153 |
+
$result->append($error);
|
154 |
}
|
155 |
+
}
|
156 |
+
catch (Exception $e) {
|
157 |
+
Mage::log($e->getMessage());
|
158 |
+
}
|
159 |
}
|
160 |
|
161 |
+
return $result;
|
162 |
+
}
|
163 |
+
|
164 |
+
public function getAllowedMethods() {
|
165 |
+
return array('couriersplease'=>$this->getConfigData('name'));
|
166 |
+
}
|
|
|
|
|
|
|
|
|
|
|
167 |
|
168 |
+
public function isTrackingAvailable() {
|
169 |
+
return true;
|
170 |
+
}
|
171 |
+
|
172 |
+
public function getTrackingInfo($tracking) {
|
173 |
+
$status = Mage::getModel('shipping/tracking_result_status');
|
174 |
+
$status->setCarrier($this->_code);
|
175 |
+
$status->setCarrierTitle($this->getConfigData('title'));
|
176 |
+
$status->setTracking($tracking);
|
177 |
+
$status->setPopup(1);
|
178 |
+
$status->setUrl("http://www2.couriersplease.com.au/37:ezytrak-results?couponid=".$tracking);
|
179 |
+
return $status;
|
180 |
+
}
|
181 |
}
|
app/code/community/Rvtech/Starshipit/Model/Carrier/Dhlexpress.php
CHANGED
@@ -1,127 +1,181 @@
|
|
1 |
<?php
|
2 |
class Rvtech_Starshipit_Model_Carrier_Dhlexpress extends Mage_Shipping_Model_Carrier_Abstract
|
3 |
implements Mage_Shipping_Model_Carrier_Interface {
|
4 |
-
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
}
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
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 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
}
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
|
|
111 |
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
|
|
|
|
116 |
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
|
|
|
|
|
1 |
<?php
|
2 |
class Rvtech_Starshipit_Model_Carrier_Dhlexpress extends Mage_Shipping_Model_Carrier_Abstract
|
3 |
implements Mage_Shipping_Model_Carrier_Interface {
|
4 |
+
protected $_code = 'dhlexpress';
|
5 |
|
6 |
+
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
|
7 |
+
{
|
8 |
+
if (!Mage::getStoreConfig('carriers/'.$this->_code.'/active')) {
|
9 |
+
return false;
|
10 |
+
}
|
11 |
+
|
12 |
+
$show = false;
|
13 |
+
$price = 0;
|
14 |
+
$doCalulate = $this->getConfigData('calculate');
|
15 |
+
if ($doCalulate==0) {
|
16 |
+
$show = true;
|
17 |
+
$price = $this->getConfigData('price');
|
18 |
+
|
19 |
+
$result = Mage::getModel('shipping/rate_result');
|
20 |
+
$method = Mage::getModel('shipping/rate_result_method');
|
21 |
+
$method->setCarrier($this->_code);
|
22 |
+
$method->setMethod($this->_code);
|
23 |
+
$method->setCarrierTitle($this->getConfigData('title'));
|
24 |
+
$method->setMethodTitle($this->getConfigData('name'));
|
25 |
+
$method->setPrice($price);
|
26 |
+
$method->setCost($price);
|
27 |
+
$result->append($method);
|
28 |
+
}
|
29 |
+
else {
|
30 |
+
try {
|
31 |
+
$shipItApiKey = Mage::helper('shipnote')->getShipItApiKey();
|
32 |
+
if ($shipItApiKey == "") {
|
33 |
+
return false;
|
34 |
}
|
35 |
+
|
36 |
+
$origCountryId = $request->getCountryId(); //Package Source Country ID
|
37 |
+
$origRegionId = $request->getRegionId(); //Package Source Region ID
|
38 |
+
$origRegionCode = $request->getRegion(); //Package Source Region Code
|
39 |
+
$origCity = $request->getCity(); //Package Source City
|
40 |
+
$origPostcode = $request->getPostcode(); //Package Source Post Code
|
41 |
+
|
42 |
+
$destCountryId = $request->getDestCountryId();
|
43 |
+
$destCountry = $request->getDestCountry();
|
44 |
+
$destRegion = $request->getDestRegionId();
|
45 |
+
$destRegionCode = $request->getDestRegionCode();
|
46 |
+
$destFullStreet = $request->getDestStreet();
|
47 |
+
$destStreet = "";
|
48 |
+
$destSuburb = "";
|
49 |
+
$destCity = $request->getDestCity();
|
50 |
+
$destPostcode = $request->getDestPostcode();
|
51 |
+
|
52 |
+
$destFullStreetArray = explode("\n", $destFullStreet);
|
53 |
+
if ($destFullStreetArray[0] !== false)
|
54 |
+
$destStreet = $destFullStreetArray[0];
|
55 |
+
if ($destFullStreetArray[1] !== false)
|
56 |
+
$destSuburb = $destFullStreetArray[1];
|
57 |
+
|
58 |
+
$packageValue = $request->getPackageValue(); //Dest Package Value
|
59 |
+
$packageValueDiscout = $request->getPackageValueWithDiscount(); //Dest Package Value After Discount
|
60 |
+
$packageWeight = $request->getPackageWeight() * 1000; //Package Weight (grams)
|
61 |
+
$packageCurrency = $request->getPackageCurrency();
|
62 |
+
|
63 |
+
$url = 'https://api.shipit.click/rate?apiKey=' . $shipItApiKey . '&integration=magento&format=json';
|
64 |
+
$post_data = '{
|
65 |
+
"rate": {
|
66 |
+
"origin": {
|
67 |
+
"country": "' . $origCountryId . '",
|
68 |
+
"postal_code": "' . $origPostcode . '",
|
69 |
+
"province": "' . $origRegionCode . '",
|
70 |
+
"city": "' . $origCity . '",
|
71 |
+
"name": null,
|
72 |
+
"address1": null,
|
73 |
+
"address2": null,
|
74 |
+
"address3": null,
|
75 |
+
"phone": null,
|
76 |
+
"fax": null,
|
77 |
+
"address_type": null,
|
78 |
+
"company_name": null
|
79 |
+
},
|
80 |
+
"destination":{
|
81 |
+
"country": "' . $destCountryId . '",
|
82 |
+
"postal_code": "' . $destPostcode . '",
|
83 |
+
"province": "' . $destRegionCode . '",
|
84 |
+
"city": "' . $destCity . '",
|
85 |
+
"name": null,
|
86 |
+
"address1": "' . $destStreet . '",
|
87 |
+
"address2": "' . $destSuburb . '",
|
88 |
+
"address3": null,
|
89 |
+
"phone": null,
|
90 |
+
"fax": null,
|
91 |
+
"address_type": null,
|
92 |
+
"company_name": null
|
93 |
+
},
|
94 |
+
"items":[
|
95 |
+
{
|
96 |
+
"name": "Total Items",
|
97 |
+
"sku": null,
|
98 |
+
"quantity": 1,
|
99 |
+
"grams": ' . $packageWeight . ' ,
|
100 |
+
"price": ' . $packageValue . ',
|
101 |
+
"vendor": null,
|
102 |
+
"requires_shipping": true,
|
103 |
+
"taxable": true,
|
104 |
+
"fulfillment_service": "manual"
|
105 |
+
}
|
106 |
+
],
|
107 |
+
"currency": "' . $packageCurrency->getCurrencyCode() . '",
|
108 |
+
"carrierid": "2"
|
109 |
+
}
|
110 |
+
}';
|
111 |
+
$contentLength = strlen($post_data);
|
112 |
+
|
113 |
+
$ch = curl_init();
|
114 |
+
curl_setopt($ch, CURLOPT_URL, $url);
|
115 |
+
curl_setopt($ch, CURLOPT_HEADER, false);
|
116 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
117 |
+
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
|
118 |
+
curl_setopt($ch, CURLOPT_POST, true);
|
119 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
|
120 |
+
$response = curl_exec($ch);
|
121 |
+
curl_close($ch);
|
122 |
+
|
123 |
+
$json_obj = json_decode($response);
|
124 |
+
$rates_obj = $json_obj->{'rates'};
|
125 |
+
|
126 |
+
$handling = Mage::getStoreConfig('carriers/'.$this->_code.'/handling');
|
127 |
+
$result = Mage::getModel('shipping/rate_result');
|
128 |
+
|
129 |
+
if (sizeof($rates_obj) > 0) {
|
130 |
+
$show = true;
|
131 |
}
|
132 |
+
|
133 |
+
if ($show) {
|
134 |
+
foreach ($rates_obj as $rate) {
|
135 |
+
if (is_object($rate)) {
|
136 |
+
// Add shipping option with shipping price
|
137 |
+
$method = Mage::getModel('shipping/rate_result_method');
|
138 |
+
$method->setCarrier($this->_code);
|
139 |
+
$method->setMethod($this->_code . $rate->{'service_code'});
|
140 |
+
$method->setCarrierTitle($this->getConfigData('title'));
|
141 |
+
$method->setMethodTitle($rate->{'service_name'});
|
142 |
+
$method->setPrice($rate->{'total_price'});
|
143 |
+
$method->setCost(0);
|
144 |
+
$result->append($method);
|
145 |
+
}
|
146 |
+
}
|
147 |
+
}
|
148 |
+
else {
|
149 |
+
$error = Mage::getModel('shipping/rate_result_error');
|
150 |
+
$error->setCarrier($this->_code);
|
151 |
+
$error->setCarrierTitle($this->getConfigData('name'));
|
152 |
+
$error->setErrorMessage($this->getConfigData('specificerrmsg'));
|
153 |
+
$result->append($error);
|
154 |
+
}
|
155 |
+
}
|
156 |
+
catch (Exception $e) {
|
157 |
+
Mage::log($e->getMessage());
|
158 |
+
}
|
159 |
+
}
|
160 |
|
161 |
+
return $result;
|
162 |
+
}
|
163 |
+
|
164 |
+
public function getAllowedMethods() {
|
165 |
+
return array('dhlexpress'=>$this->getConfigData('name'));
|
166 |
+
}
|
167 |
|
168 |
+
public function isTrackingAvailable() {
|
169 |
+
return true;
|
170 |
+
}
|
171 |
+
|
172 |
+
public function getTrackingInfo($tracking) {
|
173 |
+
$status = Mage::getModel('shipping/tracking_result_status');
|
174 |
+
$status->setCarrier($this->_code);
|
175 |
+
$status->setCarrierTitle($this->getConfigData('title'));
|
176 |
+
$status->setTracking($tracking);
|
177 |
+
$status->setPopup(1);
|
178 |
+
$status->setUrl("http://www.dhl.com/cgi-bin/tracking.pl?AWB=".$tracking);
|
179 |
+
return $status;
|
180 |
+
}
|
181 |
+
}
|
app/code/community/Rvtech/Starshipit/Model/Carrier/Fastway.php
CHANGED
@@ -1,106 +1,181 @@
|
|
1 |
<?php
|
2 |
class Rvtech_Starshipit_Model_Carrier_Fastway extends Mage_Shipping_Model_Carrier_Abstract
|
3 |
implements Mage_Shipping_Model_Carrier_Interface {
|
4 |
-
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
"carrierid"=>3,
|
35 |
-
"street"=>$destStreet,
|
36 |
-
"suburb"=>"",
|
37 |
-
"city"=> $destCity,
|
38 |
-
"postcode"=>$destPostcode,
|
39 |
-
"state"=>$destRegion,
|
40 |
-
"country"=>$destCountry,
|
41 |
-
"countryId"=>$destCountryId,
|
42 |
-
"weight"=>$packageWeight,
|
43 |
-
"height"=>$packageheight,
|
44 |
-
"width"=>$packagewidth,
|
45 |
-
"depth"=>$packagedepth
|
46 |
-
);
|
47 |
-
|
48 |
-
// Call web service.
|
49 |
-
$wsdl = 'https://app.shipit.click/shipment.svc?WSDL';
|
50 |
-
$client = new SoapClient($wsdl, array(
|
51 |
-
'cache_wsdl' => WSDL_CACHE_NONE,
|
52 |
-
'cache_ttl' => 86400,
|
53 |
-
'trace' => true,
|
54 |
-
'exceptions' => true,
|
55 |
-
));
|
56 |
-
|
57 |
-
$result = $client->__soapCall("GetQuote", array($params));
|
58 |
-
$quoteResponse = $result->GetQuoteResult;
|
59 |
-
//Mage::log("Price web:".$quoteResponse->Price, null, ShipIt.log);
|
60 |
-
$price = $quoteResponse->Price;
|
61 |
}
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
90 |
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
|
|
|
|
95 |
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
|
|
|
|
|
1 |
<?php
|
2 |
class Rvtech_Starshipit_Model_Carrier_Fastway extends Mage_Shipping_Model_Carrier_Abstract
|
3 |
implements Mage_Shipping_Model_Carrier_Interface {
|
4 |
+
protected $_code = 'fastway';
|
5 |
|
6 |
+
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
|
7 |
+
{
|
8 |
+
if (!Mage::getStoreConfig('carriers/'.$this->_code.'/active')) {
|
9 |
+
return false;
|
10 |
+
}
|
11 |
+
|
12 |
+
$show = false;
|
13 |
+
$price = 0;
|
14 |
+
$doCalulate = $this->getConfigData('calculate');
|
15 |
+
if ($doCalulate==0) {
|
16 |
+
$show = true;
|
17 |
+
$price = $this->getConfigData('price');
|
18 |
+
|
19 |
+
$result = Mage::getModel('shipping/rate_result');
|
20 |
+
$method = Mage::getModel('shipping/rate_result_method');
|
21 |
+
$method->setCarrier($this->_code);
|
22 |
+
$method->setMethod($this->_code);
|
23 |
+
$method->setCarrierTitle($this->getConfigData('title'));
|
24 |
+
$method->setMethodTitle($this->getConfigData('name'));
|
25 |
+
$method->setPrice($price);
|
26 |
+
$method->setCost($price);
|
27 |
+
$result->append($method);
|
28 |
+
}
|
29 |
+
else {
|
30 |
+
try {
|
31 |
+
$shipItApiKey = Mage::helper('shipnote')->getShipItApiKey();
|
32 |
+
if ($shipItApiKey == "") {
|
33 |
+
return false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
}
|
35 |
+
|
36 |
+
$origCountryId = $request->getCountryId(); //Package Source Country ID
|
37 |
+
$origRegionId = $request->getRegionId(); //Package Source Region ID
|
38 |
+
$origRegionCode = $request->getRegion(); //Package Source Region Code
|
39 |
+
$origCity = $request->getCity(); //Package Source City
|
40 |
+
$origPostcode = $request->getPostcode(); //Package Source Post Code
|
41 |
+
|
42 |
+
$destCountryId = $request->getDestCountryId();
|
43 |
+
$destCountry = $request->getDestCountry();
|
44 |
+
$destRegion = $request->getDestRegionId();
|
45 |
+
$destRegionCode = $request->getDestRegionCode();
|
46 |
+
$destFullStreet = $request->getDestStreet();
|
47 |
+
$destStreet = "";
|
48 |
+
$destSuburb = "";
|
49 |
+
$destCity = $request->getDestCity();
|
50 |
+
$destPostcode = $request->getDestPostcode();
|
51 |
+
|
52 |
+
$destFullStreetArray = explode("\n", $destFullStreet);
|
53 |
+
if ($destFullStreetArray[0] !== false)
|
54 |
+
$destStreet = $destFullStreetArray[0];
|
55 |
+
if ($destFullStreetArray[1] !== false)
|
56 |
+
$destSuburb = $destFullStreetArray[1];
|
57 |
+
|
58 |
+
$packageValue = $request->getPackageValue(); //Dest Package Value
|
59 |
+
$packageValueDiscout = $request->getPackageValueWithDiscount(); //Dest Package Value After Discount
|
60 |
+
$packageWeight = $request->getPackageWeight() * 1000; //Package Weight (grams)
|
61 |
+
$packageCurrency = $request->getPackageCurrency();
|
62 |
+
|
63 |
+
$url = 'https://api.shipit.click/rate?apiKey=' . $shipItApiKey . '&integration=magento&format=json';
|
64 |
+
$post_data = '{
|
65 |
+
"rate": {
|
66 |
+
"origin": {
|
67 |
+
"country": "' . $origCountryId . '",
|
68 |
+
"postal_code": "' . $origPostcode . '",
|
69 |
+
"province": "' . $origRegionCode . '",
|
70 |
+
"city": "' . $origCity . '",
|
71 |
+
"name": null,
|
72 |
+
"address1": null,
|
73 |
+
"address2": null,
|
74 |
+
"address3": null,
|
75 |
+
"phone": null,
|
76 |
+
"fax": null,
|
77 |
+
"address_type": null,
|
78 |
+
"company_name": null
|
79 |
+
},
|
80 |
+
"destination":{
|
81 |
+
"country": "' . $destCountryId . '",
|
82 |
+
"postal_code": "' . $destPostcode . '",
|
83 |
+
"province": "' . $destRegionCode . '",
|
84 |
+
"city": "' . $destCity . '",
|
85 |
+
"name": null,
|
86 |
+
"address1": "' . $destStreet . '",
|
87 |
+
"address2": "' . $destSuburb . '",
|
88 |
+
"address3": null,
|
89 |
+
"phone": null,
|
90 |
+
"fax": null,
|
91 |
+
"address_type": null,
|
92 |
+
"company_name": null
|
93 |
+
},
|
94 |
+
"items":[
|
95 |
+
{
|
96 |
+
"name": "Total Items",
|
97 |
+
"sku": null,
|
98 |
+
"quantity": 1,
|
99 |
+
"grams": ' . $packageWeight . ' ,
|
100 |
+
"price": ' . $packageValue . ',
|
101 |
+
"vendor": null,
|
102 |
+
"requires_shipping": true,
|
103 |
+
"taxable": true,
|
104 |
+
"fulfillment_service": "manual"
|
105 |
+
}
|
106 |
+
],
|
107 |
+
"currency": "' . $packageCurrency->getCurrencyCode() . '",
|
108 |
+
"carrierid": "3"
|
109 |
+
}
|
110 |
+
}';
|
111 |
+
$contentLength = strlen($post_data);
|
112 |
+
|
113 |
+
$ch = curl_init();
|
114 |
+
curl_setopt($ch, CURLOPT_URL, $url);
|
115 |
+
curl_setopt($ch, CURLOPT_HEADER, false);
|
116 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
117 |
+
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
|
118 |
+
curl_setopt($ch, CURLOPT_POST, true);
|
119 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
|
120 |
+
$response = curl_exec($ch);
|
121 |
+
curl_close($ch);
|
122 |
+
|
123 |
+
$json_obj = json_decode($response);
|
124 |
+
$rates_obj = $json_obj->{'rates'};
|
125 |
+
|
126 |
+
$handling = Mage::getStoreConfig('carriers/'.$this->_code.'/handling');
|
127 |
+
$result = Mage::getModel('shipping/rate_result');
|
128 |
+
|
129 |
+
if (sizeof($rates_obj) > 0) {
|
130 |
+
$show = true;
|
131 |
+
}
|
132 |
+
|
133 |
+
if ($show) {
|
134 |
+
foreach ($rates_obj as $rate) {
|
135 |
+
if (is_object($rate)) {
|
136 |
+
// Add shipping option with shipping price
|
137 |
+
$method = Mage::getModel('shipping/rate_result_method');
|
138 |
+
$method->setCarrier($this->_code);
|
139 |
+
$method->setMethod($this->_code . $rate->{'service_code'});
|
140 |
+
$method->setCarrierTitle($this->getConfigData('title'));
|
141 |
+
$method->setMethodTitle($rate->{'service_name'});
|
142 |
+
$method->setPrice($rate->{'total_price'});
|
143 |
+
$method->setCost(0);
|
144 |
+
$result->append($method);
|
145 |
+
}
|
146 |
+
}
|
147 |
+
}
|
148 |
+
else {
|
149 |
+
$error = Mage::getModel('shipping/rate_result_error');
|
150 |
+
$error->setCarrier($this->_code);
|
151 |
+
$error->setCarrierTitle($this->getConfigData('name'));
|
152 |
+
$error->setErrorMessage($this->getConfigData('specificerrmsg'));
|
153 |
+
$result->append($error);
|
154 |
+
}
|
155 |
+
}
|
156 |
+
catch (Exception $e) {
|
157 |
+
Mage::log($e->getMessage());
|
158 |
+
}
|
159 |
+
}
|
160 |
|
161 |
+
return $result;
|
162 |
+
}
|
163 |
+
|
164 |
+
public function getAllowedMethods() {
|
165 |
+
return array('fastway'=>$this->getConfigData('name'));
|
166 |
+
}
|
167 |
|
168 |
+
public function isTrackingAvailable() {
|
169 |
+
return true;
|
170 |
+
}
|
171 |
+
|
172 |
+
public function getTrackingInfo($tracking) {
|
173 |
+
$status = Mage::getModel('shipping/tracking_result_status');
|
174 |
+
$status->setCarrier($this->_code);
|
175 |
+
$status->setCarrierTitle($this->getConfigData('title'));
|
176 |
+
$status->setTracking($tracking);
|
177 |
+
$status->setPopup(1);
|
178 |
+
$status->setUrl("http://www.fastway.com.au/courier-services/track-your-parcel?l=".$tracking);
|
179 |
+
return $status;
|
180 |
+
}
|
181 |
+
}
|
app/code/community/Rvtech/Starshipit/Model/Carrier/Nzpost.php
CHANGED
@@ -1,112 +1,181 @@
|
|
1 |
<?php
|
2 |
class Rvtech_Starshipit_Model_Carrier_Nzpost extends Mage_Shipping_Model_Carrier_Abstract
|
3 |
implements Mage_Shipping_Model_Carrier_Interface {
|
4 |
-
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
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 |
}
|
|
|
67 |
}
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
$method->setCost($price);
|
81 |
-
$result->append($method);
|
82 |
-
|
83 |
-
}else{
|
84 |
-
$error = Mage::getModel('shipping/rate_result_error');
|
85 |
-
$error->setCarrier($this->_code);
|
86 |
-
$error->setCarrierTitle($this->getConfigData('name'));
|
87 |
-
$error->setErrorMessage($this->getConfigData('specificerrmsg'));
|
88 |
-
$result->append($error);
|
89 |
-
}
|
90 |
-
return $result;
|
91 |
-
}
|
92 |
-
public function getAllowedMethods()
|
93 |
-
{
|
94 |
-
return array('nzpost'=>$this->getConfigData('name'));
|
95 |
-
}
|
96 |
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
|
|
|
|
101 |
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
|
|
|
|
|
|
112 |
}
|
1 |
<?php
|
2 |
class Rvtech_Starshipit_Model_Carrier_Nzpost extends Mage_Shipping_Model_Carrier_Abstract
|
3 |
implements Mage_Shipping_Model_Carrier_Interface {
|
4 |
+
protected $_code = 'nzpost';
|
5 |
|
6 |
+
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
|
7 |
+
{
|
8 |
+
if (!Mage::getStoreConfig('carriers/'.$this->_code.'/active')) {
|
9 |
+
return false;
|
10 |
+
}
|
11 |
+
|
12 |
+
$show = false;
|
13 |
+
$price = 0;
|
14 |
+
$doCalulate = $this->getConfigData('calculate');
|
15 |
+
if ($doCalulate==0) {
|
16 |
+
$show = true;
|
17 |
+
$price = $this->getConfigData('price');
|
18 |
+
|
19 |
+
$result = Mage::getModel('shipping/rate_result');
|
20 |
+
$method = Mage::getModel('shipping/rate_result_method');
|
21 |
+
$method->setCarrier($this->_code);
|
22 |
+
$method->setMethod($this->_code);
|
23 |
+
$method->setCarrierTitle($this->getConfigData('title'));
|
24 |
+
$method->setMethodTitle($this->getConfigData('name'));
|
25 |
+
$method->setPrice($price);
|
26 |
+
$method->setCost($price);
|
27 |
+
$result->append($method);
|
28 |
+
}
|
29 |
+
else {
|
30 |
+
try {
|
31 |
+
$shipItApiKey = Mage::helper('shipnote')->getShipItApiKey();
|
32 |
+
if ($shipItApiKey == "") {
|
33 |
+
return false;
|
34 |
+
}
|
35 |
+
|
36 |
+
$origCountryId = $request->getCountryId(); //Package Source Country ID
|
37 |
+
$origRegionId = $request->getRegionId(); //Package Source Region ID
|
38 |
+
$origRegionCode = $request->getRegion(); //Package Source Region Code
|
39 |
+
$origCity = $request->getCity(); //Package Source City
|
40 |
+
$origPostcode = $request->getPostcode(); //Package Source Post Code
|
41 |
+
|
42 |
+
$destCountryId = $request->getDestCountryId();
|
43 |
+
$destCountry = $request->getDestCountry();
|
44 |
+
$destRegion = $request->getDestRegionId();
|
45 |
+
$destRegionCode = $request->getDestRegionCode();
|
46 |
+
$destFullStreet = $request->getDestStreet();
|
47 |
+
$destStreet = "";
|
48 |
+
$destSuburb = "";
|
49 |
+
$destCity = $request->getDestCity();
|
50 |
+
$destPostcode = $request->getDestPostcode();
|
51 |
+
|
52 |
+
$destFullStreetArray = explode("\n", $destFullStreet);
|
53 |
+
if ($destFullStreetArray[0] !== false)
|
54 |
+
$destStreet = $destFullStreetArray[0];
|
55 |
+
if ($destFullStreetArray[1] !== false)
|
56 |
+
$destSuburb = $destFullStreetArray[1];
|
57 |
+
|
58 |
+
$packageValue = $request->getPackageValue(); //Dest Package Value
|
59 |
+
$packageValueDiscout = $request->getPackageValueWithDiscount(); //Dest Package Value After Discount
|
60 |
+
$packageWeight = $request->getPackageWeight() * 1000; //Package Weight (grams)
|
61 |
+
$packageCurrency = $request->getPackageCurrency();
|
62 |
+
|
63 |
+
$url = 'https://api.shipit.click/rate?apiKey=' . $shipItApiKey . '&integration=magento&format=json';
|
64 |
+
$post_data = '{
|
65 |
+
"rate": {
|
66 |
+
"origin": {
|
67 |
+
"country": "' . $origCountryId . '",
|
68 |
+
"postal_code": "' . $origPostcode . '",
|
69 |
+
"province": "' . $origRegionCode . '",
|
70 |
+
"city": "' . $origCity . '",
|
71 |
+
"name": null,
|
72 |
+
"address1": null,
|
73 |
+
"address2": null,
|
74 |
+
"address3": null,
|
75 |
+
"phone": null,
|
76 |
+
"fax": null,
|
77 |
+
"address_type": null,
|
78 |
+
"company_name": null
|
79 |
+
},
|
80 |
+
"destination":{
|
81 |
+
"country": "' . $destCountryId . '",
|
82 |
+
"postal_code": "' . $destPostcode . '",
|
83 |
+
"province": "' . $destRegionCode . '",
|
84 |
+
"city": "' . $destCity . '",
|
85 |
+
"name": null,
|
86 |
+
"address1": "' . $destStreet . '",
|
87 |
+
"address2": "' . $destSuburb . '",
|
88 |
+
"address3": null,
|
89 |
+
"phone": null,
|
90 |
+
"fax": null,
|
91 |
+
"address_type": null,
|
92 |
+
"company_name": null
|
93 |
+
},
|
94 |
+
"items":[
|
95 |
+
{
|
96 |
+
"name": "Total Items",
|
97 |
+
"sku": null,
|
98 |
+
"quantity": 1,
|
99 |
+
"grams": ' . $packageWeight . ' ,
|
100 |
+
"price": ' . $packageValue . ',
|
101 |
+
"vendor": null,
|
102 |
+
"requires_shipping": true,
|
103 |
+
"taxable": true,
|
104 |
+
"fulfillment_service": "manual"
|
105 |
+
}
|
106 |
+
],
|
107 |
+
"currency": "' . $packageCurrency->getCurrencyCode() . '",
|
108 |
+
"carrierid": "1"
|
109 |
+
}
|
110 |
+
}';
|
111 |
+
$contentLength = strlen($post_data);
|
112 |
+
|
113 |
+
$ch = curl_init();
|
114 |
+
curl_setopt($ch, CURLOPT_URL, $url);
|
115 |
+
curl_setopt($ch, CURLOPT_HEADER, false);
|
116 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
117 |
+
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
|
118 |
+
curl_setopt($ch, CURLOPT_POST, true);
|
119 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
|
120 |
+
$response = curl_exec($ch);
|
121 |
+
curl_close($ch);
|
122 |
+
|
123 |
+
$json_obj = json_decode($response);
|
124 |
+
$rates_obj = $json_obj->{'rates'};
|
125 |
+
|
126 |
+
$handling = Mage::getStoreConfig('carriers/'.$this->_code.'/handling');
|
127 |
+
$result = Mage::getModel('shipping/rate_result');
|
128 |
+
|
129 |
+
if (sizeof($rates_obj) > 0) {
|
130 |
+
$show = true;
|
131 |
+
}
|
132 |
+
|
133 |
+
if ($show) {
|
134 |
+
foreach ($rates_obj as $rate) {
|
135 |
+
if (is_object($rate)) {
|
136 |
+
// Add shipping option with shipping price
|
137 |
+
$method = Mage::getModel('shipping/rate_result_method');
|
138 |
+
$method->setCarrier($this->_code);
|
139 |
+
$method->setMethod($this->_code . $rate->{'service_code'});
|
140 |
+
$method->setCarrierTitle($this->getConfigData('title'));
|
141 |
+
$method->setMethodTitle($rate->{'service_name'});
|
142 |
+
$method->setPrice($rate->{'total_price'});
|
143 |
+
$method->setCost(0);
|
144 |
+
$result->append($method);
|
145 |
}
|
146 |
+
}
|
147 |
}
|
148 |
+
else {
|
149 |
+
$error = Mage::getModel('shipping/rate_result_error');
|
150 |
+
$error->setCarrier($this->_code);
|
151 |
+
$error->setCarrierTitle($this->getConfigData('name'));
|
152 |
+
$error->setErrorMessage($this->getConfigData('specificerrmsg'));
|
153 |
+
$result->append($error);
|
154 |
+
}
|
155 |
+
}
|
156 |
+
catch (Exception $e) {
|
157 |
+
Mage::log($e->getMessage());
|
158 |
+
}
|
159 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
160 |
|
161 |
+
return $result;
|
162 |
+
}
|
163 |
+
|
164 |
+
public function getAllowedMethods() {
|
165 |
+
return array('nzpost'=>$this->getConfigData('name'));
|
166 |
+
}
|
167 |
|
168 |
+
public function isTrackingAvailable() {
|
169 |
+
return true;
|
170 |
+
}
|
171 |
+
|
172 |
+
public function getTrackingInfo($tracking) {
|
173 |
+
$status = Mage::getModel('shipping/tracking_result_status');
|
174 |
+
$status->setCarrier($this->_code);
|
175 |
+
$status->setCarrierTitle($this->getConfigData('title'));
|
176 |
+
$status->setTracking($tracking);
|
177 |
+
$status->setPopup(1);
|
178 |
+
$status->setUrl("https://www.nzpost.co.nz/tools/tracking/item/".$tracking);
|
179 |
+
return $status;
|
180 |
+
}
|
181 |
}
|
app/code/community/Rvtech/Starshipit/Model/Carrier/Pace.php
CHANGED
@@ -1,167 +1,181 @@
|
|
1 |
<?php
|
2 |
class Rvtech_Starshipit_Model_Carrier_Pace extends Mage_Shipping_Model_Carrier_Abstract
|
3 |
implements Mage_Shipping_Model_Carrier_Interface {
|
4 |
-
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
|
|
|
|
11 |
$price = 0;
|
12 |
$doCalulate = $this->getConfigData('calculate');
|
13 |
-
if ($doCalulate==0)
|
14 |
-
|
15 |
$price = $this->getConfigData('price');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
}
|
17 |
-
else{
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
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 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
],
|
94 |
-
"currency": "' . $packageCurrency->getCurrencyCode() . '",
|
95 |
-
"carrierid": "19"
|
96 |
}
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
$method->setCarrierTitle($this->getConfigData('title'));
|
125 |
-
$method->setMethodTitle($rate->{'service_name'});
|
126 |
-
$method->setPrice($rate->{'total_price'});
|
127 |
-
$method->setCost(0);
|
128 |
-
$result->append($method);
|
129 |
-
}
|
130 |
-
}
|
131 |
-
}
|
132 |
-
}else{
|
133 |
-
$error = Mage::getModel('shipping/rate_result_error');
|
134 |
-
$error->setCarrier($this->_code);
|
135 |
-
$error->setCarrierTitle($this->getConfigData('name'));
|
136 |
-
$error->setErrorMessage($this->getConfigData('specificerrmsg'));
|
137 |
-
$result->append($error);
|
138 |
-
}
|
139 |
}
|
140 |
-
|
141 |
-
|
|
|
|
|
|
|
|
|
142 |
}
|
|
|
|
|
|
|
|
|
143 |
}
|
144 |
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
public function isTrackingAvailable()
|
153 |
-
{
|
154 |
-
return true;
|
155 |
-
}
|
156 |
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
|
|
|
|
|
|
167 |
}
|
1 |
<?php
|
2 |
class Rvtech_Starshipit_Model_Carrier_Pace extends Mage_Shipping_Model_Carrier_Abstract
|
3 |
implements Mage_Shipping_Model_Carrier_Interface {
|
4 |
+
protected $_code = 'pace';
|
5 |
|
6 |
+
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
|
7 |
+
{
|
8 |
+
if (!Mage::getStoreConfig('carriers/'.$this->_code.'/active')) {
|
9 |
+
return false;
|
10 |
+
}
|
11 |
+
|
12 |
+
$show = false;
|
13 |
$price = 0;
|
14 |
$doCalulate = $this->getConfigData('calculate');
|
15 |
+
if ($doCalulate==0) {
|
16 |
+
$show = true;
|
17 |
$price = $this->getConfigData('price');
|
18 |
+
|
19 |
+
$result = Mage::getModel('shipping/rate_result');
|
20 |
+
$method = Mage::getModel('shipping/rate_result_method');
|
21 |
+
$method->setCarrier($this->_code);
|
22 |
+
$method->setMethod($this->_code);
|
23 |
+
$method->setCarrierTitle($this->getConfigData('title'));
|
24 |
+
$method->setMethodTitle($this->getConfigData('name'));
|
25 |
+
$method->setPrice($price);
|
26 |
+
$method->setCost($price);
|
27 |
+
$result->append($method);
|
28 |
}
|
29 |
+
else {
|
30 |
+
try {
|
31 |
+
$shipItApiKey = Mage::helper('shipnote')->getShipItApiKey();
|
32 |
+
if ($shipItApiKey == "") {
|
33 |
+
return false;
|
34 |
+
}
|
35 |
+
|
36 |
+
$origCountryId = $request->getCountryId(); //Package Source Country ID
|
37 |
+
$origRegionId = $request->getRegionId(); //Package Source Region ID
|
38 |
+
$origRegionCode = $request->getRegion(); //Package Source Region Code
|
39 |
+
$origCity = $request->getCity(); //Package Source City
|
40 |
+
$origPostcode = $request->getPostcode(); //Package Source Post Code
|
41 |
+
|
42 |
+
$destCountryId = $request->getDestCountryId();
|
43 |
+
$destCountry = $request->getDestCountry();
|
44 |
+
$destRegion = $request->getDestRegionId();
|
45 |
+
$destRegionCode = $request->getDestRegionCode();
|
46 |
+
$destFullStreet = $request->getDestStreet();
|
47 |
+
$destStreet = "";
|
48 |
+
$destSuburb = "";
|
49 |
+
$destCity = $request->getDestCity();
|
50 |
+
$destPostcode = $request->getDestPostcode();
|
51 |
+
|
52 |
+
$destFullStreetArray = explode("\n", $destFullStreet);
|
53 |
+
if ($destFullStreetArray[0] !== false)
|
54 |
+
$destStreet = $destFullStreetArray[0];
|
55 |
+
if ($destFullStreetArray[1] !== false)
|
56 |
+
$destSuburb = $destFullStreetArray[1];
|
57 |
+
|
58 |
+
$packageValue = $request->getPackageValue(); //Dest Package Value
|
59 |
+
$packageValueDiscout = $request->getPackageValueWithDiscount(); //Dest Package Value After Discount
|
60 |
+
$packageWeight = $request->getPackageWeight() * 1000; //Package Weight (grams)
|
61 |
+
$packageCurrency = $request->getPackageCurrency();
|
62 |
+
|
63 |
+
$url = 'https://api.shipit.click/rate?apiKey=' . $shipItApiKey . '&integration=magento&format=json';
|
64 |
+
$post_data = '{
|
65 |
+
"rate": {
|
66 |
+
"origin": {
|
67 |
+
"country": "' . $origCountryId . '",
|
68 |
+
"postal_code": "' . $origPostcode . '",
|
69 |
+
"province": "' . $origRegionCode . '",
|
70 |
+
"city": "' . $origCity . '",
|
71 |
+
"name": null,
|
72 |
+
"address1": null,
|
73 |
+
"address2": null,
|
74 |
+
"address3": null,
|
75 |
+
"phone": null,
|
76 |
+
"fax": null,
|
77 |
+
"address_type": null,
|
78 |
+
"company_name": null
|
79 |
+
},
|
80 |
+
"destination":{
|
81 |
+
"country": "' . $destCountryId . '",
|
82 |
+
"postal_code": "' . $destPostcode . '",
|
83 |
+
"province": "' . $destRegionCode . '",
|
84 |
+
"city": "' . $destCity . '",
|
85 |
+
"name": null,
|
86 |
+
"address1": "' . $destStreet . '",
|
87 |
+
"address2": "' . $destSuburb . '",
|
88 |
+
"address3": null,
|
89 |
+
"phone": null,
|
90 |
+
"fax": null,
|
91 |
+
"address_type": null,
|
92 |
+
"company_name": null
|
93 |
+
},
|
94 |
+
"items":[
|
95 |
+
{
|
96 |
+
"name": "Total Items",
|
97 |
+
"sku": null,
|
98 |
+
"quantity": 1,
|
99 |
+
"grams": ' . $packageWeight . ' ,
|
100 |
+
"price": ' . $packageValue . ',
|
101 |
+
"vendor": null,
|
102 |
+
"requires_shipping": true,
|
103 |
+
"taxable": true,
|
104 |
+
"fulfillment_service": "manual"
|
|
|
|
|
|
|
105 |
}
|
106 |
+
],
|
107 |
+
"currency": "' . $packageCurrency->getCurrencyCode() . '",
|
108 |
+
"carrierid": "19"
|
109 |
+
}
|
110 |
+
}';
|
111 |
+
$contentLength = strlen($post_data);
|
112 |
+
|
113 |
+
$ch = curl_init();
|
114 |
+
curl_setopt($ch, CURLOPT_URL, $url);
|
115 |
+
curl_setopt($ch, CURLOPT_HEADER, false);
|
116 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
117 |
+
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
|
118 |
+
curl_setopt($ch, CURLOPT_POST, true);
|
119 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
|
120 |
+
$response = curl_exec($ch);
|
121 |
+
curl_close($ch);
|
122 |
+
|
123 |
+
$json_obj = json_decode($response);
|
124 |
+
$rates_obj = $json_obj->{'rates'};
|
125 |
+
|
126 |
+
$handling = Mage::getStoreConfig('carriers/'.$this->_code.'/handling');
|
127 |
+
$result = Mage::getModel('shipping/rate_result');
|
128 |
+
|
129 |
+
if (sizeof($rates_obj) > 0) {
|
130 |
+
$show = true;
|
131 |
+
}
|
132 |
|
133 |
+
if ($show) {
|
134 |
+
foreach ($rates_obj as $rate) {
|
135 |
+
if (is_object($rate)) {
|
136 |
+
// Add shipping option with shipping price
|
137 |
+
$method = Mage::getModel('shipping/rate_result_method');
|
138 |
+
$method->setCarrier($this->_code);
|
139 |
+
$method->setMethod($this->_code . $rate->{'service_code'});
|
140 |
+
$method->setCarrierTitle($this->getConfigData('title'));
|
141 |
+
$method->setMethodTitle($rate->{'service_name'});
|
142 |
+
$method->setPrice($rate->{'total_price'});
|
143 |
+
$method->setCost(0);
|
144 |
+
$result->append($method);
|
145 |
+
}
|
146 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
147 |
}
|
148 |
+
else {
|
149 |
+
$error = Mage::getModel('shipping/rate_result_error');
|
150 |
+
$error->setCarrier($this->_code);
|
151 |
+
$error->setCarrierTitle($this->getConfigData('name'));
|
152 |
+
$error->setErrorMessage($this->getConfigData('specificerrmsg'));
|
153 |
+
$result->append($error);
|
154 |
}
|
155 |
+
}
|
156 |
+
catch (Exception $e) {
|
157 |
+
Mage::log($e->getMessage());
|
158 |
+
}
|
159 |
}
|
160 |
|
161 |
+
return $result;
|
162 |
+
}
|
163 |
+
|
164 |
+
public function getAllowedMethods() {
|
165 |
+
return array('pace'=>$this->getConfigData('name'));
|
166 |
+
}
|
|
|
|
|
|
|
|
|
|
|
167 |
|
168 |
+
public function isTrackingAvailable() {
|
169 |
+
return true;
|
170 |
+
}
|
171 |
+
|
172 |
+
public function getTrackingInfo($tracking) {
|
173 |
+
$status = Mage::getModel('shipping/tracking_result_status');
|
174 |
+
$status->setCarrier($this->_code);
|
175 |
+
$status->setCarrierTitle($this->getConfigData('title'));
|
176 |
+
$status->setTracking($tracking);
|
177 |
+
$status->setPopup(1);
|
178 |
+
$status->setUrl("https://www.nzpost.co.nz/tools/tracking/item/".$tracking);
|
179 |
+
return $status;
|
180 |
+
}
|
181 |
}
|
app/code/community/Rvtech/Starshipit/Model/Carrier/Shipit.php
CHANGED
@@ -1,166 +1,180 @@
|
|
1 |
<?php
|
2 |
class Rvtech_Starshipit_Model_Carrier_Shipit extends Mage_Shipping_Model_Carrier_Abstract
|
3 |
implements Mage_Shipping_Model_Carrier_Interface {
|
4 |
-
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
|
|
|
|
11 |
$price = 0;
|
12 |
$doCalulate = $this->getConfigData('calculate');
|
13 |
-
if ($doCalulate==0)
|
14 |
-
|
15 |
$price = $this->getConfigData('price');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
}
|
17 |
-
else{
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
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 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
],
|
94 |
-
"currency": "' . $packageCurrency->getCurrencyCode() . '"
|
95 |
}
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
108 |
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
$method->setCarrierTitle($this->getConfigData('title'));
|
124 |
-
$method->setMethodTitle($rate->{'service_name'});
|
125 |
-
$method->setPrice($rate->{'total_price'});
|
126 |
-
$method->setCost(0);
|
127 |
-
$result->append($method);
|
128 |
-
}
|
129 |
-
}
|
130 |
-
}
|
131 |
-
}else{
|
132 |
-
$error = Mage::getModel('shipping/rate_result_error');
|
133 |
-
$error->setCarrier($this->_code);
|
134 |
-
$error->setCarrierTitle($this->getConfigData('name'));
|
135 |
-
$error->setErrorMessage($this->getConfigData('specificerrmsg'));
|
136 |
-
$result->append($error);
|
137 |
-
}
|
138 |
}
|
139 |
-
|
140 |
-
|
|
|
|
|
|
|
|
|
141 |
}
|
|
|
|
|
|
|
|
|
142 |
}
|
143 |
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
public function isTrackingAvailable()
|
152 |
-
{
|
153 |
-
return true;
|
154 |
-
}
|
155 |
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
|
|
|
|
|
|
166 |
}
|
1 |
<?php
|
2 |
class Rvtech_Starshipit_Model_Carrier_Shipit extends Mage_Shipping_Model_Carrier_Abstract
|
3 |
implements Mage_Shipping_Model_Carrier_Interface {
|
4 |
+
protected $_code = 'shipit';
|
5 |
|
6 |
+
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
|
7 |
+
{
|
8 |
+
if (!Mage::getStoreConfig('carriers/'.$this->_code.'/active')) {
|
9 |
+
return false;
|
10 |
+
}
|
11 |
+
|
12 |
+
$show = false;
|
13 |
$price = 0;
|
14 |
$doCalulate = $this->getConfigData('calculate');
|
15 |
+
if ($doCalulate==0) {
|
16 |
+
$show = true;
|
17 |
$price = $this->getConfigData('price');
|
18 |
+
|
19 |
+
$result = Mage::getModel('shipping/rate_result');
|
20 |
+
$method = Mage::getModel('shipping/rate_result_method');
|
21 |
+
$method->setCarrier($this->_code);
|
22 |
+
$method->setMethod($this->_code);
|
23 |
+
$method->setCarrierTitle($this->getConfigData('title'));
|
24 |
+
$method->setMethodTitle($this->getConfigData('name'));
|
25 |
+
$method->setPrice($price);
|
26 |
+
$method->setCost($price);
|
27 |
+
$result->append($method);
|
28 |
}
|
29 |
+
else {
|
30 |
+
try {
|
31 |
+
$shipItApiKey = Mage::helper('shipnote')->getShipItApiKey();
|
32 |
+
if ($shipItApiKey == "") {
|
33 |
+
return false;
|
34 |
+
}
|
35 |
+
|
36 |
+
$origCountryId = $request->getCountryId(); //Package Source Country ID
|
37 |
+
$origRegionId = $request->getRegionId(); //Package Source Region ID
|
38 |
+
$origRegionCode = $request->getRegion(); //Package Source Region Code
|
39 |
+
$origCity = $request->getCity(); //Package Source City
|
40 |
+
$origPostcode = $request->getPostcode(); //Package Source Post Code
|
41 |
+
|
42 |
+
$destCountryId = $request->getDestCountryId();
|
43 |
+
$destCountry = $request->getDestCountry();
|
44 |
+
$destRegion = $request->getDestRegionId();
|
45 |
+
$destRegionCode = $request->getDestRegionCode();
|
46 |
+
$destFullStreet = $request->getDestStreet();
|
47 |
+
$destStreet = "";
|
48 |
+
$destSuburb = "";
|
49 |
+
$destCity = $request->getDestCity();
|
50 |
+
$destPostcode = $request->getDestPostcode();
|
51 |
+
|
52 |
+
$destFullStreetArray = explode("\n", $destFullStreet);
|
53 |
+
if ($destFullStreetArray[0] !== false)
|
54 |
+
$destStreet = $destFullStreetArray[0];
|
55 |
+
if ($destFullStreetArray[1] !== false)
|
56 |
+
$destSuburb = $destFullStreetArray[1];
|
57 |
+
|
58 |
+
$packageValue = $request->getPackageValue(); //Dest Package Value
|
59 |
+
$packageValueDiscout = $request->getPackageValueWithDiscount(); //Dest Package Value After Discount
|
60 |
+
$packageWeight = $request->getPackageWeight() * 1000; //Package Weight (grams)
|
61 |
+
$packageCurrency = $request->getPackageCurrency();
|
62 |
+
|
63 |
+
$url = 'https://api.shipit.click/rate?apiKey=' . $shipItApiKey . '&integration=magento&format=json';
|
64 |
+
$post_data = '{
|
65 |
+
"rate": {
|
66 |
+
"origin": {
|
67 |
+
"country": "' . $origCountryId . '",
|
68 |
+
"postal_code": "' . $origPostcode . '",
|
69 |
+
"province": "' . $origRegionCode . '",
|
70 |
+
"city": "' . $origCity . '",
|
71 |
+
"name": null,
|
72 |
+
"address1": null,
|
73 |
+
"address2": null,
|
74 |
+
"address3": null,
|
75 |
+
"phone": null,
|
76 |
+
"fax": null,
|
77 |
+
"address_type": null,
|
78 |
+
"company_name": null
|
79 |
+
},
|
80 |
+
"destination":{
|
81 |
+
"country": "' . $destCountryId . '",
|
82 |
+
"postal_code": "' . $destPostcode . '",
|
83 |
+
"province": "' . $destRegionCode . '",
|
84 |
+
"city": "' . $destCity . '",
|
85 |
+
"name": null,
|
86 |
+
"address1": "' . $destStreet . '",
|
87 |
+
"address2": "' . $destSuburb . '",
|
88 |
+
"address3": null,
|
89 |
+
"phone": null,
|
90 |
+
"fax": null,
|
91 |
+
"address_type": null,
|
92 |
+
"company_name": null
|
93 |
+
},
|
94 |
+
"items":[
|
95 |
+
{
|
96 |
+
"name": "Total Items",
|
97 |
+
"sku": null,
|
98 |
+
"quantity": 1,
|
99 |
+
"grams": ' . $packageWeight . ' ,
|
100 |
+
"price": ' . $packageValue . ',
|
101 |
+
"vendor": null,
|
102 |
+
"requires_shipping": true,
|
103 |
+
"taxable": true,
|
104 |
+
"fulfillment_service": "manual"
|
|
|
|
|
105 |
}
|
106 |
+
],
|
107 |
+
"currency": "' . $packageCurrency->getCurrencyCode() . '"
|
108 |
+
}
|
109 |
+
}';
|
110 |
+
$contentLength = strlen($post_data);
|
111 |
+
|
112 |
+
$ch = curl_init();
|
113 |
+
curl_setopt($ch, CURLOPT_URL, $url);
|
114 |
+
curl_setopt($ch, CURLOPT_HEADER, false);
|
115 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
116 |
+
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
|
117 |
+
curl_setopt($ch, CURLOPT_POST, true);
|
118 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
|
119 |
+
$response = curl_exec($ch);
|
120 |
+
curl_close($ch);
|
121 |
+
|
122 |
+
$json_obj = json_decode($response);
|
123 |
+
$rates_obj = $json_obj->{'rates'};
|
124 |
+
|
125 |
+
$handling = Mage::getStoreConfig('carriers/'.$this->_code.'/handling');
|
126 |
+
$result = Mage::getModel('shipping/rate_result');
|
127 |
+
|
128 |
+
if (sizeof($rates_obj) > 0) {
|
129 |
+
$show = true;
|
130 |
+
}
|
131 |
|
132 |
+
if ($show) {
|
133 |
+
foreach ($rates_obj as $rate) {
|
134 |
+
if (is_object($rate)) {
|
135 |
+
// Add shipping option with shipping price
|
136 |
+
$method = Mage::getModel('shipping/rate_result_method');
|
137 |
+
$method->setCarrier($this->_code);
|
138 |
+
$method->setMethod($this->_code . $rate->{'service_code'});
|
139 |
+
$method->setCarrierTitle($this->getConfigData('title'));
|
140 |
+
$method->setMethodTitle($rate->{'service_name'});
|
141 |
+
$method->setPrice($rate->{'total_price'});
|
142 |
+
$method->setCost(0);
|
143 |
+
$result->append($method);
|
144 |
+
}
|
145 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
146 |
}
|
147 |
+
else {
|
148 |
+
$error = Mage::getModel('shipping/rate_result_error');
|
149 |
+
$error->setCarrier($this->_code);
|
150 |
+
$error->setCarrierTitle($this->getConfigData('name'));
|
151 |
+
$error->setErrorMessage($this->getConfigData('specificerrmsg'));
|
152 |
+
$result->append($error);
|
153 |
}
|
154 |
+
}
|
155 |
+
catch (Exception $e) {
|
156 |
+
Mage::log($e->getMessage());
|
157 |
+
}
|
158 |
}
|
159 |
|
160 |
+
return $result;
|
161 |
+
}
|
162 |
+
|
163 |
+
public function getAllowedMethods() {
|
164 |
+
return array('shipit'=>$this->getConfigData('name'));
|
165 |
+
}
|
|
|
|
|
|
|
|
|
|
|
166 |
|
167 |
+
public function isTrackingAvailable() {
|
168 |
+
return true;
|
169 |
+
}
|
170 |
+
|
171 |
+
public function getTrackingInfo($tracking) {
|
172 |
+
$status = Mage::getModel('shipping/tracking_result_status');
|
173 |
+
$status->setCarrier($this->_code);
|
174 |
+
$status->setCarrierTitle($this->getConfigData('title'));
|
175 |
+
$status->setTracking($tracking);
|
176 |
+
$status->setPopup(1);
|
177 |
+
$status->setUrl("https://app.shipit.click/track-your-parcel?l=".$tracking);
|
178 |
+
return $status;
|
179 |
+
}
|
180 |
}
|
app/code/community/Rvtech/Starshipit/Model/Carrier/Startrack.php
CHANGED
@@ -1,167 +1,181 @@
|
|
1 |
<?php
|
2 |
class Rvtech_Starshipit_Model_Carrier_Startrack extends Mage_Shipping_Model_Carrier_Abstract
|
3 |
implements Mage_Shipping_Model_Carrier_Interface {
|
4 |
-
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
|
|
|
|
11 |
$price = 0;
|
12 |
$doCalulate = $this->getConfigData('calculate');
|
13 |
-
if ($doCalulate==0)
|
14 |
-
|
15 |
$price = $this->getConfigData('price');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
}
|
17 |
-
else{
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
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 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
],
|
94 |
-
"currency": "' . $packageCurrency->getCurrencyCode() . '",
|
95 |
-
"carrierid": "18"
|
96 |
}
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
$method->setCarrierTitle($this->getConfigData('title'));
|
125 |
-
$method->setMethodTitle($rate->{'service_name'});
|
126 |
-
$method->setPrice($rate->{'total_price'});
|
127 |
-
$method->setCost(0);
|
128 |
-
$result->append($method);
|
129 |
-
}
|
130 |
-
}
|
131 |
-
}
|
132 |
-
}else{
|
133 |
-
$error = Mage::getModel('shipping/rate_result_error');
|
134 |
-
$error->setCarrier($this->_code);
|
135 |
-
$error->setCarrierTitle($this->getConfigData('name'));
|
136 |
-
$error->setErrorMessage($this->getConfigData('specificerrmsg'));
|
137 |
-
$result->append($error);
|
138 |
-
}
|
139 |
}
|
140 |
-
|
141 |
-
|
|
|
|
|
|
|
|
|
142 |
}
|
|
|
|
|
|
|
|
|
143 |
}
|
144 |
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
public function isTrackingAvailable()
|
153 |
-
{
|
154 |
-
return true;
|
155 |
-
}
|
156 |
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
|
|
|
|
|
|
167 |
}
|
1 |
<?php
|
2 |
class Rvtech_Starshipit_Model_Carrier_Startrack extends Mage_Shipping_Model_Carrier_Abstract
|
3 |
implements Mage_Shipping_Model_Carrier_Interface {
|
4 |
+
protected $_code = 'startrack';
|
5 |
|
6 |
+
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
|
7 |
+
{
|
8 |
+
if (!Mage::getStoreConfig('carriers/'.$this->_code.'/active')) {
|
9 |
+
return false;
|
10 |
+
}
|
11 |
+
|
12 |
+
$show = false;
|
13 |
$price = 0;
|
14 |
$doCalulate = $this->getConfigData('calculate');
|
15 |
+
if ($doCalulate==0) {
|
16 |
+
$show = true;
|
17 |
$price = $this->getConfigData('price');
|
18 |
+
|
19 |
+
$result = Mage::getModel('shipping/rate_result');
|
20 |
+
$method = Mage::getModel('shipping/rate_result_method');
|
21 |
+
$method->setCarrier($this->_code);
|
22 |
+
$method->setMethod($this->_code);
|
23 |
+
$method->setCarrierTitle($this->getConfigData('title'));
|
24 |
+
$method->setMethodTitle($this->getConfigData('name'));
|
25 |
+
$method->setPrice($price);
|
26 |
+
$method->setCost($price);
|
27 |
+
$result->append($method);
|
28 |
}
|
29 |
+
else {
|
30 |
+
try {
|
31 |
+
$shipItApiKey = Mage::helper('shipnote')->getShipItApiKey();
|
32 |
+
if ($shipItApiKey == "") {
|
33 |
+
return false;
|
34 |
+
}
|
35 |
+
|
36 |
+
$origCountryId = $request->getCountryId(); //Package Source Country ID
|
37 |
+
$origRegionId = $request->getRegionId(); //Package Source Region ID
|
38 |
+
$origRegionCode = $request->getRegion(); //Package Source Region Code
|
39 |
+
$origCity = $request->getCity(); //Package Source City
|
40 |
+
$origPostcode = $request->getPostcode(); //Package Source Post Code
|
41 |
+
|
42 |
+
$destCountryId = $request->getDestCountryId();
|
43 |
+
$destCountry = $request->getDestCountry();
|
44 |
+
$destRegion = $request->getDestRegionId();
|
45 |
+
$destRegionCode = $request->getDestRegionCode();
|
46 |
+
$destFullStreet = $request->getDestStreet();
|
47 |
+
$destStreet = "";
|
48 |
+
$destSuburb = "";
|
49 |
+
$destCity = $request->getDestCity();
|
50 |
+
$destPostcode = $request->getDestPostcode();
|
51 |
+
|
52 |
+
$destFullStreetArray = explode("\n", $destFullStreet);
|
53 |
+
if ($destFullStreetArray[0] !== false)
|
54 |
+
$destStreet = $destFullStreetArray[0];
|
55 |
+
if ($destFullStreetArray[1] !== false)
|
56 |
+
$destSuburb = $destFullStreetArray[1];
|
57 |
+
|
58 |
+
$packageValue = $request->getPackageValue(); //Dest Package Value
|
59 |
+
$packageValueDiscout = $request->getPackageValueWithDiscount(); //Dest Package Value After Discount
|
60 |
+
$packageWeight = $request->getPackageWeight() * 1000; //Package Weight (grams)
|
61 |
+
$packageCurrency = $request->getPackageCurrency();
|
62 |
+
|
63 |
+
$url = 'https://api.shipit.click/rate?apiKey=' . $shipItApiKey . '&integration=magento&format=json';
|
64 |
+
$post_data = '{
|
65 |
+
"rate": {
|
66 |
+
"origin": {
|
67 |
+
"country": "' . $origCountryId . '",
|
68 |
+
"postal_code": "' . $origPostcode . '",
|
69 |
+
"province": "' . $origRegionCode . '",
|
70 |
+
"city": "' . $origCity . '",
|
71 |
+
"name": null,
|
72 |
+
"address1": null,
|
73 |
+
"address2": null,
|
74 |
+
"address3": null,
|
75 |
+
"phone": null,
|
76 |
+
"fax": null,
|
77 |
+
"address_type": null,
|
78 |
+
"company_name": null
|
79 |
+
},
|
80 |
+
"destination":{
|
81 |
+
"country": "' . $destCountryId . '",
|
82 |
+
"postal_code": "' . $destPostcode . '",
|
83 |
+
"province": "' . $destRegionCode . '",
|
84 |
+
"city": "' . $destCity . '",
|
85 |
+
"name": null,
|
86 |
+
"address1": "' . $destStreet . '",
|
87 |
+
"address2": "' . $destSuburb . '",
|
88 |
+
"address3": null,
|
89 |
+
"phone": null,
|
90 |
+
"fax": null,
|
91 |
+
"address_type": null,
|
92 |
+
"company_name": null
|
93 |
+
},
|
94 |
+
"items":[
|
95 |
+
{
|
96 |
+
"name": "Total Items",
|
97 |
+
"sku": null,
|
98 |
+
"quantity": 1,
|
99 |
+
"grams": ' . $packageWeight . ' ,
|
100 |
+
"price": ' . $packageValue . ',
|
101 |
+
"vendor": null,
|
102 |
+
"requires_shipping": true,
|
103 |
+
"taxable": true,
|
104 |
+
"fulfillment_service": "manual"
|
|
|
|
|
|
|
105 |
}
|
106 |
+
],
|
107 |
+
"currency": "' . $packageCurrency->getCurrencyCode() . '",
|
108 |
+
"carrierid": "18"
|
109 |
+
}
|
110 |
+
}';
|
111 |
+
$contentLength = strlen($post_data);
|
112 |
+
|
113 |
+
$ch = curl_init();
|
114 |
+
curl_setopt($ch, CURLOPT_URL, $url);
|
115 |
+
curl_setopt($ch, CURLOPT_HEADER, false);
|
116 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
117 |
+
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
|
118 |
+
curl_setopt($ch, CURLOPT_POST, true);
|
119 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
|
120 |
+
$response = curl_exec($ch);
|
121 |
+
curl_close($ch);
|
122 |
+
|
123 |
+
$json_obj = json_decode($response);
|
124 |
+
$rates_obj = $json_obj->{'rates'};
|
125 |
+
|
126 |
+
$handling = Mage::getStoreConfig('carriers/'.$this->_code.'/handling');
|
127 |
+
$result = Mage::getModel('shipping/rate_result');
|
128 |
+
|
129 |
+
if (sizeof($rates_obj) > 0) {
|
130 |
+
$show = true;
|
131 |
+
}
|
132 |
|
133 |
+
if ($show) {
|
134 |
+
foreach ($rates_obj as $rate) {
|
135 |
+
if (is_object($rate)) {
|
136 |
+
// Add shipping option with shipping price
|
137 |
+
$method = Mage::getModel('shipping/rate_result_method');
|
138 |
+
$method->setCarrier($this->_code);
|
139 |
+
$method->setMethod($this->_code . $rate->{'service_code'});
|
140 |
+
$method->setCarrierTitle($this->getConfigData('title'));
|
141 |
+
$method->setMethodTitle($rate->{'service_name'});
|
142 |
+
$method->setPrice($rate->{'total_price'});
|
143 |
+
$method->setCost(0);
|
144 |
+
$result->append($method);
|
145 |
+
}
|
146 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
147 |
}
|
148 |
+
else {
|
149 |
+
$error = Mage::getModel('shipping/rate_result_error');
|
150 |
+
$error->setCarrier($this->_code);
|
151 |
+
$error->setCarrierTitle($this->getConfigData('name'));
|
152 |
+
$error->setErrorMessage($this->getConfigData('specificerrmsg'));
|
153 |
+
$result->append($error);
|
154 |
}
|
155 |
+
}
|
156 |
+
catch (Exception $e) {
|
157 |
+
Mage::log($e->getMessage());
|
158 |
+
}
|
159 |
}
|
160 |
|
161 |
+
return $result;
|
162 |
+
}
|
163 |
+
|
164 |
+
public function getAllowedMethods() {
|
165 |
+
return array('startrack'=>$this->getConfigData('name'));
|
166 |
+
}
|
|
|
|
|
|
|
|
|
|
|
167 |
|
168 |
+
public function isTrackingAvailable() {
|
169 |
+
return true;
|
170 |
+
}
|
171 |
+
|
172 |
+
public function getTrackingInfo($tracking) {
|
173 |
+
$status = Mage::getModel('shipping/tracking_result_status');
|
174 |
+
$status->setCarrier($this->_code);
|
175 |
+
$status->setCarrierTitle($this->getConfigData('title'));
|
176 |
+
$status->setTracking($tracking);
|
177 |
+
$status->setPopup(1);
|
178 |
+
$status->setUrl("http://www.startrack.com.au/track-trace/?id=".$tracking);
|
179 |
+
return $status;
|
180 |
+
}
|
181 |
}
|
app/code/community/Rvtech/Starshipit/Model/Carrier/Startrackexpress.php
CHANGED
@@ -1,167 +1,181 @@
|
|
1 |
<?php
|
2 |
class Rvtech_Starshipit_Model_Carrier_Startrackexpress extends Mage_Shipping_Model_Carrier_Abstract
|
3 |
implements Mage_Shipping_Model_Carrier_Interface {
|
4 |
-
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
|
|
|
|
11 |
$price = 0;
|
12 |
$doCalulate = $this->getConfigData('calculate');
|
13 |
-
if ($doCalulate==0)
|
14 |
-
|
15 |
$price = $this->getConfigData('price');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
}
|
17 |
-
else{
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
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 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
],
|
94 |
-
"currency": "' . $packageCurrency->getCurrencyCode() . '",
|
95 |
-
"carrierid": "20"
|
96 |
}
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
$method->setCarrierTitle($this->getConfigData('title'));
|
125 |
-
$method->setMethodTitle($rate->{'service_name'});
|
126 |
-
$method->setPrice($rate->{'total_price'});
|
127 |
-
$method->setCost(0);
|
128 |
-
$result->append($method);
|
129 |
-
}
|
130 |
-
}
|
131 |
-
}
|
132 |
-
}else{
|
133 |
-
$error = Mage::getModel('shipping/rate_result_error');
|
134 |
-
$error->setCarrier($this->_code);
|
135 |
-
$error->setCarrierTitle($this->getConfigData('name'));
|
136 |
-
$error->setErrorMessage($this->getConfigData('specificerrmsg'));
|
137 |
-
$result->append($error);
|
138 |
-
}
|
139 |
}
|
140 |
-
|
141 |
-
|
|
|
|
|
|
|
|
|
142 |
}
|
|
|
|
|
|
|
|
|
143 |
}
|
144 |
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
public function isTrackingAvailable()
|
153 |
-
{
|
154 |
-
return true;
|
155 |
-
}
|
156 |
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
|
|
|
|
|
|
167 |
}
|
1 |
<?php
|
2 |
class Rvtech_Starshipit_Model_Carrier_Startrackexpress extends Mage_Shipping_Model_Carrier_Abstract
|
3 |
implements Mage_Shipping_Model_Carrier_Interface {
|
4 |
+
protected $_code = 'startrackexpress';
|
5 |
|
6 |
+
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
|
7 |
+
{
|
8 |
+
if (!Mage::getStoreConfig('carriers/'.$this->_code.'/active')) {
|
9 |
+
return false;
|
10 |
+
}
|
11 |
+
|
12 |
+
$show = false;
|
13 |
$price = 0;
|
14 |
$doCalulate = $this->getConfigData('calculate');
|
15 |
+
if ($doCalulate==0) {
|
16 |
+
$show = true;
|
17 |
$price = $this->getConfigData('price');
|
18 |
+
|
19 |
+
$result = Mage::getModel('shipping/rate_result');
|
20 |
+
$method = Mage::getModel('shipping/rate_result_method');
|
21 |
+
$method->setCarrier($this->_code);
|
22 |
+
$method->setMethod($this->_code);
|
23 |
+
$method->setCarrierTitle($this->getConfigData('title'));
|
24 |
+
$method->setMethodTitle($this->getConfigData('name'));
|
25 |
+
$method->setPrice($price);
|
26 |
+
$method->setCost($price);
|
27 |
+
$result->append($method);
|
28 |
}
|
29 |
+
else {
|
30 |
+
try {
|
31 |
+
$shipItApiKey = Mage::helper('shipnote')->getShipItApiKey();
|
32 |
+
if ($shipItApiKey == "") {
|
33 |
+
return false;
|
34 |
+
}
|
35 |
+
|
36 |
+
$origCountryId = $request->getCountryId(); //Package Source Country ID
|
37 |
+
$origRegionId = $request->getRegionId(); //Package Source Region ID
|
38 |
+
$origRegionCode = $request->getRegion(); //Package Source Region Code
|
39 |
+
$origCity = $request->getCity(); //Package Source City
|
40 |
+
$origPostcode = $request->getPostcode(); //Package Source Post Code
|
41 |
+
|
42 |
+
$destCountryId = $request->getDestCountryId();
|
43 |
+
$destCountry = $request->getDestCountry();
|
44 |
+
$destRegion = $request->getDestRegionId();
|
45 |
+
$destRegionCode = $request->getDestRegionCode();
|
46 |
+
$destFullStreet = $request->getDestStreet();
|
47 |
+
$destStreet = "";
|
48 |
+
$destSuburb = "";
|
49 |
+
$destCity = $request->getDestCity();
|
50 |
+
$destPostcode = $request->getDestPostcode();
|
51 |
+
|
52 |
+
$destFullStreetArray = explode("\n", $destFullStreet);
|
53 |
+
if ($destFullStreetArray[0] !== false)
|
54 |
+
$destStreet = $destFullStreetArray[0];
|
55 |
+
if ($destFullStreetArray[1] !== false)
|
56 |
+
$destSuburb = $destFullStreetArray[1];
|
57 |
+
|
58 |
+
$packageValue = $request->getPackageValue(); //Dest Package Value
|
59 |
+
$packageValueDiscout = $request->getPackageValueWithDiscount(); //Dest Package Value After Discount
|
60 |
+
$packageWeight = $request->getPackageWeight() * 1000; //Package Weight (grams)
|
61 |
+
$packageCurrency = $request->getPackageCurrency();
|
62 |
+
|
63 |
+
$url = 'https://api.shipit.click/rate?apiKey=' . $shipItApiKey . '&integration=magento&format=json';
|
64 |
+
$post_data = '{
|
65 |
+
"rate": {
|
66 |
+
"origin": {
|
67 |
+
"country": "' . $origCountryId . '",
|
68 |
+
"postal_code": "' . $origPostcode . '",
|
69 |
+
"province": "' . $origRegionCode . '",
|
70 |
+
"city": "' . $origCity . '",
|
71 |
+
"name": null,
|
72 |
+
"address1": null,
|
73 |
+
"address2": null,
|
74 |
+
"address3": null,
|
75 |
+
"phone": null,
|
76 |
+
"fax": null,
|
77 |
+
"address_type": null,
|
78 |
+
"company_name": null
|
79 |
+
},
|
80 |
+
"destination":{
|
81 |
+
"country": "' . $destCountryId . '",
|
82 |
+
"postal_code": "' . $destPostcode . '",
|
83 |
+
"province": "' . $destRegionCode . '",
|
84 |
+
"city": "' . $destCity . '",
|
85 |
+
"name": null,
|
86 |
+
"address1": "' . $destStreet . '",
|
87 |
+
"address2": "' . $destSuburb . '",
|
88 |
+
"address3": null,
|
89 |
+
"phone": null,
|
90 |
+
"fax": null,
|
91 |
+
"address_type": null,
|
92 |
+
"company_name": null
|
93 |
+
},
|
94 |
+
"items":[
|
95 |
+
{
|
96 |
+
"name": "Total Items",
|
97 |
+
"sku": null,
|
98 |
+
"quantity": 1,
|
99 |
+
"grams": ' . $packageWeight . ' ,
|
100 |
+
"price": ' . $packageValue . ',
|
101 |
+
"vendor": null,
|
102 |
+
"requires_shipping": true,
|
103 |
+
"taxable": true,
|
104 |
+
"fulfillment_service": "manual"
|
|
|
|
|
|
|
105 |
}
|
106 |
+
],
|
107 |
+
"currency": "' . $packageCurrency->getCurrencyCode() . '",
|
108 |
+
"carrierid": "20"
|
109 |
+
}
|
110 |
+
}';
|
111 |
+
$contentLength = strlen($post_data);
|
112 |
+
|
113 |
+
$ch = curl_init();
|
114 |
+
curl_setopt($ch, CURLOPT_URL, $url);
|
115 |
+
curl_setopt($ch, CURLOPT_HEADER, false);
|
116 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
117 |
+
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
|
118 |
+
curl_setopt($ch, CURLOPT_POST, true);
|
119 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
|
120 |
+
$response = curl_exec($ch);
|
121 |
+
curl_close($ch);
|
122 |
+
|
123 |
+
$json_obj = json_decode($response);
|
124 |
+
$rates_obj = $json_obj->{'rates'};
|
125 |
+
|
126 |
+
$handling = Mage::getStoreConfig('carriers/'.$this->_code.'/handling');
|
127 |
+
$result = Mage::getModel('shipping/rate_result');
|
128 |
+
|
129 |
+
if (sizeof($rates_obj) > 0) {
|
130 |
+
$show = true;
|
131 |
+
}
|
132 |
|
133 |
+
if ($show) {
|
134 |
+
foreach ($rates_obj as $rate) {
|
135 |
+
if (is_object($rate)) {
|
136 |
+
// Add shipping option with shipping price
|
137 |
+
$method = Mage::getModel('shipping/rate_result_method');
|
138 |
+
$method->setCarrier($this->_code);
|
139 |
+
$method->setMethod($this->_code . $rate->{'service_code'});
|
140 |
+
$method->setCarrierTitle($this->getConfigData('title'));
|
141 |
+
$method->setMethodTitle($rate->{'service_name'});
|
142 |
+
$method->setPrice($rate->{'total_price'});
|
143 |
+
$method->setCost(0);
|
144 |
+
$result->append($method);
|
145 |
+
}
|
146 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
147 |
}
|
148 |
+
else {
|
149 |
+
$error = Mage::getModel('shipping/rate_result_error');
|
150 |
+
$error->setCarrier($this->_code);
|
151 |
+
$error->setCarrierTitle($this->getConfigData('name'));
|
152 |
+
$error->setErrorMessage($this->getConfigData('specificerrmsg'));
|
153 |
+
$result->append($error);
|
154 |
}
|
155 |
+
}
|
156 |
+
catch (Exception $e) {
|
157 |
+
Mage::log($e->getMessage());
|
158 |
+
}
|
159 |
}
|
160 |
|
161 |
+
return $result;
|
162 |
+
}
|
163 |
+
|
164 |
+
public function getAllowedMethods() {
|
165 |
+
return array('startrackexpress'=>$this->getConfigData('name'));
|
166 |
+
}
|
|
|
|
|
|
|
|
|
|
|
167 |
|
168 |
+
public function isTrackingAvailable() {
|
169 |
+
return true;
|
170 |
+
}
|
171 |
+
|
172 |
+
public function getTrackingInfo($tracking) {
|
173 |
+
$status = Mage::getModel('shipping/tracking_result_status');
|
174 |
+
$status->setCarrier($this->_code);
|
175 |
+
$status->setCarrierTitle($this->getConfigData('title'));
|
176 |
+
$status->setTracking($tracking);
|
177 |
+
$status->setPopup(1);
|
178 |
+
$status->setUrl("http://www.startrack.com.au/track-trace/?id=".$tracking);
|
179 |
+
return $status;
|
180 |
+
}
|
181 |
}
|
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Rvtech_Starshipit</name>
|
4 |
-
<version>1.6.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
|
7 |
<channel>community</channel>
|
@@ -18,12 +18,12 @@ From ShipIT shipping labels can be produced, tracking of orders is supported, qu
|
|
18 |
DHL Express Worldwide is supported as well 
|
19 |

|
20 |
Australia Post eParcel, CourierPost, Fastways, and more.</description>
|
21 |
-
<notes>-
|
22 |
-
- Added
|
23 |
<authors><author><name>George Plummer</name><user>GeorgeSPlummer</user><email>george@shipit.click</email></author></authors>
|
24 |
-
<date>2016-
|
25 |
-
<time>
|
26 |
-
<contents><target name="mageetc"><dir name="modules"><file name="Rvtech_Starshipit.xml" hash="5f957b335ffd3ef220188acc0a4261c2"/></dir></target><target name="magecommunity"><dir name="Rvtech"><dir name="Starshipit"><dir name="Block"><dir name="Adminhtml"><dir name="Sales"><dir name="Order"><dir name="Create"><file name="Shipnote.php" hash="e3978a998056ca01f2c1eecadad492f9"/></dir><file name="Note.php" hash="b176725ad1d11312fc9b2e6da10300a3"/></dir></dir><dir name="System"><dir name="Config"><dir name="Form"><file name="Button.php" hash="bef51209ace24c39e1d0933c4695665c"/><file name="Syncbutton.php" hash="1b90bc1d0ce6f8fd85783771ffc3720b"/></dir></dir></dir></dir><file name="Note.php" hash="d89159b063408b3496b5a7c1238b9f90"/><dir name="Sales"><dir name="Order"><file name="Grid.php" hash="bcec9d256397a5c39879eba37520370e"/><file name="View.php" hash="bee1026715c9a99d4d0ab31c2cb58325"/></dir></dir><file name="Ship.php" hash="19080a45c06dc07b7991dd694d83708a"/><file name="Shiptracking.php" hash="a64dbb626cb60a3f62994564e0d3e288"/></dir><dir name="Helper"><file name="Data.php" hash="09a753bbbc36ce95a6222587d53cd1c1"/><file name="Starship.php" hash="ebc879a96df5c80ffae9744d11a6cac5"/></dir><dir name="Model"><dir name="Adminhtml"><file name="Observer.php" hash="2956099cbc3109242139fb0b8e07ba47"/></dir><file name="Api.php" hash="9c0c7ad4df68db05f5caf2970b91a542"/><dir name="Carrier"><file name="Auspost.php" hash="
|
27 |
<compatible/>
|
28 |
-
<dependencies><required><php><min>5.1.0</min><max>7.0.
|
29 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Rvtech_Starshipit</name>
|
4 |
+
<version>1.6.5.0</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
|
7 |
<channel>community</channel>
|
18 |
DHL Express Worldwide is supported as well 
|
19 |

|
20 |
Australia Post eParcel, CourierPost, Fastways, and more.</description>
|
21 |
+
<notes>- Updated rates at checkout API for all carriers
|
22 |
+
- Added support for recent PHP releases</notes>
|
23 |
<authors><author><name>George Plummer</name><user>GeorgeSPlummer</user><email>george@shipit.click</email></author></authors>
|
24 |
+
<date>2016-09-27</date>
|
25 |
+
<time>22:29:59</time>
|
26 |
+
<contents><target name="mageetc"><dir name="modules"><file name="Rvtech_Starshipit.xml" hash="5f957b335ffd3ef220188acc0a4261c2"/></dir></target><target name="magecommunity"><dir name="Rvtech"><dir name="Starshipit"><dir name="Block"><dir name="Adminhtml"><dir name="Sales"><dir name="Order"><dir name="Create"><file name="Shipnote.php" hash="e3978a998056ca01f2c1eecadad492f9"/></dir><file name="Note.php" hash="b176725ad1d11312fc9b2e6da10300a3"/></dir></dir><dir name="System"><dir name="Config"><dir name="Form"><file name="Button.php" hash="bef51209ace24c39e1d0933c4695665c"/><file name="Syncbutton.php" hash="1b90bc1d0ce6f8fd85783771ffc3720b"/></dir></dir></dir></dir><file name="Note.php" hash="d89159b063408b3496b5a7c1238b9f90"/><dir name="Sales"><dir name="Order"><file name="Grid.php" hash="bcec9d256397a5c39879eba37520370e"/><file name="View.php" hash="bee1026715c9a99d4d0ab31c2cb58325"/></dir></dir><file name="Ship.php" hash="19080a45c06dc07b7991dd694d83708a"/><file name="Shiptracking.php" hash="a64dbb626cb60a3f62994564e0d3e288"/></dir><dir name="Helper"><file name="Data.php" hash="09a753bbbc36ce95a6222587d53cd1c1"/><file name="Starship.php" hash="ebc879a96df5c80ffae9744d11a6cac5"/></dir><dir name="Model"><dir name="Adminhtml"><file name="Observer.php" hash="2956099cbc3109242139fb0b8e07ba47"/></dir><file name="Api.php" hash="9c0c7ad4df68db05f5caf2970b91a542"/><dir name="Carrier"><file name="Auspost.php" hash="46f89ad1bb974e9bb467393f7afc88af"/><file name="Courierpost.php" hash="6991245610e5dab49c80eaa78d750c91"/><file name="Couriersplease.php" hash="a6ad5ce45687756cc8433d3e917d625b"/><file name="Dhlexpress.php" hash="a477bb792b202b346bab76ddc5bf7ddd"/><file name="Fastway.php" hash="c1e8750933e7e63ec9b5e2b1dc44f488"/><file name="Nzpost.php" hash="7e0dcf7cb19d258f709b9a589e14950b"/><file name="Pace.php" hash="81f0b6a8245e62b8b06999268b398b98"/><file name="Shipit.php" hash="1af1829820ffd182d58bfe8ec885fdc4"/><file name="Startrack.php" hash="f79d611788e3b3646ce76318179e501f"/><file name="Startrackexpress.php" hash="e268a24e96d84bd475d9be4ea3a8e24f"/></dir><file name="Note.php" hash="91fdbf3caa65797d8050e999a487c4ae"/><file name="Observer.php" hash="c21ae81b45649c886a30a2a9b6c99425"/><file name="Orders.php" hash="5e6d34681f4ffde9b8b0fcad9f898481"/><dir name="Resource"><dir name="Note"><file name="Collection.php" hash="2526c09006bf6a74b1ddcf2d94b85bd1"/></dir><file name="Note.php" hash="188639765c95bb03abf24785bbcfabbe"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="ShipItController.php" hash="7a82038aa1b2e9fd8bc543b402dcbf9a"/></dir><file name="IndexController.php" hash="20b9637c3eb1a5e7c6a97faa72a0a3fb"/></dir><dir name="etc"><file name="adminhtml.xml" hash="02121bfdaabeb4aa30733462d532b211"/><file name="api.xml" hash="03ba9d58ced7f06da747006e8ddf6861"/><file name="config.xml" hash="4b619f8ed4dbfd9ccfb7c7f2651b48a7"/><file name="system.xml" hash="837db42e1eb469603a3c002537f3d6d8"/></dir><dir name="sql"><dir name="shipnote_setup"><file name="install-1.6.2.0.php" hash="3440e960c4ae3a4036c797c02703f025"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="shipit.xml" hash="61408954f82f5ac2edcf77d859fd4591"/><file name="shipnote.xml" hash="b30f8ced0fa77550a09c3ab5ee03f28d"/></dir><dir name="template"><dir name="shipit"><dir name="system"><dir name="config"><file name="button.phtml" hash="064f053f67fc7b749d1aec40cd352ce1"/><file name="syncbutton.phtml" hash="3e67731254d4d0298891cd2598471dc9"/></dir></dir></dir><dir name="shipnote"><file name="note-create.phtml" hash="218318453338adb8a43d01dcf3aa74f3"/><file name="note.phtml" hash="dc72f98a11c955181a3d4706e9cfd297"/><dir name="sales"><dir name="order"><dir name="create"><file name="data.phtml" hash="63aa7c2343f1d801b92e61b8497b99cb"/><file name="shipnote.phtml" hash="101f8cbd09937b1c9b232a94592e72dd"/></dir><dir name="creditmemo"><dir name="create"><file name="form.phtml" hash="95b2ca2ff1b2d48519cc9f0302179804"/></dir><dir name="view"><file name="form.phtml" hash="0b851bb2da3a68d6b21195cc88d9c3a3"/></dir></dir><dir name="invoice"><dir name="create"><file name="form.phtml" hash="00a1d471675697ff345fb8744b337a54"/></dir><dir name="view"><file name="form.phtml" hash="eb85ea9873900429a859f31585ecb93b"/></dir></dir><dir name="shipment"><dir name="create"><file name="form.phtml" hash="6655a2814e346290ebefce2d45225127"/></dir><dir name="view"><file name="form.phtml" hash="1f5790819a38b162f76a32ec725a0b77"/></dir></dir><dir name="view"><dir name="tab"><file name="info.phtml" hash="66fd085aa3d4e985f914e61ef4ca6748"/></dir></dir></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="shipnote.xml" hash="4662d0b069083e71689f79ad5ce0102e"/><file name="addressautocomplete.xml" hash="88a6cbeb5077d85cac0e98632b467b2a"/><file name="shiptracking.xml" hash="cd598d60854e00759d7e201a9b819a65"/></dir><dir name="template"><dir name="shipnote"><file name="note.phtml" hash="f6199bbe2739b4689cadd2a854a3d753"/></dir><dir name="shiptracking"><file name="shiptracking.phtml" hash="dc155a0bf7d2d83579492d432de1a6f9"/><file name="trackdetail.phtml" hash="1e6967f50a922088ec1aaf9d23910163"/></dir></dir></dir></dir></dir></target><target name="magelocale"><dir><dir name="en_GB"><file name="Rvtech_StarshipitNote.csv" hash="45582b181cd95563d26e516d9dc5efe4"/></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><file name="shipnote.css" hash="1cd880ba6ee2ae963fd8b6208d9e6fd8"/></dir><dir name="js"><dir name="shipit"><file name="jquery-1.10.2.min.js" hash="628072e7212db1e8cdacb22b21752cda"/><file name="noconflict.js" hash="3179f2255b046d5f2e9a71e365287bef"/><file name="onstepcheckout.js" hash="c58f76856d83f7a72dbc30b3295f015b"/><file name="onstepcheckout_shipping.js" hash="01ad944a649fff8f20537af9ca4d3faa"/></dir></dir><dir name="shiptracking"><dir name="css"><file name="shiptracking.css" hash="71583b99e56b8cc1ebd9b575e17e9414"/></dir><dir name="images"><file name="ajax-loader-tr.gif" hash="01a95f2b5387dfec28b58bab64aa32ae"/></dir></dir></dir></dir></dir></target><target name="mageweb"><dir name="js"><dir name="shipit"><dir name="adminhtml"><file name="grid.js" hash="dbf45931948c6c611e1af954ae2430e5"/></dir></dir></dir></target></contents>
|
27 |
<compatible/>
|
28 |
+
<dependencies><required><php><min>5.1.0</min><max>7.0.10</max></php></required></dependencies>
|
29 |
</package>
|