Picqer_PostNL - Version 1.1.0

Version Notes

Added Letterbox product support.

Download this release

Release Info

Developer Stephan Groen
Extension Picqer_PostNL
Version 1.1.0
Comparing to
See all releases


Code changes from version 1.0.0 to 1.1.0

app/code/community/Picqer/PostNL/Model/Sales/Order/Api.php CHANGED
@@ -12,20 +12,17 @@ class Picqer_PostNL_Model_Sales_Order_Api extends Mage_Sales_Model_Order_Api
12
  */
13
  public function picqerPostNL($orderIncrementId)
14
  {
15
- $active = Mage::getStoreConfig('picqer_shipping_options/postnl_settings/picqer_postnl_active');
16
- if ($active != 1)
 
 
 
17
  {
18
- return [ ];
19
  }
20
 
21
  $order = $this->_initOrder($orderIncrementId);
22
 
23
- // Check if TIG_PostNL is installed and enabled
24
- $tigInstalled = Mage::helper('core')->isModuleEnabled('TIG_PostNL');
25
- if ( ! $tigInstalled) {
26
- return [ ];
27
- }
28
-
29
  // Fetch TIG_PostNL order
30
  $tigPostNlOrder = Mage::getModel('postnl_core/order')->loadByOrder($order);
31
 
@@ -59,8 +56,10 @@ class Picqer_PostNL_Model_Sales_Order_Api extends Mage_Sales_Model_Order_Api
59
  'expectedDeliveryTimeStart' => $this->toCorrectTimeZone($tigPostNlOrder->getExpectedDeliveryTimeStart(),
60
  $storeTimezone)->format('H:i'),
61
  'expectedDeliveryTimeEnd' => $expectedDeliveryTimeEnd,
62
- 'pakjeGemakAddress' => $tigPostNlOrder->getIsPakjeGemak() || $tigPostNlOrder->getIsPakketautomaat() ? $this->_getAttributes($tigPostNlOrder->getPakjeGemakAddress(),
63
- 'order_address') : null,
 
 
64
  ];
65
 
66
  return $result;
@@ -83,4 +82,94 @@ class Picqer_PostNL_Model_Sales_Order_Api extends Mage_Sales_Model_Order_Api
83
  return $dateTime;
84
  }
85
 
86
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  */
13
  public function picqerPostNL($orderIncrementId)
14
  {
15
+ if (! $this->extensionActive()) {
16
+ return [];
17
+ }
18
+
19
+ if (! $this->tigPostNlExtensionInstalled())
20
  {
21
+ return [];
22
  }
23
 
24
  $order = $this->_initOrder($orderIncrementId);
25
 
 
 
 
 
 
 
26
  // Fetch TIG_PostNL order
27
  $tigPostNlOrder = Mage::getModel('postnl_core/order')->loadByOrder($order);
28
 
56
  'expectedDeliveryTimeStart' => $this->toCorrectTimeZone($tigPostNlOrder->getExpectedDeliveryTimeStart(),
57
  $storeTimezone)->format('H:i'),
58
  'expectedDeliveryTimeEnd' => $expectedDeliveryTimeEnd,
59
+ 'pakjeGemakAddress' => $tigPostNlOrder->getIsPakjeGemak() || $tigPostNlOrder->getIsPakketautomaat()
60
+ ? $this->_getAttributes($tigPostNlOrder->getPakjeGemakAddress(), 'order_address')
61
+ : null,
62
+ 'isBrievenbuspakje' => $this->useBuspakje($order, $tigPostNlOrder),
63
  ];
64
 
65
  return $result;
82
  return $dateTime;
83
  }
84
 
85
+ /**
86
+ * Determine if this is a cash on delivery order
87
+ * @param $order
88
+ * @return bool
89
+ */
90
+ private function isCod($order)
91
+ {
92
+ $codPaymentMethods = Mage::helper('postnl/payment')->getCodPaymentMethods();
93
+ $paymentMethod = $order->getPayment()->getMethod();
94
+ if (in_array($paymentMethod, $codPaymentMethods)) {
95
+ return true;
96
+ }
97
+
98
+ return false;
99
+ }
100
+
101
+ /**
102
+ * Are we allowed to use Buspakje by preferences from Magento
103
+ * @return mixed
104
+ */
105
+ private function canUseBuspakje()
106
+ {
107
+ return Mage::helper('postnl')->canUseBuspakje();
108
+ }
109
+
110
+ /**
111
+ * Does the order fit as a Buspakje
112
+ * @param $order
113
+ * @return mixed
114
+ */
115
+ private function fitsAsBuspakje($order)
116
+ {
117
+ $orderItems = $order->getItemsCollection();
118
+ return Mage::helper('postnl')->fitsAsBuspakje($orderItems, true);
119
+ }
120
+
121
+ /**
122
+ * Is this a Dutch shipment
123
+ * @param $order
124
+ * @return bool
125
+ */
126
+ private function isDutchShipment($order)
127
+ {
128
+ return $order->getShippingAddress()->getCountry() == 'NL';
129
+ }
130
+
131
+ /**
132
+ * Check whether this extension is active
133
+ * @return bool
134
+ */
135
+ private function extensionActive()
136
+ {
137
+ $active = Mage::getStoreConfig('picqer_shipping_options/postnl_settings/picqer_postnl_active');
138
+ if ($active != 1)
139
+ {
140
+ return false;
141
+ }
142
+
143
+ return true;
144
+ }
145
+
146
+ /**
147
+ * Check whether the TIG PostNL extension is installed
148
+ * @return bool
149
+ */
150
+ private function tigPostNlExtensionInstalled()
151
+ {
152
+ $tigInstalled = Mage::helper('core')->isModuleEnabled('TIG_PostNL');
153
+ if ( ! $tigInstalled) {
154
+ return false;
155
+ }
156
+
157
+ return true;
158
+ }
159
+
160
+ /**
161
+ * Calculate if this should be a buspakje shipment
162
+ * @param $order
163
+ * @param $tigOrder
164
+ * @return bool
165
+ */
166
+ private function useBuspakje($order, $tigOrder)
167
+ {
168
+ return $this->isDutchShipment($order)
169
+ && ! $this->isCod($order)
170
+ && ! $tigOrder->getIsPakjeGemak()
171
+ && ! $tigOrder->getIsPakketautomaat()
172
+ && $this->fitsAsBuspakje($order)
173
+ && $this->canUseBuspakje();
174
+ }
175
+ }
package.xml CHANGED
@@ -1,18 +1,18 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Picqer_PostNL</name>
4
- <version>1.0.0</version>
5
  <stability>stable</stability>
6
  <license>MIT</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Extension to support PostNL shipments from TIG PostNL extension for Picqer.</summary>
10
  <description>This extension enables you to use the official PostNL extension by TIG with Picqer. Shipments in Picqer will automatically use the right settings, based on the choices of your customer.</description>
11
- <notes>First version of the Picqer_PostNL extension to support integration with Picqer and your Magento store with the TIG_PostNL extension.</notes>
12
  <authors><author><name>Stephan Groen</name><user>stephangroen</user><email>stephan@picqer.com</email></author></authors>
13
- <date>2015-07-09</date>
14
- <time>12:26:01</time>
15
- <contents><target name="magecommunity"><dir name="Picqer"><dir name="PostNL"><dir name="Helper"><file name="Data.php" hash="50023c1bdbcd34331dc380c239b1fbad"/></dir><dir name="Model"><file name="Active.php" hash="4d756a5f96e91f3f9be5194f7378d8bf"/><dir name="Sales"><dir name="Order"><file name="Api.php" hash="66b037b5b422e19e9eb3ecad0b24c400"/></dir></dir></dir><dir name="etc"><file name="api.xml" hash="6f5f5494324d29ae5ed9b14c3826dbad"/><file name="config.xml" hash="11db5c78279c13328828aa8abba867f2"/><file name="system.xml" hash="f2a526f1d32f243ef253e3d3b3883938"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Picqer_PostNL.xml" hash="908eb08b0b31bc34766f8cfa6aa4d713"/></dir></target></contents>
16
  <compatible/>
17
- <dependencies><required><php><min>5.4.0</min><max>5.6.9</max></php><package><name>TIG_PostNL</name><channel>community</channel><min>1.5.3</min><max/></package></required></dependencies>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Picqer_PostNL</name>
4
+ <version>1.1.0</version>
5
  <stability>stable</stability>
6
  <license>MIT</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Extension to support PostNL shipments from TIG PostNL extension for Picqer.</summary>
10
  <description>This extension enables you to use the official PostNL extension by TIG with Picqer. Shipments in Picqer will automatically use the right settings, based on the choices of your customer.</description>
11
+ <notes>Added Letterbox product support.</notes>
12
  <authors><author><name>Stephan Groen</name><user>stephangroen</user><email>stephan@picqer.com</email></author></authors>
13
+ <date>2015-11-19</date>
14
+ <time>15:20:27</time>
15
+ <contents><target name="magecommunity"><dir name="Picqer"><dir name="PostNL"><dir name="Helper"><file name="Data.php" hash="50023c1bdbcd34331dc380c239b1fbad"/></dir><dir name="Model"><file name="Active.php" hash="4d756a5f96e91f3f9be5194f7378d8bf"/><dir name="Sales"><dir name="Order"><file name="Api.php" hash="5bb37d022c6cd232d1d4a04c101ff484"/></dir></dir></dir><dir name="etc"><file name="api.xml" hash="6f5f5494324d29ae5ed9b14c3826dbad"/><file name="config.xml" hash="11db5c78279c13328828aa8abba867f2"/><file name="system.xml" hash="f2a526f1d32f243ef253e3d3b3883938"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Picqer_PostNL.xml" hash="908eb08b0b31bc34766f8cfa6aa4d713"/></dir></target></contents>
16
  <compatible/>
17
+ <dependencies><required><php><min>5.4.0</min><max>5.6.14</max></php><package><name>TIG_PostNL</name><channel>community</channel><min>1.5.3</min><max/></package></required></dependencies>
18
  </package>