Version Notes
First version of the Picqer_PostNL extension to support integration with Picqer and your Magento store with the TIG_PostNL extension.
Download this release
Release Info
Developer | Stephan Groen |
Extension | Picqer_PostNL |
Version | 1.0.0 |
Comparing to | |
See all releases |
Version 1.0.0
- app/code/community/Picqer/PostNL/Helper/Data.php +6 -0
- app/code/community/Picqer/PostNL/Model/Active.php +12 -0
- app/code/community/Picqer/PostNL/Model/Sales/Order/Api.php +86 -0
- app/code/community/Picqer/PostNL/etc/api.xml +18 -0
- app/code/community/Picqer/PostNL/etc/config.xml +69 -0
- app/code/community/Picqer/PostNL/etc/system.xml +41 -0
- app/etc/modules/Picqer_PostNL.xml +13 -0
- package.xml +18 -0
app/code/community/Picqer/PostNL/Helper/Data.php
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Picqer_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
|
4 |
+
{
|
5 |
+
//
|
6 |
+
}
|
app/code/community/Picqer/PostNL/Model/Active.php
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Picqer_PostNL_Model_Active
|
4 |
+
{
|
5 |
+
public function toOptionArray()
|
6 |
+
{
|
7 |
+
return array(
|
8 |
+
array('value' => 1, 'label' => Mage::helper('picqer_postnl')->__('Yes')),
|
9 |
+
array('value' => 0, 'label' => Mage::helper('picqer_postnl')->__('No'))
|
10 |
+
);
|
11 |
+
}
|
12 |
+
}
|
app/code/community/Picqer/PostNL/Model/Sales/Order/Api.php
ADDED
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Picqer_PostNL_Model_Sales_Order_Api extends Mage_Sales_Model_Order_Api
|
4 |
+
{
|
5 |
+
|
6 |
+
/**
|
7 |
+
* API call returns PostNL shipping info generated by TIG_PostNL
|
8 |
+
*
|
9 |
+
* @param $orderIncrementId
|
10 |
+
*
|
11 |
+
* @return array
|
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 |
+
|
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,
|
34 |
+
$tigPostNlOrder->getStoreId());
|
35 |
+
$storeTimezone = new DateTimeZone($storeTimezone);
|
36 |
+
|
37 |
+
if ($tigPostNlOrder->hasExpectedDeliveryTimeEnd()) {
|
38 |
+
$expectedDeliveryTimeEnd = $this->toCorrectTimeZone($tigPostNlOrder->getExpectedDeliveryTimeEnd(),
|
39 |
+
$storeTimezone)->format('H:i');
|
40 |
+
} else {
|
41 |
+
$expectedDeliveryTimeEnd = null;
|
42 |
+
}
|
43 |
+
|
44 |
+
// Add TIG_PostNL information to API
|
45 |
+
$result = [
|
46 |
+
'confirmDate' => $this->toCorrectTimeZone($tigPostNlOrder->getConfirmDate(), $storeTimezone)
|
47 |
+
->format('Y-m-d H:i:s'),
|
48 |
+
'isActive' => $tigPostNlOrder->getIsActive(),
|
49 |
+
'shipmentCosts' => $tigPostNlOrder->getShipmentCosts(),
|
50 |
+
'productCode' => $tigPostNlOrder->getProductCode(),
|
51 |
+
'isPakjeGemak' => $tigPostNlOrder->getIsPakjeGemak(),
|
52 |
+
'isCanceled' => $tigPostNlOrder->getIsCanceled(),
|
53 |
+
'deliveryDate' => $this->toCorrectTimeZone($tigPostNlOrder->getDeliveryDate(), $storeTimezone)
|
54 |
+
->format('Y-m-d H:i:s'),
|
55 |
+
'type' => $tigPostNlOrder->getType(),
|
56 |
+
'mobilePhoneNumber' => $tigPostNlOrder->getMobilePhoneNumber(),
|
57 |
+
'isPakketautomaat' => $tigPostNlOrder->getIsPakketautomaat(),
|
58 |
+
'options' => $tigPostNlOrder->getUnserializedOptions(),
|
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;
|
67 |
+
}
|
68 |
+
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Change the time zone of a date and time
|
72 |
+
*
|
73 |
+
* @param $value
|
74 |
+
* @param DateTimeZone $dateTimeZone
|
75 |
+
*
|
76 |
+
* @return DateTime
|
77 |
+
*/
|
78 |
+
private function toCorrectTimeZone($value, DateTimeZone $dateTimeZone)
|
79 |
+
{
|
80 |
+
$dateTime = new DateTime($value);
|
81 |
+
$dateTime->setTimezone($dateTimeZone);
|
82 |
+
|
83 |
+
return $dateTime;
|
84 |
+
}
|
85 |
+
|
86 |
+
}
|
app/code/community/Picqer/PostNL/etc/api.xml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<api>
|
4 |
+
<resources>
|
5 |
+
<sales_order translate="title" module="sales">
|
6 |
+
<model>sales/order_api</model>
|
7 |
+
<title>Order API</title>
|
8 |
+
<acl>sales/order</acl>
|
9 |
+
<methods>
|
10 |
+
<picqerPostNL translate="title" module="sales">
|
11 |
+
<title>Retrieve TIG PostNL information</title>
|
12 |
+
<acl>sales/order/info</acl>
|
13 |
+
</picqerPostNL>
|
14 |
+
</methods>
|
15 |
+
</sales_order>
|
16 |
+
</resources>
|
17 |
+
</api>
|
18 |
+
</config>
|
app/code/community/Picqer/PostNL/etc/config.xml
ADDED
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Picqer_PostNL>
|
5 |
+
<version>1.0.0</version>
|
6 |
+
</Picqer_PostNL>
|
7 |
+
</modules>
|
8 |
+
<global>
|
9 |
+
<models>
|
10 |
+
<sales>
|
11 |
+
<rewrite>
|
12 |
+
<order_api>Picqer_PostNL_Model_Sales_Order_Api</order_api>
|
13 |
+
</rewrite>
|
14 |
+
</sales>
|
15 |
+
<picqer_postnl>
|
16 |
+
<class>Picqer_PostNL_Model</class>
|
17 |
+
</picqer_postnl>
|
18 |
+
</models>
|
19 |
+
<helpers>
|
20 |
+
<picqer_postnl>
|
21 |
+
<class>Picqer_PostNL_Helper</class>
|
22 |
+
</picqer_postnl>
|
23 |
+
</helpers>
|
24 |
+
</global>
|
25 |
+
<adminhtml>
|
26 |
+
<events>
|
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>
|
40 |
+
<sales_order_shipment_save_after>
|
41 |
+
<observers>
|
42 |
+
<!-- Creates a postnl shipment entity and generates a barcode through CIF -->
|
43 |
+
<postnl_shipment_generate_barcode>
|
44 |
+
<type>disabled</type>
|
45 |
+
</postnl_shipment_generate_barcode>
|
46 |
+
</observers>
|
47 |
+
</sales_order_shipment_save_after>
|
48 |
+
</events>
|
49 |
+
<acl>
|
50 |
+
<resources>
|
51 |
+
<admin>
|
52 |
+
<children>
|
53 |
+
<system>
|
54 |
+
<children>
|
55 |
+
<config>
|
56 |
+
<children>
|
57 |
+
<picqer_shipping_options>
|
58 |
+
<title>Store Picqer Shipping Section</title>
|
59 |
+
</picqer_shipping_options>
|
60 |
+
</children>
|
61 |
+
</config>
|
62 |
+
</children>
|
63 |
+
</system>
|
64 |
+
</children>
|
65 |
+
</admin>
|
66 |
+
</resources>
|
67 |
+
</acl>
|
68 |
+
</adminhtml>
|
69 |
+
</config>
|
app/code/community/Picqer/PostNL/etc/system.xml
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<tabs>
|
4 |
+
<picqer translate="label" module="picqer_postnl">
|
5 |
+
<label>Picqer</label>
|
6 |
+
<sort_order>99999</sort_order>
|
7 |
+
</picqer>
|
8 |
+
</tabs>
|
9 |
+
<sections>
|
10 |
+
<picqer_shipping_options translate="label" module="picqer_postnl">
|
11 |
+
<label>Shipping</label>
|
12 |
+
<tab>picqer</tab>
|
13 |
+
<frontend_type>text</frontend_type>
|
14 |
+
<sort_order>1000</sort_order>
|
15 |
+
<show_in_default>1</show_in_default>
|
16 |
+
<show_in_website>1</show_in_website>
|
17 |
+
<show_in_store>1</show_in_store>
|
18 |
+
<groups>
|
19 |
+
<postnl_settings translate="label">
|
20 |
+
<label>PostNL</label>
|
21 |
+
<frontend_type>text</frontend_type>
|
22 |
+
<sort_order>1</sort_order>
|
23 |
+
<show_in_default>1</show_in_default>
|
24 |
+
<show_in_website>1</show_in_website>
|
25 |
+
<show_in_store>1</show_in_store>
|
26 |
+
<fields>
|
27 |
+
<picqer_postnl_active>
|
28 |
+
<label>Active</label>
|
29 |
+
<frontend_type>select</frontend_type>
|
30 |
+
<source_model>picqer_postnl/active</source_model>
|
31 |
+
<sort_order>1</sort_order>
|
32 |
+
<show_in_default>1</show_in_default>
|
33 |
+
<show_in_website>1</show_in_website>
|
34 |
+
<show_in_store>1</show_in_store>
|
35 |
+
</picqer_postnl_active>
|
36 |
+
</fields>
|
37 |
+
</postnl_settings>
|
38 |
+
</groups>
|
39 |
+
</picqer_shipping_options>
|
40 |
+
</sections>
|
41 |
+
</config>
|
app/etc/modules/Picqer_PostNL.xml
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Picqer_PostNL>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>community</codePool>
|
7 |
+
<depends>
|
8 |
+
<Mage_Api/>
|
9 |
+
<TIG_PostNL/>
|
10 |
+
</depends>
|
11 |
+
</Picqer_PostNL>
|
12 |
+
</modules>
|
13 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +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>
|