Mage_Shipwire - Version 1.3.4

Version Notes

Shipwire Shipping Rating API integrated

1.2.4 Added multiple Intl support

1.2.2
- Fixed issue with encoding of rate request

1.2.1
- Fixed issue with ship-to postcode not passing

1.2.5
- Fixed PHP coding error

1.3.0
- Added multiple currency support
- Fixed problem some installs had with Invoicing

1.3.1
- Fixed serialization error on some server installs

1.3.2
- Removed Core dependency

1.3.3
- Performance tuning when missing key address into needed to rate orders, like no country

1.3.4
- Support for Free Shipping. Also support for handling fees.

Download this release

Release Info

Developer Shipwire
Extension Mage_Shipwire
Version 1.3.4
Comparing to
See all releases


Code changes from version 1.3.3 to 1.3.4

app/code/local/Shipwire/Shipping/Model/Carrier/Free.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Shipwire_Shipping_Model_Carrier_Free {
3
+ public function toOptionArray()
4
+ {
5
+ return array(
6
+ array(
7
+ 'value' => '',
8
+ 'label' => 'Disabled'
9
+ ),
10
+ array(
11
+ 'value' => 'GD',
12
+ 'label' => 'Ground Service (GD)'
13
+ ),
14
+ array(
15
+ 'value' => '2D',
16
+ 'label' => 'Two Day Service (2D)'
17
+ ),
18
+ array(
19
+ 'value' => '1D',
20
+ 'label' => 'One Day Service (1D)'
21
+ ),
22
+ array(
23
+ 'value' => 'INTL',
24
+ 'label' => 'International Service (INTL)'
25
+ ),
26
+ array(
27
+ 'value' => 'E-INTL',
28
+ 'label' => 'International Economy Service (E-INTL)'
29
+ ),
30
+ array(
31
+ 'value' => 'PL-INTL',
32
+ 'label' => 'International plus Service (PL-INTL)'
33
+ ),
34
+ array(
35
+ 'value' => 'PM-INTL',
36
+ 'label' => 'International Premium Service (PM-INTL)'
37
+ )
38
+ );
39
+ }
40
+ }
app/code/local/Shipwire/Shipping/Model/Carrier/Service.php CHANGED
@@ -5,35 +5,35 @@ class Shipwire_Shipping_Model_Carrier_Service {
5
  return array(
6
  array(
7
  'value' => '1D',
8
- 'label' => 'One Day Service'
9
  ),
10
  array(
11
  'value' => '2D',
12
- 'label' => 'Two Day Service'
13
  ),
14
  array(
15
  'value' => 'GD',
16
- 'label' => 'Ground Service'
17
  ),
18
  array(
19
  'value' => 'FT',
20
- 'label' => 'Freight Service'
21
  ),
22
  array(
23
  'value' => 'INTL',
24
- 'label' => 'International Service'
25
  ),
26
  array(
27
  'value' => 'E-INTL',
28
- 'label' => 'International Economy Service'
29
  ),
30
  array(
31
  'value' => 'PL-INTL',
32
- 'label' => 'International plus Service'
33
  ),
34
  array(
35
  'value' => 'PM-INTL',
36
- 'label' => 'International Premium Service'
37
  )
38
  );
39
  }
5
  return array(
6
  array(
7
  'value' => '1D',
8
+ 'label' => 'One Day Service (1D)'
9
  ),
10
  array(
11
  'value' => '2D',
12
+ 'label' => 'Two Day Service (2D)'
13
  ),
14
  array(
15
  'value' => 'GD',
16
+ 'label' => 'Ground Service (GD)'
17
  ),
18
  array(
19
  'value' => 'FT',
20
+ 'label' => 'Freight Service (FT)'
21
  ),
22
  array(
23
  'value' => 'INTL',
24
+ 'label' => 'International Service (INTL)'
25
  ),
26
  array(
27
  'value' => 'E-INTL',
28
+ 'label' => 'International Economy Service (E-INTL)'
29
  ),
30
  array(
31
  'value' => 'PL-INTL',
32
+ 'label' => 'International plus Service (PL-INTL)'
33
  ),
34
  array(
35
  'value' => 'PM-INTL',
36
+ 'label' => 'International Premium Service (PM-INTL)'
37
  )
38
  );
39
  }
app/code/local/Shipwire/Shipping/Model/Carrier/ShippingMethod.php CHANGED
@@ -13,7 +13,7 @@ class Shipwire_Shipping_Model_Carrier_ShippingMethod extends Mage_Shipping_Model
13
 
14
  protected $_apiEndpoint = 'https://api.shipwire.com/exec/RateServices.php';
15
 
16
-
17
  /**
18
  * Collect rates for this shipping method based on information in $request
19
  *
@@ -22,6 +22,8 @@ class Shipwire_Shipping_Model_Carrier_ShippingMethod extends Mage_Shipping_Model
22
  */
23
  public function collectRates(Mage_Shipping_Model_Rate_Request $request)
24
  {
 
 
25
  // skip if not enabled
26
  if (!$this->getConfigFlag('active')) {
27
  return FALSE;
@@ -63,17 +65,72 @@ class Shipwire_Shipping_Model_Carrier_ShippingMethod extends Mage_Shipping_Model
63
  $method = Mage::getModel('shipping/rate_result_method');
64
  $method->setCarrier($this->_code);
65
  $method->setCarrierTitle($this->getConfigData('title'));
 
 
 
 
66
  $method->setMethod($rMethod['code']);
67
  $method->setMethodTitle($rMethod['title']);
68
  $method->setCost($rMethod['amount']);
69
- $method->setPrice($rMethod['amount']);
70
 
71
  $result->append($method);
72
  }
73
-
74
- return $result;
 
 
 
 
 
 
 
 
 
 
 
 
75
  }
76
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
 
78
  public function getAllowedMethods()
79
  {
13
 
14
  protected $_apiEndpoint = 'https://api.shipwire.com/exec/RateServices.php';
15
 
16
+ protected $_rawRequest = NULL;
17
  /**
18
  * Collect rates for this shipping method based on information in $request
19
  *
22
  */
23
  public function collectRates(Mage_Shipping_Model_Rate_Request $request)
24
  {
25
+ $this->_rawRequest = $request;
26
+
27
  // skip if not enabled
28
  if (!$this->getConfigFlag('active')) {
29
  return FALSE;
65
  $method = Mage::getModel('shipping/rate_result_method');
66
  $method->setCarrier($this->_code);
67
  $method->setCarrierTitle($this->getConfigData('title'));
68
+
69
+ // This hook allows pricing overrides, free shipping, handeling, etc...
70
+ $price = $this->getMethodPrice($rMethod['amount'], $rMethod['code']);
71
+
72
  $method->setMethod($rMethod['code']);
73
  $method->setMethodTitle($rMethod['title']);
74
  $method->setCost($rMethod['amount']);
75
+ $method->setPrice($price);
76
 
77
  $result->append($method);
78
  }
79
+ $this->_result = $result;
80
+ $this->_updateFreeMethodQuote($request);
81
+ return $this->_result;
82
+ }
83
+ public function getMethodPricee($cost, $method='')
84
+ {
85
+ if ($method == $this->getConfigData($this->_freeMethod) && $this->getConfigData('free_shipping_enable')
86
+ && $this->getConfigData('free_shipping_subtotal') <= $this->_rawRequest->getBaseSubtotalInclTax()
87
+ ) {
88
+ $price = '0.00';
89
+ } else {
90
+ $price = $cost;
91
+ }
92
+ return $price;
93
  }
94
 
95
+ /**
96
+ * Override this for Shipwire. We only quote $0 shipping cost if all the items in the cart qualify for free shipping
97
+ * @param Mage_Shipping_Model_Rate_Request $request
98
+ * @return null
99
+ */
100
+ protected function _updateFreeMethodQuote($request)
101
+ {
102
+ // echo "getFreeMethodWeight: " . $request->getFreeMethodWeight();
103
+ // echo "hasFreeMethodWeight: " . $request->hasFreeMethodWeight();
104
+ // echo "getPackageWeight: " . $request->getPackageWeight();
105
+
106
+ if ($request->getFreeMethodWeight() == $request->getPackageWeight() || !$request->hasFreeMethodWeight()) {
107
+ return;
108
+ }
109
+
110
+ $freeMethod = $this->getConfigData($this->_freeMethod);
111
+ if (!$freeMethod) {
112
+ return;
113
+ }
114
+ $freeRateId = false;
115
+
116
+ if (is_object($this->_result)) {
117
+ foreach ($this->_result->getAllRates() as $i=>$item) {
118
+ if ($item->getMethod() == $freeMethod) {
119
+ $freeRateId = $i;
120
+ break;
121
+ }
122
+ }
123
+ }
124
+
125
+ if ($freeRateId === false) {
126
+ return;
127
+ }
128
+
129
+ if ($request->getFreeMethodWeight() == 0) { // If the entire order has no weight because it is free then set the price to 0
130
+ $this->_result->getRateById($freeRateId)->setPrice(0);
131
+ }
132
+
133
+ }
134
 
135
  public function getAllowedMethods()
136
  {
app/code/local/Shipwire/Shipping/etc/system-save.xml ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <sections>
4
+ <carriers>
5
+ <groups>
6
+ <shipwire_shipping translate="label" module="shipping">
7
+ <label>Shipwire Rating Service</label>
8
+ <frontend_type>text</frontend_type>
9
+ <sort_order>13</sort_order>
10
+ <show_in_default>1</show_in_default>
11
+ <show_in_website>1</show_in_website>
12
+ <show_in_store>1</show_in_store>
13
+ <fields>
14
+ <active translate="label">
15
+ <label>Enabled</label>
16
+ <frontend_type>select</frontend_type>
17
+ <source_model>adminhtml/system_config_source_yesno</source_model>
18
+ <sort_order>1</sort_order>
19
+ <show_in_default>1</show_in_default>
20
+ <show_in_website>1</show_in_website>
21
+ <show_in_store>1</show_in_store>
22
+ </active>
23
+ <title translate="label">
24
+ <label>Title</label>
25
+ <frontend_type>text</frontend_type>
26
+ <sort_order>2</sort_order>
27
+ <show_in_default>1</show_in_default>
28
+ <show_in_website>1</show_in_website>
29
+ <show_in_store>1</show_in_store>
30
+ </title>
31
+ <shipwire_email translate="label">
32
+ <label>Shipwire Email</label>
33
+ <frontend_type>text</frontend_type>
34
+ <sort_order>5</sort_order>
35
+ <show_in_default>1</show_in_default>
36
+ <show_in_website>1</show_in_website>
37
+ <show_in_store>1</show_in_store>
38
+ </shipwire_email>
39
+ <shipwire_password translate="label">
40
+ <label>Shipwire Password</label>
41
+ <frontend_type>password</frontend_type>
42
+ <sort_order>10</sort_order>
43
+ <show_in_default>1</show_in_default>
44
+ <show_in_website>1</show_in_website>
45
+ <show_in_store>1</show_in_store>
46
+ </shipwire_password>
47
+ <availableservices translate="label">
48
+ <label>Available Shipping Services</label>
49
+ <frontend_type>multiselect</frontend_type>
50
+ <sort_order>15</sort_order>
51
+ <source_model>shipwire_shipping/carrier_service</source_model>
52
+ <show_in_default>1</show_in_default>
53
+ <show_in_website>1</show_in_website>
54
+ <show_in_store>1</show_in_store>
55
+ </availableservices>
56
+ <free_shipping_enable translate="label">
57
+ <label>Free Shipping with Minimum Order Amount</label>
58
+ <frontend_type>select</frontend_type>
59
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
60
+ <sort_order>210</sort_order>
61
+ <show_in_default>1</show_in_default>
62
+ <show_in_website>1</show_in_website>
63
+ <show_in_store>0</show_in_store>
64
+ </free_shipping_enable>
65
+ <free_shipping_subtotal translate="label">
66
+ <label>Minimum Order Amount for Free Shipping</label>
67
+ <frontend_type>text</frontend_type>
68
+ <validate>validate-number validate-zero-or-greater</validate>
69
+ <sort_order>220</sort_order>
70
+ <show_in_default>1</show_in_default>
71
+ <show_in_website>1</show_in_website>
72
+ <show_in_store>0</show_in_store>
73
+ </free_shipping_subtotal>
74
+ <free_method translate="label">
75
+ <label>Free Method (Use service code above like GD)</label>
76
+ <frontend_type>text</frontend_type>
77
+ <frontend_class>free-method</frontend_class>
78
+ <sort_order>200</sort_order>
79
+ <show_in_default>1</show_in_default>
80
+ <show_in_website>1</show_in_website>
81
+ <show_in_store>1</show_in_store>
82
+ </free_method>
83
+ <handling_type translate="label">
84
+ <label>Calculate Handling Fee</label>
85
+ <frontend_type>select</frontend_type>
86
+ <source_model>shipping/source_handlingType</source_model>
87
+ <sort_order>110</sort_order>
88
+ <show_in_default>1</show_in_default>
89
+ <show_in_website>1</show_in_website>
90
+ <show_in_store>0</show_in_store>
91
+ </handling_type>
92
+ <handling_action translate="label">
93
+ <label>Handling Applied</label>
94
+ <frontend_type>select</frontend_type>
95
+ <source_model>shipping/source_handlingAction</source_model>
96
+ <sort_order>120</sort_order>
97
+ <show_in_default>1</show_in_default>
98
+ <show_in_website>1</show_in_website>
99
+ <show_in_store>0</show_in_store>
100
+ </handling_action>
101
+ <handling_fee translate="label">
102
+ <label>Handling Fee</label>
103
+ <frontend_type>text</frontend_type>
104
+ <validate>validate-number validate-zero-or-greater</validate>
105
+ <sort_order>130</sort_order>
106
+ <show_in_default>1</show_in_default>
107
+ <show_in_website>1</show_in_website>
108
+ <show_in_store>0</show_in_store>
109
+ </handling_fee>
110
+ </fields>
111
+ </shipwire_shipping>
112
+ </groups>
113
+ </carriers>
114
+ </sections>
115
+ </config>
app/code/local/Shipwire/Shipping/etc/system.xml CHANGED
@@ -38,7 +38,7 @@
38
  </shipwire_email>
39
  <shipwire_password translate="label">
40
  <label>Shipwire Password</label>
41
- <frontend_type>text</frontend_type>
42
  <sort_order>10</sort_order>
43
  <show_in_default>1</show_in_default>
44
  <show_in_website>1</show_in_website>
@@ -52,7 +52,62 @@
52
  <show_in_default>1</show_in_default>
53
  <show_in_website>1</show_in_website>
54
  <show_in_store>1</show_in_store>
55
- </availableservices>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
  </fields>
57
  </shipwire_shipping>
58
  </groups>
38
  </shipwire_email>
39
  <shipwire_password translate="label">
40
  <label>Shipwire Password</label>
41
+ <frontend_type>password</frontend_type>
42
  <sort_order>10</sort_order>
43
  <show_in_default>1</show_in_default>
44
  <show_in_website>1</show_in_website>
52
  <show_in_default>1</show_in_default>
53
  <show_in_website>1</show_in_website>
54
  <show_in_store>1</show_in_store>
55
+ </availableservices>
56
+ <free_shipping_enable translate="label">
57
+ <label>Free Shipping with Minimum Order Amount</label>
58
+ <frontend_type>select</frontend_type>
59
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
60
+ <sort_order>210</sort_order>
61
+ <show_in_default>1</show_in_default>
62
+ <show_in_website>1</show_in_website>
63
+ <show_in_store>0</show_in_store>
64
+ </free_shipping_enable>
65
+ <free_shipping_subtotal translate="label">
66
+ <label>Minimum Order Amount for Free Shipping</label>
67
+ <frontend_type>text</frontend_type>
68
+ <validate>validate-number validate-zero-or-greater</validate>
69
+ <sort_order>220</sort_order>
70
+ <show_in_default>1</show_in_default>
71
+ <show_in_website>1</show_in_website>
72
+ <show_in_store>0</show_in_store>
73
+ </free_shipping_subtotal>
74
+ <free_method translate="label">
75
+ <label>Free Method</label>
76
+ <frontend_type>select</frontend_type>
77
+ <source_model>shipwire_shipping/carrier_free</source_model>
78
+ <frontend_class>free-method</frontend_class>
79
+ <sort_order>200</sort_order>
80
+ <show_in_default>1</show_in_default>
81
+ <show_in_website>1</show_in_website>
82
+ <show_in_store>1</show_in_store>
83
+ </free_method>
84
+ <handling_type translate="label">
85
+ <label>Calculate Handling Fee</label>
86
+ <frontend_type>select</frontend_type>
87
+ <source_model>shipping/source_handlingType</source_model>
88
+ <sort_order>110</sort_order>
89
+ <show_in_default>1</show_in_default>
90
+ <show_in_website>1</show_in_website>
91
+ <show_in_store>0</show_in_store>
92
+ </handling_type>
93
+ <handling_action translate="label">
94
+ <label>Handling Applied</label>
95
+ <frontend_type>select</frontend_type>
96
+ <source_model>shipping/source_handlingAction</source_model>
97
+ <sort_order>120</sort_order>
98
+ <show_in_default>1</show_in_default>
99
+ <show_in_website>1</show_in_website>
100
+ <show_in_store>0</show_in_store>
101
+ </handling_action>
102
+ <handling_fee translate="label">
103
+ <label>Handling Fee</label>
104
+ <frontend_type>text</frontend_type>
105
+ <validate>validate-number validate-zero-or-greater</validate>
106
+ <sort_order>130</sort_order>
107
+ <show_in_default>1</show_in_default>
108
+ <show_in_website>1</show_in_website>
109
+ <show_in_store>0</show_in_store>
110
+ </handling_fee>
111
  </fields>
112
  </shipwire_shipping>
113
  </groups>
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Mage_Shipwire</name>
4
- <version>1.3.3</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
  <channel>community</channel>
@@ -32,11 +32,14 @@
32
  - Removed Core dependency&#xD;
33
  &#xD;
34
  1.3.3&#xD;
35
- - Performance tuning when missing key address into needed to rate orders, like no country</notes>
 
 
 
36
  <authors><author><name>Shipwire</name><user>Shipwire</user><email>magento-dev@shipwire.com</email></author></authors>
37
- <date>2013-01-07</date>
38
- <time>20:35:30</time>
39
- <contents><target name="mage"><dir name="app"><dir name="etc"><dir name="modules"><file name="Shipwire_Shipping.xml" hash="22ed62daa00faeb3219b05484c5a02a4"/></dir></dir></dir></target><target name="magelocal"><dir name="Shipwire"><dir name="Shipping"><dir name="Model"><dir name="Carrier"><file name="Service.php" hash="1499ae366ebd44d49356230248fea53e"/><file name="ShippingMethod.php" hash="cca2a70767bdfdca18be00aed5efe79b"/></dir></dir><dir name="etc"><file name="config.xml" hash="05bd86d2b0d072417c0bcefdd2c08399"/><file name="system.xml" hash="4f787402d22f2d6330225f291f3bf8e2"/></dir></dir></dir></target></contents>
40
  <compatible/>
41
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php><package><name></name><channel>connect.magentocommerce.com/core</channel><min></min><max></max></package></required></dependencies>
42
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Mage_Shipwire</name>
4
+ <version>1.3.4</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
  <channel>community</channel>
32
  - Removed Core dependency&#xD;
33
  &#xD;
34
  1.3.3&#xD;
35
+ - Performance tuning when missing key address into needed to rate orders, like no country&#xD;
36
+ &#xD;
37
+ 1.3.4&#xD;
38
+ - Support for Free Shipping. Also support for handling fees.</notes>
39
  <authors><author><name>Shipwire</name><user>Shipwire</user><email>magento-dev@shipwire.com</email></author></authors>
40
+ <date>2013-06-19</date>
41
+ <time>18:59:06</time>
42
+ <contents><target name="mage"><dir name="app"><dir name="etc"><dir name="modules"><file name="Shipwire_Shipping.xml" hash="22ed62daa00faeb3219b05484c5a02a4"/></dir></dir></dir></target><target name="magelocal"><dir name="Shipwire"><dir name="Shipping"><dir name="Model"><dir name="Carrier"><file name="Free.php" hash="f24f33a39dd4d457d41e2e13aa4dc560"/><file name="Service.php" hash="5cf9d3dbc764a42aa9260f898c67f623"/><file name="ShippingMethod.php" hash="850fa4e118c3758cec806811410e0671"/></dir></dir><dir name="etc"><file name="config.xml" hash="05bd86d2b0d072417c0bcefdd2c08399"/><file name="system-save.xml" hash="4c2dbe53aae8ae812325f642eee60258"/><file name="system.xml" hash="391e5f95aecb17f219a54cbf9ad8f34f"/></dir></dir></dir></target></contents>
43
  <compatible/>
44
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php><package><name></name><channel>connect.magentocommerce.com/core</channel><min></min><max></max></package></required></dependencies>
45
  </package>