Picqer_PostNL - Version 1.2.0

Version Notes

Turns TIG PostNL fields back on when deactivating the Picqer PostNL extension. Better retrieval of PakjeGemak address.

Download this release

Release Info

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


Code changes from version 1.1.0 to 1.2.0

app/code/community/Picqer/PostNL/Helper/Data.php CHANGED
@@ -2,5 +2,25 @@
2
 
3
  class Picqer_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
4
  {
5
- //
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  }
2
 
3
  class Picqer_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
4
  {
5
+ /**
6
+ * Check whether this extension is active
7
+ * @return bool
8
+ */
9
+ public function isExtensionActive()
10
+ {
11
+ $active = Mage::getStoreConfig('picqer_shipping_options/postnl_settings/picqer_postnl_active');
12
+
13
+ return (bool)$active;
14
+ }
15
+ /**
16
+ * Check whether the TIG PostNL extension is installed
17
+ * @return bool
18
+ */
19
+ public function isTIGPostNlExtensionInstalled()
20
+ {
21
+ $tigInstalled = Mage::helper('core')->isModuleEnabled('TIG_PostNL');
22
+
23
+ return (bool)$tigInstalled;
24
+ }
25
+
26
  }
app/code/community/Picqer/PostNL/Model/Adminhtml/Observer/OrderGrid.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Picqer_PostNL_Model_Adminhtml_Observer_OrderGrid extends TIG_PostNL_Model_Adminhtml_Observer_OrderGrid
4
+ {
5
+ public function modifyGrid(Varien_Event_Observer $observer)
6
+ {
7
+ $helper = Mage::helper('picqer_postnl');
8
+ if ($helper->isExtensionActive()) {
9
+ return $observer;
10
+ }
11
+
12
+ return parent::modifyGrid($observer);
13
+ }
14
+ }
app/code/community/Picqer/PostNL/Model/Adminhtml/Observer/Ordergrid.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Picqer_PostNL_Model_Adminhtml_Observer_Ordergrid extends TIG_PostNL_Model_Adminhtml_Observer_OrderGrid
4
+ {
5
+
6
+ public function modifyGrid(Varien_Event_Observer $observer)
7
+ {
8
+ if($this->extensionActive()) {
9
+ return $observer;
10
+ }
11
+
12
+ return parent::modifyGrid($observer);
13
+ }
14
+
15
+ /**
16
+ * Check whether this extension is active
17
+ * @return bool
18
+ */
19
+ private function extensionActive()
20
+ {
21
+ $active = Mage::getStoreConfig('picqer_shipping_options/postnl_settings/picqer_postnl_active');
22
+ if ($active != 1)
23
+ {
24
+ return false;
25
+ }
26
+
27
+ return true;
28
+ }
29
+
30
+
31
+ }
app/code/community/Picqer/PostNL/Model/Adminhtml/Observer/ShipmentGrid.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Picqer_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid
4
+ {
5
+ public function modifyGrid(Varien_Event_Observer $observer)
6
+ {
7
+ $helper = Mage::helper('picqer_postnl');
8
+ if ($helper->isExtensionActive()) {
9
+ return $observer;
10
+ }
11
+
12
+ return parent::modifyGrid($observer);
13
+ }
14
+ }
app/code/community/Picqer/PostNL/Model/Adminhtml/Observer/ShipmentView.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Picqer_PostNL_Model_Adminhtml_Observer_ShipmentView extends TIG_PostNL_Model_Adminhtml_Observer_ShipmentView
4
+ {
5
+ public function addPrintLabelButton(Varien_Event_Observer $observer)
6
+ {
7
+ $helper = Mage::helper('picqer_postnl');
8
+ if ($helper->isExtensionActive()) {
9
+ return $observer;
10
+ }
11
+
12
+ return parent::addPrintLabelButton($observer);
13
+ }
14
+ }
app/code/community/Picqer/PostNL/Model/Sales/Order/Api.php CHANGED
@@ -12,57 +12,56 @@ class Picqer_PostNL_Model_Sales_Order_Api extends Mage_Sales_Model_Order_Api
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
-
29
- // Get the store time zone and change times to match the correct time zone
30
- $storeTimezone = Mage::getStoreConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE,
31
- $tigPostNlOrder->getStoreId());
32
- $storeTimezone = new DateTimeZone($storeTimezone);
33
-
34
- if ($tigPostNlOrder->hasExpectedDeliveryTimeEnd()) {
35
- $expectedDeliveryTimeEnd = $this->toCorrectTimeZone($tigPostNlOrder->getExpectedDeliveryTimeEnd(),
36
- $storeTimezone)->format('H:i');
37
- } else {
38
- $expectedDeliveryTimeEnd = null;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
  }
40
-
41
- // Add TIG_PostNL information to API
42
- $result = [
43
- 'confirmDate' => $this->toCorrectTimeZone($tigPostNlOrder->getConfirmDate(), $storeTimezone)
44
- ->format('Y-m-d H:i:s'),
45
- 'isActive' => $tigPostNlOrder->getIsActive(),
46
- 'shipmentCosts' => $tigPostNlOrder->getShipmentCosts(),
47
- 'productCode' => $tigPostNlOrder->getProductCode(),
48
- 'isPakjeGemak' => $tigPostNlOrder->getIsPakjeGemak(),
49
- 'isCanceled' => $tigPostNlOrder->getIsCanceled(),
50
- 'deliveryDate' => $this->toCorrectTimeZone($tigPostNlOrder->getDeliveryDate(), $storeTimezone)
51
- ->format('Y-m-d H:i:s'),
52
- 'type' => $tigPostNlOrder->getType(),
53
- 'mobilePhoneNumber' => $tigPostNlOrder->getMobilePhoneNumber(),
54
- 'isPakketautomaat' => $tigPostNlOrder->getIsPakketautomaat(),
55
- 'options' => $tigPostNlOrder->getUnserializedOptions(),
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;
66
  }
67
 
68
 
@@ -128,34 +127,6 @@ class Picqer_PostNL_Model_Sales_Order_Api extends Mage_Sales_Model_Order_Api
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
@@ -172,4 +143,4 @@ class Picqer_PostNL_Model_Sales_Order_Api extends Mage_Sales_Model_Order_Api
172
  && $this->fitsAsBuspakje($order)
173
  && $this->canUseBuspakje();
174
  }
175
- }
12
  */
13
  public function picqerPostNL($orderIncrementId)
14
  {
15
+ $helper = Mage::helper('picqer_postnl');
16
+ if (! $helper->isExtensionActive()) {
17
  return [];
18
  }
19
 
20
+ if (! $helper->isTIGPostNlExtensionInstalled()) {
 
21
  return [];
22
  }
23
 
24
+ // Get the order and the PakjeGemakAddress (if set)
25
  $order = $this->_initOrder($orderIncrementId);
26
+ $postNLHelper = Mage::helper('postnl');
27
+
28
+ try {
29
+ $pakjeGemakAddress = $postNLHelper->getPakjeGemakAddressForOrder($order);
30
+ $tigPostNlOrder = Mage::getModel('postnl_core/order')->loadByOrder($order);
31
+
32
+ // Get the store time zone and change times to match the correct time zone
33
+ $storeTimezone = Mage::getStoreConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE, $tigPostNlOrder->getStoreId());
34
+ $storeTimezone = new DateTimeZone($storeTimezone);
35
+
36
+ if ($tigPostNlOrder->hasExpectedDeliveryTimeEnd()) {
37
+ $expectedDeliveryTimeEnd = $this->toCorrectTimeZone($tigPostNlOrder->getExpectedDeliveryTimeEnd(), $storeTimezone)->format('H:i');
38
+ } else {
39
+ $expectedDeliveryTimeEnd = null;
40
+ }
41
+
42
+ // Add TIG_PostNL information to API
43
+ $result = [
44
+ 'confirmDate' => $this->toCorrectTimeZone($tigPostNlOrder->getConfirmDate(), $storeTimezone)->format('Y-m-d H:i:s'),
45
+ 'isActive' => $tigPostNlOrder->getIsActive(),
46
+ 'shipmentCosts' => $tigPostNlOrder->getShipmentCosts(),
47
+ 'productCode' => $tigPostNlOrder->getProductCode(),
48
+ 'isPakjeGemak' => $tigPostNlOrder->getIsPakjeGemak(),
49
+ 'isCanceled' => $tigPostNlOrder->getIsCanceled(),
50
+ 'deliveryDate' => $this->toCorrectTimeZone($tigPostNlOrder->getDeliveryDate(), $storeTimezone)->format('Y-m-d H:i:s'),
51
+ 'type' => $tigPostNlOrder->getType(),
52
+ 'mobilePhoneNumber' => $tigPostNlOrder->getMobilePhoneNumber(),
53
+ 'isPakketautomaat' => $tigPostNlOrder->getIsPakketautomaat(),
54
+ 'options' => $tigPostNlOrder->getUnserializedOptions(),
55
+ 'expectedDeliveryTimeStart' => $this->toCorrectTimeZone($tigPostNlOrder->getExpectedDeliveryTimeStart(), $storeTimezone)->format('H:i'),
56
+ 'expectedDeliveryTimeEnd' => $expectedDeliveryTimeEnd,
57
+ 'pakjeGemakAddress' => empty($pakjeGemakAddress) ? null : $this->_getAttributes($pakjeGemakAddress),
58
+ 'isBrievenbuspakje' => $this->useBuspakje($order, $tigPostNlOrder),
59
+ ];
60
+
61
+ return $result;
62
+ } catch (\Exception $e) {
63
+ return [];
64
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
  }
66
 
67
 
127
  return $order->getShippingAddress()->getCountry() == 'NL';
128
  }
129
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
130
 
131
  /**
132
  * Calculate if this should be a buspakje shipment
143
  && $this->fitsAsBuspakje($order)
144
  && $this->canUseBuspakje();
145
  }
146
+ }
app/code/community/Picqer/PostNL/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <modules>
4
  <Picqer_PostNL>
5
- <version>1.0.0</version>
6
  </Picqer_PostNL>
7
  </modules>
8
  <global>
@@ -27,13 +27,16 @@
27
  <adminhtml_block_html_before>
28
  <observers>
29
  <postnl_adminhtml_ordergrid>
30
- <type>disabled</type>
 
31
  </postnl_adminhtml_ordergrid>
32
  <postnl_adminhtml_shipmentgrid>
33
- <type>disabled</type>
 
34
  </postnl_adminhtml_shipmentgrid>
35
  <postnl_adminhtml_shipmentview>
36
- <type>disabled</type>
 
37
  </postnl_adminhtml_shipmentview>
38
  </observers>
39
  </adminhtml_block_html_before>
2
  <config>
3
  <modules>
4
  <Picqer_PostNL>
5
+ <version>1.2.0</version>
6
  </Picqer_PostNL>
7
  </modules>
8
  <global>
27
  <adminhtml_block_html_before>
28
  <observers>
29
  <postnl_adminhtml_ordergrid>
30
+ <class>Picqer_PostNL_Model_Adminhtml_Observer_OrderGrid</class>
31
+ <method>modifyGrid</method>
32
  </postnl_adminhtml_ordergrid>
33
  <postnl_adminhtml_shipmentgrid>
34
+ <class>Picqer_PostNL_Model_Adminhtml_Observer_ShipmentGrid</class>
35
+ <method>modifyGrid</method>
36
  </postnl_adminhtml_shipmentgrid>
37
  <postnl_adminhtml_shipmentview>
38
+ <class>Picqer_PostNL_Model_Adminhtml_Observer_ShipmentView</class>
39
+ <method>addPrintLabelButton</method>
40
  </postnl_adminhtml_shipmentview>
41
  </observers>
42
  </adminhtml_block_html_before>
package.xml CHANGED
@@ -1,18 +1,18 @@
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>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Picqer_PostNL</name>
4
+ <version>1.2.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>Turns TIG PostNL fields back on when deactivating the Picqer PostNL extension. Better retrieval of PakjeGemak address.</notes>
12
  <authors><author><name>Stephan Groen</name><user>stephangroen</user><email>stephan@picqer.com</email></author></authors>
13
+ <date>2017-01-30</date>
14
+ <time>14:50:56</time>
15
+ <contents><target name="magecommunity"><dir name="Picqer"><dir name="PostNL"><dir name="Helper"><file name="Data.php" hash="da57ee165a0b33beceb01f108e870cf7"/></dir><dir name="Model"><file name="Active.php" hash="4d756a5f96e91f3f9be5194f7378d8bf"/><dir name="Adminhtml"><dir name="Observer"><file name="OrderGrid.php" hash="9df848aa164e180eb4d1aabad1ac6de1"/><file name="Ordergrid.php" hash="0a71bf13c0fdbc17692a4488747a4f00"/><file name="ShipmentGrid.php" hash="de7d9d622f260102359528811bc6654a"/><file name="ShipmentView.php" hash="9df38ce878025e4af09d6d796471b8d7"/></dir></dir><dir name="Sales"><dir name="Order"><file name="Api.php" hash="90f066fc4e00341bba836a3ad356517f"/></dir></dir></dir><dir name="etc"><file name="api.xml" hash="6f5f5494324d29ae5ed9b14c3826dbad"/><file name="config.xml" hash="8daf10d40e2078f244890f962298a826"/><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>7.1.0</max></php><package><name>TIG_PostNL</name><channel>community</channel><min>1.7.0</min><max/></package></required></dependencies>
18
  </package>