Version Notes
Bug fix: Retrieve pick up points for Click & Collect
Download this release
Release Info
Developer | PHPro |
Extension | bpost |
Version | 1.3.3 |
Comparing to | |
See all releases |
Code changes from version 1.3.2 to 1.3.3
- app/code/community/Bpost/ShM/Block/Adminhtml/Sales/AllOrders.php +13 -13
- app/code/community/Bpost/ShM/Block/Adminhtml/Sales/AllOrders/Grid.php +67 -67
- app/code/community/Bpost/ShM/Block/Adminhtml/Sales/Grid.php +228 -228
- app/code/community/Bpost/ShM/Block/Adminhtml/Sales/Grid/Renderer/Dropdate/Dateformat.php +16 -16
- app/code/community/Bpost/ShM/Block/Adminhtml/Sales/Grid/Renderer/Label/Download.php +24 -24
- app/code/community/Bpost/ShM/Block/Adminhtml/Sales/Order/View/Tab/Returnbarcode.php +136 -136
- app/code/community/Bpost/ShM/Block/Adminhtml/Sales/Order/View/Tab/Returnlabels.php +219 -219
- app/code/community/Bpost/ShM/Block/Adminhtml/Sales/PendingOrders.php +17 -17
- app/code/community/Bpost/ShM/Block/Adminhtml/Sales/PendingOrders/Grid.php +71 -71
- app/code/community/Bpost/ShM/Block/Adminhtml/Shipping/Carrier/Bpost/Tablerate/Clickcollect/Grid.php +118 -118
- app/code/community/Bpost/ShM/Block/Adminhtml/Shipping/Carrier/Bpost/Tablerate/Homedelivery/Grid.php +118 -118
- app/code/community/Bpost/ShM/Block/Adminhtml/Shipping/Carrier/Bpost/Tablerate/International/Grid.php +118 -118
- app/code/community/Bpost/ShM/Block/Adminhtml/Shipping/Carrier/Bpost/Tablerate/Parcellocker/Grid.php +118 -118
- app/code/community/Bpost/ShM/Block/Adminhtml/Shipping/Carrier/Bpost/Tablerate/Pickuppoint/Grid.php +118 -118
- app/code/community/Bpost/ShM/Block/Adminhtml/System/Config/Form/Api/Import/Countries.php +28 -28
- app/code/community/Bpost/ShM/Block/Adminhtml/System/Config/Form/Field/Cacheinfo.php +22 -22
- app/code/community/Bpost/ShM/Block/Adminhtml/System/Config/Form/Field/Choose.php +25 -25
- app/code/community/Bpost/ShM/Block/Adminhtml/System/Config/Form/Field/Clickcollect.php +20 -20
- app/code/community/Bpost/ShM/Block/Adminhtml/System/Config/Form/Field/Hour.php +42 -42
- app/code/community/Bpost/ShM/Block/Adminhtml/System/Config/Form/Field/Info.php +21 -21
- app/code/community/Bpost/ShM/Block/Adminhtml/System/Config/Form/Field/Logo.php +38 -38
- app/code/community/Bpost/ShM/Block/Adminhtml/System/Config/Form/Field/Subheader.php +16 -16
- app/code/community/Bpost/ShM/Block/Adminhtml/System/Config/Form/Tablerates/Export/Clickcollect.php +29 -29
- app/code/community/Bpost/ShM/Block/Adminhtml/System/Config/Form/Tablerates/Export/Homedelivery.php +29 -29
- app/code/community/Bpost/ShM/Block/Adminhtml/System/Config/Form/Tablerates/Export/International.php +29 -29
- app/code/community/Bpost/ShM/Block/Adminhtml/System/Config/Form/Tablerates/Export/Parcellocker.php +29 -29
- app/code/community/Bpost/ShM/Block/Adminhtml/System/Config/Form/Tablerates/Export/Pickuppoint.php +29 -29
- app/code/community/Bpost/ShM/Block/Carrier/Bpost.php +133 -133
- app/code/community/Bpost/ShM/Controller/ShM/Order.php +173 -173
- app/code/community/Bpost/ShM/Helper/Data.php +847 -847
- app/code/community/Bpost/ShM/Helper/Returnlabel.php +46 -46
- app/code/community/Bpost/ShM/Helper/System/Config.php +49 -49
- app/code/community/Bpost/ShM/Model/Adminhtml/Bpostgrid.php +484 -484
- app/code/community/Bpost/ShM/Model/Adminhtml/Observer.php +217 -217
- app/code/community/Bpost/ShM/Model/Adminhtml/System/Config/Backend/Shipping/Tablerates/Clickcollect.php +10 -10
- app/code/community/Bpost/ShM/Model/Adminhtml/System/Config/Backend/Shipping/Tablerates/Homedelivery.php +10 -10
- app/code/community/Bpost/ShM/Model/Adminhtml/System/Config/Backend/Shipping/Tablerates/International.php +10 -10
- app/code/community/Bpost/ShM/Model/Adminhtml/System/Config/Backend/Shipping/Tablerates/Parcellocker.php +10 -10
- app/code/community/Bpost/ShM/Model/Adminhtml/System/Config/Backend/Shipping/Tablerates/Pickuppoint.php +10 -10
- app/code/community/Bpost/ShM/Model/Adminhtml/System/Config/Source/Datecomment.php +30 -30
- app/code/community/Bpost/ShM/Model/Adminhtml/System/Config/Source/Shipping.php +52 -52
- app/code/community/Bpost/ShM/Model/Api.php +312 -312
- app/code/community/Bpost/ShM/Model/Api/Abstract.php +285 -285
- app/code/community/Bpost/ShM/Model/Api/Domcreator.php +785 -779
- app/code/community/Bpost/ShM/Model/Country.php +23 -23
- app/code/community/Bpost/ShM/Model/Holidays.php +23 -23
- app/code/community/Bpost/ShM/Model/Observer.php +365 -365
- app/code/community/Bpost/ShM/Model/Resource/Country.php +31 -31
- app/code/community/Bpost/ShM/Model/Resource/Country/Collection.php +54 -54
- app/code/community/Bpost/ShM/Model/Resource/Holidays.php +23 -23
- app/code/community/Bpost/ShM/Model/Resource/Holidays/Collection.php +40 -40
- app/code/community/Bpost/ShM/Model/Resource/Returnlabel.php +23 -23
- app/code/community/Bpost/ShM/Model/Resource/Returnlabel/Collection.php +23 -23
- app/code/community/Bpost/ShM/Model/Resource/Tablerates/Clickcollect.php +420 -420
- app/code/community/Bpost/ShM/Model/Resource/Tablerates/Clickcollect/Collection.php +94 -94
- app/code/community/Bpost/ShM/Model/Resource/Tablerates/Homedelivery.php +420 -420
- app/code/community/Bpost/ShM/Model/Resource/Tablerates/Homedelivery/Collection.php +94 -94
- app/code/community/Bpost/ShM/Model/Resource/Tablerates/International.php +422 -422
- app/code/community/Bpost/ShM/Model/Resource/Tablerates/International/Collection.php +94 -94
- app/code/community/Bpost/ShM/Model/Resource/Tablerates/Parcellocker.php +420 -420
- app/code/community/Bpost/ShM/Model/Resource/Tablerates/Parcellocker/Collection.php +94 -94
- app/code/community/Bpost/ShM/Model/Resource/Tablerates/Pickuppoint.php +420 -420
- app/code/community/Bpost/ShM/Model/Resource/Tablerates/Pickuppoint/Collection.php +94 -94
- app/code/community/Bpost/ShM/Model/Returnlabel.php +124 -124
- app/code/community/Bpost/ShM/Model/Shipping/Carrier/BpostShM.php +345 -339
- app/code/community/Bpost/ShM/Model/Shipping/Geocode.php +143 -143
- app/code/community/Bpost/ShM/Model/Shipping/Rate/Result.php +11 -11
- app/code/community/Bpost/ShM/Model/System/Config/Source/Country.php +27 -27
- app/code/community/Bpost/ShM/Model/System/Config/Source/Product.php +43 -43
- app/code/community/Bpost/ShM/Model/System/Config/Source/Ratetypes.php +43 -43
- app/code/community/Bpost/ShM/Model/System/Config/Source/Weightunit.php +46 -46
- app/code/community/Bpost/ShM/Model/Tablerates/Clickcollect.php +8 -8
- app/code/community/Bpost/ShM/Model/Tablerates/Homedelivery.php +8 -8
- app/code/community/Bpost/ShM/Model/Tablerates/International.php +8 -8
- app/code/community/Bpost/ShM/Model/Tablerates/Parcellocker.php +8 -8
- app/code/community/Bpost/ShM/Model/Tablerates/Pickuppoint.php +8 -8
- app/code/community/Bpost/ShM/controllers/Adminhtml/Bpost/ShM/AllOrdersController.php +64 -64
- app/code/community/Bpost/ShM/controllers/Adminhtml/Bpost/ShM/ConfigController.php +152 -152
- app/code/community/Bpost/ShM/controllers/Adminhtml/Bpost/ShM/DownloadController.php +115 -115
- app/code/community/Bpost/ShM/controllers/Adminhtml/Bpost/ShM/PendingOrdersController.php +41 -41
- app/code/community/Bpost/ShM/controllers/AjaxController.php +150 -150
- app/code/community/Bpost/ShM/etc/adminhtml.xml +70 -70
- app/code/community/Bpost/ShM/etc/config.xml +403 -403
- app/code/community/Bpost/ShM/etc/system.xml +1447 -1447
- app/code/community/Bpost/ShM/sql/bpost_shm_setup/install-0.0.1.php +29 -29
- app/code/community/Bpost/ShM/sql/bpost_shm_setup/upgrade-0.0.1-0.0.2.php +26 -26
- app/code/community/Bpost/ShM/sql/bpost_shm_setup/upgrade-0.0.10-0.1.0.php +17 -17
- app/code/community/Bpost/ShM/sql/bpost_shm_setup/upgrade-0.0.2-0.0.3.php +26 -26
- app/code/community/Bpost/ShM/sql/bpost_shm_setup/upgrade-0.0.3-0.0.4.php +35 -35
- app/code/community/Bpost/ShM/sql/bpost_shm_setup/upgrade-0.0.4-0.0.5.php +19 -19
- app/code/community/Bpost/ShM/sql/bpost_shm_setup/upgrade-0.0.5-0.0.6.php +23 -23
- app/code/community/Bpost/ShM/sql/bpost_shm_setup/upgrade-0.0.6-0.0.7.php +16 -16
- app/code/community/Bpost/ShM/sql/bpost_shm_setup/upgrade-0.0.7-0.0.8.php +38 -38
- app/code/community/Bpost/ShM/sql/bpost_shm_setup/upgrade-0.0.8-0.0.9.php +17 -17
- app/code/community/Bpost/ShM/sql/bpost_shm_setup/upgrade-0.0.9-0.0.10.php +30 -30
- app/code/community/Bpost/ShM/sql/bpost_shm_setup/upgrade-0.1.0-0.1.1.php +17 -17
- app/code/community/Bpost/ShM/sql/bpost_shm_setup/upgrade-0.1.1-0.1.2.php +17 -17
- app/code/community/Bpost/ShM/sql/bpost_shm_setup/upgrade-0.1.2-0.1.3.php +23 -23
- app/code/community/Bpost/ShM/sql/bpost_shm_setup/upgrade-0.1.3-0.1.4.php +65 -65
- app/code/community/Bpost/ShM/sql/bpost_shm_setup/upgrade-0.1.4-0.1.5.php +18 -18
- app/code/community/Bpost/ShM/sql/bpost_shm_setup/upgrade-0.1.5-0.1.6.php +18 -18
- app/code/community/Bpost/ShM/sql/bpost_shm_setup/upgrade-0.1.6-0.1.7.php +17 -17
- app/code/community/Bpost/ShM/sql/bpost_shm_setup/upgrade-0.1.7-0.1.8.php +14 -14
- app/code/community/Bpost/ShM/sql/bpost_shm_setup/upgrade-0.1.8-1.1.3.php +26 -26
- app/design/adminhtml/default/default/layout/bpost/shm.xml +70 -70
- app/design/adminhtml/default/default/template/bpost/empty.phtml +15 -15
- app/design/adminhtml/default/default/template/bpost/informationpopup.phtml +14 -14
- app/design/adminhtml/default/default/template/bpost/screenshotpopup.phtml +1 -1
- app/design/adminhtml/default/default/template/bpost/widget/grid/massaction.phtml +86 -86
- app/design/frontend/base/default/layout/bpost/shm.xml +35 -35
- app/design/frontend/base/default/template/bpost/shm/append_bpost_shippingmethod.phtml +124 -128
app/code/community/Bpost/ShM/Block/Adminhtml/Sales/AllOrders.php
CHANGED
@@ -1,14 +1,14 @@
|
|
1 |
-
<?php
|
2 |
-
class Bpost_ShM_Block_Adminhtml_Sales_AllOrders extends Mage_Adminhtml_Block_Widget_Grid_Container{
|
3 |
-
/**
|
4 |
-
*
|
5 |
-
*/
|
6 |
-
public function __construct()
|
7 |
-
{
|
8 |
-
$this->_blockGroup = 'bpost_shm';
|
9 |
-
$this->_controller = 'adminhtml_sales_allOrders';
|
10 |
-
$this->_headerText = Mage::helper('bpost_shm')->__('All bposts orders');
|
11 |
-
parent::__construct();
|
12 |
-
$this->_removeButton('add');
|
13 |
-
}
|
14 |
}
|
1 |
+
<?php
|
2 |
+
class Bpost_ShM_Block_Adminhtml_Sales_AllOrders extends Mage_Adminhtml_Block_Widget_Grid_Container{
|
3 |
+
/**
|
4 |
+
*
|
5 |
+
*/
|
6 |
+
public function __construct()
|
7 |
+
{
|
8 |
+
$this->_blockGroup = 'bpost_shm';
|
9 |
+
$this->_controller = 'adminhtml_sales_allOrders';
|
10 |
+
$this->_headerText = Mage::helper('bpost_shm')->__('All bposts orders');
|
11 |
+
parent::__construct();
|
12 |
+
$this->_removeButton('add');
|
13 |
+
}
|
14 |
}
|
app/code/community/Bpost/ShM/Block/Adminhtml/Sales/AllOrders/Grid.php
CHANGED
@@ -1,68 +1,68 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Bpost_ShM_Block_Adminhtml_Sales_AllOrders_Grid extends Bpost_ShM_Block_Adminhtml_Sales_Grid
|
4 |
-
{
|
5 |
-
/**
|
6 |
-
* Constructs the grid and sets basic parameters.
|
7 |
-
*/
|
8 |
-
public function __construct()
|
9 |
-
{
|
10 |
-
parent::__construct();
|
11 |
-
$this->setId('bpost_shm_grid');
|
12 |
-
$this->setDefaultSort('created_at');
|
13 |
-
$this->setDefaultDir('DESC');
|
14 |
-
$this->setSaveParametersInSession(true);
|
15 |
-
}
|
16 |
-
|
17 |
-
/**
|
18 |
-
* prepare collection to use for the grid.
|
19 |
-
*
|
20 |
-
* @return $this
|
21 |
-
*/
|
22 |
-
protected function _prepareCollection()
|
23 |
-
{
|
24 |
-
/** @var Mage_Sales_Model_Resource_Order_Grid_Collection $collection */
|
25 |
-
$collection = Mage::getResourceModel('sales/order_grid_collection');
|
26 |
-
$collection->getSelect()->join(
|
27 |
-
Mage::getConfig()->getTablePrefix() . 'sales_flat_order as sfo',
|
28 |
-
'sfo.entity_id=`main_table`.entity_id',
|
29 |
-
array(
|
30 |
-
'shipping_method' => 'shipping_method',
|
31 |
-
'total_qty_ordered' => 'ROUND(sfo.total_qty_ordered,0)',
|
32 |
-
'bpost_label_exported' => 'bpost_label_exported',
|
33 |
-
'bpost_label_exists' => 'bpost_label_exists',
|
34 |
-
'bpost_drop_date' => 'bpost_drop_date',
|
35 |
-
'bpost_status' => 'bpost_status',
|
36 |
-
'state' => 'state'
|
37 |
-
)
|
38 |
-
);
|
39 |
-
$collection->addExpressionFieldToSelect(
|
40 |
-
'shipping_customer_name',
|
41 |
-
"IF(sfo.shipping_method='bpostshm_bpost_international', CONCAT('International: ', main_table.shipping_name), main_table.shipping_name)" ,
|
42 |
-
'shipping_customer_name'
|
43 |
-
);
|
44 |
-
$collection->addAttributeToFilter('sfo.shipping_method', array('like' => '%bpostshm%'));
|
45 |
-
$this->setCollection($collection);
|
46 |
-
|
47 |
-
parent::_prepareCollection();
|
48 |
-
|
49 |
-
Mage::dispatchEvent('bpost_shm_prepare_grid_collection_after', array('collection' => $collection));
|
50 |
-
return $this;
|
51 |
-
}
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
/**
|
56 |
-
* Generate rowurl.
|
57 |
-
*
|
58 |
-
* @param $row
|
59 |
-
* @return string
|
60 |
-
*/
|
61 |
-
public function getRowUrl($row)
|
62 |
-
{
|
63 |
-
if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) {
|
64 |
-
return $this->getUrl('*/sales_order/view', array('order_id' => $row->getId(), 'bpostReturn' => '1'));
|
65 |
-
}
|
66 |
-
return false;
|
67 |
-
}
|
68 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Bpost_ShM_Block_Adminhtml_Sales_AllOrders_Grid extends Bpost_ShM_Block_Adminhtml_Sales_Grid
|
4 |
+
{
|
5 |
+
/**
|
6 |
+
* Constructs the grid and sets basic parameters.
|
7 |
+
*/
|
8 |
+
public function __construct()
|
9 |
+
{
|
10 |
+
parent::__construct();
|
11 |
+
$this->setId('bpost_shm_grid');
|
12 |
+
$this->setDefaultSort('created_at');
|
13 |
+
$this->setDefaultDir('DESC');
|
14 |
+
$this->setSaveParametersInSession(true);
|
15 |
+
}
|
16 |
+
|
17 |
+
/**
|
18 |
+
* prepare collection to use for the grid.
|
19 |
+
*
|
20 |
+
* @return $this
|
21 |
+
*/
|
22 |
+
protected function _prepareCollection()
|
23 |
+
{
|
24 |
+
/** @var Mage_Sales_Model_Resource_Order_Grid_Collection $collection */
|
25 |
+
$collection = Mage::getResourceModel('sales/order_grid_collection');
|
26 |
+
$collection->getSelect()->join(
|
27 |
+
Mage::getConfig()->getTablePrefix() . 'sales_flat_order as sfo',
|
28 |
+
'sfo.entity_id=`main_table`.entity_id',
|
29 |
+
array(
|
30 |
+
'shipping_method' => 'shipping_method',
|
31 |
+
'total_qty_ordered' => 'ROUND(sfo.total_qty_ordered,0)',
|
32 |
+
'bpost_label_exported' => 'bpost_label_exported',
|
33 |
+
'bpost_label_exists' => 'bpost_label_exists',
|
34 |
+
'bpost_drop_date' => 'bpost_drop_date',
|
35 |
+
'bpost_status' => 'bpost_status',
|
36 |
+
'state' => 'state'
|
37 |
+
)
|
38 |
+
);
|
39 |
+
$collection->addExpressionFieldToSelect(
|
40 |
+
'shipping_customer_name',
|
41 |
+
"IF(sfo.shipping_method='bpostshm_bpost_international', CONCAT('International: ', main_table.shipping_name), main_table.shipping_name)" ,
|
42 |
+
'shipping_customer_name'
|
43 |
+
);
|
44 |
+
$collection->addAttributeToFilter('sfo.shipping_method', array('like' => '%bpostshm%'));
|
45 |
+
$this->setCollection($collection);
|
46 |
+
|
47 |
+
parent::_prepareCollection();
|
48 |
+
|
49 |
+
Mage::dispatchEvent('bpost_shm_prepare_grid_collection_after', array('collection' => $collection));
|
50 |
+
return $this;
|
51 |
+
}
|
52 |
+
|
53 |
+
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Generate rowurl.
|
57 |
+
*
|
58 |
+
* @param $row
|
59 |
+
* @return string
|
60 |
+
*/
|
61 |
+
public function getRowUrl($row)
|
62 |
+
{
|
63 |
+
if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) {
|
64 |
+
return $this->getUrl('*/sales_order/view', array('order_id' => $row->getId(), 'bpostReturn' => '1'));
|
65 |
+
}
|
66 |
+
return false;
|
67 |
+
}
|
68 |
}
|
app/code/community/Bpost/ShM/Block/Adminhtml/Sales/Grid.php
CHANGED
@@ -1,229 +1,229 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Class Bpost_ShM_Block_Adminhtml_Sales_Grid
|
5 |
-
*/
|
6 |
-
class Bpost_ShM_Block_Adminhtml_Sales_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
7 |
-
{
|
8 |
-
|
9 |
-
public function __construct()
|
10 |
-
{
|
11 |
-
parent::__construct();
|
12 |
-
$this->setUseAjax(true);
|
13 |
-
}
|
14 |
-
|
15 |
-
/**
|
16 |
-
* @return Mage_Adminhtml_Block_Widget_Grid|void
|
17 |
-
*/
|
18 |
-
protected function _prepareCollection(){
|
19 |
-
//bugfix collection getSize function
|
20 |
-
//trigger getSize before group statement will set the correct collection size
|
21 |
-
$this->getCollection()->getSize();
|
22 |
-
|
23 |
-
if ($this->getCollection()) {
|
24 |
-
$this->getCollection()->getSelect()->joinLeft(Mage::getConfig()->getTablePrefix() . 'sales_flat_shipment as sfs', 'sfs.order_id=`main_table`.entity_id', array(
|
25 |
-
'bpost_label_path' => 'bpost_label_path',
|
26 |
-
))->group('main_table.entity_id');
|
27 |
-
}
|
28 |
-
|
29 |
-
parent::_prepareCollection();
|
30 |
-
}
|
31 |
-
|
32 |
-
/**
|
33 |
-
* prepare columns used in the grid.
|
34 |
-
*
|
35 |
-
* @return $this
|
36 |
-
*/
|
37 |
-
protected function _prepareColumns()
|
38 |
-
{
|
39 |
-
$configHelper = Mage::helper('bpost_shm/system_config');
|
40 |
-
|
41 |
-
$helper = Mage::helper('bpost_shm');
|
42 |
-
$this->addColumn('real_order_id', array(
|
43 |
-
'header' => $helper->__('Order #'),
|
44 |
-
'width' => '80px',
|
45 |
-
'type' => 'text',
|
46 |
-
'index' => 'increment_id',
|
47 |
-
'filter_index' => 'main_table.increment_id'
|
48 |
-
));
|
49 |
-
if (!Mage::app()->isSingleStoreMode()) {
|
50 |
-
$this->addColumn('store_id', array(
|
51 |
-
'header' => $helper->__('Purchased From (Store)'),
|
52 |
-
'index' => 'store_id',
|
53 |
-
'type' => 'store',
|
54 |
-
'store_view' => true,
|
55 |
-
'display_deleted' => true,
|
56 |
-
'filter_index' => 'sfo.store_id'
|
57 |
-
));
|
58 |
-
}
|
59 |
-
$this->addColumn('created_at', array(
|
60 |
-
'header' => $helper->__('Purchased On'),
|
61 |
-
'index' => 'created_at',
|
62 |
-
'type' => 'datetime',
|
63 |
-
'width' => '100px',
|
64 |
-
'filter_index' => 'main_table.created_at'
|
65 |
-
));
|
66 |
-
$this->addColumn('billing_name', array(
|
67 |
-
'header' => $helper->__('Bill to Name'),
|
68 |
-
'index' => 'billing_name',
|
69 |
-
'filter_index' => 'main_table.billing_name'
|
70 |
-
));
|
71 |
-
$this->addColumn('shipping_name', array(
|
72 |
-
'header' => $helper->__('Ship to Name'),
|
73 |
-
'index' => 'shipping_customer_name',
|
74 |
-
'filter_condition_callback' => array($this, '_shippingNameFilter'),
|
75 |
-
));
|
76 |
-
$this->addColumn('grand_total', array(
|
77 |
-
'header' => $helper->__('G.T. (Purchased)'),
|
78 |
-
'index' => 'grand_total',
|
79 |
-
'type' => 'currency',
|
80 |
-
'currency' => 'order_currency_code',
|
81 |
-
'filter_index' => 'main_table.grand_total'
|
82 |
-
));
|
83 |
-
$this->addColumn('total_qty_ordered', array(
|
84 |
-
'header' => $helper->__('# of Items'),
|
85 |
-
'type' => 'int',
|
86 |
-
'index' => 'total_qty_ordered',
|
87 |
-
'width' => '100px',
|
88 |
-
));
|
89 |
-
$this->addColumn('status', array(
|
90 |
-
'header' => $helper->__('Status'),
|
91 |
-
'index' => 'status',
|
92 |
-
'type' => 'options',
|
93 |
-
'width' => '70px',
|
94 |
-
'options' => Mage::getSingleton('sales/order_config')->getStatuses(),
|
95 |
-
'filter_index' => 'main_table.status'
|
96 |
-
));
|
97 |
-
$this->addColumn('bpost_status', array(
|
98 |
-
'header' => $helper->__('bpost status'),
|
99 |
-
'index' => 'bpost_status',
|
100 |
-
'type' => 'text',
|
101 |
-
'width' => '100px'
|
102 |
-
));
|
103 |
-
$this->addColumn('bpost_label_exists', array(
|
104 |
-
'header' => $helper->__('Label download'),
|
105 |
-
'index' => 'bpost_label_exists',
|
106 |
-
'width' => '100px',
|
107 |
-
'renderer' => 'bpost_shm/adminhtml_sales_grid_renderer_label_download',
|
108 |
-
'type' => 'options',
|
109 |
-
'options' => array('1' => 'Yes', '0' => 'No'),
|
110 |
-
'filter_index' => 'sfo.bpost_label_exists'
|
111 |
-
));
|
112 |
-
if ($configHelper->getBpostShippingConfig('display_delivery_date', Mage::app()->getStore()->getId())) {
|
113 |
-
$this->addColumn('bpost_drop_date', array(
|
114 |
-
'header' => $helper->__('Drop date'),
|
115 |
-
'index' => 'bpost_drop_date',
|
116 |
-
'type' => 'date',
|
117 |
-
'width' => '100px',
|
118 |
-
'renderer' => 'bpost_shm/adminhtml_sales_grid_renderer_dropdate_dateformat'
|
119 |
-
));
|
120 |
-
}
|
121 |
-
if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) {
|
122 |
-
$this->addColumn('action',
|
123 |
-
array(
|
124 |
-
'header' => $helper->__('Action'),
|
125 |
-
'width' => '50px',
|
126 |
-
'type' => 'action',
|
127 |
-
'getter' => 'getId',
|
128 |
-
'actions' => array(
|
129 |
-
array(
|
130 |
-
'caption' => $helper->__('View'),
|
131 |
-
'url' => array('base' => '*/sales_order/view', 'params' => array('bpostReturn' => '2')),
|
132 |
-
'field' => 'order_id',
|
133 |
-
)
|
134 |
-
),
|
135 |
-
'filter' => false,
|
136 |
-
'sortable' => false,
|
137 |
-
'index' => 'stores',
|
138 |
-
'is_system' => true,
|
139 |
-
));
|
140 |
-
}
|
141 |
-
return parent::_prepareColumns();
|
142 |
-
}
|
143 |
-
|
144 |
-
/**
|
145 |
-
* Gets grid url for callbacks.
|
146 |
-
*
|
147 |
-
* @return string
|
148 |
-
*/
|
149 |
-
public function getGridUrl()
|
150 |
-
{
|
151 |
-
return $this->getUrl('*/*/grid', array('_current' => true));
|
152 |
-
}
|
153 |
-
|
154 |
-
/**
|
155 |
-
* Prepares Massactions for the grid.
|
156 |
-
*
|
157 |
-
* @return $this
|
158 |
-
*/
|
159 |
-
protected function _prepareMassaction()
|
160 |
-
{
|
161 |
-
$this->setMassactionIdField('`main_table`.entity_id');
|
162 |
-
$massaActionBlock = $this->getMassactionBlock();
|
163 |
-
$massaActionBlock->setFormFieldName('entity_id');
|
164 |
-
|
165 |
-
$massaActionBlock->addItem('generateAndComplete', array(
|
166 |
-
'label' => Mage::helper('bpost_shm')->__('Generate Label and Complete'),
|
167 |
-
'url' => $this->getUrl('*/*/ajaxGenerateAndComplete'),
|
168 |
-
));
|
169 |
-
|
170 |
-
$massaActionBlock->addItem('dowloadAllUndownloaded', array(
|
171 |
-
'label' => Mage::helper('bpost_shm')->__('Download all undownloaded'),
|
172 |
-
'url' => $this->getUrl('*/*/dowloadAllUndownloaded'),
|
173 |
-
));
|
174 |
-
return $this;
|
175 |
-
}
|
176 |
-
|
177 |
-
/**
|
178 |
-
* Prepare grid massaction block
|
179 |
-
*
|
180 |
-
* @return Mage_Adminhtml_Block_Widget_Grid
|
181 |
-
*/
|
182 |
-
protected function _prepareMassactionBlock()
|
183 |
-
{
|
184 |
-
$massActionJsName = $this->getHtmlId()."_massactionJsObject";
|
185 |
-
$gridJsObjectName = $this->getHtmlId()."JsObject";
|
186 |
-
$massActionBlock = $this->getLayout()->createBlock($this->getMassactionBlockName());
|
187 |
-
|
188 |
-
$buttonHtml = $this->getLayout()
|
189 |
-
->createBlock('adminhtml/widget_button')
|
190 |
-
->setData(array(
|
191 |
-
'label' => Mage::helper('bpost_shm')->__('Submit'),
|
192 |
-
'onclick' => "generateAndComplete('".$massActionJsName."','".$gridJsObjectName."')",
|
193 |
-
))->toHtml();
|
194 |
-
|
195 |
-
$this->setChild('massaction', $massActionBlock
|
196 |
-
->setSubmitButtonHtml($buttonHtml)
|
197 |
-
->setUseAjax(true)
|
198 |
-
->setTemplate("bpost/widget/grid/massaction.phtml")
|
199 |
-
);
|
200 |
-
|
201 |
-
$this->_prepareMassaction();
|
202 |
-
|
203 |
-
if($this->getMassactionBlock()->isAvailable()) {
|
204 |
-
$this->_prepareMassactionColumn();
|
205 |
-
}
|
206 |
-
|
207 |
-
return $this;
|
208 |
-
}
|
209 |
-
|
210 |
-
|
211 |
-
/**
|
212 |
-
* @param $collection
|
213 |
-
* @param $column
|
214 |
-
* @return $this
|
215 |
-
*/
|
216 |
-
protected function _shippingNameFilter($collection, $column)
|
217 |
-
{
|
218 |
-
if (!$value = $column->getFilter()->getValue()) {
|
219 |
-
return $this;
|
220 |
-
}
|
221 |
-
|
222 |
-
$collection->getSelect()->where(
|
223 |
-
"IF(shipping_method='bpostshm_bpost_international', CONCAT('International: ', shipping_name), shipping_name) like ?"
|
224 |
-
, "%$value%"
|
225 |
-
);
|
226 |
-
|
227 |
-
return $this;
|
228 |
-
}
|
229 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class Bpost_ShM_Block_Adminhtml_Sales_Grid
|
5 |
+
*/
|
6 |
+
class Bpost_ShM_Block_Adminhtml_Sales_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
7 |
+
{
|
8 |
+
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
$this->setUseAjax(true);
|
13 |
+
}
|
14 |
+
|
15 |
+
/**
|
16 |
+
* @return Mage_Adminhtml_Block_Widget_Grid|void
|
17 |
+
*/
|
18 |
+
protected function _prepareCollection(){
|
19 |
+
//bugfix collection getSize function
|
20 |
+
//trigger getSize before group statement will set the correct collection size
|
21 |
+
$this->getCollection()->getSize();
|
22 |
+
|
23 |
+
if ($this->getCollection()) {
|
24 |
+
$this->getCollection()->getSelect()->joinLeft(Mage::getConfig()->getTablePrefix() . 'sales_flat_shipment as sfs', 'sfs.order_id=`main_table`.entity_id', array(
|
25 |
+
'bpost_label_path' => 'bpost_label_path',
|
26 |
+
))->group('main_table.entity_id');
|
27 |
+
}
|
28 |
+
|
29 |
+
parent::_prepareCollection();
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* prepare columns used in the grid.
|
34 |
+
*
|
35 |
+
* @return $this
|
36 |
+
*/
|
37 |
+
protected function _prepareColumns()
|
38 |
+
{
|
39 |
+
$configHelper = Mage::helper('bpost_shm/system_config');
|
40 |
+
|
41 |
+
$helper = Mage::helper('bpost_shm');
|
42 |
+
$this->addColumn('real_order_id', array(
|
43 |
+
'header' => $helper->__('Order #'),
|
44 |
+
'width' => '80px',
|
45 |
+
'type' => 'text',
|
46 |
+
'index' => 'increment_id',
|
47 |
+
'filter_index' => 'main_table.increment_id'
|
48 |
+
));
|
49 |
+
if (!Mage::app()->isSingleStoreMode()) {
|
50 |
+
$this->addColumn('store_id', array(
|
51 |
+
'header' => $helper->__('Purchased From (Store)'),
|
52 |
+
'index' => 'store_id',
|
53 |
+
'type' => 'store',
|
54 |
+
'store_view' => true,
|
55 |
+
'display_deleted' => true,
|
56 |
+
'filter_index' => 'sfo.store_id'
|
57 |
+
));
|
58 |
+
}
|
59 |
+
$this->addColumn('created_at', array(
|
60 |
+
'header' => $helper->__('Purchased On'),
|
61 |
+
'index' => 'created_at',
|
62 |
+
'type' => 'datetime',
|
63 |
+
'width' => '100px',
|
64 |
+
'filter_index' => 'main_table.created_at'
|
65 |
+
));
|
66 |
+
$this->addColumn('billing_name', array(
|
67 |
+
'header' => $helper->__('Bill to Name'),
|
68 |
+
'index' => 'billing_name',
|
69 |
+
'filter_index' => 'main_table.billing_name'
|
70 |
+
));
|
71 |
+
$this->addColumn('shipping_name', array(
|
72 |
+
'header' => $helper->__('Ship to Name'),
|
73 |
+
'index' => 'shipping_customer_name',
|
74 |
+
'filter_condition_callback' => array($this, '_shippingNameFilter'),
|
75 |
+
));
|
76 |
+
$this->addColumn('grand_total', array(
|
77 |
+
'header' => $helper->__('G.T. (Purchased)'),
|
78 |
+
'index' => 'grand_total',
|
79 |
+
'type' => 'currency',
|
80 |
+
'currency' => 'order_currency_code',
|
81 |
+
'filter_index' => 'main_table.grand_total'
|
82 |
+
));
|
83 |
+
$this->addColumn('total_qty_ordered', array(
|
84 |
+
'header' => $helper->__('# of Items'),
|
85 |
+
'type' => 'int',
|
86 |
+
'index' => 'total_qty_ordered',
|
87 |
+
'width' => '100px',
|
88 |
+
));
|
89 |
+
$this->addColumn('status', array(
|
90 |
+
'header' => $helper->__('Status'),
|
91 |
+
'index' => 'status',
|
92 |
+
'type' => 'options',
|
93 |
+
'width' => '70px',
|
94 |
+
'options' => Mage::getSingleton('sales/order_config')->getStatuses(),
|
95 |
+
'filter_index' => 'main_table.status'
|
96 |
+
));
|
97 |
+
$this->addColumn('bpost_status', array(
|
98 |
+
'header' => $helper->__('bpost status'),
|
99 |
+
'index' => 'bpost_status',
|
100 |
+
'type' => 'text',
|
101 |
+
'width' => '100px'
|
102 |
+
));
|
103 |
+
$this->addColumn('bpost_label_exists', array(
|
104 |
+
'header' => $helper->__('Label download'),
|
105 |
+
'index' => 'bpost_label_exists',
|
106 |
+
'width' => '100px',
|
107 |
+
'renderer' => 'bpost_shm/adminhtml_sales_grid_renderer_label_download',
|
108 |
+
'type' => 'options',
|
109 |
+
'options' => array('1' => 'Yes', '0' => 'No'),
|
110 |
+
'filter_index' => 'sfo.bpost_label_exists'
|
111 |
+
));
|
112 |
+
if ($configHelper->getBpostShippingConfig('display_delivery_date', Mage::app()->getStore()->getId())) {
|
113 |
+
$this->addColumn('bpost_drop_date', array(
|
114 |
+
'header' => $helper->__('Drop date'),
|
115 |
+
'index' => 'bpost_drop_date',
|
116 |
+
'type' => 'date',
|
117 |
+
'width' => '100px',
|
118 |
+
'renderer' => 'bpost_shm/adminhtml_sales_grid_renderer_dropdate_dateformat'
|
119 |
+
));
|
120 |
+
}
|
121 |
+
if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) {
|
122 |
+
$this->addColumn('action',
|
123 |
+
array(
|
124 |
+
'header' => $helper->__('Action'),
|
125 |
+
'width' => '50px',
|
126 |
+
'type' => 'action',
|
127 |
+
'getter' => 'getId',
|
128 |
+
'actions' => array(
|
129 |
+
array(
|
130 |
+
'caption' => $helper->__('View'),
|
131 |
+
'url' => array('base' => '*/sales_order/view', 'params' => array('bpostReturn' => '2')),
|
132 |
+
'field' => 'order_id',
|
133 |
+
)
|
134 |
+
),
|
135 |
+
'filter' => false,
|
136 |
+
'sortable' => false,
|
137 |
+
'index' => 'stores',
|
138 |
+
'is_system' => true,
|
139 |
+
));
|
140 |
+
}
|
141 |
+
return parent::_prepareColumns();
|
142 |
+
}
|
143 |
+
|
144 |
+
/**
|
145 |
+
* Gets grid url for callbacks.
|
146 |
+
*
|
147 |
+
* @return string
|
148 |
+
*/
|
149 |
+
public function getGridUrl()
|
150 |
+
{
|
151 |
+
return $this->getUrl('*/*/grid', array('_current' => true));
|
152 |
+
}
|
153 |
+
|
154 |
+
/**
|
155 |
+
* Prepares Massactions for the grid.
|
156 |
+
*
|
157 |
+
* @return $this
|
158 |
+
*/
|
159 |
+
protected function _prepareMassaction()
|
160 |
+
{
|
161 |
+
$this->setMassactionIdField('`main_table`.entity_id');
|
162 |
+
$massaActionBlock = $this->getMassactionBlock();
|
163 |
+
$massaActionBlock->setFormFieldName('entity_id');
|
164 |
+
|
165 |
+
$massaActionBlock->addItem('generateAndComplete', array(
|
166 |
+
'label' => Mage::helper('bpost_shm')->__('Generate Label and Complete'),
|
167 |
+
'url' => $this->getUrl('*/*/ajaxGenerateAndComplete'),
|
168 |
+
));
|
169 |
+
|
170 |
+
$massaActionBlock->addItem('dowloadAllUndownloaded', array(
|
171 |
+
'label' => Mage::helper('bpost_shm')->__('Download all undownloaded'),
|
172 |
+
'url' => $this->getUrl('*/*/dowloadAllUndownloaded'),
|
173 |
+
));
|
174 |
+
return $this;
|
175 |
+
}
|
176 |
+
|
177 |
+
/**
|
178 |
+
* Prepare grid massaction block
|
179 |
+
*
|
180 |
+
* @return Mage_Adminhtml_Block_Widget_Grid
|
181 |
+
*/
|
182 |
+
protected function _prepareMassactionBlock()
|
183 |
+
{
|
184 |
+
$massActionJsName = $this->getHtmlId()."_massactionJsObject";
|
185 |
+
$gridJsObjectName = $this->getHtmlId()."JsObject";
|
186 |
+
$massActionBlock = $this->getLayout()->createBlock($this->getMassactionBlockName());
|
187 |
+
|
188 |
+
$buttonHtml = $this->getLayout()
|
189 |
+
->createBlock('adminhtml/widget_button')
|
190 |
+
->setData(array(
|
191 |
+
'label' => Mage::helper('bpost_shm')->__('Submit'),
|
192 |
+
'onclick' => "generateAndComplete('".$massActionJsName."','".$gridJsObjectName."')",
|
193 |
+
))->toHtml();
|
194 |
+
|
195 |
+
$this->setChild('massaction', $massActionBlock
|
196 |
+
->setSubmitButtonHtml($buttonHtml)
|
197 |
+
->setUseAjax(true)
|
198 |
+
->setTemplate("bpost/widget/grid/massaction.phtml")
|
199 |
+
);
|
200 |
+
|
201 |
+
$this->_prepareMassaction();
|
202 |
+
|
203 |
+
if($this->getMassactionBlock()->isAvailable()) {
|
204 |
+
$this->_prepareMassactionColumn();
|
205 |
+
}
|
206 |
+
|
207 |
+
return $this;
|
208 |
+
}
|
209 |
+
|
210 |
+
|
211 |
+
/**
|
212 |
+
* @param $collection
|
213 |
+
* @param $column
|
214 |
+
* @return $this
|
215 |
+
*/
|
216 |
+
protected function _shippingNameFilter($collection, $column)
|
217 |
+
{
|
218 |
+
if (!$value = $column->getFilter()->getValue()) {
|
219 |
+
return $this;
|
220 |
+
}
|
221 |
+
|
222 |
+
$collection->getSelect()->where(
|
223 |
+
"IF(shipping_method='bpostshm_bpost_international', CONCAT('International: ', shipping_name), shipping_name) like ?"
|
224 |
+
, "%$value%"
|
225 |
+
);
|
226 |
+
|
227 |
+
return $this;
|
228 |
+
}
|
229 |
}
|
app/code/community/Bpost/ShM/Block/Adminhtml/Sales/Grid/Renderer/Dropdate/Dateformat.php
CHANGED
@@ -1,17 +1,17 @@
|
|
1 |
-
<?php
|
2 |
-
class Bpost_ShM_Block_Adminhtml_Sales_Grid_Renderer_Dropdate_Dateformat extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
|
3 |
-
{
|
4 |
-
public function render(Varien_Object $row)
|
5 |
-
{
|
6 |
-
$value = $row->getData($this->getColumn()->getIndex());
|
7 |
-
$returnValue = $value;
|
8 |
-
$now = date('Y-m-d');
|
9 |
-
if($value == $now){
|
10 |
-
$returnValue = '<strong>'.$value.'</strong>';
|
11 |
-
}
|
12 |
-
elseif($value < $now){
|
13 |
-
$returnValue = '<span style="color:red;">'.$value.'</span>';
|
14 |
-
}
|
15 |
-
return $returnValue;
|
16 |
-
}
|
17 |
}
|
1 |
+
<?php
|
2 |
+
class Bpost_ShM_Block_Adminhtml_Sales_Grid_Renderer_Dropdate_Dateformat extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
|
3 |
+
{
|
4 |
+
public function render(Varien_Object $row)
|
5 |
+
{
|
6 |
+
$value = $row->getData($this->getColumn()->getIndex());
|
7 |
+
$returnValue = $value;
|
8 |
+
$now = date('Y-m-d');
|
9 |
+
if($value == $now){
|
10 |
+
$returnValue = '<strong>'.$value.'</strong>';
|
11 |
+
}
|
12 |
+
elseif($value < $now){
|
13 |
+
$returnValue = '<span style="color:red;">'.$value.'</span>';
|
14 |
+
}
|
15 |
+
return $returnValue;
|
16 |
+
}
|
17 |
}
|
app/code/community/Bpost/ShM/Block/Adminhtml/Sales/Grid/Renderer/Label/Download.php
CHANGED
@@ -1,25 +1,25 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Class Bpost_ShM_Block_Adminhtml_Sales_Grid_Renderer_Label_Download
|
5 |
-
*/
|
6 |
-
class Bpost_ShM_Block_Adminhtml_Sales_Grid_Renderer_Label_Download extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
|
7 |
-
{
|
8 |
-
/**
|
9 |
-
* @param Varien_Object $row
|
10 |
-
* @return string
|
11 |
-
* function renders a label download link
|
12 |
-
*/
|
13 |
-
public function render(Varien_Object $row)
|
14 |
-
{
|
15 |
-
$helper = Mage::helper("adminhtml");
|
16 |
-
|
17 |
-
if(!$row->getBpostLabelExists() || !$row->getBpostLabelPath() || $row->getBpostLabelPath() == ""){
|
18 |
-
return $helper->__("No");
|
19 |
-
}
|
20 |
-
|
21 |
-
$returnValue = '<a href="'.$helper->getUrl("*/bpost_shM_download/label", array("order_id" => $row->getId())).'"><img src="'.Mage::getDesign()->getSkinUrl('images/bpost/pdf_icon.png').'" alt="download label"/></a>';
|
22 |
-
|
23 |
-
return $returnValue;
|
24 |
-
}
|
25 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class Bpost_ShM_Block_Adminhtml_Sales_Grid_Renderer_Label_Download
|
5 |
+
*/
|
6 |
+
class Bpost_ShM_Block_Adminhtml_Sales_Grid_Renderer_Label_Download extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
|
7 |
+
{
|
8 |
+
/**
|
9 |
+
* @param Varien_Object $row
|
10 |
+
* @return string
|
11 |
+
* function renders a label download link
|
12 |
+
*/
|
13 |
+
public function render(Varien_Object $row)
|
14 |
+
{
|
15 |
+
$helper = Mage::helper("adminhtml");
|
16 |
+
|
17 |
+
if(!$row->getBpostLabelExists() || !$row->getBpostLabelPath() || $row->getBpostLabelPath() == ""){
|
18 |
+
return $helper->__("No");
|
19 |
+
}
|
20 |
+
|
21 |
+
$returnValue = '<a href="'.$helper->getUrl("*/bpost_shM_download/label", array("order_id" => $row->getId())).'"><img src="'.Mage::getDesign()->getSkinUrl('images/bpost/pdf_icon.png').'" alt="download label"/></a>';
|
22 |
+
|
23 |
+
return $returnValue;
|
24 |
+
}
|
25 |
}
|
app/code/community/Bpost/ShM/Block/Adminhtml/Sales/Order/View/Tab/Returnbarcode.php
CHANGED
@@ -1,137 +1,137 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Created by PHPro
|
4 |
-
*
|
5 |
-
* @subpackage Shipping
|
6 |
-
* @author PHPro (info@phpro.be)
|
7 |
-
*/
|
8 |
-
|
9 |
-
/**
|
10 |
-
* Class Bpost_ShM_Block_Adminhtml_Sales_Order_View_Tab_Returnbarcode
|
11 |
-
*/
|
12 |
-
class Bpost_ShM_Block_Adminhtml_Sales_Order_View_Tab_Returnbarcode
|
13 |
-
extends Mage_Adminhtml_Block_Widget_Grid
|
14 |
-
implements Mage_Adminhtml_Block_Widget_Tab_Interface{
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Constructs the block
|
18 |
-
*
|
19 |
-
*/
|
20 |
-
public function __construct(){
|
21 |
-
parent::__construct();
|
22 |
-
$this->setId('bpost_returnbarcode_grid');
|
23 |
-
$this->setDefaultDir('DESC');
|
24 |
-
$this->setSaveParametersInSession(true);
|
25 |
-
$this->setUseAjax(true);
|
26 |
-
|
27 |
-
$textString = "This order did not (yet) generate labels which automatically returned return label barcodes. This feature might not be actived. Please refer to the documentation and your Shipping Settings under 'System > Configuration > Sales' for more information.";
|
28 |
-
$this->_emptyText = Mage::helper('adminhtml')->__($textString);
|
29 |
-
}
|
30 |
-
|
31 |
-
/**
|
32 |
-
* prepare collection to use for the grid.
|
33 |
-
*
|
34 |
-
* @return $this
|
35 |
-
*/
|
36 |
-
protected function _prepareCollection()
|
37 |
-
{
|
38 |
-
$collection = Mage::getModel('sales/order_shipment')
|
39 |
-
->getCollection()
|
40 |
-
->addFieldToFilter('order_id',array('eq' => $this->getOrder()->getId()))
|
41 |
-
->addFieldToFilter('bpost_return_barcode',array('notnull'=>1));
|
42 |
-
$this->setCollection($collection);
|
43 |
-
parent::_prepareCollection();
|
44 |
-
return $this;
|
45 |
-
}
|
46 |
-
/**
|
47 |
-
* prepare columns used in the grid.
|
48 |
-
*
|
49 |
-
* @return $this
|
50 |
-
*/
|
51 |
-
protected function _prepareColumns()
|
52 |
-
{
|
53 |
-
$helper = Mage::helper('bpost_shm');
|
54 |
-
|
55 |
-
$this->addColumn('increment_id', array(
|
56 |
-
'header' => $helper->__('Shipment'),
|
57 |
-
'type' => 'text',
|
58 |
-
'index' => 'increment_id',
|
59 |
-
'filter_index' => 'main_table.increment_id'
|
60 |
-
));
|
61 |
-
|
62 |
-
$this->addColumn('returnbarcode', array(
|
63 |
-
'header' => $helper->__('Barcode #'),
|
64 |
-
'type' => 'text',
|
65 |
-
'index' => 'bpost_return_barcode',
|
66 |
-
'filter_index' => 'main_table.bpost_return_barcode'
|
67 |
-
));
|
68 |
-
|
69 |
-
return parent::_prepareColumns();
|
70 |
-
}
|
71 |
-
|
72 |
-
/**
|
73 |
-
* Gets grid url for callbacks.
|
74 |
-
*
|
75 |
-
* @return string
|
76 |
-
*/
|
77 |
-
public function getGridUrl()
|
78 |
-
{
|
79 |
-
return $this->getUrl('*/*/grid', array('_current' => true));
|
80 |
-
}
|
81 |
-
|
82 |
-
/**
|
83 |
-
* Generate rowurl.
|
84 |
-
*
|
85 |
-
* @param $row
|
86 |
-
* @return string
|
87 |
-
*/
|
88 |
-
public function getRowUrl($row)
|
89 |
-
{
|
90 |
-
return false;
|
91 |
-
}
|
92 |
-
|
93 |
-
/**
|
94 |
-
* Returns tab label.
|
95 |
-
*
|
96 |
-
* @return string
|
97 |
-
*/
|
98 |
-
public function getTabLabel() {
|
99 |
-
return Mage::helper('bpost_shm')->__('bpost Return Barcodes');
|
100 |
-
}
|
101 |
-
|
102 |
-
/**
|
103 |
-
* Returns tab title.
|
104 |
-
*
|
105 |
-
* @return string
|
106 |
-
*/
|
107 |
-
public function getTabTitle() {
|
108 |
-
return Mage::helper('bpost_shm')->__('bpost Return Barcodes');
|
109 |
-
}
|
110 |
-
|
111 |
-
/**
|
112 |
-
* Checks if tab can be shown.
|
113 |
-
*
|
114 |
-
* @return bool
|
115 |
-
*/
|
116 |
-
public function canShowTab() {
|
117 |
-
return true;
|
118 |
-
}
|
119 |
-
|
120 |
-
/**
|
121 |
-
* Checks if the tab has to be hidden.
|
122 |
-
*
|
123 |
-
* @return bool
|
124 |
-
*/
|
125 |
-
public function isHidden() {
|
126 |
-
return false;
|
127 |
-
}
|
128 |
-
|
129 |
-
/**
|
130 |
-
* Returns the order object.
|
131 |
-
*
|
132 |
-
* @return mixed
|
133 |
-
*/
|
134 |
-
public function getOrder(){
|
135 |
-
return Mage::registry('current_order');
|
136 |
-
}
|
137 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Created by PHPro
|
4 |
+
*
|
5 |
+
* @subpackage Shipping
|
6 |
+
* @author PHPro (info@phpro.be)
|
7 |
+
*/
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Class Bpost_ShM_Block_Adminhtml_Sales_Order_View_Tab_Returnbarcode
|
11 |
+
*/
|
12 |
+
class Bpost_ShM_Block_Adminhtml_Sales_Order_View_Tab_Returnbarcode
|
13 |
+
extends Mage_Adminhtml_Block_Widget_Grid
|
14 |
+
implements Mage_Adminhtml_Block_Widget_Tab_Interface{
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Constructs the block
|
18 |
+
*
|
19 |
+
*/
|
20 |
+
public function __construct(){
|
21 |
+
parent::__construct();
|
22 |
+
$this->setId('bpost_returnbarcode_grid');
|
23 |
+
$this->setDefaultDir('DESC');
|
24 |
+
$this->setSaveParametersInSession(true);
|
25 |
+
$this->setUseAjax(true);
|
26 |
+
|
27 |
+
$textString = "This order did not (yet) generate labels which automatically returned return label barcodes. This feature might not be actived. Please refer to the documentation and your Shipping Settings under 'System > Configuration > Sales' for more information.";
|
28 |
+
$this->_emptyText = Mage::helper('adminhtml')->__($textString);
|
29 |
+
}
|
30 |
+
|
31 |
+
/**
|
32 |
+
* prepare collection to use for the grid.
|
33 |
+
*
|
34 |
+
* @return $this
|
35 |
+
*/
|
36 |
+
protected function _prepareCollection()
|
37 |
+
{
|
38 |
+
$collection = Mage::getModel('sales/order_shipment')
|
39 |
+
->getCollection()
|
40 |
+
->addFieldToFilter('order_id',array('eq' => $this->getOrder()->getId()))
|
41 |
+
->addFieldToFilter('bpost_return_barcode',array('notnull'=>1));
|
42 |
+
$this->setCollection($collection);
|
43 |
+
parent::_prepareCollection();
|
44 |
+
return $this;
|
45 |
+
}
|
46 |
+
/**
|
47 |
+
* prepare columns used in the grid.
|
48 |
+
*
|
49 |
+
* @return $this
|
50 |
+
*/
|
51 |
+
protected function _prepareColumns()
|
52 |
+
{
|
53 |
+
$helper = Mage::helper('bpost_shm');
|
54 |
+
|
55 |
+
$this->addColumn('increment_id', array(
|
56 |
+
'header' => $helper->__('Shipment'),
|
57 |
+
'type' => 'text',
|
58 |
+
'index' => 'increment_id',
|
59 |
+
'filter_index' => 'main_table.increment_id'
|
60 |
+
));
|
61 |
+
|
62 |
+
$this->addColumn('returnbarcode', array(
|
63 |
+
'header' => $helper->__('Barcode #'),
|
64 |
+
'type' => 'text',
|
65 |
+
'index' => 'bpost_return_barcode',
|
66 |
+
'filter_index' => 'main_table.bpost_return_barcode'
|
67 |
+
));
|
68 |
+
|
69 |
+
return parent::_prepareColumns();
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Gets grid url for callbacks.
|
74 |
+
*
|
75 |
+
* @return string
|
76 |
+
*/
|
77 |
+
public function getGridUrl()
|
78 |
+
{
|
79 |
+
return $this->getUrl('*/*/grid', array('_current' => true));
|
80 |
+
}
|
81 |
+
|
82 |
+
/**
|
83 |
+
* Generate rowurl.
|
84 |
+
*
|
85 |
+
* @param $row
|
86 |
+
* @return string
|
87 |
+
*/
|
88 |
+
public function getRowUrl($row)
|
89 |
+
{
|
90 |
+
return false;
|
91 |
+
}
|
92 |
+
|
93 |
+
/**
|
94 |
+
* Returns tab label.
|
95 |
+
*
|
96 |
+
* @return string
|
97 |
+
*/
|
98 |
+
public function getTabLabel() {
|
99 |
+
return Mage::helper('bpost_shm')->__('bpost Return Barcodes');
|
100 |
+
}
|
101 |
+
|
102 |
+
/**
|
103 |
+
* Returns tab title.
|
104 |
+
*
|
105 |
+
* @return string
|
106 |
+
*/
|
107 |
+
public function getTabTitle() {
|
108 |
+
return Mage::helper('bpost_shm')->__('bpost Return Barcodes');
|
109 |
+
}
|
110 |
+
|
111 |
+
/**
|
112 |
+
* Checks if tab can be shown.
|
113 |
+
*
|
114 |
+
* @return bool
|
115 |
+
*/
|
116 |
+
public function canShowTab() {
|
117 |
+
return true;
|
118 |
+
}
|
119 |
+
|
120 |
+
/**
|
121 |
+
* Checks if the tab has to be hidden.
|
122 |
+
*
|
123 |
+
* @return bool
|
124 |
+
*/
|
125 |
+
public function isHidden() {
|
126 |
+
return false;
|
127 |
+
}
|
128 |
+
|
129 |
+
/**
|
130 |
+
* Returns the order object.
|
131 |
+
*
|
132 |
+
* @return mixed
|
133 |
+
*/
|
134 |
+
public function getOrder(){
|
135 |
+
return Mage::registry('current_order');
|
136 |
+
}
|
137 |
}
|
app/code/community/Bpost/ShM/Block/Adminhtml/Sales/Order/View/Tab/Returnlabels.php
CHANGED
@@ -1,220 +1,220 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Created by PHPro
|
4 |
-
*
|
5 |
-
* @package Bpost
|
6 |
-
* @subpackage ShM
|
7 |
-
* @author PHPro (info@phpro.be)
|
8 |
-
*/
|
9 |
-
|
10 |
-
/**
|
11 |
-
* Class Bpost_ShM_Block_Adminhtml_Sales_Order_View_Tab_Returnlabels_Returnlabels
|
12 |
-
*/
|
13 |
-
class Bpost_ShM_Block_Adminhtml_Sales_Order_View_Tab_Returnlabels
|
14 |
-
extends Mage_Adminhtml_Block_Widget_Grid
|
15 |
-
implements Mage_Adminhtml_Block_Widget_Tab_Interface{
|
16 |
-
|
17 |
-
/**
|
18 |
-
* Constructs the block
|
19 |
-
*
|
20 |
-
*/
|
21 |
-
protected function _construct()
|
22 |
-
{
|
23 |
-
$this->setId('bpost_returnlabel_grid');
|
24 |
-
$this->setDefaultDir('DESC');
|
25 |
-
$this->setSaveParametersInSession(true);
|
26 |
-
$this->setUseAjax(true);
|
27 |
-
}
|
28 |
-
|
29 |
-
/**
|
30 |
-
* prepare collection to use for the grid.
|
31 |
-
*
|
32 |
-
* @return $this
|
33 |
-
*/
|
34 |
-
protected function _prepareCollection()
|
35 |
-
{
|
36 |
-
$collection = Mage::getModel('bpost_shm/returnlabel')
|
37 |
-
->getCollection()
|
38 |
-
->addFieldToFilter('order_id',array('eq' => $this->getOrder()->getId()));
|
39 |
-
|
40 |
-
$this->setCollection($collection);
|
41 |
-
parent::_prepareCollection();
|
42 |
-
return $this;
|
43 |
-
}
|
44 |
-
|
45 |
-
/**
|
46 |
-
* prepare columns used in the grid.
|
47 |
-
*
|
48 |
-
* @return $this
|
49 |
-
*/
|
50 |
-
protected function _prepareColumns()
|
51 |
-
{
|
52 |
-
$helper = Mage::helper('bpost_shm');
|
53 |
-
|
54 |
-
$mediaUrl = Mage::getBaseUrl("media");
|
55 |
-
if(substr($mediaUrl, -1) == DS){
|
56 |
-
$mediaUrl = substr($mediaUrl, 0, -1);
|
57 |
-
}
|
58 |
-
|
59 |
-
$this->addColumn('date_created', array(
|
60 |
-
'header' => $helper->__('Date Created'),
|
61 |
-
'type' => 'text',
|
62 |
-
'index' => 'date_created',
|
63 |
-
'filter_index' => 'main_table.date_created'
|
64 |
-
));
|
65 |
-
|
66 |
-
$this->addColumn('label_barcode', array(
|
67 |
-
'header' => $helper->__('Label Barcode #'),
|
68 |
-
'type' => 'text',
|
69 |
-
'index' => 'label_barcode',
|
70 |
-
'filter_index' => 'main_table.label_barcode'
|
71 |
-
));
|
72 |
-
|
73 |
-
$this->addColumn('label_pdf_path', array(
|
74 |
-
'header' => $helper->__('Filepath'),
|
75 |
-
'index' => 'label_pdf_path',
|
76 |
-
'filter_index' => 'main_table.label_pdf_path'
|
77 |
-
));
|
78 |
-
|
79 |
-
$this->addColumn('Download', array(
|
80 |
-
'header' => $helper->__('Action'),
|
81 |
-
'type' => 'action',
|
82 |
-
'getter' => 'getLabelPdfPath',
|
83 |
-
'actions' => array(
|
84 |
-
array(
|
85 |
-
'caption' => Mage::helper('catalog')->__('Download'),
|
86 |
-
'url' => $mediaUrl.Bpost_ShM_Model_Returnlabel::MEDIA_RETURNLABEL_PATH .'$label_pdf_path',
|
87 |
-
'target' => '_blank',
|
88 |
-
)
|
89 |
-
),
|
90 |
-
'filter' => false,
|
91 |
-
'sortable' => false,
|
92 |
-
'index' => 'label_pdf_path',
|
93 |
-
));
|
94 |
-
|
95 |
-
$this->addColumn('Email', array(
|
96 |
-
'header' => $helper->__('Email'),
|
97 |
-
'type' => 'action',
|
98 |
-
'getter' => 'getId',
|
99 |
-
'actions' => array(
|
100 |
-
array(
|
101 |
-
'caption' => Mage::helper('catalog')->__('Send Email'),
|
102 |
-
'url' => array(
|
103 |
-
'base'=>'adminhtml/bpost_shM_allOrders/sendEmail',
|
104 |
-
),
|
105 |
-
'field'=> 'return_id'
|
106 |
-
)
|
107 |
-
),
|
108 |
-
'filter' => false,
|
109 |
-
'sortable' => false,
|
110 |
-
'index' => '',
|
111 |
-
));
|
112 |
-
|
113 |
-
return parent::_prepareColumns();
|
114 |
-
}
|
115 |
-
|
116 |
-
public function _afterToHtml($html)
|
117 |
-
{
|
118 |
-
$suphtml = "";
|
119 |
-
$returnSessionValue = Mage::getSingleton('core/session')->getBpostReturn();
|
120 |
-
$returnParam = Mage::app()->getRequest()->getParam('bpostReturn');
|
121 |
-
|
122 |
-
if($returnParam || $returnSessionValue){
|
123 |
-
|
124 |
-
if(!$returnParam && !$returnSessionValue){
|
125 |
-
$returnParam = 1;
|
126 |
-
}elseif($returnSessionValue){
|
127 |
-
$returnParam = $returnSessionValue;
|
128 |
-
}
|
129 |
-
|
130 |
-
if(!$returnSessionValue){
|
131 |
-
Mage::getSingleton('core/session')->setBpostReturn($returnParam);
|
132 |
-
}
|
133 |
-
|
134 |
-
if($returnParam == 1){
|
135 |
-
$url = Mage::helper("adminhtml")->getUrl("adminhtml/bpost_shM_allOrders");
|
136 |
-
}else{
|
137 |
-
$url = Mage::helper("adminhtml")->getUrl("adminhtml/bpost_shM_PendingOrders");
|
138 |
-
}
|
139 |
-
|
140 |
-
$suphtml = '
|
141 |
-
<script type="text/javascript">
|
142 |
-
document.observe("dom:loaded", function (evt) {
|
143 |
-
$$(".form-buttons .back")[0].observe("click", function () {
|
144 |
-
setLocation("'.$url.'");
|
145 |
-
evt.preventDefault();
|
146 |
-
});
|
147 |
-
});
|
148 |
-
</script>';
|
149 |
-
}
|
150 |
-
|
151 |
-
|
152 |
-
return $suphtml .$html;
|
153 |
-
}
|
154 |
-
|
155 |
-
/**
|
156 |
-
* Gets grid url for callbacks.
|
157 |
-
*
|
158 |
-
* @return string
|
159 |
-
*/
|
160 |
-
public function getGridUrl()
|
161 |
-
{
|
162 |
-
return $this->getUrl('*/*/grid', array('_current' => true));
|
163 |
-
}
|
164 |
-
|
165 |
-
/**
|
166 |
-
* Generate rowurl.
|
167 |
-
*
|
168 |
-
* @param $row
|
169 |
-
* @return string
|
170 |
-
*/
|
171 |
-
public function getRowUrl($row)
|
172 |
-
{
|
173 |
-
return false;
|
174 |
-
}
|
175 |
-
|
176 |
-
/**
|
177 |
-
* Returns tab label.
|
178 |
-
*
|
179 |
-
* @return string
|
180 |
-
*/
|
181 |
-
public function getTabLabel() {
|
182 |
-
return Mage::helper('bpost_shm')->__('bpost Return Labels');
|
183 |
-
}
|
184 |
-
|
185 |
-
/**
|
186 |
-
* Returns tab title.
|
187 |
-
*
|
188 |
-
* @return string
|
189 |
-
*/
|
190 |
-
public function getTabTitle() {
|
191 |
-
return Mage::helper('bpost_shm')->__('bpost Return Labels');
|
192 |
-
}
|
193 |
-
|
194 |
-
/**
|
195 |
-
* Checks if tab can be shown.
|
196 |
-
*
|
197 |
-
* @return bool
|
198 |
-
*/
|
199 |
-
public function canShowTab() {
|
200 |
-
return true;
|
201 |
-
}
|
202 |
-
|
203 |
-
/**
|
204 |
-
* Checks if the tab has to be hidden.
|
205 |
-
*
|
206 |
-
* @return bool
|
207 |
-
*/
|
208 |
-
public function isHidden() {
|
209 |
-
return false;
|
210 |
-
}
|
211 |
-
|
212 |
-
/**
|
213 |
-
* Returns the order object.
|
214 |
-
*
|
215 |
-
* @return mixed
|
216 |
-
*/
|
217 |
-
public function getOrder(){
|
218 |
-
return Mage::registry('current_order');
|
219 |
-
}
|
220 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Created by PHPro
|
4 |
+
*
|
5 |
+
* @package Bpost
|
6 |
+
* @subpackage ShM
|
7 |
+
* @author PHPro (info@phpro.be)
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Class Bpost_ShM_Block_Adminhtml_Sales_Order_View_Tab_Returnlabels_Returnlabels
|
12 |
+
*/
|
13 |
+
class Bpost_ShM_Block_Adminhtml_Sales_Order_View_Tab_Returnlabels
|
14 |
+
extends Mage_Adminhtml_Block_Widget_Grid
|
15 |
+
implements Mage_Adminhtml_Block_Widget_Tab_Interface{
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Constructs the block
|
19 |
+
*
|
20 |
+
*/
|
21 |
+
protected function _construct()
|
22 |
+
{
|
23 |
+
$this->setId('bpost_returnlabel_grid');
|
24 |
+
$this->setDefaultDir('DESC');
|
25 |
+
$this->setSaveParametersInSession(true);
|
26 |
+
$this->setUseAjax(true);
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* prepare collection to use for the grid.
|
31 |
+
*
|
32 |
+
* @return $this
|
33 |
+
*/
|
34 |
+
protected function _prepareCollection()
|
35 |
+
{
|
36 |
+
$collection = Mage::getModel('bpost_shm/returnlabel')
|
37 |
+
->getCollection()
|
38 |
+
->addFieldToFilter('order_id',array('eq' => $this->getOrder()->getId()));
|
39 |
+
|
40 |
+
$this->setCollection($collection);
|
41 |
+
parent::_prepareCollection();
|
42 |
+
return $this;
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* prepare columns used in the grid.
|
47 |
+
*
|
48 |
+
* @return $this
|
49 |
+
*/
|
50 |
+
protected function _prepareColumns()
|
51 |
+
{
|
52 |
+
$helper = Mage::helper('bpost_shm');
|
53 |
+
|
54 |
+
$mediaUrl = Mage::getBaseUrl("media");
|
55 |
+
if(substr($mediaUrl, -1) == DS){
|
56 |
+
$mediaUrl = substr($mediaUrl, 0, -1);
|
57 |
+
}
|
58 |
+
|
59 |
+
$this->addColumn('date_created', array(
|
60 |
+
'header' => $helper->__('Date Created'),
|
61 |
+
'type' => 'text',
|
62 |
+
'index' => 'date_created',
|
63 |
+
'filter_index' => 'main_table.date_created'
|
64 |
+
));
|
65 |
+
|
66 |
+
$this->addColumn('label_barcode', array(
|
67 |
+
'header' => $helper->__('Label Barcode #'),
|
68 |
+
'type' => 'text',
|
69 |
+
'index' => 'label_barcode',
|
70 |
+
'filter_index' => 'main_table.label_barcode'
|
71 |
+
));
|
72 |
+
|
73 |
+
$this->addColumn('label_pdf_path', array(
|
74 |
+
'header' => $helper->__('Filepath'),
|
75 |
+
'index' => 'label_pdf_path',
|
76 |
+
'filter_index' => 'main_table.label_pdf_path'
|
77 |
+
));
|
78 |
+
|
79 |
+
$this->addColumn('Download', array(
|
80 |
+
'header' => $helper->__('Action'),
|
81 |
+
'type' => 'action',
|
82 |
+
'getter' => 'getLabelPdfPath',
|
83 |
+
'actions' => array(
|
84 |
+
array(
|
85 |
+
'caption' => Mage::helper('catalog')->__('Download'),
|
86 |
+
'url' => $mediaUrl.Bpost_ShM_Model_Returnlabel::MEDIA_RETURNLABEL_PATH .'$label_pdf_path',
|
87 |
+
'target' => '_blank',
|
88 |
+
)
|
89 |
+
),
|
90 |
+
'filter' => false,
|
91 |
+
'sortable' => false,
|
92 |
+
'index' => 'label_pdf_path',
|
93 |
+
));
|
94 |
+
|
95 |
+
$this->addColumn('Email', array(
|
96 |
+
'header' => $helper->__('Email'),
|
97 |
+
'type' => 'action',
|
98 |
+
'getter' => 'getId',
|
99 |
+
'actions' => array(
|
100 |
+
array(
|
101 |
+
'caption' => Mage::helper('catalog')->__('Send Email'),
|
102 |
+
'url' => array(
|
103 |
+
'base'=>'adminhtml/bpost_shM_allOrders/sendEmail',
|
104 |
+
),
|
105 |
+
'field'=> 'return_id'
|
106 |
+
)
|
107 |
+
),
|
108 |
+
'filter' => false,
|
109 |
+
'sortable' => false,
|
110 |
+
'index' => '',
|
111 |
+
));
|
112 |
+
|
113 |
+
return parent::_prepareColumns();
|
114 |
+
}
|
115 |
+
|
116 |
+
public function _afterToHtml($html)
|
117 |
+
{
|
118 |
+
$suphtml = "";
|
119 |
+
$returnSessionValue = Mage::getSingleton('core/session')->getBpostReturn();
|
120 |
+
$returnParam = Mage::app()->getRequest()->getParam('bpostReturn');
|
121 |
+
|
122 |
+
if($returnParam || $returnSessionValue){
|
123 |
+
|
124 |
+
if(!$returnParam && !$returnSessionValue){
|
125 |
+
$returnParam = 1;
|
126 |
+
}elseif($returnSessionValue){
|
127 |
+
$returnParam = $returnSessionValue;
|
128 |
+
}
|
129 |
+
|
130 |
+
if(!$returnSessionValue){
|
131 |
+
Mage::getSingleton('core/session')->setBpostReturn($returnParam);
|
132 |
+
}
|
133 |
+
|
134 |
+
if($returnParam == 1){
|
135 |
+
$url = Mage::helper("adminhtml")->getUrl("adminhtml/bpost_shM_allOrders");
|
136 |
+
}else{
|
137 |
+
$url = Mage::helper("adminhtml")->getUrl("adminhtml/bpost_shM_PendingOrders");
|
138 |
+
}
|
139 |
+
|
140 |
+
$suphtml = '
|
141 |
+
<script type="text/javascript">
|
142 |
+
document.observe("dom:loaded", function (evt) {
|
143 |
+
$$(".form-buttons .back")[0].observe("click", function () {
|
144 |
+
setLocation("'.$url.'");
|
145 |
+
evt.preventDefault();
|
146 |
+
});
|
147 |
+
});
|
148 |
+
</script>';
|
149 |
+
}
|
150 |
+
|
151 |
+
|
152 |
+
return $suphtml .$html;
|
153 |
+
}
|
154 |
+
|
155 |
+
/**
|
156 |
+
* Gets grid url for callbacks.
|
157 |
+
*
|
158 |
+
* @return string
|
159 |
+
*/
|
160 |
+
public function getGridUrl()
|
161 |
+
{
|
162 |
+
return $this->getUrl('*/*/grid', array('_current' => true));
|
163 |
+
}
|
164 |
+
|
165 |
+
/**
|
166 |
+
* Generate rowurl.
|
167 |
+
*
|
168 |
+
* @param $row
|
169 |
+
* @return string
|
170 |
+
*/
|
171 |
+
public function getRowUrl($row)
|
172 |
+
{
|
173 |
+
return false;
|
174 |
+
}
|
175 |
+
|
176 |
+
/**
|
177 |
+
* Returns tab label.
|
178 |
+
*
|
179 |
+
* @return string
|
180 |
+
*/
|
181 |
+
public function getTabLabel() {
|
182 |
+
return Mage::helper('bpost_shm')->__('bpost Return Labels');
|
183 |
+
}
|
184 |
+
|
185 |
+
/**
|
186 |
+
* Returns tab title.
|
187 |
+
*
|
188 |
+
* @return string
|
189 |
+
*/
|
190 |
+
public function getTabTitle() {
|
191 |
+
return Mage::helper('bpost_shm')->__('bpost Return Labels');
|
192 |
+
}
|
193 |
+
|
194 |
+
/**
|
195 |
+
* Checks if tab can be shown.
|
196 |
+
*
|
197 |
+
* @return bool
|
198 |
+
*/
|
199 |
+
public function canShowTab() {
|
200 |
+
return true;
|
201 |
+
}
|
202 |
+
|
203 |
+
/**
|
204 |
+
* Checks if the tab has to be hidden.
|
205 |
+
*
|
206 |
+
* @return bool
|
207 |
+
*/
|
208 |
+
public function isHidden() {
|
209 |
+
return false;
|
210 |
+
}
|
211 |
+
|
212 |
+
/**
|
213 |
+
* Returns the order object.
|
214 |
+
*
|
215 |
+
* @return mixed
|
216 |
+
*/
|
217 |
+
public function getOrder(){
|
218 |
+
return Mage::registry('current_order');
|
219 |
+
}
|
220 |
}
|
app/code/community/Bpost/ShM/Block/Adminhtml/Sales/PendingOrders.php
CHANGED
@@ -1,18 +1,18 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Class Bpost_ShM_Block_Adminhtml_Sales_PendingOrders
|
5 |
-
*/
|
6 |
-
class Bpost_ShM_Block_Adminhtml_Sales_PendingOrders extends Mage_Adminhtml_Block_Widget_Grid_Container{
|
7 |
-
/**
|
8 |
-
*
|
9 |
-
*/
|
10 |
-
public function __construct()
|
11 |
-
{
|
12 |
-
$this->_blockGroup = 'bpost_shm';
|
13 |
-
$this->_controller = 'adminhtml_sales_pendingOrders';
|
14 |
-
$this->_headerText = Mage::helper('bpost_shm')->__('Pending bpost orders');
|
15 |
-
parent::__construct();
|
16 |
-
$this->_removeButton('add');
|
17 |
-
}
|
18 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class Bpost_ShM_Block_Adminhtml_Sales_PendingOrders
|
5 |
+
*/
|
6 |
+
class Bpost_ShM_Block_Adminhtml_Sales_PendingOrders extends Mage_Adminhtml_Block_Widget_Grid_Container{
|
7 |
+
/**
|
8 |
+
*
|
9 |
+
*/
|
10 |
+
public function __construct()
|
11 |
+
{
|
12 |
+
$this->_blockGroup = 'bpost_shm';
|
13 |
+
$this->_controller = 'adminhtml_sales_pendingOrders';
|
14 |
+
$this->_headerText = Mage::helper('bpost_shm')->__('Pending bpost orders');
|
15 |
+
parent::__construct();
|
16 |
+
$this->_removeButton('add');
|
17 |
+
}
|
18 |
}
|
app/code/community/Bpost/ShM/Block/Adminhtml/Sales/PendingOrders/Grid.php
CHANGED
@@ -1,72 +1,72 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Bpost_ShM_Block_Adminhtml_Sales_PendingOrders_Grid extends Bpost_ShM_Block_Adminhtml_Sales_Grid
|
4 |
-
{
|
5 |
-
/**
|
6 |
-
* Constructs the grid and sets basic parameters.
|
7 |
-
*/
|
8 |
-
public function __construct()
|
9 |
-
{
|
10 |
-
parent::__construct();
|
11 |
-
$this->setId('bpost_shm_grid');
|
12 |
-
$this->setDefaultSort('created_at');
|
13 |
-
$this->setDefaultDir('DESC');
|
14 |
-
$this->setSaveParametersInSession(true);
|
15 |
-
}
|
16 |
-
|
17 |
-
/**
|
18 |
-
* prepare collection to use for the grid.
|
19 |
-
*
|
20 |
-
* @return $this
|
21 |
-
*/
|
22 |
-
protected function _prepareCollection()
|
23 |
-
{
|
24 |
-
$collection = Mage::getResourceModel('sales/order_grid_collection');
|
25 |
-
$collection->getSelect()->join(
|
26 |
-
Mage::getConfig()->getTablePrefix() . 'sales_flat_order as sfo',
|
27 |
-
'sfo.entity_id=`main_table`.entity_id',
|
28 |
-
array(
|
29 |
-
'shipping_method' => 'shipping_method',
|
30 |
-
'total_qty_ordered' => 'ROUND(sfo.total_qty_ordered,0)',
|
31 |
-
'bpost_label_exported' => 'bpost_label_exported',
|
32 |
-
'bpost_label_exists' => 'bpost_label_exists',
|
33 |
-
'bpost_drop_date' => 'bpost_drop_date',
|
34 |
-
'bpost_status' => 'bpost_status',
|
35 |
-
'state' => 'state'
|
36 |
-
)
|
37 |
-
);
|
38 |
-
$collection->addExpressionFieldToSelect(
|
39 |
-
'shipping_customer_name',
|
40 |
-
"IF(sfo.shipping_method='bpostshm_bpost_international', CONCAT('International: ', main_table.shipping_name), main_table.shipping_name)" ,
|
41 |
-
'shipping_customer_name'
|
42 |
-
);
|
43 |
-
$collection->addAttributeToFilter('sfo.shipping_method', array('like' => '%bpostshm%'));
|
44 |
-
$collection->addAttributeToFilter('main_table.status', array('nin' => array('complete', 'closed', 'canceled')));
|
45 |
-
|
46 |
-
$this->setCollection($collection);
|
47 |
-
parent::_prepareCollection();
|
48 |
-
|
49 |
-
$configHelper = Mage::helper('bpost_shm/system_config');
|
50 |
-
if ($configHelper->getBpostShippingConfig('display_delivery_date', $this->getStore())) {
|
51 |
-
$this->_setCollectionOrder($this->_columns['bpost_drop_date']);
|
52 |
-
}
|
53 |
-
|
54 |
-
Mage::dispatchEvent('bpost_shm_prepare_grid_collection_after', array('collection' => $collection));
|
55 |
-
return $this;
|
56 |
-
}
|
57 |
-
|
58 |
-
|
59 |
-
/**
|
60 |
-
* Generate rowurl.
|
61 |
-
*
|
62 |
-
* @param $row
|
63 |
-
* @return string
|
64 |
-
*/
|
65 |
-
public function getRowUrl($row)
|
66 |
-
{
|
67 |
-
if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) {
|
68 |
-
return $this->getUrl('*/sales_order/view', array('order_id' => $row->getId(), 'bpostReturn' => '2'));
|
69 |
-
}
|
70 |
-
return false;
|
71 |
-
}
|
72 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Bpost_ShM_Block_Adminhtml_Sales_PendingOrders_Grid extends Bpost_ShM_Block_Adminhtml_Sales_Grid
|
4 |
+
{
|
5 |
+
/**
|
6 |
+
* Constructs the grid and sets basic parameters.
|
7 |
+
*/
|
8 |
+
public function __construct()
|
9 |
+
{
|
10 |
+
parent::__construct();
|
11 |
+
$this->setId('bpost_shm_grid');
|
12 |
+
$this->setDefaultSort('created_at');
|
13 |
+
$this->setDefaultDir('DESC');
|
14 |
+
$this->setSaveParametersInSession(true);
|
15 |
+
}
|
16 |
+
|
17 |
+
/**
|
18 |
+
* prepare collection to use for the grid.
|
19 |
+
*
|
20 |
+
* @return $this
|
21 |
+
*/
|
22 |
+
protected function _prepareCollection()
|
23 |
+
{
|
24 |
+
$collection = Mage::getResourceModel('sales/order_grid_collection');
|
25 |
+
$collection->getSelect()->join(
|
26 |
+
Mage::getConfig()->getTablePrefix() . 'sales_flat_order as sfo',
|
27 |
+
'sfo.entity_id=`main_table`.entity_id',
|
28 |
+
array(
|
29 |
+
'shipping_method' => 'shipping_method',
|
30 |
+
'total_qty_ordered' => 'ROUND(sfo.total_qty_ordered,0)',
|
31 |
+
'bpost_label_exported' => 'bpost_label_exported',
|
32 |
+
'bpost_label_exists' => 'bpost_label_exists',
|
33 |
+
'bpost_drop_date' => 'bpost_drop_date',
|
34 |
+
'bpost_status' => 'bpost_status',
|
35 |
+
'state' => 'state'
|
36 |
+
)
|
37 |
+
);
|
38 |
+
$collection->addExpressionFieldToSelect(
|
39 |
+
'shipping_customer_name',
|
40 |
+
"IF(sfo.shipping_method='bpostshm_bpost_international', CONCAT('International: ', main_table.shipping_name), main_table.shipping_name)" ,
|
41 |
+
'shipping_customer_name'
|
42 |
+
);
|
43 |
+
$collection->addAttributeToFilter('sfo.shipping_method', array('like' => '%bpostshm%'));
|
44 |
+
$collection->addAttributeToFilter('main_table.status', array('nin' => array('complete', 'closed', 'canceled')));
|
45 |
+
|
46 |
+
$this->setCollection($collection);
|
47 |
+
parent::_prepareCollection();
|
48 |
+
|
49 |
+
$configHelper = Mage::helper('bpost_shm/system_config');
|
50 |
+
if ($configHelper->getBpostShippingConfig('display_delivery_date', $this->getStore())) {
|
51 |
+
$this->_setCollectionOrder($this->_columns['bpost_drop_date']);
|
52 |
+
}
|
53 |
+
|
54 |
+
Mage::dispatchEvent('bpost_shm_prepare_grid_collection_after', array('collection' => $collection));
|
55 |
+
return $this;
|
56 |
+
}
|
57 |
+
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Generate rowurl.
|
61 |
+
*
|
62 |
+
* @param $row
|
63 |
+
* @return string
|
64 |
+
*/
|
65 |
+
public function getRowUrl($row)
|
66 |
+
{
|
67 |
+
if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) {
|
68 |
+
return $this->getUrl('*/sales_order/view', array('order_id' => $row->getId(), 'bpostReturn' => '2'));
|
69 |
+
}
|
70 |
+
return false;
|
71 |
+
}
|
72 |
}
|
app/code/community/Bpost/ShM/Block/Adminhtml/Shipping/Carrier/Bpost/Tablerate/Clickcollect/Grid.php
CHANGED
@@ -1,119 +1,119 @@
|
|
1 |
-
<?php
|
2 |
-
class Bpost_ShM_Block_Adminhtml_Shipping_Carrier_Bpost_Tablerate_Clickcollect_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
3 |
-
{
|
4 |
-
/**
|
5 |
-
* Website filter
|
6 |
-
*
|
7 |
-
* @var int
|
8 |
-
*/
|
9 |
-
protected $_websiteId;
|
10 |
-
|
11 |
-
/**
|
12 |
-
* Condition filter
|
13 |
-
*
|
14 |
-
* @var string
|
15 |
-
*/
|
16 |
-
protected $_conditionName;
|
17 |
-
|
18 |
-
|
19 |
-
/**
|
20 |
-
*
|
21 |
-
*/
|
22 |
-
public function __construct()
|
23 |
-
{
|
24 |
-
parent::__construct();
|
25 |
-
$this->setId('shippingClickcollectTablerateGrid');
|
26 |
-
$this->_exportPageSize = 10000;
|
27 |
-
}
|
28 |
-
|
29 |
-
/**
|
30 |
-
* @return Mage_Adminhtml_Block_Widget_Grid
|
31 |
-
*/
|
32 |
-
protected function _prepareCollection()
|
33 |
-
{
|
34 |
-
$collection = Mage::getResourceModel('bpost_shm/tablerates_clickcollect_collection');
|
35 |
-
$collection->setConditionFilter($this->getConditionName())
|
36 |
-
->setWebsiteFilter($this->getWebsiteId());
|
37 |
-
|
38 |
-
$this->setCollection($collection);
|
39 |
-
|
40 |
-
return parent::_prepareCollection();
|
41 |
-
}
|
42 |
-
|
43 |
-
/**
|
44 |
-
* @return string
|
45 |
-
*/
|
46 |
-
public function getConditionName()
|
47 |
-
{
|
48 |
-
return $this->_conditionName;
|
49 |
-
}
|
50 |
-
|
51 |
-
/**
|
52 |
-
* @param $name
|
53 |
-
* @return $this
|
54 |
-
*/
|
55 |
-
public function setConditionName($name)
|
56 |
-
{
|
57 |
-
$this->_conditionName = $name;
|
58 |
-
return $this;
|
59 |
-
}
|
60 |
-
|
61 |
-
/**
|
62 |
-
* @return int|mixed
|
63 |
-
*/
|
64 |
-
public function getWebsiteId()
|
65 |
-
{
|
66 |
-
if (is_null($this->_websiteId)) {
|
67 |
-
$this->_websiteId = Mage::app()->getWebsite()->getId();
|
68 |
-
}
|
69 |
-
return $this->_websiteId;
|
70 |
-
}
|
71 |
-
|
72 |
-
/**
|
73 |
-
* @param $websiteId
|
74 |
-
* @return $this
|
75 |
-
*/
|
76 |
-
public function setWebsiteId($websiteId)
|
77 |
-
{
|
78 |
-
$this->_websiteId = Mage::app()->getWebsite($websiteId)->getId();
|
79 |
-
return $this;
|
80 |
-
}
|
81 |
-
|
82 |
-
/**
|
83 |
-
* @return $this
|
84 |
-
*/
|
85 |
-
protected function _prepareColumns()
|
86 |
-
{
|
87 |
-
$this->addColumn('dest_country', array(
|
88 |
-
'header' => Mage::helper('bpost_shm')->__('Country'),
|
89 |
-
'index' => 'dest_country',
|
90 |
-
'default' => '*',
|
91 |
-
));
|
92 |
-
|
93 |
-
$this->addColumn('dest_region', array(
|
94 |
-
'header' => Mage::helper('bpost_shm')->__('Region/State'),
|
95 |
-
'index' => 'dest_region',
|
96 |
-
'default' => '*',
|
97 |
-
));
|
98 |
-
|
99 |
-
$this->addColumn('dest_zip', array(
|
100 |
-
'header' => Mage::helper('bpost_shm')->__('Zip/Postal Code'),
|
101 |
-
'index' => 'dest_zip',
|
102 |
-
'default' => '*',
|
103 |
-
));
|
104 |
-
|
105 |
-
$label = Mage::getSingleton('shipping/carrier_tablerate')
|
106 |
-
->getCode('condition_name_short', $this->getConditionName());
|
107 |
-
$this->addColumn('condition_value', array(
|
108 |
-
'header' => $label,
|
109 |
-
'index' => 'condition_value',
|
110 |
-
));
|
111 |
-
|
112 |
-
$this->addColumn('price', array(
|
113 |
-
'header' => Mage::helper('bpost_shm')->__('Shipping Price'),
|
114 |
-
'index' => 'price',
|
115 |
-
));
|
116 |
-
|
117 |
-
return parent::_prepareColumns();
|
118 |
-
}
|
119 |
}
|
1 |
+
<?php
|
2 |
+
class Bpost_ShM_Block_Adminhtml_Shipping_Carrier_Bpost_Tablerate_Clickcollect_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
3 |
+
{
|
4 |
+
/**
|
5 |
+
* Website filter
|
6 |
+
*
|
7 |
+
* @var int
|
8 |
+
*/
|
9 |
+
protected $_websiteId;
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Condition filter
|
13 |
+
*
|
14 |
+
* @var string
|
15 |
+
*/
|
16 |
+
protected $_conditionName;
|
17 |
+
|
18 |
+
|
19 |
+
/**
|
20 |
+
*
|
21 |
+
*/
|
22 |
+
public function __construct()
|
23 |
+
{
|
24 |
+
parent::__construct();
|
25 |
+
$this->setId('shippingClickcollectTablerateGrid');
|
26 |
+
$this->_exportPageSize = 10000;
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* @return Mage_Adminhtml_Block_Widget_Grid
|
31 |
+
*/
|
32 |
+
protected function _prepareCollection()
|
33 |
+
{
|
34 |
+
$collection = Mage::getResourceModel('bpost_shm/tablerates_clickcollect_collection');
|
35 |
+
$collection->setConditionFilter($this->getConditionName())
|
36 |
+
->setWebsiteFilter($this->getWebsiteId());
|
37 |
+
|
38 |
+
$this->setCollection($collection);
|
39 |
+
|
40 |
+
return parent::_prepareCollection();
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* @return string
|
45 |
+
*/
|
46 |
+
public function getConditionName()
|
47 |
+
{
|
48 |
+
return $this->_conditionName;
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* @param $name
|
53 |
+
* @return $this
|
54 |
+
*/
|
55 |
+
public function setConditionName($name)
|
56 |
+
{
|
57 |
+
$this->_conditionName = $name;
|
58 |
+
return $this;
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* @return int|mixed
|
63 |
+
*/
|
64 |
+
public function getWebsiteId()
|
65 |
+
{
|
66 |
+
if (is_null($this->_websiteId)) {
|
67 |
+
$this->_websiteId = Mage::app()->getWebsite()->getId();
|
68 |
+
}
|
69 |
+
return $this->_websiteId;
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* @param $websiteId
|
74 |
+
* @return $this
|
75 |
+
*/
|
76 |
+
public function setWebsiteId($websiteId)
|
77 |
+
{
|
78 |
+
$this->_websiteId = Mage::app()->getWebsite($websiteId)->getId();
|
79 |
+
return $this;
|
80 |
+
}
|
81 |
+
|
82 |
+
/**
|
83 |
+
* @return $this
|
84 |
+
*/
|
85 |
+
protected function _prepareColumns()
|
86 |
+
{
|
87 |
+
$this->addColumn('dest_country', array(
|
88 |
+
'header' => Mage::helper('bpost_shm')->__('Country'),
|
89 |
+
'index' => 'dest_country',
|
90 |
+
'default' => '*',
|
91 |
+
));
|
92 |
+
|
93 |
+
$this->addColumn('dest_region', array(
|
94 |
+
'header' => Mage::helper('bpost_shm')->__('Region/State'),
|
95 |
+
'index' => 'dest_region',
|
96 |
+
'default' => '*',
|
97 |
+
));
|
98 |
+
|
99 |
+
$this->addColumn('dest_zip', array(
|
100 |
+
'header' => Mage::helper('bpost_shm')->__('Zip/Postal Code'),
|
101 |
+
'index' => 'dest_zip',
|
102 |
+
'default' => '*',
|
103 |
+
));
|
104 |
+
|
105 |
+
$label = Mage::getSingleton('shipping/carrier_tablerate')
|
106 |
+
->getCode('condition_name_short', $this->getConditionName());
|
107 |
+
$this->addColumn('condition_value', array(
|
108 |
+
'header' => $label,
|
109 |
+
'index' => 'condition_value',
|
110 |
+
));
|
111 |
+
|
112 |
+
$this->addColumn('price', array(
|
113 |
+
'header' => Mage::helper('bpost_shm')->__('Shipping Price'),
|
114 |
+
'index' => 'price',
|
115 |
+
));
|
116 |
+
|
117 |
+
return parent::_prepareColumns();
|
118 |
+
}
|
119 |
}
|
app/code/community/Bpost/ShM/Block/Adminhtml/Shipping/Carrier/Bpost/Tablerate/Homedelivery/Grid.php
CHANGED
@@ -1,119 +1,119 @@
|
|
1 |
-
<?php
|
2 |
-
class Bpost_ShM_Block_Adminhtml_Shipping_Carrier_Bpost_Tablerate_Homedelivery_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
3 |
-
{
|
4 |
-
/**
|
5 |
-
* Website filter
|
6 |
-
*
|
7 |
-
* @var int
|
8 |
-
*/
|
9 |
-
protected $_websiteId;
|
10 |
-
|
11 |
-
/**
|
12 |
-
* Condition filter
|
13 |
-
*
|
14 |
-
* @var string
|
15 |
-
*/
|
16 |
-
protected $_conditionName;
|
17 |
-
|
18 |
-
|
19 |
-
/**
|
20 |
-
*
|
21 |
-
*/
|
22 |
-
public function __construct()
|
23 |
-
{
|
24 |
-
parent::__construct();
|
25 |
-
$this->setId('shippingHomedeliveryTablerateGrid');
|
26 |
-
$this->_exportPageSize = 10000;
|
27 |
-
}
|
28 |
-
|
29 |
-
/**
|
30 |
-
* @return Mage_Adminhtml_Block_Widget_Grid
|
31 |
-
*/
|
32 |
-
protected function _prepareCollection()
|
33 |
-
{
|
34 |
-
$collection = Mage::getResourceModel('bpost_shm/tablerates_homedelivery_collection');
|
35 |
-
$collection->setConditionFilter($this->getConditionName())
|
36 |
-
->setWebsiteFilter($this->getWebsiteId());
|
37 |
-
|
38 |
-
$this->setCollection($collection);
|
39 |
-
|
40 |
-
return parent::_prepareCollection();
|
41 |
-
}
|
42 |
-
|
43 |
-
/**
|
44 |
-
* @return string
|
45 |
-
*/
|
46 |
-
public function getConditionName()
|
47 |
-
{
|
48 |
-
return $this->_conditionName;
|
49 |
-
}
|
50 |
-
|
51 |
-
/**
|
52 |
-
* @param $name
|
53 |
-
* @return $this
|
54 |
-
*/
|
55 |
-
public function setConditionName($name)
|
56 |
-
{
|
57 |
-
$this->_conditionName = $name;
|
58 |
-
return $this;
|
59 |
-
}
|
60 |
-
|
61 |
-
/**
|
62 |
-
* @return int|mixed
|
63 |
-
*/
|
64 |
-
public function getWebsiteId()
|
65 |
-
{
|
66 |
-
if (is_null($this->_websiteId)) {
|
67 |
-
$this->_websiteId = Mage::app()->getWebsite()->getId();
|
68 |
-
}
|
69 |
-
return $this->_websiteId;
|
70 |
-
}
|
71 |
-
|
72 |
-
/**
|
73 |
-
* @param $websiteId
|
74 |
-
* @return $this
|
75 |
-
*/
|
76 |
-
public function setWebsiteId($websiteId)
|
77 |
-
{
|
78 |
-
$this->_websiteId = Mage::app()->getWebsite($websiteId)->getId();
|
79 |
-
return $this;
|
80 |
-
}
|
81 |
-
|
82 |
-
/**
|
83 |
-
* @return $this
|
84 |
-
*/
|
85 |
-
protected function _prepareColumns()
|
86 |
-
{
|
87 |
-
$this->addColumn('dest_country', array(
|
88 |
-
'header' => Mage::helper('bpost_shm')->__('Country'),
|
89 |
-
'index' => 'dest_country',
|
90 |
-
'default' => '*',
|
91 |
-
));
|
92 |
-
|
93 |
-
$this->addColumn('dest_region', array(
|
94 |
-
'header' => Mage::helper('bpost_shm')->__('Region/State'),
|
95 |
-
'index' => 'dest_region',
|
96 |
-
'default' => '*',
|
97 |
-
));
|
98 |
-
|
99 |
-
$this->addColumn('dest_zip', array(
|
100 |
-
'header' => Mage::helper('bpost_shm')->__('Zip/Postal Code'),
|
101 |
-
'index' => 'dest_zip',
|
102 |
-
'default' => '*',
|
103 |
-
));
|
104 |
-
|
105 |
-
$label = Mage::getSingleton('shipping/carrier_tablerate')
|
106 |
-
->getCode('condition_name_short', $this->getConditionName());
|
107 |
-
$this->addColumn('condition_value', array(
|
108 |
-
'header' => $label,
|
109 |
-
'index' => 'condition_value',
|
110 |
-
));
|
111 |
-
|
112 |
-
$this->addColumn('price', array(
|
113 |
-
'header' => Mage::helper('bpost_shm')->__('Shipping Price'),
|
114 |
-
'index' => 'price',
|
115 |
-
));
|
116 |
-
|
117 |
-
return parent::_prepareColumns();
|
118 |
-
}
|
119 |
}
|
1 |
+
<?php
|
2 |
+
class Bpost_ShM_Block_Adminhtml_Shipping_Carrier_Bpost_Tablerate_Homedelivery_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
3 |
+
{
|
4 |
+
/**
|
5 |
+
* Website filter
|
6 |
+
*
|
7 |
+
* @var int
|
8 |
+
*/
|
9 |
+
protected $_websiteId;
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Condition filter
|
13 |
+
*
|
14 |
+
* @var string
|
15 |
+
*/
|
16 |
+
protected $_conditionName;
|
17 |
+
|
18 |
+
|
19 |
+
/**
|
20 |
+
*
|
21 |
+
*/
|
22 |
+
public function __construct()
|
23 |
+
{
|
24 |
+
parent::__construct();
|
25 |
+
$this->setId('shippingHomedeliveryTablerateGrid');
|
26 |
+
$this->_exportPageSize = 10000;
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* @return Mage_Adminhtml_Block_Widget_Grid
|
31 |
+
*/
|
32 |
+
protected function _prepareCollection()
|
33 |
+
{
|
34 |
+
$collection = Mage::getResourceModel('bpost_shm/tablerates_homedelivery_collection');
|
35 |
+
$collection->setConditionFilter($this->getConditionName())
|
36 |
+
->setWebsiteFilter($this->getWebsiteId());
|
37 |
+
|
38 |
+
$this->setCollection($collection);
|
39 |
+
|
40 |
+
return parent::_prepareCollection();
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* @return string
|
45 |
+
*/
|
46 |
+
public function getConditionName()
|
47 |
+
{
|
48 |
+
return $this->_conditionName;
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* @param $name
|
53 |
+
* @return $this
|
54 |
+
*/
|
55 |
+
public function setConditionName($name)
|
56 |
+
{
|
57 |
+
$this->_conditionName = $name;
|
58 |
+
return $this;
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* @return int|mixed
|
63 |
+
*/
|
64 |
+
public function getWebsiteId()
|
65 |
+
{
|
66 |
+
if (is_null($this->_websiteId)) {
|
67 |
+
$this->_websiteId = Mage::app()->getWebsite()->getId();
|
68 |
+
}
|
69 |
+
return $this->_websiteId;
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* @param $websiteId
|
74 |
+
* @return $this
|
75 |
+
*/
|
76 |
+
public function setWebsiteId($websiteId)
|
77 |
+
{
|
78 |
+
$this->_websiteId = Mage::app()->getWebsite($websiteId)->getId();
|
79 |
+
return $this;
|
80 |
+
}
|
81 |
+
|
82 |
+
/**
|
83 |
+
* @return $this
|
84 |
+
*/
|
85 |
+
protected function _prepareColumns()
|
86 |
+
{
|
87 |
+
$this->addColumn('dest_country', array(
|
88 |
+
'header' => Mage::helper('bpost_shm')->__('Country'),
|
89 |
+
'index' => 'dest_country',
|
90 |
+
'default' => '*',
|
91 |
+
));
|
92 |
+
|
93 |
+
$this->addColumn('dest_region', array(
|
94 |
+
'header' => Mage::helper('bpost_shm')->__('Region/State'),
|
95 |
+
'index' => 'dest_region',
|
96 |
+
'default' => '*',
|
97 |
+
));
|
98 |
+
|
99 |
+
$this->addColumn('dest_zip', array(
|
100 |
+
'header' => Mage::helper('bpost_shm')->__('Zip/Postal Code'),
|
101 |
+
'index' => 'dest_zip',
|
102 |
+
'default' => '*',
|
103 |
+
));
|
104 |
+
|
105 |
+
$label = Mage::getSingleton('shipping/carrier_tablerate')
|
106 |
+
->getCode('condition_name_short', $this->getConditionName());
|
107 |
+
$this->addColumn('condition_value', array(
|
108 |
+
'header' => $label,
|
109 |
+
'index' => 'condition_value',
|
110 |
+
));
|
111 |
+
|
112 |
+
$this->addColumn('price', array(
|
113 |
+
'header' => Mage::helper('bpost_shm')->__('Shipping Price'),
|
114 |
+
'index' => 'price',
|
115 |
+
));
|
116 |
+
|
117 |
+
return parent::_prepareColumns();
|
118 |
+
}
|
119 |
}
|
app/code/community/Bpost/ShM/Block/Adminhtml/Shipping/Carrier/Bpost/Tablerate/International/Grid.php
CHANGED
@@ -1,119 +1,119 @@
|
|
1 |
-
<?php
|
2 |
-
class Bpost_ShM_Block_Adminhtml_Shipping_Carrier_Bpost_Tablerate_International_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
3 |
-
{
|
4 |
-
/**
|
5 |
-
* Website filter
|
6 |
-
*
|
7 |
-
* @var int
|
8 |
-
*/
|
9 |
-
protected $_websiteId;
|
10 |
-
|
11 |
-
/**
|
12 |
-
* Condition filter
|
13 |
-
*
|
14 |
-
* @var string
|
15 |
-
*/
|
16 |
-
protected $_conditionName;
|
17 |
-
|
18 |
-
|
19 |
-
/**
|
20 |
-
*
|
21 |
-
*/
|
22 |
-
public function __construct()
|
23 |
-
{
|
24 |
-
parent::__construct();
|
25 |
-
$this->setId('shippingInternationalTablerateGrid');
|
26 |
-
$this->_exportPageSize = 10000;
|
27 |
-
}
|
28 |
-
|
29 |
-
/**
|
30 |
-
* @return Mage_Adminhtml_Block_Widget_Grid
|
31 |
-
*/
|
32 |
-
protected function _prepareCollection()
|
33 |
-
{
|
34 |
-
$collection = Mage::getResourceModel('bpost_shm/tablerates_international_collection');
|
35 |
-
$collection->setConditionFilter($this->getConditionName())
|
36 |
-
->setWebsiteFilter($this->getWebsiteId());
|
37 |
-
|
38 |
-
$this->setCollection($collection);
|
39 |
-
|
40 |
-
return parent::_prepareCollection();
|
41 |
-
}
|
42 |
-
|
43 |
-
/**
|
44 |
-
* @return string
|
45 |
-
*/
|
46 |
-
public function getConditionName()
|
47 |
-
{
|
48 |
-
return $this->_conditionName;
|
49 |
-
}
|
50 |
-
|
51 |
-
/**
|
52 |
-
* @param $name
|
53 |
-
* @return $this
|
54 |
-
*/
|
55 |
-
public function setConditionName($name)
|
56 |
-
{
|
57 |
-
$this->_conditionName = $name;
|
58 |
-
return $this;
|
59 |
-
}
|
60 |
-
|
61 |
-
/**
|
62 |
-
* @return int|mixed
|
63 |
-
*/
|
64 |
-
public function getWebsiteId()
|
65 |
-
{
|
66 |
-
if (is_null($this->_websiteId)) {
|
67 |
-
$this->_websiteId = Mage::app()->getWebsite()->getId();
|
68 |
-
}
|
69 |
-
return $this->_websiteId;
|
70 |
-
}
|
71 |
-
|
72 |
-
/**
|
73 |
-
* @param $websiteId
|
74 |
-
* @return $this
|
75 |
-
*/
|
76 |
-
public function setWebsiteId($websiteId)
|
77 |
-
{
|
78 |
-
$this->_websiteId = Mage::app()->getWebsite($websiteId)->getId();
|
79 |
-
return $this;
|
80 |
-
}
|
81 |
-
|
82 |
-
/**
|
83 |
-
* @return $this
|
84 |
-
*/
|
85 |
-
protected function _prepareColumns()
|
86 |
-
{
|
87 |
-
$this->addColumn('dest_country', array(
|
88 |
-
'header' => Mage::helper('bpost_shm')->__('Country'),
|
89 |
-
'index' => 'dest_country',
|
90 |
-
'default' => '*',
|
91 |
-
));
|
92 |
-
|
93 |
-
$this->addColumn('dest_region', array(
|
94 |
-
'header' => Mage::helper('bpost_shm')->__('Region/State'),
|
95 |
-
'index' => 'dest_region',
|
96 |
-
'default' => '*',
|
97 |
-
));
|
98 |
-
|
99 |
-
$this->addColumn('dest_zip', array(
|
100 |
-
'header' => Mage::helper('bpost_shm')->__('Zip/Postal Code'),
|
101 |
-
'index' => 'dest_zip',
|
102 |
-
'default' => '*',
|
103 |
-
));
|
104 |
-
|
105 |
-
$label = Mage::getSingleton('shipping/carrier_tablerate')
|
106 |
-
->getCode('condition_name_short', $this->getConditionName());
|
107 |
-
$this->addColumn('condition_value', array(
|
108 |
-
'header' => $label,
|
109 |
-
'index' => 'condition_value',
|
110 |
-
));
|
111 |
-
|
112 |
-
$this->addColumn('price', array(
|
113 |
-
'header' => Mage::helper('bpost_shm')->__('Shipping Price'),
|
114 |
-
'index' => 'price',
|
115 |
-
));
|
116 |
-
|
117 |
-
return parent::_prepareColumns();
|
118 |
-
}
|
119 |
}
|
1 |
+
<?php
|
2 |
+
class Bpost_ShM_Block_Adminhtml_Shipping_Carrier_Bpost_Tablerate_International_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
3 |
+
{
|
4 |
+
/**
|
5 |
+
* Website filter
|
6 |
+
*
|
7 |
+
* @var int
|
8 |
+
*/
|
9 |
+
protected $_websiteId;
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Condition filter
|
13 |
+
*
|
14 |
+
* @var string
|
15 |
+
*/
|
16 |
+
protected $_conditionName;
|
17 |
+
|
18 |
+
|
19 |
+
/**
|
20 |
+
*
|
21 |
+
*/
|
22 |
+
public function __construct()
|
23 |
+
{
|
24 |
+
parent::__construct();
|
25 |
+
$this->setId('shippingInternationalTablerateGrid');
|
26 |
+
$this->_exportPageSize = 10000;
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* @return Mage_Adminhtml_Block_Widget_Grid
|
31 |
+
*/
|
32 |
+
protected function _prepareCollection()
|
33 |
+
{
|
34 |
+
$collection = Mage::getResourceModel('bpost_shm/tablerates_international_collection');
|
35 |
+
$collection->setConditionFilter($this->getConditionName())
|
36 |
+
->setWebsiteFilter($this->getWebsiteId());
|
37 |
+
|
38 |
+
$this->setCollection($collection);
|
39 |
+
|
40 |
+
return parent::_prepareCollection();
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* @return string
|
45 |
+
*/
|
46 |
+
public function getConditionName()
|
47 |
+
{
|
48 |
+
return $this->_conditionName;
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* @param $name
|
53 |
+
* @return $this
|
54 |
+
*/
|
55 |
+
public function setConditionName($name)
|
56 |
+
{
|
57 |
+
$this->_conditionName = $name;
|
58 |
+
return $this;
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* @return int|mixed
|
63 |
+
*/
|
64 |
+
public function getWebsiteId()
|
65 |
+
{
|
66 |
+
if (is_null($this->_websiteId)) {
|
67 |
+
$this->_websiteId = Mage::app()->getWebsite()->getId();
|
68 |
+
}
|
69 |
+
return $this->_websiteId;
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* @param $websiteId
|
74 |
+
* @return $this
|
75 |
+
*/
|
76 |
+
public function setWebsiteId($websiteId)
|
77 |
+
{
|
78 |
+
$this->_websiteId = Mage::app()->getWebsite($websiteId)->getId();
|
79 |
+
return $this;
|
80 |
+
}
|
81 |
+
|
82 |
+
/**
|
83 |
+
* @return $this
|
84 |
+
*/
|
85 |
+
protected function _prepareColumns()
|
86 |
+
{
|
87 |
+
$this->addColumn('dest_country', array(
|
88 |
+
'header' => Mage::helper('bpost_shm')->__('Country'),
|
89 |
+
'index' => 'dest_country',
|
90 |
+
'default' => '*',
|
91 |
+
));
|
92 |
+
|
93 |
+
$this->addColumn('dest_region', array(
|
94 |
+
'header' => Mage::helper('bpost_shm')->__('Region/State'),
|
95 |
+
'index' => 'dest_region',
|
96 |
+
'default' => '*',
|
97 |
+
));
|
98 |
+
|
99 |
+
$this->addColumn('dest_zip', array(
|
100 |
+
'header' => Mage::helper('bpost_shm')->__('Zip/Postal Code'),
|
101 |
+
'index' => 'dest_zip',
|
102 |
+
'default' => '*',
|
103 |
+
));
|
104 |
+
|
105 |
+
$label = Mage::getSingleton('shipping/carrier_tablerate')
|
106 |
+
->getCode('condition_name_short', $this->getConditionName());
|
107 |
+
$this->addColumn('condition_value', array(
|
108 |
+
'header' => $label,
|
109 |
+
'index' => 'condition_value',
|
110 |
+
));
|
111 |
+
|
112 |
+
$this->addColumn('price', array(
|
113 |
+
'header' => Mage::helper('bpost_shm')->__('Shipping Price'),
|
114 |
+
'index' => 'price',
|
115 |
+
));
|
116 |
+
|
117 |
+
return parent::_prepareColumns();
|
118 |
+
}
|
119 |
}
|
app/code/community/Bpost/ShM/Block/Adminhtml/Shipping/Carrier/Bpost/Tablerate/Parcellocker/Grid.php
CHANGED
@@ -1,119 +1,119 @@
|
|
1 |
-
<?php
|
2 |
-
class Bpost_ShM_Block_Adminhtml_Shipping_Carrier_Bpost_Tablerate_Parcellocker_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
3 |
-
{
|
4 |
-
/**
|
5 |
-
* Website filter
|
6 |
-
*
|
7 |
-
* @var int
|
8 |
-
*/
|
9 |
-
protected $_websiteId;
|
10 |
-
|
11 |
-
/**
|
12 |
-
* Condition filter
|
13 |
-
*
|
14 |
-
* @var string
|
15 |
-
*/
|
16 |
-
protected $_conditionName;
|
17 |
-
|
18 |
-
|
19 |
-
/**
|
20 |
-
*
|
21 |
-
*/
|
22 |
-
public function __construct()
|
23 |
-
{
|
24 |
-
parent::__construct();
|
25 |
-
$this->setId('shippingParcellockerTablerateGrid');
|
26 |
-
$this->_exportPageSize = 10000;
|
27 |
-
}
|
28 |
-
|
29 |
-
/**
|
30 |
-
* @return Mage_Adminhtml_Block_Widget_Grid
|
31 |
-
*/
|
32 |
-
protected function _prepareCollection()
|
33 |
-
{
|
34 |
-
$collection = Mage::getResourceModel('bpost_shm/tablerates_parcellocker_collection');
|
35 |
-
$collection->setConditionFilter($this->getConditionName())
|
36 |
-
->setWebsiteFilter($this->getWebsiteId());
|
37 |
-
|
38 |
-
$this->setCollection($collection);
|
39 |
-
|
40 |
-
return parent::_prepareCollection();
|
41 |
-
}
|
42 |
-
|
43 |
-
/**
|
44 |
-
* @return string
|
45 |
-
*/
|
46 |
-
public function getConditionName()
|
47 |
-
{
|
48 |
-
return $this->_conditionName;
|
49 |
-
}
|
50 |
-
|
51 |
-
/**
|
52 |
-
* @param $name
|
53 |
-
* @return $this
|
54 |
-
*/
|
55 |
-
public function setConditionName($name)
|
56 |
-
{
|
57 |
-
$this->_conditionName = $name;
|
58 |
-
return $this;
|
59 |
-
}
|
60 |
-
|
61 |
-
/**
|
62 |
-
* @return int|mixed
|
63 |
-
*/
|
64 |
-
public function getWebsiteId()
|
65 |
-
{
|
66 |
-
if (is_null($this->_websiteId)) {
|
67 |
-
$this->_websiteId = Mage::app()->getWebsite()->getId();
|
68 |
-
}
|
69 |
-
return $this->_websiteId;
|
70 |
-
}
|
71 |
-
|
72 |
-
/**
|
73 |
-
* @param $websiteId
|
74 |
-
* @return $this
|
75 |
-
*/
|
76 |
-
public function setWebsiteId($websiteId)
|
77 |
-
{
|
78 |
-
$this->_websiteId = Mage::app()->getWebsite($websiteId)->getId();
|
79 |
-
return $this;
|
80 |
-
}
|
81 |
-
|
82 |
-
/**
|
83 |
-
* @return $this
|
84 |
-
*/
|
85 |
-
protected function _prepareColumns()
|
86 |
-
{
|
87 |
-
$this->addColumn('dest_country', array(
|
88 |
-
'header' => Mage::helper('bpost_shm')->__('Country'),
|
89 |
-
'index' => 'dest_country',
|
90 |
-
'default' => '*',
|
91 |
-
));
|
92 |
-
|
93 |
-
$this->addColumn('dest_region', array(
|
94 |
-
'header' => Mage::helper('bpost_shm')->__('Region/State'),
|
95 |
-
'index' => 'dest_region',
|
96 |
-
'default' => '*',
|
97 |
-
));
|
98 |
-
|
99 |
-
$this->addColumn('dest_zip', array(
|
100 |
-
'header' => Mage::helper('bpost_shm')->__('Zip/Postal Code'),
|
101 |
-
'index' => 'dest_zip',
|
102 |
-
'default' => '*',
|
103 |
-
));
|
104 |
-
|
105 |
-
$label = Mage::getSingleton('shipping/carrier_tablerate')
|
106 |
-
->getCode('condition_name_short', $this->getConditionName());
|
107 |
-
$this->addColumn('condition_value', array(
|
108 |
-
'header' => $label,
|
109 |
-
'index' => 'condition_value',
|
110 |
-
));
|
111 |
-
|
112 |
-
$this->addColumn('price', array(
|
113 |
-
'header' => Mage::helper('bpost_shm')->__('Shipping Price'),
|
114 |
-
'index' => 'price',
|
115 |
-
));
|
116 |
-
|
117 |
-
return parent::_prepareColumns();
|
118 |
-
}
|
119 |
}
|
1 |
+
<?php
|
2 |
+
class Bpost_ShM_Block_Adminhtml_Shipping_Carrier_Bpost_Tablerate_Parcellocker_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
3 |
+
{
|
4 |
+
/**
|
5 |
+
* Website filter
|
6 |
+
*
|
7 |
+
* @var int
|
8 |
+
*/
|
9 |
+
protected $_websiteId;
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Condition filter
|
13 |
+
*
|
14 |
+
* @var string
|
15 |
+
*/
|
16 |
+
protected $_conditionName;
|
17 |
+
|
18 |
+
|
19 |
+
/**
|
20 |
+
*
|
21 |
+
*/
|
22 |
+
public function __construct()
|
23 |
+
{
|
24 |
+
parent::__construct();
|
25 |
+
$this->setId('shippingParcellockerTablerateGrid');
|
26 |
+
$this->_exportPageSize = 10000;
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* @return Mage_Adminhtml_Block_Widget_Grid
|
31 |
+
*/
|
32 |
+
protected function _prepareCollection()
|
33 |
+
{
|
34 |
+
$collection = Mage::getResourceModel('bpost_shm/tablerates_parcellocker_collection');
|
35 |
+
$collection->setConditionFilter($this->getConditionName())
|
36 |
+
->setWebsiteFilter($this->getWebsiteId());
|
37 |
+
|
38 |
+
$this->setCollection($collection);
|
39 |
+
|
40 |
+
return parent::_prepareCollection();
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* @return string
|
45 |
+
*/
|
46 |
+
public function getConditionName()
|
47 |
+
{
|
48 |
+
return $this->_conditionName;
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* @param $name
|
53 |
+
* @return $this
|
54 |
+
*/
|
55 |
+
public function setConditionName($name)
|
56 |
+
{
|
57 |
+
$this->_conditionName = $name;
|
58 |
+
return $this;
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* @return int|mixed
|
63 |
+
*/
|
64 |
+
public function getWebsiteId()
|
65 |
+
{
|
66 |
+
if (is_null($this->_websiteId)) {
|
67 |
+
$this->_websiteId = Mage::app()->getWebsite()->getId();
|
68 |
+
}
|
69 |
+
return $this->_websiteId;
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* @param $websiteId
|
74 |
+
* @return $this
|
75 |
+
*/
|
76 |
+
public function setWebsiteId($websiteId)
|
77 |
+
{
|
78 |
+
$this->_websiteId = Mage::app()->getWebsite($websiteId)->getId();
|
79 |
+
return $this;
|
80 |
+
}
|
81 |
+
|
82 |
+
/**
|
83 |
+
* @return $this
|
84 |
+
*/
|
85 |
+
protected function _prepareColumns()
|
86 |
+
{
|
87 |
+
$this->addColumn('dest_country', array(
|
88 |
+
'header' => Mage::helper('bpost_shm')->__('Country'),
|
89 |
+
'index' => 'dest_country',
|
90 |
+
'default' => '*',
|
91 |
+
));
|
92 |
+
|
93 |
+
$this->addColumn('dest_region', array(
|
94 |
+
'header' => Mage::helper('bpost_shm')->__('Region/State'),
|
95 |
+
'index' => 'dest_region',
|
96 |
+
'default' => '*',
|
97 |
+
));
|
98 |
+
|
99 |
+
$this->addColumn('dest_zip', array(
|
100 |
+
'header' => Mage::helper('bpost_shm')->__('Zip/Postal Code'),
|
101 |
+
'index' => 'dest_zip',
|
102 |
+
'default' => '*',
|
103 |
+
));
|
104 |
+
|
105 |
+
$label = Mage::getSingleton('shipping/carrier_tablerate')
|
106 |
+
->getCode('condition_name_short', $this->getConditionName());
|
107 |
+
$this->addColumn('condition_value', array(
|
108 |
+
'header' => $label,
|
109 |
+
'index' => 'condition_value',
|
110 |
+
));
|
111 |
+
|
112 |
+
$this->addColumn('price', array(
|
113 |
+
'header' => Mage::helper('bpost_shm')->__('Shipping Price'),
|
114 |
+
'index' => 'price',
|
115 |
+
));
|
116 |
+
|
117 |
+
return parent::_prepareColumns();
|
118 |
+
}
|
119 |
}
|
app/code/community/Bpost/ShM/Block/Adminhtml/Shipping/Carrier/Bpost/Tablerate/Pickuppoint/Grid.php
CHANGED
@@ -1,119 +1,119 @@
|
|
1 |
-
<?php
|
2 |
-
class Bpost_ShM_Block_Adminhtml_Shipping_Carrier_Bpost_Tablerate_Pickuppoint_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
3 |
-
{
|
4 |
-
/**
|
5 |
-
* Website filter
|
6 |
-
*
|
7 |
-
* @var int
|
8 |
-
*/
|
9 |
-
protected $_websiteId;
|
10 |
-
|
11 |
-
/**
|
12 |
-
* Condition filter
|
13 |
-
*
|
14 |
-
* @var string
|
15 |
-
*/
|
16 |
-
protected $_conditionName;
|
17 |
-
|
18 |
-
|
19 |
-
/**
|
20 |
-
*
|
21 |
-
*/
|
22 |
-
public function __construct()
|
23 |
-
{
|
24 |
-
parent::__construct();
|
25 |
-
$this->setId('shippingPickuppointTablerateGrid');
|
26 |
-
$this->_exportPageSize = 10000;
|
27 |
-
}
|
28 |
-
|
29 |
-
/**
|
30 |
-
* @return Mage_Adminhtml_Block_Widget_Grid
|
31 |
-
*/
|
32 |
-
protected function _prepareCollection()
|
33 |
-
{
|
34 |
-
$collection = Mage::getResourceModel('bpost_shm/tablerates_pickuppoint_collection');
|
35 |
-
$collection->setConditionFilter($this->getConditionName())
|
36 |
-
->setWebsiteFilter($this->getWebsiteId());
|
37 |
-
|
38 |
-
$this->setCollection($collection);
|
39 |
-
|
40 |
-
return parent::_prepareCollection();
|
41 |
-
}
|
42 |
-
|
43 |
-
/**
|
44 |
-
* @return string
|
45 |
-
*/
|
46 |
-
public function getConditionName()
|
47 |
-
{
|
48 |
-
return $this->_conditionName;
|
49 |
-
}
|
50 |
-
|
51 |
-
/**
|
52 |
-
* @param $name
|
53 |
-
* @return $this
|
54 |
-
*/
|
55 |
-
public function setConditionName($name)
|
56 |
-
{
|
57 |
-
$this->_conditionName = $name;
|
58 |
-
return $this;
|
59 |
-
}
|
60 |
-
|
61 |
-
/**
|
62 |
-
* @return int|mixed
|
63 |
-
*/
|
64 |
-
public function getWebsiteId()
|
65 |
-
{
|
66 |
-
if (is_null($this->_websiteId)) {
|
67 |
-
$this->_websiteId = Mage::app()->getWebsite()->getId();
|
68 |
-
}
|
69 |
-
return $this->_websiteId;
|
70 |
-
}
|
71 |
-
|
72 |
-
/**
|
73 |
-
* @param $websiteId
|
74 |
-
* @return $this
|
75 |
-
*/
|
76 |
-
public function setWebsiteId($websiteId)
|
77 |
-
{
|
78 |
-
$this->_websiteId = Mage::app()->getWebsite($websiteId)->getId();
|
79 |
-
return $this;
|
80 |
-
}
|
81 |
-
|
82 |
-
/**
|
83 |
-
* @return $this
|
84 |
-
*/
|
85 |
-
protected function _prepareColumns()
|
86 |
-
{
|
87 |
-
$this->addColumn('dest_country', array(
|
88 |
-
'header' => Mage::helper('bpost_shm')->__('Country'),
|
89 |
-
'index' => 'dest_country',
|
90 |
-
'default' => '*',
|
91 |
-
));
|
92 |
-
|
93 |
-
$this->addColumn('dest_region', array(
|
94 |
-
'header' => Mage::helper('bpost_shm')->__('Region/State'),
|
95 |
-
'index' => 'dest_region',
|
96 |
-
'default' => '*',
|
97 |
-
));
|
98 |
-
|
99 |
-
$this->addColumn('dest_zip', array(
|
100 |
-
'header' => Mage::helper('bpost_shm')->__('Zip/Postal Code'),
|
101 |
-
'index' => 'dest_zip',
|
102 |
-
'default' => '*',
|
103 |
-
));
|
104 |
-
|
105 |
-
$label = Mage::getSingleton('shipping/carrier_tablerate')
|
106 |
-
->getCode('condition_name_short', $this->getConditionName());
|
107 |
-
$this->addColumn('condition_value', array(
|
108 |
-
'header' => $label,
|
109 |
-
'index' => 'condition_value',
|
110 |
-
));
|
111 |
-
|
112 |
-
$this->addColumn('price', array(
|
113 |
-
'header' => Mage::helper('bpost_shm')->__('Shipping Price'),
|
114 |
-
'index' => 'price',
|
115 |
-
));
|
116 |
-
|
117 |
-
return parent::_prepareColumns();
|
118 |
-
}
|
119 |
}
|
1 |
+
<?php
|
2 |
+
class Bpost_ShM_Block_Adminhtml_Shipping_Carrier_Bpost_Tablerate_Pickuppoint_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
3 |
+
{
|
4 |
+
/**
|
5 |
+
* Website filter
|
6 |
+
*
|
7 |
+
* @var int
|
8 |
+
*/
|
9 |
+
protected $_websiteId;
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Condition filter
|
13 |
+
*
|
14 |
+
* @var string
|
15 |
+
*/
|
16 |
+
protected $_conditionName;
|
17 |
+
|
18 |
+
|
19 |
+
/**
|
20 |
+
*
|
21 |
+
*/
|
22 |
+
public function __construct()
|
23 |
+
{
|
24 |
+
parent::__construct();
|
25 |
+
$this->setId('shippingPickuppointTablerateGrid');
|
26 |
+
$this->_exportPageSize = 10000;
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* @return Mage_Adminhtml_Block_Widget_Grid
|
31 |
+
*/
|
32 |
+
protected function _prepareCollection()
|
33 |
+
{
|
34 |
+
$collection = Mage::getResourceModel('bpost_shm/tablerates_pickuppoint_collection');
|
35 |
+
$collection->setConditionFilter($this->getConditionName())
|
36 |
+
->setWebsiteFilter($this->getWebsiteId());
|
37 |
+
|
38 |
+
$this->setCollection($collection);
|
39 |
+
|
40 |
+
return parent::_prepareCollection();
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* @return string
|
45 |
+
*/
|
46 |
+
public function getConditionName()
|
47 |
+
{
|
48 |
+
return $this->_conditionName;
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* @param $name
|
53 |
+
* @return $this
|
54 |
+
*/
|
55 |
+
public function setConditionName($name)
|
56 |
+
{
|
57 |
+
$this->_conditionName = $name;
|
58 |
+
return $this;
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* @return int|mixed
|
63 |
+
*/
|
64 |
+
public function getWebsiteId()
|
65 |
+
{
|
66 |
+
if (is_null($this->_websiteId)) {
|
67 |
+
$this->_websiteId = Mage::app()->getWebsite()->getId();
|
68 |
+
}
|
69 |
+
return $this->_websiteId;
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* @param $websiteId
|
74 |
+
* @return $this
|
75 |
+
*/
|
76 |
+
public function setWebsiteId($websiteId)
|
77 |
+
{
|
78 |
+
$this->_websiteId = Mage::app()->getWebsite($websiteId)->getId();
|
79 |
+
return $this;
|
80 |
+
}
|
81 |
+
|
82 |
+
/**
|
83 |
+
* @return $this
|
84 |
+
*/
|
85 |
+
protected function _prepareColumns()
|
86 |
+
{
|
87 |
+
$this->addColumn('dest_country', array(
|
88 |
+
'header' => Mage::helper('bpost_shm')->__('Country'),
|
89 |
+
'index' => 'dest_country',
|
90 |
+
'default' => '*',
|
91 |
+
));
|
92 |
+
|
93 |
+
$this->addColumn('dest_region', array(
|
94 |
+
'header' => Mage::helper('bpost_shm')->__('Region/State'),
|
95 |
+
'index' => 'dest_region',
|
96 |
+
'default' => '*',
|
97 |
+
));
|
98 |
+
|
99 |
+
$this->addColumn('dest_zip', array(
|
100 |
+
'header' => Mage::helper('bpost_shm')->__('Zip/Postal Code'),
|
101 |
+
'index' => 'dest_zip',
|
102 |
+
'default' => '*',
|
103 |
+
));
|
104 |
+
|
105 |
+
$label = Mage::getSingleton('shipping/carrier_tablerate')
|
106 |
+
->getCode('condition_name_short', $this->getConditionName());
|
107 |
+
$this->addColumn('condition_value', array(
|
108 |
+
'header' => $label,
|
109 |
+
'index' => 'condition_value',
|
110 |
+
));
|
111 |
+
|
112 |
+
$this->addColumn('price', array(
|
113 |
+
'header' => Mage::helper('bpost_shm')->__('Shipping Price'),
|
114 |
+
'index' => 'price',
|
115 |
+
));
|
116 |
+
|
117 |
+
return parent::_prepareColumns();
|
118 |
+
}
|
119 |
}
|
app/code/community/Bpost/ShM/Block/Adminhtml/System/Config/Form/Api/Import/Countries.php
CHANGED
@@ -1,29 +1,29 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Class Bpost_ShM_Block_Adminhtml_System_Config_Form_Api_Import_Countries
|
5 |
-
*/
|
6 |
-
class Bpost_ShM_Block_Adminhtml_System_Config_Form_Api_Import_Countries
|
7 |
-
extends Mage_Adminhtml_Block_System_Config_Form_Field implements Varien_Data_Form_Element_Renderer_Interface
|
8 |
-
{
|
9 |
-
/**
|
10 |
-
* @param Varien_Data_Form_Element_Abstract $element
|
11 |
-
* @return mixed
|
12 |
-
*/
|
13 |
-
public function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
14 |
-
{
|
15 |
-
$buttonBlock = Mage::app()->getLayout()->createBlock('adminhtml/widget_button');
|
16 |
-
$url = Mage::helper('adminhtml')->getUrl("adminhtml/bpost_shM_config/importCountriesByApi");
|
17 |
-
|
18 |
-
$data = array(
|
19 |
-
'label' => Mage::helper('adminhtml')->__('Import'),
|
20 |
-
'onclick' => 'setLocation(\'' . $url . '\')',
|
21 |
-
'class' => '',
|
22 |
-
'id' => 'carriers_international_countries_import'
|
23 |
-
);
|
24 |
-
|
25 |
-
$html = $buttonBlock->setData($data)->toHtml();
|
26 |
-
|
27 |
-
return $html;
|
28 |
-
}
|
29 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class Bpost_ShM_Block_Adminhtml_System_Config_Form_Api_Import_Countries
|
5 |
+
*/
|
6 |
+
class Bpost_ShM_Block_Adminhtml_System_Config_Form_Api_Import_Countries
|
7 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field implements Varien_Data_Form_Element_Renderer_Interface
|
8 |
+
{
|
9 |
+
/**
|
10 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
11 |
+
* @return mixed
|
12 |
+
*/
|
13 |
+
public function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
14 |
+
{
|
15 |
+
$buttonBlock = Mage::app()->getLayout()->createBlock('adminhtml/widget_button');
|
16 |
+
$url = Mage::helper('adminhtml')->getUrl("adminhtml/bpost_shM_config/importCountriesByApi");
|
17 |
+
|
18 |
+
$data = array(
|
19 |
+
'label' => Mage::helper('adminhtml')->__('Import'),
|
20 |
+
'onclick' => 'setLocation(\'' . $url . '\')',
|
21 |
+
'class' => '',
|
22 |
+
'id' => 'carriers_international_countries_import'
|
23 |
+
);
|
24 |
+
|
25 |
+
$html = $buttonBlock->setData($data)->toHtml();
|
26 |
+
|
27 |
+
return $html;
|
28 |
+
}
|
29 |
}
|
app/code/community/Bpost/ShM/Block/Adminhtml/System/Config/Form/Field/Cacheinfo.php
CHANGED
@@ -1,23 +1,23 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Class Bpost_ShM_Block_Adminhtml_System_Config_Form_Field_Clickcollect
|
5 |
-
*/
|
6 |
-
class Bpost_ShM_Block_Adminhtml_System_Config_Form_Field_Cacheinfo extends Mage_Adminhtml_Block_System_Config_Form_Field
|
7 |
-
{
|
8 |
-
|
9 |
-
public function render(Varien_Data_Form_Element_Abstract $element)
|
10 |
-
{
|
11 |
-
$text = '<p><a href="http://bpost.freshdesk.com/support/solutions/articles/4000078153-click-collect-for-magento" target="_blank" style="color:red; font-weight:bold;">';
|
12 |
-
$text .= Mage::helper('bpost_shm')->__('Before using this delivery method, make sure that Click & Collect is duely activated. This is a 2 step process. Find out how here.');
|
13 |
-
$text .= '</a></p>';
|
14 |
-
$text .= '<p>';
|
15 |
-
$text .= Mage::helper('bpost_shm')->__('Please note that the Click & Collect points are updated once a day.') . ' ';
|
16 |
-
$text .= Mage::helper('bpost_shm')->__('If you have added or removed Click & Collect points in Shipping Manager, be aware that it will take up to 24h to be operational in the bpost Magento plugin.') . ' ';
|
17 |
-
$text .= Mage::helper('bpost_shm')->__('If the points don’t appear after 24h, make sure to have cleared the Magento cache.');
|
18 |
-
$text .= '</p>';
|
19 |
-
$html = '<tr><td colspan="4" class="value fulltext"><div id="' . $element->getHtmlId() . '" style="color:red;">' . $text . '</div></td></tr>';
|
20 |
-
|
21 |
-
return $html;
|
22 |
-
}
|
23 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class Bpost_ShM_Block_Adminhtml_System_Config_Form_Field_Clickcollect
|
5 |
+
*/
|
6 |
+
class Bpost_ShM_Block_Adminhtml_System_Config_Form_Field_Cacheinfo extends Mage_Adminhtml_Block_System_Config_Form_Field
|
7 |
+
{
|
8 |
+
|
9 |
+
public function render(Varien_Data_Form_Element_Abstract $element)
|
10 |
+
{
|
11 |
+
$text = '<p><a href="http://bpost.freshdesk.com/support/solutions/articles/4000078153-click-collect-for-magento" target="_blank" style="color:red; font-weight:bold;">';
|
12 |
+
$text .= Mage::helper('bpost_shm')->__('Before using this delivery method, make sure that Click & Collect is duely activated. This is a 2 step process. Find out how here.');
|
13 |
+
$text .= '</a></p>';
|
14 |
+
$text .= '<p>';
|
15 |
+
$text .= Mage::helper('bpost_shm')->__('Please note that the Click & Collect points are updated once a day.') . ' ';
|
16 |
+
$text .= Mage::helper('bpost_shm')->__('If you have added or removed Click & Collect points in Shipping Manager, be aware that it will take up to 24h to be operational in the bpost Magento plugin.') . ' ';
|
17 |
+
$text .= Mage::helper('bpost_shm')->__('If the points don’t appear after 24h, make sure to have cleared the Magento cache.');
|
18 |
+
$text .= '</p>';
|
19 |
+
$html = '<tr><td colspan="4" class="value fulltext"><div id="' . $element->getHtmlId() . '" style="color:red;">' . $text . '</div></td></tr>';
|
20 |
+
|
21 |
+
return $html;
|
22 |
+
}
|
23 |
}
|
app/code/community/Bpost/ShM/Block/Adminhtml/System/Config/Form/Field/Choose.php
CHANGED
@@ -1,26 +1,26 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Class Bpost_ShM_Block_Adminhtml_System_Config_Form_Field_Choose
|
5 |
-
*/
|
6 |
-
class Bpost_ShM_Block_Adminhtml_System_Config_Form_Field_Choose extends Mage_Adminhtml_Block_System_Config_Form_Field
|
7 |
-
{
|
8 |
-
|
9 |
-
/**
|
10 |
-
* Set choose delivery date value to No when display delivery date is set to no
|
11 |
-
*
|
12 |
-
* @param Varien_Data_Form_Element_Abstract $element
|
13 |
-
* @return parent
|
14 |
-
*/
|
15 |
-
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
16 |
-
{
|
17 |
-
$configHelper = Mage::helper("bpost_shm/system_config");
|
18 |
-
$displayDeliveryDate = (bool)$configHelper->getBpostShippingConfig("display_delivery_date", Mage::app()->getStore()->getId());
|
19 |
-
|
20 |
-
if(!$displayDeliveryDate) {
|
21 |
-
$element->setValue(0);
|
22 |
-
}
|
23 |
-
|
24 |
-
return parent::_getElementHtml($element);
|
25 |
-
}
|
26 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class Bpost_ShM_Block_Adminhtml_System_Config_Form_Field_Choose
|
5 |
+
*/
|
6 |
+
class Bpost_ShM_Block_Adminhtml_System_Config_Form_Field_Choose extends Mage_Adminhtml_Block_System_Config_Form_Field
|
7 |
+
{
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Set choose delivery date value to No when display delivery date is set to no
|
11 |
+
*
|
12 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
13 |
+
* @return parent
|
14 |
+
*/
|
15 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
16 |
+
{
|
17 |
+
$configHelper = Mage::helper("bpost_shm/system_config");
|
18 |
+
$displayDeliveryDate = (bool)$configHelper->getBpostShippingConfig("display_delivery_date", Mage::app()->getStore()->getId());
|
19 |
+
|
20 |
+
if(!$displayDeliveryDate) {
|
21 |
+
$element->setValue(0);
|
22 |
+
}
|
23 |
+
|
24 |
+
return parent::_getElementHtml($element);
|
25 |
+
}
|
26 |
}
|
app/code/community/Bpost/ShM/Block/Adminhtml/System/Config/Form/Field/Clickcollect.php
CHANGED
@@ -1,21 +1,21 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Class Bpost_ShM_Block_Adminhtml_System_Config_Form_Field_Clickcollect
|
5 |
-
*/
|
6 |
-
class Bpost_ShM_Block_Adminhtml_System_Config_Form_Field_Clickcollect extends Mage_Adminhtml_Block_System_Config_Form_Field
|
7 |
-
{
|
8 |
-
|
9 |
-
public function render(Varien_Data_Form_Element_Abstract $element)
|
10 |
-
{
|
11 |
-
$text = Mage::helper('bpost_shm')->__('You would like to deliver your parcel in your own stores?');
|
12 |
-
$text .= " " . Mage::helper('bpost_shm')->__('Click & Collect is the most convenient option for you.');
|
13 |
-
$text .= " " . Mage::helper('bpost_shm')->__('Please find more information on %s.',
|
14 |
-
'<a href="http://www.bpost.be/site/en/business/send_post/parcels/clickandcollect.html">http://www.bpost.be/site/en/business/send_post/parcels/clickandcollect.html</a>' );
|
15 |
-
$text .= "<br /> " . Mage::helper('bpost_shm')->__('The delivery method Click & Collect is not activated by default on your contract.');
|
16 |
-
$text .= " " . Mage::helper('bpost_shm')->__('Please request an activation of the service in order to use it on your website.');
|
17 |
-
$html = '<tr><td colspan="4" class="value fulltext"><div id="' . $element->getHtmlId() . '">' . $text . '</div></td></tr>';
|
18 |
-
|
19 |
-
return $html;
|
20 |
-
}
|
21 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class Bpost_ShM_Block_Adminhtml_System_Config_Form_Field_Clickcollect
|
5 |
+
*/
|
6 |
+
class Bpost_ShM_Block_Adminhtml_System_Config_Form_Field_Clickcollect extends Mage_Adminhtml_Block_System_Config_Form_Field
|
7 |
+
{
|
8 |
+
|
9 |
+
public function render(Varien_Data_Form_Element_Abstract $element)
|
10 |
+
{
|
11 |
+
$text = Mage::helper('bpost_shm')->__('You would like to deliver your parcel in your own stores?');
|
12 |
+
$text .= " " . Mage::helper('bpost_shm')->__('Click & Collect is the most convenient option for you.');
|
13 |
+
$text .= " " . Mage::helper('bpost_shm')->__('Please find more information on %s.',
|
14 |
+
'<a href="http://www.bpost.be/site/en/business/send_post/parcels/clickandcollect.html">http://www.bpost.be/site/en/business/send_post/parcels/clickandcollect.html</a>' );
|
15 |
+
$text .= "<br /> " . Mage::helper('bpost_shm')->__('The delivery method Click & Collect is not activated by default on your contract.');
|
16 |
+
$text .= " " . Mage::helper('bpost_shm')->__('Please request an activation of the service in order to use it on your website.');
|
17 |
+
$html = '<tr><td colspan="4" class="value fulltext"><div id="' . $element->getHtmlId() . '">' . $text . '</div></td></tr>';
|
18 |
+
|
19 |
+
return $html;
|
20 |
+
}
|
21 |
}
|
app/code/community/Bpost/ShM/Block/Adminhtml/System/Config/Form/Field/Hour.php
CHANGED
@@ -1,43 +1,43 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Class Bpost_ShM_Block_Adminhtml_System_Config_Form_Field_Hour
|
5 |
-
*/
|
6 |
-
class Bpost_ShM_Block_Adminhtml_System_Config_Form_Field_Hour extends Mage_Adminhtml_Block_System_Config_Form_Field
|
7 |
-
{
|
8 |
-
|
9 |
-
/**
|
10 |
-
* @param Varien_Data_Form_Element_Abstract $element
|
11 |
-
* we use the standard time element but with no seconds
|
12 |
-
* @return string
|
13 |
-
*/
|
14 |
-
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
15 |
-
{
|
16 |
-
$value = $element->getEscapedValue().",00";
|
17 |
-
$element->setValue($value);
|
18 |
-
|
19 |
-
$html = $element->getElementHtml();
|
20 |
-
|
21 |
-
$dom = new DOMDocument();
|
22 |
-
$dom->loadHTML($html);
|
23 |
-
|
24 |
-
$secondsElement = $dom->getElementsByTagName('select')->item(2);
|
25 |
-
|
26 |
-
if(!$secondsElement){
|
27 |
-
//return the original html
|
28 |
-
return $html;
|
29 |
-
}
|
30 |
-
|
31 |
-
$secondsElement->parentNode->removeChild($secondsElement);
|
32 |
-
|
33 |
-
//check if we have
|
34 |
-
//remove last : character
|
35 |
-
$html = $dom->saveHTML();
|
36 |
-
|
37 |
-
if( ( $pos = strrpos( $html , ":" ) ) !== false ) {
|
38 |
-
$html = substr_replace( $html , "" , $pos , 1 );
|
39 |
-
}
|
40 |
-
|
41 |
-
return $html;
|
42 |
-
}
|
43 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class Bpost_ShM_Block_Adminhtml_System_Config_Form_Field_Hour
|
5 |
+
*/
|
6 |
+
class Bpost_ShM_Block_Adminhtml_System_Config_Form_Field_Hour extends Mage_Adminhtml_Block_System_Config_Form_Field
|
7 |
+
{
|
8 |
+
|
9 |
+
/**
|
10 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
11 |
+
* we use the standard time element but with no seconds
|
12 |
+
* @return string
|
13 |
+
*/
|
14 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
15 |
+
{
|
16 |
+
$value = $element->getEscapedValue().",00";
|
17 |
+
$element->setValue($value);
|
18 |
+
|
19 |
+
$html = $element->getElementHtml();
|
20 |
+
|
21 |
+
$dom = new DOMDocument();
|
22 |
+
$dom->loadHTML($html);
|
23 |
+
|
24 |
+
$secondsElement = $dom->getElementsByTagName('select')->item(2);
|
25 |
+
|
26 |
+
if(!$secondsElement){
|
27 |
+
//return the original html
|
28 |
+
return $html;
|
29 |
+
}
|
30 |
+
|
31 |
+
$secondsElement->parentNode->removeChild($secondsElement);
|
32 |
+
|
33 |
+
//check if we have
|
34 |
+
//remove last : character
|
35 |
+
$html = $dom->saveHTML();
|
36 |
+
|
37 |
+
if( ( $pos = strrpos( $html , ":" ) ) !== false ) {
|
38 |
+
$html = substr_replace( $html , "" , $pos , 1 );
|
39 |
+
}
|
40 |
+
|
41 |
+
return $html;
|
42 |
+
}
|
43 |
}
|
app/code/community/Bpost/ShM/Block/Adminhtml/System/Config/Form/Field/Info.php
CHANGED
@@ -1,22 +1,22 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Class Bpost_ShM_Block_Adminhtml_System_Config_Form_Field_Info
|
5 |
-
*/
|
6 |
-
class Bpost_ShM_Block_Adminhtml_System_Config_Form_Field_Info extends Mage_Adminhtml_Block_System_Config_Form_Field
|
7 |
-
{
|
8 |
-
/**
|
9 |
-
* Enter description here...
|
10 |
-
*
|
11 |
-
* @param Varien_Data_Form_Element_Abstract $element
|
12 |
-
* @return string
|
13 |
-
*/
|
14 |
-
public function render(Varien_Data_Form_Element_Abstract $element)
|
15 |
-
{
|
16 |
-
$telephone = "02/201 11 11";
|
17 |
-
$url = "http://bpost.freshdesk.com/solution/articles/174847";
|
18 |
-
$html = "<tr><td colspan='4'>".Mage::helper("bpost_shm")->__("You need a user account from bpost to use this module. Call %s for more information.", $telephone)." <a target='_blank' href='$url'>".$url."</a></td></tr>";
|
19 |
-
|
20 |
-
return $html;
|
21 |
-
}
|
22 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class Bpost_ShM_Block_Adminhtml_System_Config_Form_Field_Info
|
5 |
+
*/
|
6 |
+
class Bpost_ShM_Block_Adminhtml_System_Config_Form_Field_Info extends Mage_Adminhtml_Block_System_Config_Form_Field
|
7 |
+
{
|
8 |
+
/**
|
9 |
+
* Enter description here...
|
10 |
+
*
|
11 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
12 |
+
* @return string
|
13 |
+
*/
|
14 |
+
public function render(Varien_Data_Form_Element_Abstract $element)
|
15 |
+
{
|
16 |
+
$telephone = "02/201 11 11";
|
17 |
+
$url = "http://bpost.freshdesk.com/solution/articles/174847";
|
18 |
+
$html = "<tr><td colspan='4'>".Mage::helper("bpost_shm")->__("You need a user account from bpost to use this module. Call %s for more information.", $telephone)." <a target='_blank' href='$url'>".$url."</a></td></tr>";
|
19 |
+
|
20 |
+
return $html;
|
21 |
+
}
|
22 |
}
|
app/code/community/Bpost/ShM/Block/Adminhtml/System/Config/Form/Field/Logo.php
CHANGED
@@ -1,39 +1,39 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Class Bpost_ShM_Block_Adminhtml_System_Config_Form_Field_Logo
|
5 |
-
*/
|
6 |
-
class Bpost_ShM_Block_Adminhtml_System_Config_Form_Field_Logo extends Mage_Adminhtml_Block_System_Config_Form_Field
|
7 |
-
{
|
8 |
-
|
9 |
-
/**
|
10 |
-
* @param Varien_Data_Form_Element_Abstract $element
|
11 |
-
* @return string
|
12 |
-
*/
|
13 |
-
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
14 |
-
{
|
15 |
-
$bpostLogoMessage = Mage::helper('bpost_shm')->__('Click here for more information');
|
16 |
-
$popupUrl = "'" . $this->getUrl('adminhtml/bpost_shM_config/informationpopup') . "'";
|
17 |
-
$html = '<a id="' . $element->getHtmlId() . '" class="bpostInfo" href="#" onclick="openPopup(' . $popupUrl . ',600,400);">';
|
18 |
-
$html .= '<span>' . $bpostLogoMessage . '</span> ';
|
19 |
-
$html .= '</a>';
|
20 |
-
return $html;
|
21 |
-
}
|
22 |
-
|
23 |
-
/**
|
24 |
-
* Enter description here...
|
25 |
-
*
|
26 |
-
* @param Varien_Data_Form_Element_Abstract $element
|
27 |
-
* @return string
|
28 |
-
*/
|
29 |
-
public function render(Varien_Data_Form_Element_Abstract $element)
|
30 |
-
{
|
31 |
-
$html = '';
|
32 |
-
$elementHtml = $this->_getElementHtml($element);
|
33 |
-
$html .= '<td class="value" colspan="4">';
|
34 |
-
$html .= $elementHtml;
|
35 |
-
$html .= '</td>';
|
36 |
-
|
37 |
-
return $html;
|
38 |
-
}
|
39 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class Bpost_ShM_Block_Adminhtml_System_Config_Form_Field_Logo
|
5 |
+
*/
|
6 |
+
class Bpost_ShM_Block_Adminhtml_System_Config_Form_Field_Logo extends Mage_Adminhtml_Block_System_Config_Form_Field
|
7 |
+
{
|
8 |
+
|
9 |
+
/**
|
10 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
11 |
+
* @return string
|
12 |
+
*/
|
13 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
14 |
+
{
|
15 |
+
$bpostLogoMessage = Mage::helper('bpost_shm')->__('Click here for more information');
|
16 |
+
$popupUrl = "'" . $this->getUrl('adminhtml/bpost_shM_config/informationpopup') . "'";
|
17 |
+
$html = '<a id="' . $element->getHtmlId() . '" class="bpostInfo" href="#" onclick="openPopup(' . $popupUrl . ',600,400);">';
|
18 |
+
$html .= '<span>' . $bpostLogoMessage . '</span> ';
|
19 |
+
$html .= '</a>';
|
20 |
+
return $html;
|
21 |
+
}
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Enter description here...
|
25 |
+
*
|
26 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
27 |
+
* @return string
|
28 |
+
*/
|
29 |
+
public function render(Varien_Data_Form_Element_Abstract $element)
|
30 |
+
{
|
31 |
+
$html = '';
|
32 |
+
$elementHtml = $this->_getElementHtml($element);
|
33 |
+
$html .= '<td class="value" colspan="4">';
|
34 |
+
$html .= $elementHtml;
|
35 |
+
$html .= '</td>';
|
36 |
+
|
37 |
+
return $html;
|
38 |
+
}
|
39 |
}
|
app/code/community/Bpost/ShM/Block/Adminhtml/System/Config/Form/Field/Subheader.php
CHANGED
@@ -1,17 +1,17 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Class Bpost_ShM_Block_Adminhtml_System_Config_Form_Field_Subheader
|
5 |
-
*/
|
6 |
-
class Bpost_ShM_Block_Adminhtml_System_Config_Form_Field_Subheader extends Mage_Adminhtml_Block_System_Config_Form_Field
|
7 |
-
{
|
8 |
-
|
9 |
-
public function render(Varien_Data_Form_Element_Abstract $element)
|
10 |
-
{
|
11 |
-
$label = $element->getLabelHtml();
|
12 |
-
$html = '<tr><td colspan="4" class="subheader value"><div id="' . $element->getHtmlId() . '">' .
|
13 |
-
Mage::helper("bpost_shm")->__($label).'</div></td></tr>';
|
14 |
-
|
15 |
-
return $html;
|
16 |
-
}
|
17 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class Bpost_ShM_Block_Adminhtml_System_Config_Form_Field_Subheader
|
5 |
+
*/
|
6 |
+
class Bpost_ShM_Block_Adminhtml_System_Config_Form_Field_Subheader extends Mage_Adminhtml_Block_System_Config_Form_Field
|
7 |
+
{
|
8 |
+
|
9 |
+
public function render(Varien_Data_Form_Element_Abstract $element)
|
10 |
+
{
|
11 |
+
$label = $element->getLabelHtml();
|
12 |
+
$html = '<tr><td colspan="4" class="subheader value"><div id="' . $element->getHtmlId() . '">' .
|
13 |
+
Mage::helper("bpost_shm")->__($label).'</div></td></tr>';
|
14 |
+
|
15 |
+
return $html;
|
16 |
+
}
|
17 |
}
|
app/code/community/Bpost/ShM/Block/Adminhtml/System/Config/Form/Tablerates/Export/Clickcollect.php
CHANGED
@@ -1,30 +1,30 @@
|
|
1 |
-
<?php
|
2 |
-
class Bpost_ShM_Block_Adminhtml_System_Config_Form_Tablerates_Export_Clickcollect
|
3 |
-
extends Mage_Adminhtml_Block_System_Config_Form_Field implements Varien_Data_Form_Element_Renderer_Interface
|
4 |
-
{
|
5 |
-
/**
|
6 |
-
* @param Varien_Data_Form_Element_Abstract $element
|
7 |
-
* @return mixed
|
8 |
-
*/
|
9 |
-
public function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
10 |
-
{
|
11 |
-
$buttonBlock = Mage::app()->getLayout()->createBlock('adminhtml/widget_button');
|
12 |
-
|
13 |
-
$params = array(
|
14 |
-
'website' => $buttonBlock->getRequest()->getParam('website'),
|
15 |
-
'method' => 'clickcollect',
|
16 |
-
'filename' => 'bpost_clickcollect_tablerates.csv'
|
17 |
-
);
|
18 |
-
|
19 |
-
$data = array(
|
20 |
-
'label' => Mage::helper('adminhtml')->__('Export CSV'),
|
21 |
-
'onclick' => 'setLocation(\'' . Mage::helper('adminhtml')->getUrl("adminhtml/bpost_shM_config/exportTablerates", $params) . 'conditionName/\' + $(\'carriers_bpost_clickcollect_condition_name\').value + \'/bpost_clickcollect_tablerates.csv\' )',
|
22 |
-
'class' => '',
|
23 |
-
'id' => 'carriers_clickcollect_tablerates_export'
|
24 |
-
);
|
25 |
-
|
26 |
-
$html = $buttonBlock->setData($data)->toHtml();
|
27 |
-
|
28 |
-
return $html;
|
29 |
-
}
|
30 |
}
|
1 |
+
<?php
|
2 |
+
class Bpost_ShM_Block_Adminhtml_System_Config_Form_Tablerates_Export_Clickcollect
|
3 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field implements Varien_Data_Form_Element_Renderer_Interface
|
4 |
+
{
|
5 |
+
/**
|
6 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
7 |
+
* @return mixed
|
8 |
+
*/
|
9 |
+
public function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
10 |
+
{
|
11 |
+
$buttonBlock = Mage::app()->getLayout()->createBlock('adminhtml/widget_button');
|
12 |
+
|
13 |
+
$params = array(
|
14 |
+
'website' => $buttonBlock->getRequest()->getParam('website'),
|
15 |
+
'method' => 'clickcollect',
|
16 |
+
'filename' => 'bpost_clickcollect_tablerates.csv'
|
17 |
+
);
|
18 |
+
|
19 |
+
$data = array(
|
20 |
+
'label' => Mage::helper('adminhtml')->__('Export CSV'),
|
21 |
+
'onclick' => 'setLocation(\'' . Mage::helper('adminhtml')->getUrl("adminhtml/bpost_shM_config/exportTablerates", $params) . 'conditionName/\' + $(\'carriers_bpost_clickcollect_condition_name\').value + \'/bpost_clickcollect_tablerates.csv\' )',
|
22 |
+
'class' => '',
|
23 |
+
'id' => 'carriers_clickcollect_tablerates_export'
|
24 |
+
);
|
25 |
+
|
26 |
+
$html = $buttonBlock->setData($data)->toHtml();
|
27 |
+
|
28 |
+
return $html;
|
29 |
+
}
|
30 |
}
|
app/code/community/Bpost/ShM/Block/Adminhtml/System/Config/Form/Tablerates/Export/Homedelivery.php
CHANGED
@@ -1,30 +1,30 @@
|
|
1 |
-
<?php
|
2 |
-
class Bpost_ShM_Block_Adminhtml_System_Config_Form_Tablerates_Export_Homedelivery
|
3 |
-
extends Mage_Adminhtml_Block_System_Config_Form_Field implements Varien_Data_Form_Element_Renderer_Interface
|
4 |
-
{
|
5 |
-
/**
|
6 |
-
* @param Varien_Data_Form_Element_Abstract $element
|
7 |
-
* @return mixed
|
8 |
-
*/
|
9 |
-
public function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
10 |
-
{
|
11 |
-
$buttonBlock = Mage::app()->getLayout()->createBlock('adminhtml/widget_button');
|
12 |
-
|
13 |
-
$params = array(
|
14 |
-
'website' => $buttonBlock->getRequest()->getParam('website'),
|
15 |
-
'method' => 'homedelivery',
|
16 |
-
'filename' => 'bpost_homedelivery_tablerates.csv'
|
17 |
-
);
|
18 |
-
|
19 |
-
$data = array(
|
20 |
-
'label' => Mage::helper('adminhtml')->__('Export CSV'),
|
21 |
-
'onclick' => 'setLocation(\'' . Mage::helper('adminhtml')->getUrl("adminhtml/bpost_shM_config/exportTablerates", $params) . 'conditionName/\' + $(\'carriers_bpost_homedelivery_condition_name\').value + \'/bpost_homedelivery_tablerates.csv\' )',
|
22 |
-
'class' => '',
|
23 |
-
'id' => 'carriers_homedelivery_tablerates_export'
|
24 |
-
);
|
25 |
-
|
26 |
-
$html = $buttonBlock->setData($data)->toHtml();
|
27 |
-
|
28 |
-
return $html;
|
29 |
-
}
|
30 |
}
|
1 |
+
<?php
|
2 |
+
class Bpost_ShM_Block_Adminhtml_System_Config_Form_Tablerates_Export_Homedelivery
|
3 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field implements Varien_Data_Form_Element_Renderer_Interface
|
4 |
+
{
|
5 |
+
/**
|
6 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
7 |
+
* @return mixed
|
8 |
+
*/
|
9 |
+
public function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
10 |
+
{
|
11 |
+
$buttonBlock = Mage::app()->getLayout()->createBlock('adminhtml/widget_button');
|
12 |
+
|
13 |
+
$params = array(
|
14 |
+
'website' => $buttonBlock->getRequest()->getParam('website'),
|
15 |
+
'method' => 'homedelivery',
|
16 |
+
'filename' => 'bpost_homedelivery_tablerates.csv'
|
17 |
+
);
|
18 |
+
|
19 |
+
$data = array(
|
20 |
+
'label' => Mage::helper('adminhtml')->__('Export CSV'),
|
21 |
+
'onclick' => 'setLocation(\'' . Mage::helper('adminhtml')->getUrl("adminhtml/bpost_shM_config/exportTablerates", $params) . 'conditionName/\' + $(\'carriers_bpost_homedelivery_condition_name\').value + \'/bpost_homedelivery_tablerates.csv\' )',
|
22 |
+
'class' => '',
|
23 |
+
'id' => 'carriers_homedelivery_tablerates_export'
|
24 |
+
);
|
25 |
+
|
26 |
+
$html = $buttonBlock->setData($data)->toHtml();
|
27 |
+
|
28 |
+
return $html;
|
29 |
+
}
|
30 |
}
|
app/code/community/Bpost/ShM/Block/Adminhtml/System/Config/Form/Tablerates/Export/International.php
CHANGED
@@ -1,30 +1,30 @@
|
|
1 |
-
<?php
|
2 |
-
class Bpost_ShM_Block_Adminhtml_System_Config_Form_Tablerates_Export_International
|
3 |
-
extends Mage_Adminhtml_Block_System_Config_Form_Field implements Varien_Data_Form_Element_Renderer_Interface
|
4 |
-
{
|
5 |
-
/**
|
6 |
-
* @param Varien_Data_Form_Element_Abstract $element
|
7 |
-
* @return mixed
|
8 |
-
*/
|
9 |
-
public function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
10 |
-
{
|
11 |
-
$buttonBlock = Mage::app()->getLayout()->createBlock('adminhtml/widget_button');
|
12 |
-
|
13 |
-
$params = array(
|
14 |
-
'website' => $buttonBlock->getRequest()->getParam('website'),
|
15 |
-
'method' => 'international',
|
16 |
-
'filename' => 'bpost_international_tablerates.csv'
|
17 |
-
);
|
18 |
-
|
19 |
-
$data = array(
|
20 |
-
'label' => Mage::helper('adminhtml')->__('Export CSV'),
|
21 |
-
'onclick' => 'setLocation(\'' . Mage::helper('adminhtml')->getUrl("adminhtml/bpost_shM_config/exportTablerates", $params) . 'conditionName/\' + $(\'carriers_bpost_international_condition_name\').value)',
|
22 |
-
'class' => '',
|
23 |
-
'id' => 'carriers_international_tablerates_export'
|
24 |
-
);
|
25 |
-
|
26 |
-
$html = $buttonBlock->setData($data)->toHtml();
|
27 |
-
|
28 |
-
return $html;
|
29 |
-
}
|
30 |
}
|
1 |
+
<?php
|
2 |
+
class Bpost_ShM_Block_Adminhtml_System_Config_Form_Tablerates_Export_International
|
3 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field implements Varien_Data_Form_Element_Renderer_Interface
|
4 |
+
{
|
5 |
+
/**
|
6 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
7 |
+
* @return mixed
|
8 |
+
*/
|
9 |
+
public function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
10 |
+
{
|
11 |
+
$buttonBlock = Mage::app()->getLayout()->createBlock('adminhtml/widget_button');
|
12 |
+
|
13 |
+
$params = array(
|
14 |
+
'website' => $buttonBlock->getRequest()->getParam('website'),
|
15 |
+
'method' => 'international',
|
16 |
+
'filename' => 'bpost_international_tablerates.csv'
|
17 |
+
);
|
18 |
+
|
19 |
+
$data = array(
|
20 |
+
'label' => Mage::helper('adminhtml')->__('Export CSV'),
|
21 |
+
'onclick' => 'setLocation(\'' . Mage::helper('adminhtml')->getUrl("adminhtml/bpost_shM_config/exportTablerates", $params) . 'conditionName/\' + $(\'carriers_bpost_international_condition_name\').value)',
|
22 |
+
'class' => '',
|
23 |
+
'id' => 'carriers_international_tablerates_export'
|
24 |
+
);
|
25 |
+
|
26 |
+
$html = $buttonBlock->setData($data)->toHtml();
|
27 |
+
|
28 |
+
return $html;
|
29 |
+
}
|
30 |
}
|
app/code/community/Bpost/ShM/Block/Adminhtml/System/Config/Form/Tablerates/Export/Parcellocker.php
CHANGED
@@ -1,30 +1,30 @@
|
|
1 |
-
<?php
|
2 |
-
class Bpost_ShM_Block_Adminhtml_System_Config_Form_Tablerates_Export_Parcellocker
|
3 |
-
extends Mage_Adminhtml_Block_System_Config_Form_Field implements Varien_Data_Form_Element_Renderer_Interface
|
4 |
-
{
|
5 |
-
/**
|
6 |
-
* @param Varien_Data_Form_Element_Abstract $element
|
7 |
-
* @return mixed
|
8 |
-
*/
|
9 |
-
public function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
10 |
-
{
|
11 |
-
$buttonBlock = Mage::app()->getLayout()->createBlock('adminhtml/widget_button');
|
12 |
-
|
13 |
-
$params = array(
|
14 |
-
'website' => $buttonBlock->getRequest()->getParam('website'),
|
15 |
-
'method' => 'parcellocker',
|
16 |
-
'filename' => 'bpost_parcellocker_tablerates.csv'
|
17 |
-
);
|
18 |
-
|
19 |
-
$data = array(
|
20 |
-
'label' => Mage::helper('adminhtml')->__('Export CSV'),
|
21 |
-
'onclick' => 'setLocation(\'' . Mage::helper('adminhtml')->getUrl("adminhtml/bpost_shM_config/exportTablerates", $params) . 'conditionName/\' + $(\'carriers_bpost_parcellocker_condition_name\').value)',
|
22 |
-
'class' => '',
|
23 |
-
'id' => 'carriers_parcellocker_tablerates_export'
|
24 |
-
);
|
25 |
-
|
26 |
-
$html = $buttonBlock->setData($data)->toHtml();
|
27 |
-
|
28 |
-
return $html;
|
29 |
-
}
|
30 |
}
|
1 |
+
<?php
|
2 |
+
class Bpost_ShM_Block_Adminhtml_System_Config_Form_Tablerates_Export_Parcellocker
|
3 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field implements Varien_Data_Form_Element_Renderer_Interface
|
4 |
+
{
|
5 |
+
/**
|
6 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
7 |
+
* @return mixed
|
8 |
+
*/
|
9 |
+
public function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
10 |
+
{
|
11 |
+
$buttonBlock = Mage::app()->getLayout()->createBlock('adminhtml/widget_button');
|
12 |
+
|
13 |
+
$params = array(
|
14 |
+
'website' => $buttonBlock->getRequest()->getParam('website'),
|
15 |
+
'method' => 'parcellocker',
|
16 |
+
'filename' => 'bpost_parcellocker_tablerates.csv'
|
17 |
+
);
|
18 |
+
|
19 |
+
$data = array(
|
20 |
+
'label' => Mage::helper('adminhtml')->__('Export CSV'),
|
21 |
+
'onclick' => 'setLocation(\'' . Mage::helper('adminhtml')->getUrl("adminhtml/bpost_shM_config/exportTablerates", $params) . 'conditionName/\' + $(\'carriers_bpost_parcellocker_condition_name\').value)',
|
22 |
+
'class' => '',
|
23 |
+
'id' => 'carriers_parcellocker_tablerates_export'
|
24 |
+
);
|
25 |
+
|
26 |
+
$html = $buttonBlock->setData($data)->toHtml();
|
27 |
+
|
28 |
+
return $html;
|
29 |
+
}
|
30 |
}
|
app/code/community/Bpost/ShM/Block/Adminhtml/System/Config/Form/Tablerates/Export/Pickuppoint.php
CHANGED
@@ -1,30 +1,30 @@
|
|
1 |
-
<?php
|
2 |
-
class Bpost_ShM_Block_Adminhtml_System_Config_Form_Tablerates_Export_Pickuppoint
|
3 |
-
extends Mage_Adminhtml_Block_System_Config_Form_Field implements Varien_Data_Form_Element_Renderer_Interface
|
4 |
-
{
|
5 |
-
/**
|
6 |
-
* @param Varien_Data_Form_Element_Abstract $element
|
7 |
-
* @return mixed
|
8 |
-
*/
|
9 |
-
public function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
10 |
-
{
|
11 |
-
$buttonBlock = Mage::app()->getLayout()->createBlock('adminhtml/widget_button');
|
12 |
-
|
13 |
-
$params = array(
|
14 |
-
'website' => $buttonBlock->getRequest()->getParam('website'),
|
15 |
-
'method' => 'pickuppoint',
|
16 |
-
'filename' => 'bpost_pickuppoint_tablerates.csv'
|
17 |
-
);
|
18 |
-
|
19 |
-
$data = array(
|
20 |
-
'label' => Mage::helper('adminhtml')->__('Export CSV'),
|
21 |
-
'onclick' => 'setLocation(\'' . Mage::helper('adminhtml')->getUrl("adminhtml/bpost_shM_config/exportTablerates", $params) . 'conditionName/\' + $(\'carriers_bpost_pickuppoint_condition_name\').value + \'/bpost_pickuppoint_tablerates.csv\' )',
|
22 |
-
'class' => '',
|
23 |
-
'id' => 'carriers_pickuppoint_tablerates_export'
|
24 |
-
);
|
25 |
-
|
26 |
-
$html = $buttonBlock->setData($data)->toHtml();
|
27 |
-
|
28 |
-
return $html;
|
29 |
-
}
|
30 |
}
|
1 |
+
<?php
|
2 |
+
class Bpost_ShM_Block_Adminhtml_System_Config_Form_Tablerates_Export_Pickuppoint
|
3 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field implements Varien_Data_Form_Element_Renderer_Interface
|
4 |
+
{
|
5 |
+
/**
|
6 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
7 |
+
* @return mixed
|
8 |
+
*/
|
9 |
+
public function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
10 |
+
{
|
11 |
+
$buttonBlock = Mage::app()->getLayout()->createBlock('adminhtml/widget_button');
|
12 |
+
|
13 |
+
$params = array(
|
14 |
+
'website' => $buttonBlock->getRequest()->getParam('website'),
|
15 |
+
'method' => 'pickuppoint',
|
16 |
+
'filename' => 'bpost_pickuppoint_tablerates.csv'
|
17 |
+
);
|
18 |
+
|
19 |
+
$data = array(
|
20 |
+
'label' => Mage::helper('adminhtml')->__('Export CSV'),
|
21 |
+
'onclick' => 'setLocation(\'' . Mage::helper('adminhtml')->getUrl("adminhtml/bpost_shM_config/exportTablerates", $params) . 'conditionName/\' + $(\'carriers_bpost_pickuppoint_condition_name\').value + \'/bpost_pickuppoint_tablerates.csv\' )',
|
22 |
+
'class' => '',
|
23 |
+
'id' => 'carriers_pickuppoint_tablerates_export'
|
24 |
+
);
|
25 |
+
|
26 |
+
$html = $buttonBlock->setData($data)->toHtml();
|
27 |
+
|
28 |
+
return $html;
|
29 |
+
}
|
30 |
}
|
app/code/community/Bpost/ShM/Block/Carrier/Bpost.php
CHANGED
@@ -1,133 +1,133 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Created by PHPro
|
5 |
-
*
|
6 |
-
* @package Bpost
|
7 |
-
* @subpackage ShM
|
8 |
-
* @author PHPro (info@phpro.be)
|
9 |
-
*/
|
10 |
-
|
11 |
-
/**
|
12 |
-
* Class Bpost_ShM_Block_Carrier_Bpost
|
13 |
-
*/
|
14 |
-
class Bpost_ShM_Block_Carrier_Bpost extends Mage_Core_Block_Template
|
15 |
-
{
|
16 |
-
/**
|
17 |
-
* Returns a settings array used during checkout
|
18 |
-
*
|
19 |
-
* @return array
|
20 |
-
*/
|
21 |
-
public function getSettings()
|
22 |
-
{
|
23 |
-
$bpostHelper = Mage::helper('bpost_shm');
|
24 |
-
$configHelper = Mage::helper("bpost_shm/system_config");
|
25 |
-
$settings = array(
|
26 |
-
"monday" => $bpostHelper->__('Monday'),
|
27 |
-
"tuesday" => $bpostHelper->__('Tuesday'),
|
28 |
-
"wednesday" => $bpostHelper->__('Wednesday'),
|
29 |
-
"thursday" => $bpostHelper->__('Thursday'),
|
30 |
-
"friday" => $bpostHelper->__('Friday'),
|
31 |
-
"saturday" => $bpostHelper->__('Saturday'),
|
32 |
-
"sunday" => $bpostHelper->__('Sunday'),
|
33 |
-
"closed" => $bpostHelper->__('Closed'),
|
34 |
-
"close_label" => $bpostHelper->__('Close'),
|
35 |
-
"select_text" => $bpostHelper->__('Click here to choose a bpost pick-up point.'),
|
36 |
-
"select_text_parcel_locker" => $bpostHelper->__('Click here to choose a bpost parcel locker point.'),
|
37 |
-
"select_text_clickcollect" => $bpostHelper->__('Click here to choose a bpost Click & Collect point.'),
|
38 |
-
"change_text" => $bpostHelper->__('Click here to change the bpost pick-up point.'),
|
39 |
-
"change_text_parcel_locker" => $bpostHelper->__('Click here to change the bpost parcel locker point.'),
|
40 |
-
"change_text_clickcollect" => $bpostHelper->__('Click here to change the bpost Click & Collect point.'),
|
41 |
-
"label_filter" => $bpostHelper->__("Filter"),
|
42 |
-
"label_select" => $bpostHelper->__("Select"),
|
43 |
-
"label_postcode" => $bpostHelper->__("Type in a location"),
|
44 |
-
"label_loading" => $bpostHelper->__("Please wait. Loading bpost map based on your address"),
|
45 |
-
"notifications_text_pickup_point" => $bpostHelper->__("How do you want to be notified when your parcel is available in the pick-up point?"),
|
46 |
-
"notifications_text_parcel_locker" => $bpostHelper->__("How do you want to be notified when your parcel is available in the parcel locker?"),
|
47 |
-
"notifications_sms_pickup_point" => $bpostHelper->__("via SMS"),
|
48 |
-
"notifications_sms_parcel_locker" => $bpostHelper->__("send additional SMS notification"),
|
49 |
-
"notifications_email" => $bpostHelper->__("via E-mail"),
|
50 |
-
"no_telephone_number" => $bpostHelper->__("no telephone number found, please fill in a number in the shipping address"),
|
51 |
-
"no_points_found" => $bpostHelper->__("No points could be found. Please use the filter above or drag the map to get a better result."),
|
52 |
-
"imgpath" => DS . "skin" . DS . "frontend" . DS . "base" . DS . "default" . DS . "images" . DS . "bpost" . DS,
|
53 |
-
"location_postoffice_default_image" => $this->getSkinUrl('images/bpost/location_postoffice_default.png'),
|
54 |
-
"location_postpoint_default_image" => $this->getSkinUrl('images/bpost/location_postpoint_default.png'),
|
55 |
-
"location_parcellocker_default_image" => $this->getSkinUrl('images/bpost/location_parcellocker_default.png'),
|
56 |
-
"location_clickcollect_default_image" => $this->getSkinUrl('images/bpost/location_clickcollect_default.png'),
|
57 |
-
"location_clickcollect_custom_image" => ($configHelper->getBpostCarriersConfig('marker', 'bpost_clickcollect', Mage::app()->getStore()->getId()) ? Mage::getBaseUrl('media') . "bpost/" . $configHelper->getBpostCarriersConfig("marker", "bpost_clickcollect", Mage::app()->getStore()->getId()) : ""),
|
58 |
-
"base_url" => Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK, Mage::app()->getStore()->isCurrentlySecure()),
|
59 |
-
"datepicker_display" => (bool)$configHelper->getBpostShippingConfig("display_delivery_date", Mage::app()->getStore()->getId()),
|
60 |
-
"datepicker_choose" => (bool)$configHelper->getBpostShippingConfig("choose_delivery_date", Mage::app()->getStore()->getId()),
|
61 |
-
"datepicker_text" => $bpostHelper->__("Select your preferred delivery date"),
|
62 |
-
"datepicker_delivery_date_text" => $bpostHelper->__("Delivery Date"),
|
63 |
-
"datepicker_saturday_delivery_text" => $bpostHelper->__("I don't want my parcel to be delivered on a Saturday"),
|
64 |
-
"datepicker_saturday_delivery_cost" => $bpostHelper->__("(extra cost Saturday delivery: %s EUR)"),
|
65 |
-
"datepicker_saturday_homedelivery" => (bool)$configHelper->getBpostCarriersConfig("saturday_delivery", "bpost_homedelivery", Mage::app()->getStore()->getId()),
|
66 |
-
"datepicker_saturday_pickuppoint" => (bool)$configHelper->getBpostCarriersConfig("saturday_delivery", "bpost_pickuppoint", Mage::app()->getStore()->getId()),
|
67 |
-
"datepicker_saturday_parcellocker" => (bool)$configHelper->getBpostCarriersConfig("saturday_delivery", "bpost_parcellocker", Mage::app()->getStore()->getId()),
|
68 |
-
"datepicker_saturday_clickcollect" => (bool)$configHelper->getBpostCarriersConfig("saturday_delivery", "bpost_clickcollect", Mage::app()->getStore()->getId()),
|
69 |
-
"datepicker_days" => $this->getShippingDates(),
|
70 |
-
"onestepcheckout_active" => $bpostHelper->isOnestepCheckout(),
|
71 |
-
"onestepcheckout_shipping_address_error" => $bpostHelper->__("Please select a postcode or city first.")
|
72 |
-
);
|
73 |
-
|
74 |
-
return $settings;
|
75 |
-
}
|
76 |
-
|
77 |
-
/**
|
78 |
-
* Returns the quote's shipping address telephone number
|
79 |
-
*
|
80 |
-
* @return string
|
81 |
-
*/
|
82 |
-
public function getBpostNotificationSms()
|
83 |
-
{
|
84 |
-
return Mage::getSingleton('checkout/session')->getQuote()->getShippingAddress()->getTelephone();
|
85 |
-
}
|
86 |
-
|
87 |
-
/**
|
88 |
-
* Returns the quote's shipping address e-mail address
|
89 |
-
*
|
90 |
-
* @return string
|
91 |
-
*/
|
92 |
-
public function getBpostNotificationEmail()
|
93 |
-
{
|
94 |
-
return Mage::getSingleton('checkout/session')->getQuote()->getShippingAddress()->getEmail();
|
95 |
-
}
|
96 |
-
|
97 |
-
/**
|
98 |
-
* Returns the current shipping method
|
99 |
-
*
|
100 |
-
* @return string
|
101 |
-
*/
|
102 |
-
public function getCurrentShippingMethod()
|
103 |
-
{
|
104 |
-
return Mage::getSingleton('checkout/session')->getQuote()->getShippingAddress()->getShippingMethod();
|
105 |
-
}
|
106 |
-
|
107 |
-
/**
|
108 |
-
* Returns the delivery date array
|
109 |
-
*
|
110 |
-
* @return array
|
111 |
-
*/
|
112 |
-
public function getShippingDates()
|
113 |
-
{
|
114 |
-
return Mage::helper('bpost_shm')->getBpostShippingDates();
|
115 |
-
}
|
116 |
-
|
117 |
-
/*
|
118 |
-
* This method retrieves the fixed saturday delivery cost
|
119 |
-
*
|
120 |
-
* @return string|bool
|
121 |
-
*/
|
122 |
-
public function getSaturdayDeliveryCost()
|
123 |
-
{
|
124 |
-
$configHelper = Mage::helper("bpost_shm/system_config");
|
125 |
-
$saturdayDeliveryCost = $configHelper->getBpostShippingConfig("saturday_delivery_cost", Mage::app()->getStore()->getId());
|
126 |
-
|
127 |
-
if(!empty($saturdayDeliveryCost) && $saturdayDeliveryCost > 0) {
|
128 |
-
return $saturdayDeliveryCost;
|
129 |
-
}
|
130 |
-
|
131 |
-
return false;
|
132 |
-
}
|
133 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Created by PHPro
|
5 |
+
*
|
6 |
+
* @package Bpost
|
7 |
+
* @subpackage ShM
|
8 |
+
* @author PHPro (info@phpro.be)
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Class Bpost_ShM_Block_Carrier_Bpost
|
13 |
+
*/
|
14 |
+
class Bpost_ShM_Block_Carrier_Bpost extends Mage_Core_Block_Template
|
15 |
+
{
|
16 |
+
/**
|
17 |
+
* Returns a settings array used during checkout
|
18 |
+
*
|
19 |
+
* @return array
|
20 |
+
*/
|
21 |
+
public function getSettings()
|
22 |
+
{
|
23 |
+
$bpostHelper = Mage::helper('bpost_shm');
|
24 |
+
$configHelper = Mage::helper("bpost_shm/system_config");
|
25 |
+
$settings = array(
|
26 |
+
"monday" => $bpostHelper->__('Monday'),
|
27 |
+
"tuesday" => $bpostHelper->__('Tuesday'),
|
28 |
+
"wednesday" => $bpostHelper->__('Wednesday'),
|
29 |
+
"thursday" => $bpostHelper->__('Thursday'),
|
30 |
+
"friday" => $bpostHelper->__('Friday'),
|
31 |
+
"saturday" => $bpostHelper->__('Saturday'),
|
32 |
+
"sunday" => $bpostHelper->__('Sunday'),
|
33 |
+
"closed" => $bpostHelper->__('Closed'),
|
34 |
+
"close_label" => $bpostHelper->__('Close'),
|
35 |
+
"select_text" => $bpostHelper->__('Click here to choose a bpost pick-up point.'),
|
36 |
+
"select_text_parcel_locker" => $bpostHelper->__('Click here to choose a bpost parcel locker point.'),
|
37 |
+
"select_text_clickcollect" => $bpostHelper->__('Click here to choose a bpost Click & Collect point.'),
|
38 |
+
"change_text" => $bpostHelper->__('Click here to change the bpost pick-up point.'),
|
39 |
+
"change_text_parcel_locker" => $bpostHelper->__('Click here to change the bpost parcel locker point.'),
|
40 |
+
"change_text_clickcollect" => $bpostHelper->__('Click here to change the bpost Click & Collect point.'),
|
41 |
+
"label_filter" => $bpostHelper->__("Filter"),
|
42 |
+
"label_select" => $bpostHelper->__("Select"),
|
43 |
+
"label_postcode" => $bpostHelper->__("Type in a location"),
|
44 |
+
"label_loading" => $bpostHelper->__("Please wait. Loading bpost map based on your address"),
|
45 |
+
"notifications_text_pickup_point" => $bpostHelper->__("How do you want to be notified when your parcel is available in the pick-up point?"),
|
46 |
+
"notifications_text_parcel_locker" => $bpostHelper->__("How do you want to be notified when your parcel is available in the parcel locker?"),
|
47 |
+
"notifications_sms_pickup_point" => $bpostHelper->__("via SMS"),
|
48 |
+
"notifications_sms_parcel_locker" => $bpostHelper->__("send additional SMS notification"),
|
49 |
+
"notifications_email" => $bpostHelper->__("via E-mail"),
|
50 |
+
"no_telephone_number" => $bpostHelper->__("no telephone number found, please fill in a number in the shipping address"),
|
51 |
+
"no_points_found" => $bpostHelper->__("No points could be found. Please use the filter above or drag the map to get a better result."),
|
52 |
+
"imgpath" => DS . "skin" . DS . "frontend" . DS . "base" . DS . "default" . DS . "images" . DS . "bpost" . DS,
|
53 |
+
"location_postoffice_default_image" => $this->getSkinUrl('images/bpost/location_postoffice_default.png'),
|
54 |
+
"location_postpoint_default_image" => $this->getSkinUrl('images/bpost/location_postpoint_default.png'),
|
55 |
+
"location_parcellocker_default_image" => $this->getSkinUrl('images/bpost/location_parcellocker_default.png'),
|
56 |
+
"location_clickcollect_default_image" => $this->getSkinUrl('images/bpost/location_clickcollect_default.png'),
|
57 |
+
"location_clickcollect_custom_image" => ($configHelper->getBpostCarriersConfig('marker', 'bpost_clickcollect', Mage::app()->getStore()->getId()) ? Mage::getBaseUrl('media') . "bpost/" . $configHelper->getBpostCarriersConfig("marker", "bpost_clickcollect", Mage::app()->getStore()->getId()) : ""),
|
58 |
+
"base_url" => Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK, Mage::app()->getStore()->isCurrentlySecure()),
|
59 |
+
"datepicker_display" => (bool)$configHelper->getBpostShippingConfig("display_delivery_date", Mage::app()->getStore()->getId()),
|
60 |
+
"datepicker_choose" => (bool)$configHelper->getBpostShippingConfig("choose_delivery_date", Mage::app()->getStore()->getId()),
|
61 |
+
"datepicker_text" => $bpostHelper->__("Select your preferred delivery date"),
|
62 |
+
"datepicker_delivery_date_text" => $bpostHelper->__("Delivery Date"),
|
63 |
+
"datepicker_saturday_delivery_text" => $bpostHelper->__("I don't want my parcel to be delivered on a Saturday"),
|
64 |
+
"datepicker_saturday_delivery_cost" => $bpostHelper->__("(extra cost Saturday delivery: %s EUR)"),
|
65 |
+
"datepicker_saturday_homedelivery" => (bool)$configHelper->getBpostCarriersConfig("saturday_delivery", "bpost_homedelivery", Mage::app()->getStore()->getId()),
|
66 |
+
"datepicker_saturday_pickuppoint" => (bool)$configHelper->getBpostCarriersConfig("saturday_delivery", "bpost_pickuppoint", Mage::app()->getStore()->getId()),
|
67 |
+
"datepicker_saturday_parcellocker" => (bool)$configHelper->getBpostCarriersConfig("saturday_delivery", "bpost_parcellocker", Mage::app()->getStore()->getId()),
|
68 |
+
"datepicker_saturday_clickcollect" => (bool)$configHelper->getBpostCarriersConfig("saturday_delivery", "bpost_clickcollect", Mage::app()->getStore()->getId()),
|
69 |
+
"datepicker_days" => $this->getShippingDates(),
|
70 |
+
"onestepcheckout_active" => $bpostHelper->isOnestepCheckout(),
|
71 |
+
"onestepcheckout_shipping_address_error" => $bpostHelper->__("Please select a postcode or city first.")
|
72 |
+
);
|
73 |
+
|
74 |
+
return $settings;
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* Returns the quote's shipping address telephone number
|
79 |
+
*
|
80 |
+
* @return string
|
81 |
+
*/
|
82 |
+
public function getBpostNotificationSms()
|
83 |
+
{
|
84 |
+
return Mage::getSingleton('checkout/session')->getQuote()->getShippingAddress()->getTelephone();
|
85 |
+
}
|
86 |
+
|
87 |
+
/**
|
88 |
+
* Returns the quote's shipping address e-mail address
|
89 |
+
*
|
90 |
+
* @return string
|
91 |
+
*/
|
92 |
+
public function getBpostNotificationEmail()
|
93 |
+
{
|
94 |
+
return Mage::getSingleton('checkout/session')->getQuote()->getShippingAddress()->getEmail();
|
95 |
+
}
|
96 |
+
|
97 |
+
/**
|
98 |
+
* Returns the current shipping method
|
99 |
+
*
|
100 |
+
* @return string
|
101 |
+
*/
|
102 |
+
public function getCurrentShippingMethod()
|
103 |
+
{
|
104 |
+
return Mage::getSingleton('checkout/session')->getQuote()->getShippingAddress()->getShippingMethod();
|
105 |
+
}
|
106 |
+
|
107 |
+
/**
|
108 |
+
* Returns the delivery date array
|
109 |
+
*
|
110 |
+
* @return array
|
111 |
+
*/
|
112 |
+
public function getShippingDates()
|
113 |
+
{
|
114 |
+
return Mage::helper('bpost_shm')->getBpostShippingDates();
|
115 |
+
}
|
116 |
+
|
117 |
+
/*
|
118 |
+
* This method retrieves the fixed saturday delivery cost
|
119 |
+
*
|
120 |
+
* @return string|bool
|
121 |
+
*/
|
122 |
+
public function getSaturdayDeliveryCost()
|
123 |
+
{
|
124 |
+
$configHelper = Mage::helper("bpost_shm/system_config");
|
125 |
+
$saturdayDeliveryCost = $configHelper->getBpostShippingConfig("saturday_delivery_cost", Mage::app()->getStore()->getId());
|
126 |
+
|
127 |
+
if(!empty($saturdayDeliveryCost) && $saturdayDeliveryCost > 0) {
|
128 |
+
return $saturdayDeliveryCost;
|
129 |
+
}
|
130 |
+
|
131 |
+
return false;
|
132 |
+
}
|
133 |
+
}
|
app/code/community/Bpost/ShM/Controller/ShM/Order.php
CHANGED
@@ -1,173 +1,173 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Created by PHPro
|
4 |
-
*
|
5 |
-
* @package Bpost
|
6 |
-
* @subpackage ShM
|
7 |
-
* @author PHPro (info@phpro.be)
|
8 |
-
*/
|
9 |
-
class Bpost_ShM_Controller_ShM_Order extends Mage_Adminhtml_Controller_Action
|
10 |
-
{
|
11 |
-
//we use this class for functions that will be used more than one time
|
12 |
-
//all orders and pending orders are extending this one
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Generates a label and completes the shipment.
|
16 |
-
* This is called by the action in the order grid dropdown.
|
17 |
-
* By ajax call
|
18 |
-
*/
|
19 |
-
public function ajaxGenerateAndCompleteAction(){
|
20 |
-
$ajaxResult = array('messages' => '');
|
21 |
-
|
22 |
-
ini_set('max_execution_time', 120);
|
23 |
-
$orderIds = $this->getRequest()->getParam('entity_id');
|
24 |
-
$counter = 0;
|
25 |
-
$gridModel = Mage::getModel('bpost_shm/adminhtml_bpostgrid');
|
26 |
-
|
27 |
-
$messages = array("success" => array(), "error" => array(), "notice" => array());
|
28 |
-
|
29 |
-
if (!is_array($orderIds)) {
|
30 |
-
try {
|
31 |
-
|
32 |
-
$order = Mage::getModel("sales/order")->load($orderIds);
|
33 |
-
$gridModel->generateAndCompleteOrder($order);
|
34 |
-
|
35 |
-
if(!is_object(Mage::getSingleton('core/session')->getMessages()->getLastAddedMessage())){
|
36 |
-
$message = Mage::helper('bpost_shm')->__("Your label has been generated and statuses have been changed.");
|
37 |
-
$messages["success"][] = $message;
|
38 |
-
$ajaxResult['status'] = 'success';
|
39 |
-
}
|
40 |
-
} catch (Exception $e) {
|
41 |
-
Mage::helper('bpost_shm')->log($e->getMessage(), Zend_Log::ERR);
|
42 |
-
$message = Mage::helper('bpost_shm')->__("Your selected order is not ready to be shipped or has already been shipped, operation canceled.");
|
43 |
-
$messages["error"][] = $message;
|
44 |
-
}
|
45 |
-
}else {
|
46 |
-
|
47 |
-
try {
|
48 |
-
$orderCollection = Mage::getModel("sales/order")->getCollection()->addFieldToFilter("entity_id", array("in" => $orderIds));
|
49 |
-
|
50 |
-
foreach ($orderCollection as $order) {
|
51 |
-
try {
|
52 |
-
$counter += $gridModel->generateAndCompleteOrder($order);
|
53 |
-
} catch (Exception $e) {
|
54 |
-
Mage::helper('bpost_shm')->log($e->getMessage(), Zend_Log::ERR);
|
55 |
-
$messages["error"][] = $e->getMessage();
|
56 |
-
}
|
57 |
-
}
|
58 |
-
|
59 |
-
if($counter > 0){
|
60 |
-
$message = Mage::helper('bpost_shm')->__("%s label(s) have been generated and statuses have been changed.", $counter);
|
61 |
-
$messages["success"][] = $message;
|
62 |
-
}
|
63 |
-
} catch (Exception $e) {
|
64 |
-
Mage::helper('bpost_shm')->log($e->getMessage(), Zend_Log::ERR);
|
65 |
-
$message = Mage::helper('bpost_shm')->__("Some of the selected orders are not ready to be shipped or have already been shipped, operation canceled.");
|
66 |
-
$messages["error"][] = $message;
|
67 |
-
}
|
68 |
-
}
|
69 |
-
|
70 |
-
try {
|
71 |
-
//we save our grid transaction
|
72 |
-
$gridModel->saveTransaction();
|
73 |
-
}catch (Exception $e){
|
74 |
-
Mage::helper('bpost_shm')->log($e->getMessage(), Zend_Log::ERR);
|
75 |
-
$message = Mage::helper('bpost_shm')->__($e->getMessage());
|
76 |
-
$messages["error"][] = $message;
|
77 |
-
}
|
78 |
-
|
79 |
-
|
80 |
-
//first check if we have already messages in this request
|
81 |
-
//if so, add these to the messages array
|
82 |
-
foreach(Mage::getSingleton('core/session')->getMessages()->getItems() as $sessionMessage){
|
83 |
-
switch($sessionMessage->getType()){
|
84 |
-
case "notice":
|
85 |
-
$messages["notice"][] = $sessionMessage->getCode();
|
86 |
-
break;
|
87 |
-
|
88 |
-
case "error":
|
89 |
-
$messages["error"][] = $sessionMessage->getCode();
|
90 |
-
break;
|
91 |
-
|
92 |
-
case "success":
|
93 |
-
$messages["success"][] = $sessionMessage->getCode();
|
94 |
-
break;
|
95 |
-
}
|
96 |
-
}
|
97 |
-
|
98 |
-
$ajaxResult["messages"] = $messages;
|
99 |
-
|
100 |
-
//remove messages from session
|
101 |
-
Mage::getSingleton('core/session')->getMessages(true);
|
102 |
-
|
103 |
-
$this->getResponse()->setBody ( Zend_Json::encode($ajaxResult) );
|
104 |
-
}
|
105 |
-
|
106 |
-
|
107 |
-
/**
|
108 |
-
* Zips all undownloaded labels and gives downloadlink.
|
109 |
-
*/
|
110 |
-
public function dowloadAllUndownloadedAction()
|
111 |
-
{
|
112 |
-
$orderIds = $this->getRequest()->getParam('entity_id');
|
113 |
-
try {
|
114 |
-
|
115 |
-
$fileName = Mage::getModel('bpost_shm/adminhtml_bpostgrid')->processUndownloadedLabels($orderIds);
|
116 |
-
|
117 |
-
if (!$fileName) {
|
118 |
-
$message = Mage::helper('bpost_shm')->__('No undownloaded labels found.');
|
119 |
-
Mage::getSingleton('core/session')->addError($message);
|
120 |
-
$this->_redirect('*/*/index');
|
121 |
-
} else {
|
122 |
-
|
123 |
-
//check for .zip files
|
124 |
-
//if zip, do not render
|
125 |
-
if(substr($fileName, -4) == ".zip"){
|
126 |
-
$url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . Bpost_ShM_Model_Adminhtml_Bpostgrid::MEDIA_LABEL_PATH."zips".DS.$fileName;
|
127 |
-
}else{
|
128 |
-
$url = $this->getUrl("*/*/download", array("file_name" => $fileName));
|
129 |
-
}
|
130 |
-
|
131 |
-
$message = Mage::helper('bpost_shm')->__('Successfully exported order(s). Download the file here: %s',
|
132 |
-
' <a id="downloadzip" href="'
|
133 |
-
. $url . '" target="_blank">'
|
134 |
-
. $fileName . '</a>');
|
135 |
-
|
136 |
-
Mage::getSingleton('core/session')->addSuccess($message);
|
137 |
-
$this->_redirect('*/*/index');
|
138 |
-
}
|
139 |
-
|
140 |
-
}catch (Exception $e){
|
141 |
-
Mage::helper('bpost_shm')->log($e->getMessage(), Zend_Log::ERR);
|
142 |
-
$message = Mage::helper('bpost_shm')->__("The file(s) could not be downloaded, please check your bpost logs.");
|
143 |
-
Mage::getSingleton('core/session')->addError($message);
|
144 |
-
$this->_redirect('*/*/index');
|
145 |
-
}
|
146 |
-
}
|
147 |
-
|
148 |
-
|
149 |
-
/**
|
150 |
-
* Download responseAction for the zip
|
151 |
-
*/
|
152 |
-
public function downloadAction()
|
153 |
-
{
|
154 |
-
$fileName = $this->getRequest()->getParam('file_name');
|
155 |
-
|
156 |
-
if(substr($fileName, -4) == ".zip"){
|
157 |
-
$fileName = "zips".DS.$fileName;
|
158 |
-
}
|
159 |
-
|
160 |
-
$fileLocation = Mage::getBaseDir('media') . Bpost_ShM_Model_Adminhtml_Bpostgrid::MEDIA_LABEL_PATH. $fileName;
|
161 |
-
$ioFile = new Varien_Io_File();
|
162 |
-
|
163 |
-
if ($ioFile->fileExists($fileLocation)) {
|
164 |
-
$file = Zend_Pdf::load($fileLocation);
|
165 |
-
$this->_prepareDownloadResponse($fileName, $file->render());
|
166 |
-
} else {
|
167 |
-
$message = Mage::helper('bpost_shm')->__("The requested file does not exist, it is either removed or not readable.");
|
168 |
-
$this->_getSession()->addError($message);
|
169 |
-
$this->_redirect('*/*/index');
|
170 |
-
}
|
171 |
-
}
|
172 |
-
}
|
173 |
-
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Created by PHPro
|
4 |
+
*
|
5 |
+
* @package Bpost
|
6 |
+
* @subpackage ShM
|
7 |
+
* @author PHPro (info@phpro.be)
|
8 |
+
*/
|
9 |
+
class Bpost_ShM_Controller_ShM_Order extends Mage_Adminhtml_Controller_Action
|
10 |
+
{
|
11 |
+
//we use this class for functions that will be used more than one time
|
12 |
+
//all orders and pending orders are extending this one
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Generates a label and completes the shipment.
|
16 |
+
* This is called by the action in the order grid dropdown.
|
17 |
+
* By ajax call
|
18 |
+
*/
|
19 |
+
public function ajaxGenerateAndCompleteAction(){
|
20 |
+
$ajaxResult = array('messages' => '');
|
21 |
+
|
22 |
+
ini_set('max_execution_time', 120);
|
23 |
+
$orderIds = $this->getRequest()->getParam('entity_id');
|
24 |
+
$counter = 0;
|
25 |
+
$gridModel = Mage::getModel('bpost_shm/adminhtml_bpostgrid');
|
26 |
+
|
27 |
+
$messages = array("success" => array(), "error" => array(), "notice" => array());
|
28 |
+
|
29 |
+
if (!is_array($orderIds)) {
|
30 |
+
try {
|
31 |
+
|
32 |
+
$order = Mage::getModel("sales/order")->load($orderIds);
|
33 |
+
$gridModel->generateAndCompleteOrder($order);
|
34 |
+
|
35 |
+
if(!is_object(Mage::getSingleton('core/session')->getMessages()->getLastAddedMessage())){
|
36 |
+
$message = Mage::helper('bpost_shm')->__("Your label has been generated and statuses have been changed.");
|
37 |
+
$messages["success"][] = $message;
|
38 |
+
$ajaxResult['status'] = 'success';
|
39 |
+
}
|
40 |
+
} catch (Exception $e) {
|
41 |
+
Mage::helper('bpost_shm')->log($e->getMessage(), Zend_Log::ERR);
|
42 |
+
$message = Mage::helper('bpost_shm')->__("Your selected order is not ready to be shipped or has already been shipped, operation canceled.");
|
43 |
+
$messages["error"][] = $message;
|
44 |
+
}
|
45 |
+
}else {
|
46 |
+
|
47 |
+
try {
|
48 |
+
$orderCollection = Mage::getModel("sales/order")->getCollection()->addFieldToFilter("entity_id", array("in" => $orderIds));
|
49 |
+
|
50 |
+
foreach ($orderCollection as $order) {
|
51 |
+
try {
|
52 |
+
$counter += $gridModel->generateAndCompleteOrder($order);
|
53 |
+
} catch (Exception $e) {
|
54 |
+
Mage::helper('bpost_shm')->log($e->getMessage(), Zend_Log::ERR);
|
55 |
+
$messages["error"][] = $e->getMessage();
|
56 |
+
}
|
57 |
+
}
|
58 |
+
|
59 |
+
if($counter > 0){
|
60 |
+
$message = Mage::helper('bpost_shm')->__("%s label(s) have been generated and statuses have been changed.", $counter);
|
61 |
+
$messages["success"][] = $message;
|
62 |
+
}
|
63 |
+
} catch (Exception $e) {
|
64 |
+
Mage::helper('bpost_shm')->log($e->getMessage(), Zend_Log::ERR);
|
65 |
+
$message = Mage::helper('bpost_shm')->__("Some of the selected orders are not ready to be shipped or have already been shipped, operation canceled.");
|
66 |
+
$messages["error"][] = $message;
|
67 |
+
}
|
68 |
+
}
|
69 |
+
|
70 |
+
try {
|
71 |
+
//we save our grid transaction
|
72 |
+
$gridModel->saveTransaction();
|
73 |
+
}catch (Exception $e){
|
74 |
+
Mage::helper('bpost_shm')->log($e->getMessage(), Zend_Log::ERR);
|
75 |
+
$message = Mage::helper('bpost_shm')->__($e->getMessage());
|
76 |
+
$messages["error"][] = $message;
|
77 |
+
}
|
78 |
+
|
79 |
+
|
80 |
+
//first check if we have already messages in this request
|
81 |
+
//if so, add these to the messages array
|
82 |
+
foreach(Mage::getSingleton('core/session')->getMessages()->getItems() as $sessionMessage){
|
83 |
+
switch($sessionMessage->getType()){
|
84 |
+
case "notice":
|
85 |
+
$messages["notice"][] = $sessionMessage->getCode();
|
86 |
+
break;
|
87 |
+
|
88 |
+
case "error":
|
89 |
+
$messages["error"][] = $sessionMessage->getCode();
|
90 |
+
break;
|
91 |
+
|
92 |
+
case "success":
|
93 |
+
$messages["success"][] = $sessionMessage->getCode();
|
94 |
+
break;
|
95 |
+
}
|
96 |
+
}
|
97 |
+
|
98 |
+
$ajaxResult["messages"] = $messages;
|
99 |
+
|
100 |
+
//remove messages from session
|
101 |
+
Mage::getSingleton('core/session')->getMessages(true);
|
102 |
+
|
103 |
+
$this->getResponse()->setBody ( Zend_Json::encode($ajaxResult) );
|
104 |
+
}
|
105 |
+
|
106 |
+
|
107 |
+
/**
|
108 |
+
* Zips all undownloaded labels and gives downloadlink.
|
109 |
+
*/
|
110 |
+
public function dowloadAllUndownloadedAction()
|
111 |
+
{
|
112 |
+
$orderIds = $this->getRequest()->getParam('entity_id');
|
113 |
+
try {
|
114 |
+
|
115 |
+
$fileName = Mage::getModel('bpost_shm/adminhtml_bpostgrid')->processUndownloadedLabels($orderIds);
|
116 |
+
|
117 |
+
if (!$fileName) {
|
118 |
+
$message = Mage::helper('bpost_shm')->__('No undownloaded labels found.');
|
119 |
+
Mage::getSingleton('core/session')->addError($message);
|
120 |
+
$this->_redirect('*/*/index');
|
121 |
+
} else {
|
122 |
+
|
123 |
+
//check for .zip files
|
124 |
+
//if zip, do not render
|
125 |
+
if(substr($fileName, -4) == ".zip"){
|
126 |
+
$url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . Bpost_ShM_Model_Adminhtml_Bpostgrid::MEDIA_LABEL_PATH."zips".DS.$fileName;
|
127 |
+
}else{
|
128 |
+
$url = $this->getUrl("*/*/download", array("file_name" => $fileName));
|
129 |
+
}
|
130 |
+
|
131 |
+
$message = Mage::helper('bpost_shm')->__('Successfully exported order(s). Download the file here: %s',
|
132 |
+
' <a id="downloadzip" href="'
|
133 |
+
. $url . '" target="_blank">'
|
134 |
+
. $fileName . '</a>');
|
135 |
+
|
136 |
+
Mage::getSingleton('core/session')->addSuccess($message);
|
137 |
+
$this->_redirect('*/*/index');
|
138 |
+
}
|
139 |
+
|
140 |
+
}catch (Exception $e){
|
141 |
+
Mage::helper('bpost_shm')->log($e->getMessage(), Zend_Log::ERR);
|
142 |
+
$message = Mage::helper('bpost_shm')->__("The file(s) could not be downloaded, please check your bpost logs.");
|
143 |
+
Mage::getSingleton('core/session')->addError($message);
|
144 |
+
$this->_redirect('*/*/index');
|
145 |
+
}
|
146 |
+
}
|
147 |
+
|
148 |
+
|
149 |
+
/**
|
150 |
+
* Download responseAction for the zip
|
151 |
+
*/
|
152 |
+
public function downloadAction()
|
153 |
+
{
|
154 |
+
$fileName = $this->getRequest()->getParam('file_name');
|
155 |
+
|
156 |
+
if(substr($fileName, -4) == ".zip"){
|
157 |
+
$fileName = "zips".DS.$fileName;
|
158 |
+
}
|
159 |
+
|
160 |
+
$fileLocation = Mage::getBaseDir('media') . Bpost_ShM_Model_Adminhtml_Bpostgrid::MEDIA_LABEL_PATH. $fileName;
|
161 |
+
$ioFile = new Varien_Io_File();
|
162 |
+
|
163 |
+
if ($ioFile->fileExists($fileLocation)) {
|
164 |
+
$file = Zend_Pdf::load($fileLocation);
|
165 |
+
$this->_prepareDownloadResponse($fileName, $file->render());
|
166 |
+
} else {
|
167 |
+
$message = Mage::helper('bpost_shm')->__("The requested file does not exist, it is either removed or not readable.");
|
168 |
+
$this->_getSession()->addError($message);
|
169 |
+
$this->_redirect('*/*/index');
|
170 |
+
}
|
171 |
+
}
|
172 |
+
}
|
173 |
+
|
app/code/community/Bpost/ShM/Helper/Data.php
CHANGED
@@ -1,847 +1,847 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Created by PHPro
|
5 |
-
*
|
6 |
-
* @package Bpost
|
7 |
-
* @subpackage ShM
|
8 |
-
* @author PHPro (info@phpro.be)
|
9 |
-
*/
|
10 |
-
|
11 |
-
/**
|
12 |
-
* Class Bpost_ShM_Helper_Data
|
13 |
-
*/
|
14 |
-
class Bpost_ShM_Helper_Data extends Mage_Core_Helper_Abstract
|
15 |
-
{
|
16 |
-
/**
|
17 |
-
* Standard shm logging
|
18 |
-
*
|
19 |
-
* @param $message
|
20 |
-
* @param $level
|
21 |
-
* @param $storeId
|
22 |
-
*/
|
23 |
-
public function log($message, $level, $storeId = 0)
|
24 |
-
{
|
25 |
-
$configHelper = Mage::helper("bpost_shm/system_config");
|
26 |
-
$allowedLogLevel = $configHelper->getBpostShippingConfig("log_level", $storeId);
|
27 |
-
|
28 |
-
//first check if logging is enabled
|
29 |
-
if ($configHelper->isLoggingEnabled()) {
|
30 |
-
if ($level <= $allowedLogLevel) {
|
31 |
-
Mage::log($message, $level, 'bpost.log');
|
32 |
-
}
|
33 |
-
}
|
34 |
-
}
|
35 |
-
|
36 |
-
/**
|
37 |
-
* API logging if something goes wrong
|
38 |
-
*
|
39 |
-
* @param $message
|
40 |
-
* @param $level
|
41 |
-
* @param $translate
|
42 |
-
* @param $storeId
|
43 |
-
*/
|
44 |
-
public function ApiLog($message, $level, $translate = true, $storeId = 0)
|
45 |
-
{
|
46 |
-
$configHelper = Mage::helper("bpost_shm/system_config");
|
47 |
-
$allowedLogLevel = $configHelper->getBpostShippingConfig("api_log_level", $storeId);
|
48 |
-
|
49 |
-
//first check if API logging is enabled
|
50 |
-
if ($configHelper->isApiLoggingEnabled()) {
|
51 |
-
if ($level <= $allowedLogLevel) {
|
52 |
-
if($translate){
|
53 |
-
Mage::log($this->__($message), $level, "bpost-api.log");
|
54 |
-
}else{
|
55 |
-
Mage::log($message, $level, "bpost-api.log");
|
56 |
-
}
|
57 |
-
}
|
58 |
-
}
|
59 |
-
}
|
60 |
-
|
61 |
-
/**
|
62 |
-
* Function checks if we have more address lines
|
63 |
-
* If so, we use address 2 as housenumber
|
64 |
-
* Else we need to get housenumber from the single address line
|
65 |
-
*
|
66 |
-
* @param $address
|
67 |
-
* @return $address
|
68 |
-
*/
|
69 |
-
public function formatAddress($address)
|
70 |
-
{
|
71 |
-
$address->setData("bpost_name", $address->getFirstname() . " " . $address->getLastname());
|
72 |
-
$address->setData("bpost_company", $address->getCompany());
|
73 |
-
|
74 |
-
//we assume that street 3 will be box number - not necessary
|
75 |
-
if ($address->getStreet3()) {
|
76 |
-
$address->setData("box_number", $address->getStreet3());
|
77 |
-
}
|
78 |
-
|
79 |
-
if ($address->getStreet2()) {
|
80 |
-
if($address->getData("company") && $address->getData("company") != ""){
|
81 |
-
$address->setData("bpost_company", $address->getData("bpost_name") . " (" . $address->getData("company") . ")");
|
82 |
-
}else{
|
83 |
-
$address->setData("bpost_company", $address->getData("bpost_name"));
|
84 |
-
}
|
85 |
-
|
86 |
-
$address->setData("bpost_name", $address->getStreet2());
|
87 |
-
}
|
88 |
-
|
89 |
-
$address->setData("bpost_house_number", ",");
|
90 |
-
$address->setData("bpost_street", $address->getStreet1());
|
91 |
-
|
92 |
-
return $address;
|
93 |
-
}
|
94 |
-
|
95 |
-
/**
|
96 |
-
* Validate the postal code
|
97 |
-
*
|
98 |
-
* @param $country_id
|
99 |
-
* @param $postcode
|
100 |
-
* @return regex|string
|
101 |
-
*/
|
102 |
-
public function validatePostcode($country_id, $postcode)
|
103 |
-
{
|
104 |
-
$zipValidationRules = array(
|
105 |
-
'LT' => array('99999', '/^(\d{5})$/'),
|
106 |
-
'LU' => array('9999', '/^(\d{4})$/'),
|
107 |
-
'BE' => array('9999', '/^(\d{4})$/'),
|
108 |
-
'LV' => array('9999', '/^(\d{4})$/'),
|
109 |
-
'MT' => array('AAA 9999', '/[A-Z]{3} [0-9]{4}/'),
|
110 |
-
'NL' => array('9999 AA', '/[0-9]{4} [A-Z]{2}/'),
|
111 |
-
'PL' => array('99999', '/^(\d{5})$/'),
|
112 |
-
'PT' => array('9999999', '/^([0-9]){7}$/'),
|
113 |
-
'RO' => array('999999', '/^(\d{6})$/'),
|
114 |
-
'SE' => array('999 99', '/^(\d{3} \d{2})$/'),
|
115 |
-
'SI' => array('9999', '/^(\d{4})$/'),
|
116 |
-
'SK' => array('999 99', '/^(\d{3} \d{2})$/'),
|
117 |
-
'AT' => array('9999', '/^(\d{4})$/'),
|
118 |
-
'BG' => array('9999', '/^(\d{4})$/'),
|
119 |
-
'CZ' => array('999 99', '/^[0-9]{3} [0-9]{2}$/'),
|
120 |
-
'DE' => array('99999', '/^(\d{5})$/'),
|
121 |
-
'DK' => array('9999', '/^(\d{4})$/'),
|
122 |
-
'EE' => array('99999', '/^(\d{5})$/'),
|
123 |
-
'ES' => array('99999', '/^(\d{5})$/'),
|
124 |
-
'FI' => array('99999', '/^(\d{5})$/'),
|
125 |
-
'FR' => array('99999', '/^(\d{5})$/'),
|
126 |
-
'GR' => array('999 99', '/^(\d{3}) \d{2}$/'),
|
127 |
-
'HR' => array('99999', '/^(\d{5})$/'),
|
128 |
-
'HU' => array('9999', '/^(\d{4})$/'),
|
129 |
-
'IT' => array('99999', '/^(\d{5})$/')
|
130 |
-
);
|
131 |
-
if (array_key_exists($country_id, $zipValidationRules)) {
|
132 |
-
$validationRegex = $zipValidationRules[$country_id][1];
|
133 |
-
$validationFormat = $zipValidationRules[$country_id][0];
|
134 |
-
|
135 |
-
if (!preg_match($validationRegex, $postcode)) {
|
136 |
-
return $validationFormat;
|
137 |
-
}
|
138 |
-
}
|
139 |
-
return 'passed';
|
140 |
-
}
|
141 |
-
|
142 |
-
/**
|
143 |
-
* Creates new IO object and inputs base 64 pdf string fetched from webservice.
|
144 |
-
*
|
145 |
-
* @param $pdfString
|
146 |
-
* @param $folder
|
147 |
-
* @param $name
|
148 |
-
*
|
149 |
-
* @return string
|
150 |
-
*/
|
151 |
-
public function generatePdfAndSave($pdfString, $folder, $name)
|
152 |
-
{
|
153 |
-
$hash = bin2hex(mcrypt_create_iv(5, MCRYPT_DEV_URANDOM));
|
154 |
-
$name = $name . "-" . $hash;
|
155 |
-
|
156 |
-
$varienFile = new Varien_Io_File();
|
157 |
-
$varienFile->setAllowCreateFolders(true);
|
158 |
-
$varienFile->open(array('path' => Mage::getBaseDir('media') . "/bpost/" . $folder));
|
159 |
-
$varienFile->streamOpen($name . '.pdf', 'w+');
|
160 |
-
$varienFile->streamLock(true);
|
161 |
-
$varienFile->streamWrite($pdfString);
|
162 |
-
$varienFile->streamUnlock();
|
163 |
-
$varienFile->streamClose();
|
164 |
-
return $name;
|
165 |
-
}
|
166 |
-
|
167 |
-
/**
|
168 |
-
* Function returns the locale code by order
|
169 |
-
*
|
170 |
-
* @param $order
|
171 |
-
* @param $useExceptionLanguage
|
172 |
-
* @return string
|
173 |
-
*/
|
174 |
-
public function getLocaleByOrder($order, $useExceptionLanguage = false)
|
175 |
-
{
|
176 |
-
$exceptionLanguages = array("DE");
|
177 |
-
|
178 |
-
$store = $order->getStore()->getId();
|
179 |
-
$locale = Mage::getStoreConfig("general/locale/code", $store);
|
180 |
-
$locale = strtoupper(substr($locale, 0, 2));
|
181 |
-
|
182 |
-
switch ($locale) {
|
183 |
-
case "NL":
|
184 |
-
case "FR":
|
185 |
-
case "EN":
|
186 |
-
return $locale;
|
187 |
-
break;
|
188 |
-
|
189 |
-
default:
|
190 |
-
if ($useExceptionLanguage && in_array($locale, $exceptionLanguages)) {
|
191 |
-
return $locale;
|
192 |
-
}
|
193 |
-
|
194 |
-
return "EN";
|
195 |
-
break;
|
196 |
-
}
|
197 |
-
}
|
198 |
-
|
199 |
-
/**
|
200 |
-
* Function parses the create label API response in a readable format
|
201 |
-
*
|
202 |
-
* @param $response
|
203 |
-
* @return array
|
204 |
-
*/
|
205 |
-
public function parseLabelApiResponse($response, $order){
|
206 |
-
$xml = simplexml_load_string($response->getBody());
|
207 |
-
$shippingMethod = $order->getShippingMethod();
|
208 |
-
$returnArray = array();
|
209 |
-
$returnArray["barcodeString"] = array();
|
210 |
-
|
211 |
-
//international delivery can have more label elements (instead of one with multiple barcodes), so we have to loop
|
212 |
-
foreach($xml->label as $label){
|
213 |
-
$responseBarcodeArray = (array)$label->barcode;
|
214 |
-
|
215 |
-
//we check for barcodes
|
216 |
-
//for national delivery
|
217 |
-
//barcodes ending on 030 -> regular barcode
|
218 |
-
//barcodes ending on 050 -> return barcode
|
219 |
-
|
220 |
-
//for international delivery
|
221 |
-
//barcodes starting with CD -> regular barcode, no return
|
222 |
-
|
223 |
-
//international delivery has other barcodes
|
224 |
-
//check on barcode count label
|
225 |
-
//if more than 1 -> national, otherwise international
|
226 |
-
|
227 |
-
foreach($responseBarcodeArray as $responseBarcode){
|
228 |
-
$responseBarcode = (string)$responseBarcode;
|
229 |
-
|
230 |
-
$firstTwoCharacters = substr($responseBarcode, 0, 2);
|
231 |
-
$lastThreeCharacters = substr($responseBarcode, -3);
|
232 |
-
|
233 |
-
switch($shippingMethod){
|
234 |
-
case "bpostshm_bpost_international":
|
235 |
-
if(in_array($firstTwoCharacters, array("CD","EE","CE")) && $lastThreeCharacters != '134'){
|
236 |
-
$returnArray["barcodeString"][] = $responseBarcode;
|
237 |
-
}else{
|
238 |
-
if(!isset($returnArray["returnBarcodeString"])){
|
239 |
-
$returnArray["returnBarcodeString"] = array();
|
240 |
-
}
|
241 |
-
$returnArray["returnBarcodeString"][] = $responseBarcode;
|
242 |
-
}
|
243 |
-
break;
|
244 |
-
|
245 |
-
default:
|
246 |
-
if($lastThreeCharacters == "050"){
|
247 |
-
if(!isset($returnArray["returnBarcodeString"])){
|
248 |
-
$returnArray["returnBarcodeString"] = array();
|
249 |
-
}
|
250 |
-
$returnArray["returnBarcodeString"][] = $responseBarcode;
|
251 |
-
}else{
|
252 |
-
$returnArray["barcodeString"][] = $responseBarcode;
|
253 |
-
}
|
254 |
-
break;
|
255 |
-
}
|
256 |
-
}
|
257 |
-
|
258 |
-
$pdfString = $label->bytes;
|
259 |
-
|
260 |
-
//we use the Zend_XmlRpc_Value_Base64 for decoding our string
|
261 |
-
$zendXmlRpc = new Zend_XmlRpc_Value_Base64($pdfString, true);
|
262 |
-
$pdfString = $zendXmlRpc->getValue();
|
263 |
-
|
264 |
-
if(!isset($returnArray["pdfString"])){
|
265 |
-
$returnArray["pdfString"] = array();
|
266 |
-
$returnArray["pdfString"][] = $pdfString;
|
267 |
-
}else{
|
268 |
-
$returnArray["pdfString"][] = $pdfString;
|
269 |
-
}
|
270 |
-
}
|
271 |
-
|
272 |
-
//make sure the index barcode string isset
|
273 |
-
if(empty($returnArray["barcodeString"])){
|
274 |
-
$returnArray["barcodeString"][] = $order->getBpostReference();
|
275 |
-
}
|
276 |
-
|
277 |
-
return $returnArray;
|
278 |
-
}
|
279 |
-
|
280 |
-
/**
|
281 |
-
* API function returns the bpost status
|
282 |
-
*
|
283 |
-
* @param $order
|
284 |
-
* @return boolean|string
|
285 |
-
*/
|
286 |
-
public function getBpostStatus($order){
|
287 |
-
/** @var Bpost_ShM_Model_Api $apiModel */
|
288 |
-
$apiModel = Mage::getModel('bpost_shm/api');
|
289 |
-
$apiModel->initialize($order->getStoreId());
|
290 |
-
$apiResponse = $apiModel->retrieveOrderDetails($order);
|
291 |
-
|
292 |
-
if(!$apiResponse){
|
293 |
-
return false;
|
294 |
-
}
|
295 |
-
|
296 |
-
$xml = simplexml_load_string($apiResponse->getBody());
|
297 |
-
$statuses = array();
|
298 |
-
|
299 |
-
foreach($xml->box as $box){
|
300 |
-
if($box->barcode){
|
301 |
-
$statuses[(string)$box->barcode] = (string)$box->status;
|
302 |
-
}
|
303 |
-
}
|
304 |
-
|
305 |
-
if(empty($statuses)){
|
306 |
-
return false;
|
307 |
-
}
|
308 |
-
|
309 |
-
return $statuses;
|
310 |
-
}
|
311 |
-
|
312 |
-
/**
|
313 |
-
* Gets all spots from bpost webservice based on shipping address or coordinates
|
314 |
-
*
|
315 |
-
* @param $params
|
316 |
-
* @return mixed
|
317 |
-
*/
|
318 |
-
public function getBpostSpots($params = array())
|
319 |
-
{
|
320 |
-
$request = Mage::app()->getRequest();
|
321 |
-
$bpostHelper = Mage::helper("bpost_shm");
|
322 |
-
$bpostGmapsFilter = $request->getPost("bpost-gmaps-filter");
|
323 |
-
$latitude = $request->getPost("lat");
|
324 |
-
$longitude = $request->getPost("lng");
|
325 |
-
$apiModel = Mage::getModel('bpost_shm/api', true);
|
326 |
-
$latLng = false;
|
327 |
-
$pointType = 3;
|
328 |
-
|
329 |
-
if(isset($params["pointType"])){
|
330 |
-
$pointType = $params["pointType"];
|
331 |
-
}
|
332 |
-
|
333 |
-
if(strlen($bpostGmapsFilter) > 0 || ($latitude && $longitude)) {
|
334 |
-
// Use google geocoding to get spots
|
335 |
-
if($bpostGmapsFilter) {
|
336 |
-
// Call map with filtered result
|
337 |
-
$geoCode = Mage::getModel("bpost_shm/shipping_geocode")->callGoogleMaps($bpostGmapsFilter);
|
338 |
-
} else {
|
339 |
-
// Call map with coordinates
|
340 |
-
$geoCode = Mage::getModel("bpost_shm/shipping_geocode")->callGoogleMaps(false, $latitude, $longitude);
|
341 |
-
}
|
342 |
-
|
343 |
-
if ($geoCode) {
|
344 |
-
$address = array();
|
345 |
-
$address['street'] = '';
|
346 |
-
$address['number'] = '';
|
347 |
-
$address['zone'] = $geoCode->getPostalCode();
|
348 |
-
|
349 |
-
$latLng = $geoCode->getLatLng();
|
350 |
-
}
|
351 |
-
} else {
|
352 |
-
|
353 |
-
if($bpostHelper->isOnestepCheckout()){
|
354 |
-
if(isset($params["address_id"]) && $params["address_id"] != null){
|
355 |
-
//load customer address and use
|
356 |
-
$shippingAddress = Mage::getModel("customer/address")->load($params["address_id"]);
|
357 |
-
}else{
|
358 |
-
$shippingAddress = Mage::getModel("customer/address");
|
359 |
-
|
360 |
-
if(isset($params["city"]) && $params["city"] != ""){
|
361 |
-
$shippingAddress->setCity($params["city"]);
|
362 |
-
}
|
363 |
-
|
364 |
-
if(isset($params["postcode"]) && $params["postcode"] != ""){
|
365 |
-
$shippingAddress->setPostcode($params["postcode"]);
|
366 |
-
}
|
367 |
-
|
368 |
-
if(isset($params["street"]) && $params["street"] != ""){
|
369 |
-
$shippingAddress->setStreet($params["street"]);
|
370 |
-
}
|
371 |
-
}
|
372 |
-
}else{
|
373 |
-
// Get shipping address from quote object
|
374 |
-
$shippingAddress = Mage::getSingleton('checkout/session')->getQuote()->getShippingAddress();
|
375 |
-
}
|
376 |
-
|
377 |
-
$searchString = $shippingAddress->getStreet(1).', '.$shippingAddress->getPostcode().', '.$shippingAddress->getCountry();
|
378 |
-
$geoCode = Mage::getModel("bpost_shm/shipping_geocode")->callGoogleMaps($searchString);
|
379 |
-
|
380 |
-
if(is_object($geoCode) && $geoCode->getLatLng() != "" && $geoCode->getLatLng() != null){
|
381 |
-
$latLng = $geoCode->getLatLng();
|
382 |
-
}
|
383 |
-
else{
|
384 |
-
return $geoCode;
|
385 |
-
}
|
386 |
-
|
387 |
-
|
388 |
-
$address = $this->formatShippingAddress($shippingAddress);
|
389 |
-
}
|
390 |
-
|
391 |
-
try{
|
392 |
-
$spots['poiList'] = $apiModel->getNearestServicePoints($address, $pointType);
|
393 |
-
$spots['coordinates'] = $latLng;
|
394 |
-
}catch (Exception $e){
|
395 |
-
$bpostHelper->log("Webservice: not expected result returned:" . $e->getMessage(), Zend_Log::WARN);
|
396 |
-
$spots = false;
|
397 |
-
$spots['poiList'] = false;
|
398 |
-
$spots['coordinates'] = $latLng;
|
399 |
-
}
|
400 |
-
|
401 |
-
return $spots;
|
402 |
-
}
|
403 |
-
|
404 |
-
/**
|
405 |
-
* Gets opening hours of a specific bpost spot
|
406 |
-
*
|
407 |
-
* @param $id
|
408 |
-
* @param $type
|
409 |
-
* @return mixed
|
410 |
-
*/
|
411 |
-
public function getBpostOpeningHours($id, $type) {
|
412 |
-
$cache = Mage::app()->getCache();
|
413 |
-
$key = 'bpost-shm-opening-hours-spotid-' . $id . '-type-' . $type;
|
414 |
-
|
415 |
-
if(!$data = $cache->load($key)) {
|
416 |
-
$apiCall = Mage::getModel('bpost_shm/api', true)->getServicePointDetails($id, $type);
|
417 |
-
|
418 |
-
$data = serialize($apiCall);
|
419 |
-
//set cache lifetime to null (infinite) as it should only be cleared by changing the rule
|
420 |
-
$cache->save(urlencode($data), $key, array("bpost_shm"), 86400);
|
421 |
-
} else {
|
422 |
-
$apiCall = unserialize(urldecode($data));
|
423 |
-
}
|
424 |
-
|
425 |
-
return $apiCall;
|
426 |
-
}
|
427 |
-
|
428 |
-
/**
|
429 |
-
* Formats the shipping address into a formatted array
|
430 |
-
*
|
431 |
-
* @param $address
|
432 |
-
* @return array
|
433 |
-
*/
|
434 |
-
public function formatShippingAddress($address){
|
435 |
-
$formattedAddress = array();
|
436 |
-
$number = explode(",", $address->getStreet(1));
|
437 |
-
|
438 |
-
if (is_numeric($number[0])) {
|
439 |
-
$replace = array($number[0], ",");
|
440 |
-
if ($address->getStreet(1) != "") {
|
441 |
-
$street = str_replace($replace, array('', ''), $address->getStreet(1));
|
442 |
-
}
|
443 |
-
$formattedAddress['street'] = trim($street);
|
444 |
-
$formattedAddress['number'] = trim($number[0]);
|
445 |
-
} else {
|
446 |
-
if ($address->getStreet(1) != "") {
|
447 |
-
$number = explode(" ", $address->getStreet(1));
|
448 |
-
$street = str_replace(end($number), "", $address->getStreet(1));
|
449 |
-
}
|
450 |
-
|
451 |
-
if (preg_match('~[0-9]~', end($number))) {
|
452 |
-
$formattedAddress['street'] = $street;
|
453 |
-
$formattedAddress['number'] = end($number);
|
454 |
-
} else {
|
455 |
-
if ($address->getStreet(1) != "") {
|
456 |
-
$formattedAddress['street'] = $address->getStreet(1);
|
457 |
-
}
|
458 |
-
}
|
459 |
-
}
|
460 |
-
|
461 |
-
if ($address->getStreet(2) != "") {
|
462 |
-
$formattedAddress['street'] = $address->getStreet(1);
|
463 |
-
$formattedAddress['number'] = ",";
|
464 |
-
}
|
465 |
-
|
466 |
-
$formattedAddress['street'] = trim($formattedAddress['street']);
|
467 |
-
$formattedAddress['zone'] = $address->getPostcode() ?: $address->getCity();
|
468 |
-
$formattedAddress['postcode'] = $address->getPostcode();
|
469 |
-
$formattedAddress['city'] = $address->getCity();
|
470 |
-
|
471 |
-
return $formattedAddress;
|
472 |
-
}
|
473 |
-
|
474 |
-
/**
|
475 |
-
* @return string
|
476 |
-
*/
|
477 |
-
public function getMagentoWindowCssItemType(){
|
478 |
-
if (Mage::getVersion() < '1.7' || Mage::getVersion() < '1.9' && Mage::getEdition() == 'Community' || Mage::getVersion() < '1.14' && Mage::getEdition() == 'Enterprise') {
|
479 |
-
return 'js_css';
|
480 |
-
} else {
|
481 |
-
return 'skin_css';
|
482 |
-
}
|
483 |
-
}
|
484 |
-
|
485 |
-
/**
|
486 |
-
* @return string
|
487 |
-
*/
|
488 |
-
public function getMageWindowCss()
|
489 |
-
{
|
490 |
-
if (Mage::getVersion() < '1.7' || Mage::getVersion() < '1.9' && Mage::getEdition() == 'Community' || Mage::getVersion() < '1.14' && Mage::getEdition() == 'Enterprise') {
|
491 |
-
return 'prototype/windows/themes/magento.css';
|
492 |
-
} else {
|
493 |
-
return 'lib/prototype/windows/themes/magento.css';
|
494 |
-
}
|
495 |
-
}
|
496 |
-
|
497 |
-
/**
|
498 |
-
* Function gives filename by path, alternative for basename (GrumPHP)
|
499 |
-
*
|
500 |
-
* @param $path
|
501 |
-
* @return array
|
502 |
-
*/
|
503 |
-
public function getFileNameByPath($path){
|
504 |
-
$fileName = explode("/", $path);
|
505 |
-
$fileName = $fileName[(count($fileName)-1)];
|
506 |
-
|
507 |
-
return $fileName;
|
508 |
-
}
|
509 |
-
|
510 |
-
/**
|
511 |
-
* Returns all valid delivery dates
|
512 |
-
*
|
513 |
-
* @param $closedOn
|
514 |
-
* @return array
|
515 |
-
*/
|
516 |
-
public function getBpostShippingDates($closedOn = false)
|
517 |
-
{
|
518 |
-
//quote object
|
519 |
-
$quote = Mage::getSingleton('checkout/session')->getQuote();
|
520 |
-
$grandTotal = $quote->getGrandTotal();
|
521 |
-
$shippingCost = $quote->getShippingAddress()->getData('shipping_incl_tax');
|
522 |
-
//bpost helper
|
523 |
-
$helper = Mage::helper('bpost_shm');
|
524 |
-
//get config values
|
525 |
-
$configHelper = Mage::helper("bpost_shm/system_config");
|
526 |
-
$displayDeliveryDate = (bool)$configHelper->getBpostShippingConfig("display_delivery_date", Mage::app()->getStore()->getId());
|
527 |
-
$chooseDeliveryDate = (bool)$configHelper->getBpostShippingConfig("choose_delivery_date", Mage::app()->getStore()->getId());
|
528 |
-
$daysBetweenShipment = $configHelper->getBpostShippingConfig("days_between_order_and_shipment", Mage::app()->getStore()->getId());
|
529 |
-
$nrOfDaysShown = $configHelper->getBpostShippingConfig("nr_of_delivery_days_shown", Mage::app()->getStore()->getId());
|
530 |
-
$cutoffTime = $configHelper->getBpostShippingConfig("next_day_delivery_allowed_till", Mage::app()->getStore()->getId());
|
531 |
-
//get the Magento date model
|
532 |
-
$dateModel = Mage::getSingleton('core/date');
|
533 |
-
//days to add counter, will always be 1 since delivery is never on the same day
|
534 |
-
$daysToStart = 1;
|
535 |
-
//add a day if the current time surpasses the time treshold
|
536 |
-
$time = $dateModel->date('H,i');
|
537 |
-
if($cutoffTime <= $time && substr($cutoffTime, 0, 5) != '00,00') {
|
538 |
-
$daysToStart = 2;
|
539 |
-
}
|
540 |
-
//get the current date
|
541 |
-
$currentDate = $dateModel->date();
|
542 |
-
//define all bpost shipping methods
|
543 |
-
$shippingMethods = array(
|
544 |
-
'bpost_homedelivery' => false,
|
545 |
-
'bpost_pickuppoint' => false,
|
546 |
-
'bpost_parcellocker' => false,
|
547 |
-
'bpost_clickcollect' => false
|
548 |
-
);
|
549 |
-
foreach ($shippingMethods as $method => $value) {
|
550 |
-
//get saturday delivery flags
|
551 |
-
$saturdayDelivery = (bool)$configHelper->getBpostCarriersConfig("saturday_delivery", $method, Mage::app()->getStore()->getId());
|
552 |
-
$saturdayDeliveryFrom = $this->formatSaturdayDeliveryCost($configHelper->getBpostCarriersConfig("saturday_delivery_from", $method, Mage::app()->getStore()->getId()));
|
553 |
-
//don't allow saturday delivery if saturday delivery 'yes' and 'as from' amount not exceeded
|
554 |
-
if(($grandTotal - $shippingCost) < $saturdayDeliveryFrom) {
|
555 |
-
$saturdayDelivery = false;
|
556 |
-
}
|
557 |
-
$extraDays = $daysToStart;
|
558 |
-
//add total days between order and shipment
|
559 |
-
$totalDays = $extraDays + $daysBetweenShipment;
|
560 |
-
//loop over days checking for the first valid day
|
561 |
-
for($i = 1; $i <= $totalDays; $i++) {
|
562 |
-
$nextDate = $this->_formatDeliveryDate($currentDate.' +'.$i.' days');
|
563 |
-
|
564 |
-
if(!$this->_isValidDeliveryDate($nextDate, $saturdayDelivery, $method, $closedOn)) {
|
565 |
-
$totalDays++;
|
566 |
-
}
|
567 |
-
}
|
568 |
-
$startDate = $this->_formatDeliveryDate($currentDate.' +'.$totalDays.' days');
|
569 |
-
//customer gets a date from the system
|
570 |
-
if($displayDeliveryDate && !$chooseDeliveryDate) {
|
571 |
-
$shippingMethods[$method] = array(
|
572 |
-
'date' => $this->_formatDeliveryDate($startDate),
|
573 |
-
'date_format' => $helper->__($this->_formatDeliveryDate($startDate, 'l'))." ".$this->_formatDeliveryDate($startDate, 'd/m'),
|
574 |
-
'is_saturday' => $this->_isSaturday($startDate),
|
575 |
-
'next_date' => $this->_getNextDeliveryDate($startDate),
|
576 |
-
'next_date_format' => $helper->__($this->_getNextDeliveryDate($startDate, 'l'))." ".$this->_getNextDeliveryDate($startDate, 'd/m')
|
577 |
-
);
|
578 |
-
//customer can choose own date
|
579 |
-
} else if($displayDeliveryDate && $chooseDeliveryDate) {
|
580 |
-
$days = array();
|
581 |
-
$addedDays = 0;
|
582 |
-
for($i = 0; $i < $nrOfDaysShown; $i++) {
|
583 |
-
//add starting date to array
|
584 |
-
if($i == 0) {
|
585 |
-
$days[$i] = array(
|
586 |
-
'date' => $startDate,
|
587 |
-
'date_format' => $helper->__($this->_formatDeliveryDate($startDate, 'l')).'<span>'.$this->_formatDeliveryDate($startDate, 'j')." ".strtolower($helper->__($this->_formatDeliveryDate($startDate, 'F'))).'</span>'
|
588 |
-
);
|
589 |
-
//move to next day
|
590 |
-
} else {
|
591 |
-
$addedDays++;
|
592 |
-
$nextDate = $this->_formatDeliveryDate($startDate.' +'.$addedDays.' days');
|
593 |
-
$validDate = false;
|
594 |
-
while($validDate == false) {
|
595 |
-
if($this->_isValidDeliveryDate($nextDate, $saturdayDelivery, $method, $closedOn)) {
|
596 |
-
$validDate = true;
|
597 |
-
} else {
|
598 |
-
$addedDays++;
|
599 |
-
$nextDate = $this->_formatDeliveryDate($startDate.' +'.$addedDays.' days');
|
600 |
-
}
|
601 |
-
}
|
602 |
-
$days[$i] = array(
|
603 |
-
'date' => $nextDate,
|
604 |
-
'date_format' => $helper->__($this->_formatDeliveryDate($nextDate, 'l')).'<span>'.$this->_formatDeliveryDate($nextDate, 'j')." ".strtolower($helper->__($this->_formatDeliveryDate($nextDate, 'F'))).'</span>'
|
605 |
-
);
|
606 |
-
}
|
607 |
-
}
|
608 |
-
$shippingMethods[$method] = $days;
|
609 |
-
}
|
610 |
-
}
|
611 |
-
return $shippingMethods;
|
612 |
-
}
|
613 |
-
|
614 |
-
|
615 |
-
/**
|
616 |
-
* @return date
|
617 |
-
*/
|
618 |
-
public function getPrevDeliveryDate($deliveryDate){
|
619 |
-
$days = 1;
|
620 |
-
$validDate = false;
|
621 |
-
$previousWeekday = $this->_formatDeliveryDate($deliveryDate.' -'.$days.' weekdays');
|
622 |
-
|
623 |
-
while($validDate == false) {
|
624 |
-
if($this->_isValidDeliveryDate($previousWeekday)) {
|
625 |
-
$validDate = true;
|
626 |
-
} else {
|
627 |
-
$days++;
|
628 |
-
$previousWeekday = $this->_formatDeliveryDate($deliveryDate.' -'.$days.' weekdays');
|
629 |
-
}
|
630 |
-
}
|
631 |
-
|
632 |
-
return $previousWeekday;
|
633 |
-
}
|
634 |
-
|
635 |
-
|
636 |
-
/**
|
637 |
-
* Returns the next first valid delivery date
|
638 |
-
*
|
639 |
-
* @param $date
|
640 |
-
* @param $format
|
641 |
-
* @return array
|
642 |
-
*/
|
643 |
-
protected function _getNextDeliveryDate($date, $format = "Y-m-d") {
|
644 |
-
$nextDate = false;
|
645 |
-
|
646 |
-
if($this->_isSaturday($date)) {
|
647 |
-
//add a weekday so we end up on monday
|
648 |
-
$extraWeekDays = 1;
|
649 |
-
$nextDate = $this->_formatDeliveryDate("$date +$extraWeekDays weekdays");
|
650 |
-
|
651 |
-
//check for holidays (monday will most likely not be a saturday or a sunday, and holidays sadly don't take a week)
|
652 |
-
$validDeliveryDate = false;
|
653 |
-
while($validDeliveryDate == false) {
|
654 |
-
if($this->_isValidDeliveryDate($nextDate)) {
|
655 |
-
$validDeliveryDate = true;
|
656 |
-
} else {
|
657 |
-
$extraWeekDays++;
|
658 |
-
$nextDate = $this->_formatDeliveryDate("$date +$extraWeekDays weekdays");
|
659 |
-
}
|
660 |
-
}
|
661 |
-
|
662 |
-
$nextDate = $this->_formatDeliveryDate($nextDate, $format);
|
663 |
-
}
|
664 |
-
|
665 |
-
return $nextDate;
|
666 |
-
}
|
667 |
-
|
668 |
-
|
669 |
-
protected function _isValidDeliveryDate($deliveryDate, $saturdayAllowed = false, $method = false, $closedOn = false) {
|
670 |
-
if($this->_isHoliday($deliveryDate)) {
|
671 |
-
return false;
|
672 |
-
}
|
673 |
-
if($this->_isSunday($deliveryDate)) {
|
674 |
-
return false;
|
675 |
-
}
|
676 |
-
if(!$saturdayAllowed && $this->_isSaturday($deliveryDate)) {
|
677 |
-
return false;
|
678 |
-
}
|
679 |
-
if($method == 'bpost_pickuppoint') {
|
680 |
-
//check if pick-up point is open on this day
|
681 |
-
if(is_array($closedOn)) {
|
682 |
-
$day = $this->_formatDeliveryDate($deliveryDate, 'l');
|
683 |
-
|
684 |
-
if(in_array($day, $closedOn)) {
|
685 |
-
return false;
|
686 |
-
}
|
687 |
-
}
|
688 |
-
}
|
689 |
-
|
690 |
-
if($method == 'bpost_clickcollect') {
|
691 |
-
//check if pick-up point is open on this day
|
692 |
-
if(is_array($closedOn)) {
|
693 |
-
$day = $this->_formatDeliveryDate($deliveryDate, 'l');
|
694 |
-
|
695 |
-
if(in_array($day, $closedOn)) {
|
696 |
-
return false;
|
697 |
-
}
|
698 |
-
}
|
699 |
-
}
|
700 |
-
|
701 |
-
return true;
|
702 |
-
}
|
703 |
-
|
704 |
-
|
705 |
-
/**
|
706 |
-
* Check if date is on a saturday
|
707 |
-
*
|
708 |
-
* @param $date
|
709 |
-
* @return bool
|
710 |
-
*/
|
711 |
-
protected function _isSaturday($date)
|
712 |
-
{
|
713 |
-
return ($this->_formatDeliveryDate($date, "N") == 6);
|
714 |
-
}
|
715 |
-
|
716 |
-
/**
|
717 |
-
* Check if date is on a sunday
|
718 |
-
*
|
719 |
-
* @param $date
|
720 |
-
* @return bool
|
721 |
-
*/
|
722 |
-
protected function _isSunday($date)
|
723 |
-
{
|
724 |
-
return ($this->_formatDeliveryDate($date, "N") == 7);
|
725 |
-
}
|
726 |
-
|
727 |
-
/**
|
728 |
-
* Check if date is a holiday (according to Belgian holidays)
|
729 |
-
*
|
730 |
-
* @param $date
|
731 |
-
* @return bool
|
732 |
-
*/
|
733 |
-
protected function _isHoliday($date)
|
734 |
-
{
|
735 |
-
$holidays = Mage::getModel('bpost_shm/holidays')->getCollection()->getHolidays();
|
736 |
-
|
737 |
-
if(in_array($date, $holidays)) {
|
738 |
-
return true;
|
739 |
-
}
|
740 |
-
|
741 |
-
return false;
|
742 |
-
}
|
743 |
-
|
744 |
-
|
745 |
-
/**
|
746 |
-
* Format the delivery date to any format (default: Y-m-d)
|
747 |
-
*
|
748 |
-
* @param $date
|
749 |
-
* @param $format
|
750 |
-
* @return date
|
751 |
-
*/
|
752 |
-
protected function _formatDeliveryDate($date, $format = "Y-m-d") {
|
753 |
-
return date($format, strtotime($date));
|
754 |
-
}
|
755 |
-
|
756 |
-
/**
|
757 |
-
* Format the saturday delivery cost
|
758 |
-
*
|
759 |
-
* @param $value
|
760 |
-
* @return bool|float
|
761 |
-
*/
|
762 |
-
public function formatSaturdayDeliveryCost($value)
|
763 |
-
{
|
764 |
-
$value = str_replace(',', '.', $value);
|
765 |
-
if (!is_numeric($value)) {
|
766 |
-
return false;
|
767 |
-
}
|
768 |
-
$value = (float)sprintf('%.4F', $value);
|
769 |
-
if ($value < 0.0000) {
|
770 |
-
return false;
|
771 |
-
}
|
772 |
-
return $value;
|
773 |
-
}
|
774 |
-
|
775 |
-
/**
|
776 |
-
* Check if on Onestepcheckout page or if Onestepcheckout is the refferer
|
777 |
-
*
|
778 |
-
* @return bool
|
779 |
-
*/
|
780 |
-
public function isOnestepCheckout()
|
781 |
-
{
|
782 |
-
if (strpos(Mage::helper("core/url")->getCurrentUrl(), 'onestepcheckout') !== false || strpos(Mage::app()->getRequest()->getHeader('referer'), 'onestepcheckout') !== false) {
|
783 |
-
return true;
|
784 |
-
}
|
785 |
-
|
786 |
-
return false;
|
787 |
-
}
|
788 |
-
|
789 |
-
/**
|
790 |
-
* Get Onestepcheckout version
|
791 |
-
*
|
792 |
-
* @return string
|
793 |
-
*/
|
794 |
-
public function getOnestepCheckoutVersion()
|
795 |
-
{
|
796 |
-
$version = Mage::getConfig()->getNode()->modules->Idev_OneStepCheckout->version;
|
797 |
-
list($major, $minor) = explode('.', $version);
|
798 |
-
|
799 |
-
return (string) $major . '.' . $minor;
|
800 |
-
}
|
801 |
-
|
802 |
-
/**
|
803 |
-
* Calculates total weight of a shipment.
|
804 |
-
*
|
805 |
-
* @param $shipment
|
806 |
-
* @return int
|
807 |
-
*/
|
808 |
-
public function calculateTotalShippingWeight($shipment)
|
809 |
-
{
|
810 |
-
$weight = 0;
|
811 |
-
$shipmentItems = $shipment->getAllItems();
|
812 |
-
foreach ($shipmentItems as $shipmentItem) {
|
813 |
-
$orderItem = $shipmentItem->getOrderItem();
|
814 |
-
if (!$orderItem->getParentItemId()) {
|
815 |
-
$weight = $weight + ($shipmentItem->getWeight() * $shipmentItem->getQty());
|
816 |
-
}
|
817 |
-
}
|
818 |
-
|
819 |
-
return $weight;
|
820 |
-
}
|
821 |
-
|
822 |
-
|
823 |
-
/**
|
824 |
-
* @param $shipments
|
825 |
-
* @return int
|
826 |
-
*/
|
827 |
-
public function processShipmentsWeight($order)
|
828 |
-
{
|
829 |
-
$bpostHelper = Mage::helper("bpost_shm/system_config");
|
830 |
-
$weightUnit = $bpostHelper->getBpostShippingConfig("weight_unit", $order->getStoreId());
|
831 |
-
|
832 |
-
$totalShipmentsWeight = 0;
|
833 |
-
|
834 |
-
$shipmentCollection = Mage::getModel("sales/order_shipment")->getCollection()
|
835 |
-
->addFieldToFilter("order_id", $order->getId());
|
836 |
-
|
837 |
-
foreach ($shipmentCollection as $shipment){
|
838 |
-
if ($weightUnit == "") {
|
839 |
-
$totalShipmentsWeight += $shipment->getTotalWeight() * 100;
|
840 |
-
} else {
|
841 |
-
$totalShipmentsWeight += $shipment->getTotalWeight() * $weightUnit;
|
842 |
-
}
|
843 |
-
}
|
844 |
-
|
845 |
-
return $totalShipmentsWeight;
|
846 |
-
}
|
847 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Created by PHPro
|
5 |
+
*
|
6 |
+
* @package Bpost
|
7 |
+
* @subpackage ShM
|
8 |
+
* @author PHPro (info@phpro.be)
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Class Bpost_ShM_Helper_Data
|
13 |
+
*/
|
14 |
+
class Bpost_ShM_Helper_Data extends Mage_Core_Helper_Abstract
|
15 |
+
{
|
16 |
+
/**
|
17 |
+
* Standard shm logging
|
18 |
+
*
|
19 |
+
* @param $message
|
20 |
+
* @param $level
|
21 |
+
* @param $storeId
|
22 |
+
*/
|
23 |
+
public function log($message, $level, $storeId = 0)
|
24 |
+
{
|
25 |
+
$configHelper = Mage::helper("bpost_shm/system_config");
|
26 |
+
$allowedLogLevel = $configHelper->getBpostShippingConfig("log_level", $storeId);
|
27 |
+
|
28 |
+
//first check if logging is enabled
|
29 |
+
if ($configHelper->isLoggingEnabled()) {
|
30 |
+
if ($level <= $allowedLogLevel) {
|
31 |
+
Mage::log($message, $level, 'bpost.log');
|
32 |
+
}
|
33 |
+
}
|
34 |
+
}
|
35 |
+
|
36 |
+
/**
|
37 |
+
* API logging if something goes wrong
|
38 |
+
*
|
39 |
+
* @param $message
|
40 |
+
* @param $level
|
41 |
+
* @param $translate
|
42 |
+
* @param $storeId
|
43 |
+
*/
|
44 |
+
public function ApiLog($message, $level, $translate = true, $storeId = 0)
|
45 |
+
{
|
46 |
+
$configHelper = Mage::helper("bpost_shm/system_config");
|
47 |
+
$allowedLogLevel = $configHelper->getBpostShippingConfig("api_log_level", $storeId);
|
48 |
+
|
49 |
+
//first check if API logging is enabled
|
50 |
+
if ($configHelper->isApiLoggingEnabled()) {
|
51 |
+
if ($level <= $allowedLogLevel) {
|
52 |
+
if($translate){
|
53 |
+
Mage::log($this->__($message), $level, "bpost-api.log");
|
54 |
+
}else{
|
55 |
+
Mage::log($message, $level, "bpost-api.log");
|
56 |
+
}
|
57 |
+
}
|
58 |
+
}
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* Function checks if we have more address lines
|
63 |
+
* If so, we use address 2 as housenumber
|
64 |
+
* Else we need to get housenumber from the single address line
|
65 |
+
*
|
66 |
+
* @param $address
|
67 |
+
* @return $address
|
68 |
+
*/
|
69 |
+
public function formatAddress($address)
|
70 |
+
{
|
71 |
+
$address->setData("bpost_name", $address->getFirstname() . " " . $address->getLastname());
|
72 |
+
$address->setData("bpost_company", $address->getCompany());
|
73 |
+
|
74 |
+
//we assume that street 3 will be box number - not necessary
|
75 |
+
if ($address->getStreet3()) {
|
76 |
+
$address->setData("box_number", $address->getStreet3());
|
77 |
+
}
|
78 |
+
|
79 |
+
if ($address->getStreet2()) {
|
80 |
+
if($address->getData("company") && $address->getData("company") != ""){
|
81 |
+
$address->setData("bpost_company", $address->getData("bpost_name") . " (" . $address->getData("company") . ")");
|
82 |
+
}else{
|
83 |
+
$address->setData("bpost_company", $address->getData("bpost_name"));
|
84 |
+
}
|
85 |
+
|
86 |
+
$address->setData("bpost_name", $address->getStreet2());
|
87 |
+
}
|
88 |
+
|
89 |
+
$address->setData("bpost_house_number", ",");
|
90 |
+
$address->setData("bpost_street", $address->getStreet1());
|
91 |
+
|
92 |
+
return $address;
|
93 |
+
}
|
94 |
+
|
95 |
+
/**
|
96 |
+
* Validate the postal code
|
97 |
+
*
|
98 |
+
* @param $country_id
|
99 |
+
* @param $postcode
|
100 |
+
* @return regex|string
|
101 |
+
*/
|
102 |
+
public function validatePostcode($country_id, $postcode)
|
103 |
+
{
|
104 |
+
$zipValidationRules = array(
|
105 |
+
'LT' => array('99999', '/^(\d{5})$/'),
|
106 |
+
'LU' => array('9999', '/^(\d{4})$/'),
|
107 |
+
'BE' => array('9999', '/^(\d{4})$/'),
|
108 |
+
'LV' => array('9999', '/^(\d{4})$/'),
|
109 |
+
'MT' => array('AAA 9999', '/[A-Z]{3} [0-9]{4}/'),
|
110 |
+
'NL' => array('9999 AA', '/[0-9]{4} [A-Z]{2}/'),
|
111 |
+
'PL' => array('99999', '/^(\d{5})$/'),
|
112 |
+
'PT' => array('9999999', '/^([0-9]){7}$/'),
|
113 |
+
'RO' => array('999999', '/^(\d{6})$/'),
|
114 |
+
'SE' => array('999 99', '/^(\d{3} \d{2})$/'),
|
115 |
+
'SI' => array('9999', '/^(\d{4})$/'),
|
116 |
+
'SK' => array('999 99', '/^(\d{3} \d{2})$/'),
|
117 |
+
'AT' => array('9999', '/^(\d{4})$/'),
|
118 |
+
'BG' => array('9999', '/^(\d{4})$/'),
|
119 |
+
'CZ' => array('999 99', '/^[0-9]{3} [0-9]{2}$/'),
|
120 |
+
'DE' => array('99999', '/^(\d{5})$/'),
|
121 |
+
'DK' => array('9999', '/^(\d{4})$/'),
|
122 |
+
'EE' => array('99999', '/^(\d{5})$/'),
|
123 |
+
'ES' => array('99999', '/^(\d{5})$/'),
|
124 |
+
'FI' => array('99999', '/^(\d{5})$/'),
|
125 |
+
'FR' => array('99999', '/^(\d{5})$/'),
|
126 |
+
'GR' => array('999 99', '/^(\d{3}) \d{2}$/'),
|
127 |
+
'HR' => array('99999', '/^(\d{5})$/'),
|
128 |
+
'HU' => array('9999', '/^(\d{4})$/'),
|
129 |
+
'IT' => array('99999', '/^(\d{5})$/')
|
130 |
+
);
|
131 |
+
if (array_key_exists($country_id, $zipValidationRules)) {
|
132 |
+
$validationRegex = $zipValidationRules[$country_id][1];
|
133 |
+
$validationFormat = $zipValidationRules[$country_id][0];
|
134 |
+
|
135 |
+
if (!preg_match($validationRegex, $postcode)) {
|
136 |
+
return $validationFormat;
|
137 |
+
}
|
138 |
+
}
|
139 |
+
return 'passed';
|
140 |
+
}
|
141 |
+
|
142 |
+
/**
|
143 |
+
* Creates new IO object and inputs base 64 pdf string fetched from webservice.
|
144 |
+
*
|
145 |
+
* @param $pdfString
|
146 |
+
* @param $folder
|
147 |
+
* @param $name
|
148 |
+
*
|
149 |
+
* @return string
|
150 |
+
*/
|
151 |
+
public function generatePdfAndSave($pdfString, $folder, $name)
|
152 |
+
{
|
153 |
+
$hash = bin2hex(mcrypt_create_iv(5, MCRYPT_DEV_URANDOM));
|
154 |
+
$name = $name . "-" . $hash;
|
155 |
+
|
156 |
+
$varienFile = new Varien_Io_File();
|
157 |
+
$varienFile->setAllowCreateFolders(true);
|
158 |
+
$varienFile->open(array('path' => Mage::getBaseDir('media') . "/bpost/" . $folder));
|
159 |
+
$varienFile->streamOpen($name . '.pdf', 'w+');
|
160 |
+
$varienFile->streamLock(true);
|
161 |
+
$varienFile->streamWrite($pdfString);
|
162 |
+
$varienFile->streamUnlock();
|
163 |
+
$varienFile->streamClose();
|
164 |
+
return $name;
|
165 |
+
}
|
166 |
+
|
167 |
+
/**
|
168 |
+
* Function returns the locale code by order
|
169 |
+
*
|
170 |
+
* @param $order
|
171 |
+
* @param $useExceptionLanguage
|
172 |
+
* @return string
|
173 |
+
*/
|
174 |
+
public function getLocaleByOrder($order, $useExceptionLanguage = false)
|
175 |
+
{
|
176 |
+
$exceptionLanguages = array("DE");
|
177 |
+
|
178 |
+
$store = $order->getStore()->getId();
|
179 |
+
$locale = Mage::getStoreConfig("general/locale/code", $store);
|
180 |
+
$locale = strtoupper(substr($locale, 0, 2));
|
181 |
+
|
182 |
+
switch ($locale) {
|
183 |
+
case "NL":
|
184 |
+
case "FR":
|
185 |
+
case "EN":
|
186 |
+
return $locale;
|
187 |
+
break;
|
188 |
+
|
189 |
+
default:
|
190 |
+
if ($useExceptionLanguage && in_array($locale, $exceptionLanguages)) {
|
191 |
+
return $locale;
|
192 |
+
}
|
193 |
+
|
194 |
+
return "EN";
|
195 |
+
break;
|
196 |
+
}
|
197 |
+
}
|
198 |
+
|
199 |
+
/**
|
200 |
+
* Function parses the create label API response in a readable format
|
201 |
+
*
|
202 |
+
* @param $response
|
203 |
+
* @return array
|
204 |
+
*/
|
205 |
+
public function parseLabelApiResponse($response, $order){
|
206 |
+
$xml = simplexml_load_string($response->getBody());
|
207 |
+
$shippingMethod = $order->getShippingMethod();
|
208 |
+
$returnArray = array();
|
209 |
+
$returnArray["barcodeString"] = array();
|
210 |
+
|
211 |
+
//international delivery can have more label elements (instead of one with multiple barcodes), so we have to loop
|
212 |
+
foreach($xml->label as $label){
|
213 |
+
$responseBarcodeArray = (array)$label->barcode;
|
214 |
+
|
215 |
+
//we check for barcodes
|
216 |
+
//for national delivery
|
217 |
+
//barcodes ending on 030 -> regular barcode
|
218 |
+
//barcodes ending on 050 -> return barcode
|
219 |
+
|
220 |
+
//for international delivery
|
221 |
+
//barcodes starting with CD -> regular barcode, no return
|
222 |
+
|
223 |
+
//international delivery has other barcodes
|
224 |
+
//check on barcode count label
|
225 |
+
//if more than 1 -> national, otherwise international
|
226 |
+
|
227 |
+
foreach($responseBarcodeArray as $responseBarcode){
|
228 |
+
$responseBarcode = (string)$responseBarcode;
|
229 |
+
|
230 |
+
$firstTwoCharacters = substr($responseBarcode, 0, 2);
|
231 |
+
$lastThreeCharacters = substr($responseBarcode, -3);
|
232 |
+
|
233 |
+
switch($shippingMethod){
|
234 |
+
case "bpostshm_bpost_international":
|
235 |
+
if(in_array($firstTwoCharacters, array("CD","EE","CE")) && $lastThreeCharacters != '134'){
|
236 |
+
$returnArray["barcodeString"][] = $responseBarcode;
|
237 |
+
}else{
|
238 |
+
if(!isset($returnArray["returnBarcodeString"])){
|
239 |
+
$returnArray["returnBarcodeString"] = array();
|
240 |
+
}
|
241 |
+
$returnArray["returnBarcodeString"][] = $responseBarcode;
|
242 |
+
}
|
243 |
+
break;
|
244 |
+
|
245 |
+
default:
|
246 |
+
if($lastThreeCharacters == "050"){
|
247 |
+
if(!isset($returnArray["returnBarcodeString"])){
|
248 |
+
$returnArray["returnBarcodeString"] = array();
|
249 |
+
}
|
250 |
+
$returnArray["returnBarcodeString"][] = $responseBarcode;
|
251 |
+
}else{
|
252 |
+
$returnArray["barcodeString"][] = $responseBarcode;
|
253 |
+
}
|
254 |
+
break;
|
255 |
+
}
|
256 |
+
}
|
257 |
+
|
258 |
+
$pdfString = $label->bytes;
|
259 |
+
|
260 |
+
//we use the Zend_XmlRpc_Value_Base64 for decoding our string
|
261 |
+
$zendXmlRpc = new Zend_XmlRpc_Value_Base64($pdfString, true);
|
262 |
+
$pdfString = $zendXmlRpc->getValue();
|
263 |
+
|
264 |
+
if(!isset($returnArray["pdfString"])){
|
265 |
+
$returnArray["pdfString"] = array();
|
266 |
+
$returnArray["pdfString"][] = $pdfString;
|
267 |
+
}else{
|
268 |
+
$returnArray["pdfString"][] = $pdfString;
|
269 |
+
}
|
270 |
+
}
|
271 |
+
|
272 |
+
//make sure the index barcode string isset
|
273 |
+
if(empty($returnArray["barcodeString"])){
|
274 |
+
$returnArray["barcodeString"][] = $order->getBpostReference();
|
275 |
+
}
|
276 |
+
|
277 |
+
return $returnArray;
|
278 |
+
}
|
279 |
+
|
280 |
+
/**
|
281 |
+
* API function returns the bpost status
|
282 |
+
*
|
283 |
+
* @param $order
|
284 |
+
* @return boolean|string
|
285 |
+
*/
|
286 |
+
public function getBpostStatus($order){
|
287 |
+
/** @var Bpost_ShM_Model_Api $apiModel */
|
288 |
+
$apiModel = Mage::getModel('bpost_shm/api');
|
289 |
+
$apiModel->initialize($order->getStoreId());
|
290 |
+
$apiResponse = $apiModel->retrieveOrderDetails($order);
|
291 |
+
|
292 |
+
if(!$apiResponse){
|
293 |
+
return false;
|
294 |
+
}
|
295 |
+
|
296 |
+
$xml = simplexml_load_string($apiResponse->getBody());
|
297 |
+
$statuses = array();
|
298 |
+
|
299 |
+
foreach($xml->box as $box){
|
300 |
+
if($box->barcode){
|
301 |
+
$statuses[(string)$box->barcode] = (string)$box->status;
|
302 |
+
}
|
303 |
+
}
|
304 |
+
|
305 |
+
if(empty($statuses)){
|
306 |
+
return false;
|
307 |
+
}
|
308 |
+
|
309 |
+
return $statuses;
|
310 |
+
}
|
311 |
+
|
312 |
+
/**
|
313 |
+
* Gets all spots from bpost webservice based on shipping address or coordinates
|
314 |
+
*
|
315 |
+
* @param $params
|
316 |
+
* @return mixed
|
317 |
+
*/
|
318 |
+
public function getBpostSpots($params = array())
|
319 |
+
{
|
320 |
+
$request = Mage::app()->getRequest();
|
321 |
+
$bpostHelper = Mage::helper("bpost_shm");
|
322 |
+
$bpostGmapsFilter = $request->getPost("bpost-gmaps-filter");
|
323 |
+
$latitude = $request->getPost("lat");
|
324 |
+
$longitude = $request->getPost("lng");
|
325 |
+
$apiModel = Mage::getModel('bpost_shm/api', true);
|
326 |
+
$latLng = false;
|
327 |
+
$pointType = 3;
|
328 |
+
|
329 |
+
if(isset($params["pointType"])){
|
330 |
+
$pointType = $params["pointType"];
|
331 |
+
}
|
332 |
+
|
333 |
+
if(strlen($bpostGmapsFilter) > 0 || ($latitude && $longitude)) {
|
334 |
+
// Use google geocoding to get spots
|
335 |
+
if($bpostGmapsFilter) {
|
336 |
+
// Call map with filtered result
|
337 |
+
$geoCode = Mage::getModel("bpost_shm/shipping_geocode")->callGoogleMaps($bpostGmapsFilter);
|
338 |
+
} else {
|
339 |
+
// Call map with coordinates
|
340 |
+
$geoCode = Mage::getModel("bpost_shm/shipping_geocode")->callGoogleMaps(false, $latitude, $longitude);
|
341 |
+
}
|
342 |
+
|
343 |
+
if ($geoCode) {
|
344 |
+
$address = array();
|
345 |
+
$address['street'] = '';
|
346 |
+
$address['number'] = '';
|
347 |
+
$address['zone'] = $geoCode->getPostalCode();
|
348 |
+
|
349 |
+
$latLng = $geoCode->getLatLng();
|
350 |
+
}
|
351 |
+
} else {
|
352 |
+
|
353 |
+
if($bpostHelper->isOnestepCheckout()){
|
354 |
+
if(isset($params["address_id"]) && $params["address_id"] != null){
|
355 |
+
//load customer address and use
|
356 |
+
$shippingAddress = Mage::getModel("customer/address")->load($params["address_id"]);
|
357 |
+
}else{
|
358 |
+
$shippingAddress = Mage::getModel("customer/address");
|
359 |
+
|
360 |
+
if(isset($params["city"]) && $params["city"] != ""){
|
361 |
+
$shippingAddress->setCity($params["city"]);
|
362 |
+
}
|
363 |
+
|
364 |
+
if(isset($params["postcode"]) && $params["postcode"] != ""){
|
365 |
+
$shippingAddress->setPostcode($params["postcode"]);
|
366 |
+
}
|
367 |
+
|
368 |
+
if(isset($params["street"]) && $params["street"] != ""){
|
369 |
+
$shippingAddress->setStreet($params["street"]);
|
370 |
+
}
|
371 |
+
}
|
372 |
+
}else{
|
373 |
+
// Get shipping address from quote object
|
374 |
+
$shippingAddress = Mage::getSingleton('checkout/session')->getQuote()->getShippingAddress();
|
375 |
+
}
|
376 |
+
|
377 |
+
$searchString = $shippingAddress->getStreet(1).', '.$shippingAddress->getPostcode().', '.$shippingAddress->getCountry();
|
378 |
+
$geoCode = Mage::getModel("bpost_shm/shipping_geocode")->callGoogleMaps($searchString);
|
379 |
+
|
380 |
+
if(is_object($geoCode) && $geoCode->getLatLng() != "" && $geoCode->getLatLng() != null){
|
381 |
+
$latLng = $geoCode->getLatLng();
|
382 |
+
}
|
383 |
+
else{
|
384 |
+
return $geoCode;
|
385 |
+
}
|
386 |
+
|
387 |
+
|
388 |
+
$address = $this->formatShippingAddress($shippingAddress);
|
389 |
+
}
|
390 |
+
|
391 |
+
try{
|
392 |
+
$spots['poiList'] = $apiModel->getNearestServicePoints($address, $pointType);
|
393 |
+
$spots['coordinates'] = $latLng;
|
394 |
+
}catch (Exception $e){
|
395 |
+
$bpostHelper->log("Webservice: not expected result returned:" . $e->getMessage(), Zend_Log::WARN);
|
396 |
+
$spots = false;
|
397 |
+
$spots['poiList'] = false;
|
398 |
+
$spots['coordinates'] = $latLng;
|
399 |
+
}
|
400 |
+
|
401 |
+
return $spots;
|
402 |
+
}
|
403 |
+
|
404 |
+
/**
|
405 |
+
* Gets opening hours of a specific bpost spot
|
406 |
+
*
|
407 |
+
* @param $id
|
408 |
+
* @param $type
|
409 |
+
* @return mixed
|
410 |
+
*/
|
411 |
+
public function getBpostOpeningHours($id, $type) {
|
412 |
+
$cache = Mage::app()->getCache();
|
413 |
+
$key = 'bpost-shm-opening-hours-spotid-' . $id . '-type-' . $type;
|
414 |
+
|
415 |
+
if(!$data = $cache->load($key)) {
|
416 |
+
$apiCall = Mage::getModel('bpost_shm/api', true)->getServicePointDetails($id, $type);
|
417 |
+
|
418 |
+
$data = serialize($apiCall);
|
419 |
+
//set cache lifetime to null (infinite) as it should only be cleared by changing the rule
|
420 |
+
$cache->save(urlencode($data), $key, array("bpost_shm"), 86400);
|
421 |
+
} else {
|
422 |
+
$apiCall = unserialize(urldecode($data));
|
423 |
+
}
|
424 |
+
|
425 |
+
return $apiCall;
|
426 |
+
}
|
427 |
+
|
428 |
+
/**
|
429 |
+
* Formats the shipping address into a formatted array
|
430 |
+
*
|
431 |
+
* @param $address
|
432 |
+
* @return array
|
433 |
+
*/
|
434 |
+
public function formatShippingAddress($address){
|
435 |
+
$formattedAddress = array();
|
436 |
+
$number = explode(",", $address->getStreet(1));
|
437 |
+
|
438 |
+
if (is_numeric($number[0])) {
|
439 |
+
$replace = array($number[0], ",");
|
440 |
+
if ($address->getStreet(1) != "") {
|
441 |
+
$street = str_replace($replace, array('', ''), $address->getStreet(1));
|
442 |
+
}
|
443 |
+
$formattedAddress['street'] = trim($street);
|
444 |
+
$formattedAddress['number'] = trim($number[0]);
|
445 |
+
} else {
|
446 |
+
if ($address->getStreet(1) != "") {
|
447 |
+
$number = explode(" ", $address->getStreet(1));
|
448 |
+
$street = str_replace(end($number), "", $address->getStreet(1));
|
449 |
+
}
|
450 |
+
|
451 |
+
if (preg_match('~[0-9]~', end($number))) {
|
452 |
+
$formattedAddress['street'] = $street;
|
453 |
+
$formattedAddress['number'] = end($number);
|
454 |
+
} else {
|
455 |
+
if ($address->getStreet(1) != "") {
|
456 |
+
$formattedAddress['street'] = $address->getStreet(1);
|
457 |
+
}
|
458 |
+
}
|
459 |
+
}
|
460 |
+
|
461 |
+
if ($address->getStreet(2) != "") {
|
462 |
+
$formattedAddress['street'] = $address->getStreet(1);
|
463 |
+
$formattedAddress['number'] = ",";
|
464 |
+
}
|
465 |
+
|
466 |
+
$formattedAddress['street'] = trim($formattedAddress['street']);
|
467 |
+
$formattedAddress['zone'] = $address->getPostcode() ?: $address->getCity();
|
468 |
+
$formattedAddress['postcode'] = $address->getPostcode();
|
469 |
+
$formattedAddress['city'] = $address->getCity();
|
470 |
+
|
471 |
+
return $formattedAddress;
|
472 |
+
}
|
473 |
+
|
474 |
+
/**
|
475 |
+
* @return string
|
476 |
+
*/
|
477 |
+
public function getMagentoWindowCssItemType(){
|
478 |
+
if (Mage::getVersion() < '1.7' || Mage::getVersion() < '1.9' && Mage::getEdition() == 'Community' || Mage::getVersion() < '1.14' && Mage::getEdition() == 'Enterprise') {
|
479 |
+
return 'js_css';
|
480 |
+
} else {
|
481 |
+
return 'skin_css';
|
482 |
+
}
|
483 |
+
}
|
484 |
+
|
485 |
+
/**
|
486 |
+
* @return string
|
487 |
+
*/
|
488 |
+
public function getMageWindowCss()
|
489 |
+
{
|
490 |
+
if (Mage::getVersion() < '1.7' || Mage::getVersion() < '1.9' && Mage::getEdition() == 'Community' || Mage::getVersion() < '1.14' && Mage::getEdition() == 'Enterprise') {
|
491 |
+
return 'prototype/windows/themes/magento.css';
|
492 |
+
} else {
|
493 |
+
return 'lib/prototype/windows/themes/magento.css';
|
494 |
+
}
|
495 |
+
}
|
496 |
+
|
497 |
+
/**
|
498 |
+
* Function gives filename by path, alternative for basename (GrumPHP)
|
499 |
+
*
|
500 |
+
* @param $path
|
501 |
+
* @return array
|
502 |
+
*/
|
503 |
+
public function getFileNameByPath($path){
|
504 |
+
$fileName = explode("/", $path);
|
505 |
+
$fileName = $fileName[(count($fileName)-1)];
|
506 |
+
|
507 |
+
return $fileName;
|
508 |
+
}
|
509 |
+
|
510 |
+
/**
|
511 |
+
* Returns all valid delivery dates
|
512 |
+
*
|
513 |
+
* @param $closedOn
|
514 |
+
* @return array
|
515 |
+
*/
|
516 |
+
public function getBpostShippingDates($closedOn = false)
|
517 |
+
{
|
518 |
+
//quote object
|
519 |
+
$quote = Mage::getSingleton('checkout/session')->getQuote();
|
520 |
+
$grandTotal = $quote->getGrandTotal();
|
521 |
+
$shippingCost = $quote->getShippingAddress()->getData('shipping_incl_tax');
|
522 |
+
//bpost helper
|
523 |
+
$helper = Mage::helper('bpost_shm');
|
524 |
+
//get config values
|
525 |
+
$configHelper = Mage::helper("bpost_shm/system_config");
|
526 |
+
$displayDeliveryDate = (bool)$configHelper->getBpostShippingConfig("display_delivery_date", Mage::app()->getStore()->getId());
|
527 |
+
$chooseDeliveryDate = (bool)$configHelper->getBpostShippingConfig("choose_delivery_date", Mage::app()->getStore()->getId());
|
528 |
+
$daysBetweenShipment = $configHelper->getBpostShippingConfig("days_between_order_and_shipment", Mage::app()->getStore()->getId());
|
529 |
+
$nrOfDaysShown = $configHelper->getBpostShippingConfig("nr_of_delivery_days_shown", Mage::app()->getStore()->getId());
|
530 |
+
$cutoffTime = $configHelper->getBpostShippingConfig("next_day_delivery_allowed_till", Mage::app()->getStore()->getId());
|
531 |
+
//get the Magento date model
|
532 |
+
$dateModel = Mage::getSingleton('core/date');
|
533 |
+
//days to add counter, will always be 1 since delivery is never on the same day
|
534 |
+
$daysToStart = 1;
|
535 |
+
//add a day if the current time surpasses the time treshold
|
536 |
+
$time = $dateModel->date('H,i');
|
537 |
+
if($cutoffTime <= $time && substr($cutoffTime, 0, 5) != '00,00') {
|
538 |
+
$daysToStart = 2;
|
539 |
+
}
|
540 |
+
//get the current date
|
541 |
+
$currentDate = $dateModel->date();
|
542 |
+
//define all bpost shipping methods
|
543 |
+
$shippingMethods = array(
|
544 |
+
'bpost_homedelivery' => false,
|
545 |
+
'bpost_pickuppoint' => false,
|
546 |
+
'bpost_parcellocker' => false,
|
547 |
+
'bpost_clickcollect' => false
|
548 |
+
);
|
549 |
+
foreach ($shippingMethods as $method => $value) {
|
550 |
+
//get saturday delivery flags
|
551 |
+
$saturdayDelivery = (bool)$configHelper->getBpostCarriersConfig("saturday_delivery", $method, Mage::app()->getStore()->getId());
|
552 |
+
$saturdayDeliveryFrom = $this->formatSaturdayDeliveryCost($configHelper->getBpostCarriersConfig("saturday_delivery_from", $method, Mage::app()->getStore()->getId()));
|
553 |
+
//don't allow saturday delivery if saturday delivery 'yes' and 'as from' amount not exceeded
|
554 |
+
if(($grandTotal - $shippingCost) < $saturdayDeliveryFrom) {
|
555 |
+
$saturdayDelivery = false;
|
556 |
+
}
|
557 |
+
$extraDays = $daysToStart;
|
558 |
+
//add total days between order and shipment
|
559 |
+
$totalDays = $extraDays + $daysBetweenShipment;
|
560 |
+
//loop over days checking for the first valid day
|
561 |
+
for($i = 1; $i <= $totalDays; $i++) {
|
562 |
+
$nextDate = $this->_formatDeliveryDate($currentDate.' +'.$i.' days');
|
563 |
+
|
564 |
+
if(!$this->_isValidDeliveryDate($nextDate, $saturdayDelivery, $method, $closedOn)) {
|
565 |
+
$totalDays++;
|
566 |
+
}
|
567 |
+
}
|
568 |
+
$startDate = $this->_formatDeliveryDate($currentDate.' +'.$totalDays.' days');
|
569 |
+
//customer gets a date from the system
|
570 |
+
if($displayDeliveryDate && !$chooseDeliveryDate) {
|
571 |
+
$shippingMethods[$method] = array(
|
572 |
+
'date' => $this->_formatDeliveryDate($startDate),
|
573 |
+
'date_format' => $helper->__($this->_formatDeliveryDate($startDate, 'l'))." ".$this->_formatDeliveryDate($startDate, 'd/m'),
|
574 |
+
'is_saturday' => $this->_isSaturday($startDate),
|
575 |
+
'next_date' => $this->_getNextDeliveryDate($startDate),
|
576 |
+
'next_date_format' => $helper->__($this->_getNextDeliveryDate($startDate, 'l'))." ".$this->_getNextDeliveryDate($startDate, 'd/m')
|
577 |
+
);
|
578 |
+
//customer can choose own date
|
579 |
+
} else if($displayDeliveryDate && $chooseDeliveryDate) {
|
580 |
+
$days = array();
|
581 |
+
$addedDays = 0;
|
582 |
+
for($i = 0; $i < $nrOfDaysShown; $i++) {
|
583 |
+
//add starting date to array
|
584 |
+
if($i == 0) {
|
585 |
+
$days[$i] = array(
|
586 |
+
'date' => $startDate,
|
587 |
+
'date_format' => $helper->__($this->_formatDeliveryDate($startDate, 'l')).'<span>'.$this->_formatDeliveryDate($startDate, 'j')." ".strtolower($helper->__($this->_formatDeliveryDate($startDate, 'F'))).'</span>'
|
588 |
+
);
|
589 |
+
//move to next day
|
590 |
+
} else {
|
591 |
+
$addedDays++;
|
592 |
+
$nextDate = $this->_formatDeliveryDate($startDate.' +'.$addedDays.' days');
|
593 |
+
$validDate = false;
|
594 |
+
while($validDate == false) {
|
595 |
+
if($this->_isValidDeliveryDate($nextDate, $saturdayDelivery, $method, $closedOn)) {
|
596 |
+
$validDate = true;
|
597 |
+
} else {
|
598 |
+
$addedDays++;
|
599 |
+
$nextDate = $this->_formatDeliveryDate($startDate.' +'.$addedDays.' days');
|
600 |
+
}
|
601 |
+
}
|
602 |
+
$days[$i] = array(
|
603 |
+
'date' => $nextDate,
|
604 |
+
'date_format' => $helper->__($this->_formatDeliveryDate($nextDate, 'l')).'<span>'.$this->_formatDeliveryDate($nextDate, 'j')." ".strtolower($helper->__($this->_formatDeliveryDate($nextDate, 'F'))).'</span>'
|
605 |
+
);
|
606 |
+
}
|
607 |
+
}
|
608 |
+
$shippingMethods[$method] = $days;
|
609 |
+
}
|
610 |
+
}
|
611 |
+
return $shippingMethods;
|
612 |
+
}
|
613 |
+
|
614 |
+
|
615 |
+
/**
|
616 |
+
* @return date
|
617 |
+
*/
|
618 |
+
public function getPrevDeliveryDate($deliveryDate){
|
619 |
+
$days = 1;
|
620 |
+
$validDate = false;
|
621 |
+
$previousWeekday = $this->_formatDeliveryDate($deliveryDate.' -'.$days.' weekdays');
|
622 |
+
|
623 |
+
while($validDate == false) {
|
624 |
+
if($this->_isValidDeliveryDate($previousWeekday)) {
|
625 |
+
$validDate = true;
|
626 |
+
} else {
|
627 |
+
$days++;
|
628 |
+
$previousWeekday = $this->_formatDeliveryDate($deliveryDate.' -'.$days.' weekdays');
|
629 |
+
}
|
630 |
+
}
|
631 |
+
|
632 |
+
return $previousWeekday;
|
633 |
+
}
|
634 |
+
|
635 |
+
|
636 |
+
/**
|
637 |
+
* Returns the next first valid delivery date
|
638 |
+
*
|
639 |
+
* @param $date
|
640 |
+
* @param $format
|
641 |
+
* @return array
|
642 |
+
*/
|
643 |
+
protected function _getNextDeliveryDate($date, $format = "Y-m-d") {
|
644 |
+
$nextDate = false;
|
645 |
+
|
646 |
+
if($this->_isSaturday($date)) {
|
647 |
+
//add a weekday so we end up on monday
|
648 |
+
$extraWeekDays = 1;
|
649 |
+
$nextDate = $this->_formatDeliveryDate("$date +$extraWeekDays weekdays");
|
650 |
+
|
651 |
+
//check for holidays (monday will most likely not be a saturday or a sunday, and holidays sadly don't take a week)
|
652 |
+
$validDeliveryDate = false;
|
653 |
+
while($validDeliveryDate == false) {
|
654 |
+
if($this->_isValidDeliveryDate($nextDate)) {
|
655 |
+
$validDeliveryDate = true;
|
656 |
+
} else {
|
657 |
+
$extraWeekDays++;
|
658 |
+
$nextDate = $this->_formatDeliveryDate("$date +$extraWeekDays weekdays");
|
659 |
+
}
|
660 |
+
}
|
661 |
+
|
662 |
+
$nextDate = $this->_formatDeliveryDate($nextDate, $format);
|
663 |
+
}
|
664 |
+
|
665 |
+
return $nextDate;
|
666 |
+
}
|
667 |
+
|
668 |
+
|
669 |
+
protected function _isValidDeliveryDate($deliveryDate, $saturdayAllowed = false, $method = false, $closedOn = false) {
|
670 |
+
if($this->_isHoliday($deliveryDate)) {
|
671 |
+
return false;
|
672 |
+
}
|
673 |
+
if($this->_isSunday($deliveryDate)) {
|
674 |
+
return false;
|
675 |
+
}
|
676 |
+
if(!$saturdayAllowed && $this->_isSaturday($deliveryDate)) {
|
677 |
+
return false;
|
678 |
+
}
|
679 |
+
if($method == 'bpost_pickuppoint') {
|
680 |
+
//check if pick-up point is open on this day
|
681 |
+
if(is_array($closedOn)) {
|
682 |
+
$day = $this->_formatDeliveryDate($deliveryDate, 'l');
|
683 |
+
|
684 |
+
if(in_array($day, $closedOn)) {
|
685 |
+
return false;
|
686 |
+
}
|
687 |
+
}
|
688 |
+
}
|
689 |
+
|
690 |
+
if($method == 'bpost_clickcollect') {
|
691 |
+
//check if pick-up point is open on this day
|
692 |
+
if(is_array($closedOn)) {
|
693 |
+
$day = $this->_formatDeliveryDate($deliveryDate, 'l');
|
694 |
+
|
695 |
+
if(in_array($day, $closedOn)) {
|
696 |
+
return false;
|
697 |
+
}
|
698 |
+
}
|
699 |
+
}
|
700 |
+
|
701 |
+
return true;
|
702 |
+
}
|
703 |
+
|
704 |
+
|
705 |
+
/**
|
706 |
+
* Check if date is on a saturday
|
707 |
+
*
|
708 |
+
* @param $date
|
709 |
+
* @return bool
|
710 |
+
*/
|
711 |
+
protected function _isSaturday($date)
|
712 |
+
{
|
713 |
+
return ($this->_formatDeliveryDate($date, "N") == 6);
|
714 |
+
}
|
715 |
+
|
716 |
+
/**
|
717 |
+
* Check if date is on a sunday
|
718 |
+
*
|
719 |
+
* @param $date
|
720 |
+
* @return bool
|
721 |
+
*/
|
722 |
+
protected function _isSunday($date)
|
723 |
+
{
|
724 |
+
return ($this->_formatDeliveryDate($date, "N") == 7);
|
725 |
+
}
|
726 |
+
|
727 |
+
/**
|
728 |
+
* Check if date is a holiday (according to Belgian holidays)
|
729 |
+
*
|
730 |
+
* @param $date
|
731 |
+
* @return bool
|
732 |
+
*/
|
733 |
+
protected function _isHoliday($date)
|
734 |
+
{
|
735 |
+
$holidays = Mage::getModel('bpost_shm/holidays')->getCollection()->getHolidays();
|
736 |
+
|
737 |
+
if(in_array($date, $holidays)) {
|
738 |
+
return true;
|
739 |
+
}
|
740 |
+
|
741 |
+
return false;
|
742 |
+
}
|
743 |
+
|
744 |
+
|
745 |
+
/**
|
746 |
+
* Format the delivery date to any format (default: Y-m-d)
|
747 |
+
*
|
748 |
+
* @param $date
|
749 |
+
* @param $format
|
750 |
+
* @return date
|
751 |
+
*/
|
752 |
+
protected function _formatDeliveryDate($date, $format = "Y-m-d") {
|
753 |
+
return date($format, strtotime($date));
|
754 |
+
}
|
755 |
+
|
756 |
+
/**
|
757 |
+
* Format the saturday delivery cost
|
758 |
+
*
|
759 |
+
* @param $value
|
760 |
+
* @return bool|float
|
761 |
+
*/
|
762 |
+
public function formatSaturdayDeliveryCost($value)
|
763 |
+
{
|
764 |
+
$value = str_replace(',', '.', $value);
|
765 |
+
if (!is_numeric($value)) {
|
766 |
+
return false;
|
767 |
+
}
|
768 |
+
$value = (float)sprintf('%.4F', $value);
|
769 |
+
if ($value < 0.0000) {
|
770 |
+
return false;
|
771 |
+
}
|
772 |
+
return $value;
|
773 |
+
}
|
774 |
+
|
775 |
+
/**
|
776 |
+
* Check if on Onestepcheckout page or if Onestepcheckout is the refferer
|
777 |
+
*
|
778 |
+
* @return bool
|
779 |
+
*/
|
780 |
+
public function isOnestepCheckout()
|
781 |
+
{
|
782 |
+
if (strpos(Mage::helper("core/url")->getCurrentUrl(), 'onestepcheckout') !== false || strpos(Mage::app()->getRequest()->getHeader('referer'), 'onestepcheckout') !== false) {
|
783 |
+
return true;
|
784 |
+
}
|
785 |
+
|
786 |
+
return false;
|
787 |
+
}
|
788 |
+
|
789 |
+
/**
|
790 |
+
* Get Onestepcheckout version
|
791 |
+
*
|
792 |
+
* @return string
|
793 |
+
*/
|
794 |
+
public function getOnestepCheckoutVersion()
|
795 |
+
{
|
796 |
+
$version = Mage::getConfig()->getNode()->modules->Idev_OneStepCheckout->version;
|
797 |
+
list($major, $minor) = explode('.', $version);
|
798 |
+
|
799 |
+
return (string) $major . '.' . $minor;
|
800 |
+
}
|
801 |
+
|
802 |
+
/**
|
803 |
+
* Calculates total weight of a shipment.
|
804 |
+
*
|
805 |
+
* @param $shipment
|
806 |
+
* @return int
|
807 |
+
*/
|
808 |
+
public function calculateTotalShippingWeight($shipment)
|
809 |
+
{
|
810 |
+
$weight = 0;
|
811 |
+
$shipmentItems = $shipment->getAllItems();
|
812 |
+
foreach ($shipmentItems as $shipmentItem) {
|
813 |
+
$orderItem = $shipmentItem->getOrderItem();
|
814 |
+
if (!$orderItem->getParentItemId()) {
|
815 |
+
$weight = $weight + ($shipmentItem->getWeight() * $shipmentItem->getQty());
|
816 |
+
}
|
817 |
+
}
|
818 |
+
|
819 |
+
return $weight;
|
820 |
+
}
|
821 |
+
|
822 |
+
|
823 |
+
/**
|
824 |
+
* @param $shipments
|
825 |
+
* @return int
|
826 |
+
*/
|
827 |
+
public function processShipmentsWeight($order)
|
828 |
+
{
|
829 |
+
$bpostHelper = Mage::helper("bpost_shm/system_config");
|
830 |
+
$weightUnit = $bpostHelper->getBpostShippingConfig("weight_unit", $order->getStoreId());
|
831 |
+
|
832 |
+
$totalShipmentsWeight = 0;
|
833 |
+
|
834 |
+
$shipmentCollection = Mage::getModel("sales/order_shipment")->getCollection()
|
835 |
+
->addFieldToFilter("order_id", $order->getId());
|
836 |
+
|
837 |
+
foreach ($shipmentCollection as $shipment){
|
838 |
+
if ($weightUnit == "") {
|
839 |
+
$totalShipmentsWeight += $shipment->getTotalWeight() * 100;
|
840 |
+
} else {
|
841 |
+
$totalShipmentsWeight += $shipment->getTotalWeight() * $weightUnit;
|
842 |
+
}
|
843 |
+
}
|
844 |
+
|
845 |
+
return $totalShipmentsWeight;
|
846 |
+
}
|
847 |
+
}
|
app/code/community/Bpost/ShM/Helper/Returnlabel.php
CHANGED
@@ -1,46 +1,46 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Created by PHPro
|
5 |
-
*
|
6 |
-
* @package Bpost
|
7 |
-
* @subpackage ShM
|
8 |
-
* @author PHPro (info@phpro.be)
|
9 |
-
*/
|
10 |
-
|
11 |
-
/**
|
12 |
-
* Class Bpost_ShM_Helper_Returnlabel
|
13 |
-
*/
|
14 |
-
class Bpost_ShM_Helper_Returnlabel extends Mage_Core_Helper_Abstract
|
15 |
-
{
|
16 |
-
/**
|
17 |
-
* @param $orderId
|
18 |
-
* function returns the nr of returnlabels an order has.
|
19 |
-
* unfortunately, we must do this with collection count
|
20 |
-
*/
|
21 |
-
public function getOrderReturnlabelsCount($orderId){
|
22 |
-
$labelCollection = Mage::getModel("bpost_shm/returnlabel");
|
23 |
-
$collection = $labelCollection->getCollection()->addFieldToFilter("order_id", $orderId);
|
24 |
-
|
25 |
-
return $collection->count();
|
26 |
-
}
|
27 |
-
|
28 |
-
|
29 |
-
/**
|
30 |
-
* @param $order
|
31 |
-
* @param $parsedLabelResponse
|
32 |
-
* @return string
|
33 |
-
* function returns the barcode by parsed label response
|
34 |
-
* make sures we return an unique name
|
35 |
-
* if no barcode is returned (probably never)
|
36 |
-
*/
|
37 |
-
public function getBarcodeByLabelResponse($order, $parsedLabelResponse){
|
38 |
-
if(!isset($parsedLabelResponse["returnBarcodeString"]) || $parsedLabelResponse["returnBarcodeString"][0] == ""){
|
39 |
-
$barcode = "no-barcode-".$order->getIncrementId();
|
40 |
-
}else{
|
41 |
-
$barcode = $parsedLabelResponse["returnBarcodeString"][0];
|
42 |
-
}
|
43 |
-
|
44 |
-
return $barcode;
|
45 |
-
}
|
46 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Created by PHPro
|
5 |
+
*
|
6 |
+
* @package Bpost
|
7 |
+
* @subpackage ShM
|
8 |
+
* @author PHPro (info@phpro.be)
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Class Bpost_ShM_Helper_Returnlabel
|
13 |
+
*/
|
14 |
+
class Bpost_ShM_Helper_Returnlabel extends Mage_Core_Helper_Abstract
|
15 |
+
{
|
16 |
+
/**
|
17 |
+
* @param $orderId
|
18 |
+
* function returns the nr of returnlabels an order has.
|
19 |
+
* unfortunately, we must do this with collection count
|
20 |
+
*/
|
21 |
+
public function getOrderReturnlabelsCount($orderId){
|
22 |
+
$labelCollection = Mage::getModel("bpost_shm/returnlabel");
|
23 |
+
$collection = $labelCollection->getCollection()->addFieldToFilter("order_id", $orderId);
|
24 |
+
|
25 |
+
return $collection->count();
|
26 |
+
}
|
27 |
+
|
28 |
+
|
29 |
+
/**
|
30 |
+
* @param $order
|
31 |
+
* @param $parsedLabelResponse
|
32 |
+
* @return string
|
33 |
+
* function returns the barcode by parsed label response
|
34 |
+
* make sures we return an unique name
|
35 |
+
* if no barcode is returned (probably never)
|
36 |
+
*/
|
37 |
+
public function getBarcodeByLabelResponse($order, $parsedLabelResponse){
|
38 |
+
if(!isset($parsedLabelResponse["returnBarcodeString"]) || $parsedLabelResponse["returnBarcodeString"][0] == ""){
|
39 |
+
$barcode = "no-barcode-".$order->getIncrementId();
|
40 |
+
}else{
|
41 |
+
$barcode = $parsedLabelResponse["returnBarcodeString"][0];
|
42 |
+
}
|
43 |
+
|
44 |
+
return $barcode;
|
45 |
+
}
|
46 |
+
}
|
app/code/community/Bpost/ShM/Helper/System/Config.php
CHANGED
@@ -1,49 +1,49 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Created by PHPro
|
4 |
-
*
|
5 |
-
* @package Bpost
|
6 |
-
* @subpackage ShM
|
7 |
-
* @author PHPro (info@phpro.be)
|
8 |
-
*/
|
9 |
-
class Bpost_ShM_Helper_System_Config extends Mage_Core_Helper_Abstract
|
10 |
-
{
|
11 |
-
|
12 |
-
/**
|
13 |
-
* @param $code
|
14 |
-
* @param int $storeId
|
15 |
-
* @return mixed
|
16 |
-
* function returns the configured value by system code
|
17 |
-
*/
|
18 |
-
public function getBpostShippingConfig($code, $storeId = 0){
|
19 |
-
$value = Mage::getStoreConfig("shipping/bpost_shm/$code", $storeId);
|
20 |
-
|
21 |
-
if($code == "passphrase"){
|
22 |
-
$value = Mage::helper('core')->decrypt($value);
|
23 |
-
}
|
24 |
-
|
25 |
-
return $value;
|
26 |
-
}
|
27 |
-
|
28 |
-
/**
|
29 |
-
* @param $code
|
30 |
-
* @param int $storeId
|
31 |
-
* @return mixed
|
32 |
-
* function returns the configured carrier value by system code
|
33 |
-
*/
|
34 |
-
public function getBpostCarriersConfig($code, $carrier, $storeId = 0){
|
35 |
-
return Mage::getStoreConfig("carriers/$carrier/$code", $storeId);
|
36 |
-
}
|
37 |
-
|
38 |
-
|
39 |
-
//we create separate functions for config values that are called a lot
|
40 |
-
//...
|
41 |
-
|
42 |
-
public function isApiLoggingEnabled($storeId = 0){
|
43 |
-
return (bool)$this->getBpostShippingConfig("enable_log_api", $storeId);
|
44 |
-
}
|
45 |
-
|
46 |
-
public function isLoggingEnabled($storeId = 0){
|
47 |
-
return (bool)$this->getBpostShippingConfig("enable_log", $storeId);
|
48 |
-
}
|
49 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Created by PHPro
|
4 |
+
*
|
5 |
+
* @package Bpost
|
6 |
+
* @subpackage ShM
|
7 |
+
* @author PHPro (info@phpro.be)
|
8 |
+
*/
|
9 |
+
class Bpost_ShM_Helper_System_Config extends Mage_Core_Helper_Abstract
|
10 |
+
{
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @param $code
|
14 |
+
* @param int $storeId
|
15 |
+
* @return mixed
|
16 |
+
* function returns the configured value by system code
|
17 |
+
*/
|
18 |
+
public function getBpostShippingConfig($code, $storeId = 0){
|
19 |
+
$value = Mage::getStoreConfig("shipping/bpost_shm/$code", $storeId);
|
20 |
+
|
21 |
+
if($code == "passphrase"){
|
22 |
+
$value = Mage::helper('core')->decrypt($value);
|
23 |
+
}
|
24 |
+
|
25 |
+
return $value;
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* @param $code
|
30 |
+
* @param int $storeId
|
31 |
+
* @return mixed
|
32 |
+
* function returns the configured carrier value by system code
|
33 |
+
*/
|
34 |
+
public function getBpostCarriersConfig($code, $carrier, $storeId = 0){
|
35 |
+
return Mage::getStoreConfig("carriers/$carrier/$code", $storeId);
|
36 |
+
}
|
37 |
+
|
38 |
+
|
39 |
+
//we create separate functions for config values that are called a lot
|
40 |
+
//...
|
41 |
+
|
42 |
+
public function isApiLoggingEnabled($storeId = 0){
|
43 |
+
return (bool)$this->getBpostShippingConfig("enable_log_api", $storeId);
|
44 |
+
}
|
45 |
+
|
46 |
+
public function isLoggingEnabled($storeId = 0){
|
47 |
+
return (bool)$this->getBpostShippingConfig("enable_log", $storeId);
|
48 |
+
}
|
49 |
+
}
|
app/code/community/Bpost/ShM/Model/Adminhtml/Bpostgrid.php
CHANGED
@@ -1,485 +1,485 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Created by PHPro
|
5 |
-
*
|
6 |
-
* @package Bpost
|
7 |
-
* @subpackage ShM
|
8 |
-
* @author PHPro (info@phpro.be)
|
9 |
-
*/
|
10 |
-
class Bpost_ShM_Model_Adminhtml_Bpostgrid extends Varien_Event_Observer
|
11 |
-
{
|
12 |
-
|
13 |
-
const MEDIA_LABEL_PATH = "/bpost/orderlabels/";
|
14 |
-
protected $_transaction = null;
|
15 |
-
protected $_addReturnLabels = false;
|
16 |
-
protected $_returnBarcodeArray = array();
|
17 |
-
protected $_barcodeArray = array();
|
18 |
-
|
19 |
-
|
20 |
-
/**
|
21 |
-
* Generates and completes an order, reference: generateAndCompleteAction.
|
22 |
-
* @param $order
|
23 |
-
* @return bool
|
24 |
-
*/
|
25 |
-
public function generateAndCompleteOrder($order)
|
26 |
-
{
|
27 |
-
$shipmentCollection = $order->getShipmentsCollection();
|
28 |
-
$collectionCount = $shipmentCollection->count();
|
29 |
-
$shipment = false;
|
30 |
-
|
31 |
-
$retryAutoShipment = false;
|
32 |
-
if ($collectionCount == 1 && $shipmentCollection->getFirstItem()->getBpostShipmentAutomated() == 1) {
|
33 |
-
$retryAutoShipment = true;
|
34 |
-
}
|
35 |
-
|
36 |
-
if ($collectionCount > 0 && !$order->getBpostLabelExists() && !$retryAutoShipment) {
|
37 |
-
return $this->_processAvailableShipments($order);
|
38 |
-
|
39 |
-
} elseif (!$order->getBpostLabelExists()) {
|
40 |
-
|
41 |
-
if ($retryAutoShipment) {
|
42 |
-
$shipment = $shipmentCollection->getFirstItem();
|
43 |
-
}
|
44 |
-
return $this->_createBpostShipment($order, $shipment);
|
45 |
-
} else {
|
46 |
-
$message = Mage::helper('bpost_shm')->__("The order with id %s is not ready to be shipped or has already been shipped.", $order->getIncrementId());
|
47 |
-
Mage::getSingleton('core/session')->addNotice($message);
|
48 |
-
return false;
|
49 |
-
}
|
50 |
-
}
|
51 |
-
|
52 |
-
|
53 |
-
/**
|
54 |
-
* @param $order
|
55 |
-
* @return bool
|
56 |
-
*/
|
57 |
-
protected function _processAvailableShipments(&$order)
|
58 |
-
{
|
59 |
-
$configHelper = Mage::helper('bpost_shm/system_config');
|
60 |
-
$bpostHelper = Mage::helper('bpost_shm');
|
61 |
-
|
62 |
-
$this->_addReturnLabels = (bool)$configHelper->getBpostShippingConfig("automatic_retour_labels", $order->getStoreId());
|
63 |
-
$locale = strtolower($bpostHelper->getLocaleByOrder($order, true));
|
64 |
-
|
65 |
-
$trackCollection = Mage::getResourceModel('sales/order_shipment_track_collection')
|
66 |
-
->addFieldToFilter('order_id', $order->getId())
|
67 |
-
->addFieldToFilter('carrier_code', 'bpostshm');
|
68 |
-
|
69 |
-
|
70 |
-
if ($trackCollection->count() > 0) {
|
71 |
-
$counter = 0;
|
72 |
-
|
73 |
-
$shipmentsArray = array();
|
74 |
-
foreach ($trackCollection as $tracker) {
|
75 |
-
if (!array_key_exists($tracker->getParentId(), $shipmentsArray)) {
|
76 |
-
$shipmentsArray[$tracker->getParentId()] = Mage::getResourceModel('sales/order_shipment_collection')->addFieldToFilter('entity_id', $tracker->getParentId())->setPageSize(1)->getFirstItem();
|
77 |
-
}
|
78 |
-
|
79 |
-
//first we create a bpost order
|
80 |
-
$this->_createBpostOrder($order);
|
81 |
-
$counter++;
|
82 |
-
}
|
83 |
-
|
84 |
-
$pdfBaseName = $this->_generateLabelAndReturnLabelIfEnabled($order);
|
85 |
-
|
86 |
-
if (!$pdfBaseName) {
|
87 |
-
$message = Mage::helper('bpost_shm')->__("Something went wrong while processing order #%s, please check your error logs.", $order->getIncrementId());
|
88 |
-
Mage::getSingleton('core/session')->addError($message);
|
89 |
-
return false;
|
90 |
-
}
|
91 |
-
|
92 |
-
$tmpCounter = 0;
|
93 |
-
foreach ($trackCollection as $tracker) {
|
94 |
-
$shipment = $shipmentsArray[$tracker->getParentId()];
|
95 |
-
$label = $this->_parseLabelData($order, $tmpCounter);
|
96 |
-
$barcode = $label['barcode'];
|
97 |
-
|
98 |
-
try {
|
99 |
-
if (array_key_exists('returnBarcode', $label)) {
|
100 |
-
$shipment->setBpostReturnBarcode($label['returnBarcode']);
|
101 |
-
}
|
102 |
-
|
103 |
-
$shipment->setBpostLabelPath($pdfBaseName);
|
104 |
-
$shipment->setBpostTrackingUrl('<a target="_blank" href="' . Bpost_ShM_Model_Shipping_Carrier_BpostShM::SHIPMENT_TRACK_DOMAIN . "etr/light/performSearch.do?searchByItemCode=true&oss_language='" . $locale . "&itemCodes=" . $barcode . '">' . Mage::helper('bpost_shm')->__('Track this shipment') . '</a>');
|
105 |
-
$tracker->setData("number", $barcode);
|
106 |
-
|
107 |
-
//add data to transaction
|
108 |
-
$this->_getTransaction()
|
109 |
-
->addObject($shipment)
|
110 |
-
->addObject($tracker);
|
111 |
-
|
112 |
-
} catch (Exception $e) {
|
113 |
-
Mage::helper('bpost_shm')->log($e->getMessage(), Zend_Log::ERR);
|
114 |
-
continue;
|
115 |
-
}
|
116 |
-
|
117 |
-
$tmpCounter++;
|
118 |
-
}
|
119 |
-
|
120 |
-
$order->addStatusHistoryComment(Mage::helper('bpost_shm')->__('Shipped with bpost generateLabelAndComplete'), true);
|
121 |
-
|
122 |
-
if ($this->_addReturnLabels) {
|
123 |
-
$order->setBpostReturnLabelExists(true);
|
124 |
-
}
|
125 |
-
|
126 |
-
$order->setBpostLabelExists(true);
|
127 |
-
$this->_getTransaction()->addObject($order);
|
128 |
-
|
129 |
-
return $counter;
|
130 |
-
} else {
|
131 |
-
$message = Mage::helper('bpost_shm')->__("The order with id %s only has non-bpost shipments.", $order->getIncrementId());
|
132 |
-
Mage::getSingleton('core/session')->addNotice($message);
|
133 |
-
return false;
|
134 |
-
}
|
135 |
-
}
|
136 |
-
|
137 |
-
|
138 |
-
/**
|
139 |
-
* @param $order
|
140 |
-
* @return bool
|
141 |
-
*/
|
142 |
-
protected function _createBpostShipment(&$order, $shipment = false)
|
143 |
-
{
|
144 |
-
$configHelper = Mage::helper('bpost_shm/system_config');
|
145 |
-
$bpostHelper = Mage::helper('bpost_shm');
|
146 |
-
|
147 |
-
$this->_addReturnLabels = (bool)$configHelper->getBpostShippingConfig("automatic_retour_labels", $order->getStoreId());
|
148 |
-
$locale = strtolower($bpostHelper->getLocaleByOrder($order, true));
|
149 |
-
|
150 |
-
if (!$shipment) {
|
151 |
-
$shipment = $order->prepareShipment();
|
152 |
-
$shipment->register()->setBpostShipmentAutomated(true)->save();
|
153 |
-
}
|
154 |
-
|
155 |
-
$weight = Mage::helper('bpost_shm')->calculateTotalShippingWeight($shipment);
|
156 |
-
$shipment->setTotalWeight($weight);
|
157 |
-
|
158 |
-
//first create the bpost order
|
159 |
-
$this->_createBpostOrder($order);
|
160 |
-
|
161 |
-
//then create label for order
|
162 |
-
$pdfBaseName = $this->_generateLabelAndReturnLabelIfEnabled($order);
|
163 |
-
$label = $this->_parseLabelData($order);
|
164 |
-
$barcode = $label['barcode'];
|
165 |
-
|
166 |
-
if (!$pdfBaseName) {
|
167 |
-
$message = Mage::helper('bpost_shm')->__("Something went wrong while processing order #%s, please check your error logs.", $order->getIncrementId());
|
168 |
-
Mage::getSingleton('core/session')->addError($message);
|
169 |
-
return false;
|
170 |
-
} else {
|
171 |
-
if (array_key_exists('returnBarcode', $label)) {
|
172 |
-
$shipment->setBpostReturnBarcode($label['returnBarcode']);
|
173 |
-
}
|
174 |
-
$shipment->setBpostLabelPath($pdfBaseName);
|
175 |
-
$shipment->setBpostTrackingUrl('<a target="_blank" href="' . Bpost_ShM_Model_Shipping_Carrier_BpostShM::SHIPMENT_TRACK_DOMAIN . "etr/light/performSearch.do?searchByItemCode=true&oss_language='" . $locale . "&itemCodes=" . $barcode . '">' . Mage::helper('bpost_shm')->__('Track this shipment') . '</a>');
|
176 |
-
|
177 |
-
$order->setIsInProcess(true);
|
178 |
-
$order->addStatusHistoryComment(Mage::helper('bpost_shm')->__('Shipped with bpost generateLabelAndComplete'), true);
|
179 |
-
$order->setBpostLabelExists(true);
|
180 |
-
|
181 |
-
if ($this->_addReturnLabels) {
|
182 |
-
$order->setBpostReturnLabelExists(true);
|
183 |
-
}
|
184 |
-
|
185 |
-
$tracker = Mage::getModel('sales/order_shipment_track')
|
186 |
-
->setShipment($shipment)
|
187 |
-
->setData('title', 'bpost')
|
188 |
-
->setData('number', $barcode)
|
189 |
-
->setData('carrier_code', "bpostshm")
|
190 |
-
->setData('order_id', $shipment->getData('order_id'));
|
191 |
-
|
192 |
-
try {
|
193 |
-
$shipment->save();
|
194 |
-
$order->save();
|
195 |
-
$tracker->save();
|
196 |
-
if (Mage::getStoreConfig(Mage_Sales_Model_Order_Shipment::XML_PATH_EMAIL_ENABLED, $order->getStoreId())) {
|
197 |
-
$shipment->sendEmail(true, '');
|
198 |
-
}
|
199 |
-
} catch (Exception $e) {
|
200 |
-
Mage::helper('bpost_shm')->log($e->getMessage(), Zend_Log::ERR);
|
201 |
-
}
|
202 |
-
|
203 |
-
return 1;
|
204 |
-
}
|
205 |
-
}
|
206 |
-
|
207 |
-
|
208 |
-
/**
|
209 |
-
* @param $labelData
|
210 |
-
* function parses label data and returns it
|
211 |
-
*/
|
212 |
-
protected function _parseLabelData($order, $barcodeIndex = 0)
|
213 |
-
{
|
214 |
-
$bpostHelper = Mage::helper('bpost_shm');
|
215 |
-
|
216 |
-
$returnData = array();
|
217 |
-
$locale = $bpostHelper->getLocaleByOrder($order, true);
|
218 |
-
|
219 |
-
$returnData["locale"] = $locale;
|
220 |
-
|
221 |
-
if (!isset($this->_barcodeArray[$barcodeIndex])) {
|
222 |
-
$returnData["barcode"] = "no-barcode";
|
223 |
-
} else {
|
224 |
-
$returnData["barcode"] = $this->_barcodeArray[$barcodeIndex];
|
225 |
-
}
|
226 |
-
|
227 |
-
//check if the barcode index isset
|
228 |
-
//if so, a return barcode is available
|
229 |
-
if (isset($this->_returnBarcodeArray[$barcodeIndex])) {
|
230 |
-
$returnData["returnBarcode"] = $this->_returnBarcodeArray[$barcodeIndex];
|
231 |
-
}
|
232 |
-
|
233 |
-
return $returnData;
|
234 |
-
}
|
235 |
-
|
236 |
-
|
237 |
-
/**
|
238 |
-
* function generates bpost API order
|
239 |
-
* @param $order
|
240 |
-
* @throws Mage_Core_Exception
|
241 |
-
*/
|
242 |
-
protected function _createBpostOrder(&$order)
|
243 |
-
{
|
244 |
-
$bpostHelper = Mage::helper("bpost_shm");
|
245 |
-
|
246 |
-
$webserviceModel = Mage::getModel('bpost_shm/api');
|
247 |
-
$webserviceModel->initialize($order->getStoreId());
|
248 |
-
$response = $webserviceModel->createOrder($order);
|
249 |
-
|
250 |
-
if (!$response) {
|
251 |
-
Mage::throwException($bpostHelper->__("Error while creating a bpost order for Magento order #%s. Please check your API log.", $order->getIncrementId()));
|
252 |
-
}
|
253 |
-
|
254 |
-
if (!$order->getBpostReference()) {
|
255 |
-
$order->setBpostReference($order->getIncrementId());
|
256 |
-
}
|
257 |
-
}
|
258 |
-
|
259 |
-
|
260 |
-
/**
|
261 |
-
* Generates a shipment label and saves it on the harddisk.
|
262 |
-
*
|
263 |
-
* @param $order
|
264 |
-
* @param $shipment
|
265 |
-
* @return mixed
|
266 |
-
*/
|
267 |
-
protected function _generateLabelAndReturnLabelIfEnabled(&$order)
|
268 |
-
{
|
269 |
-
$bpostHelper = Mage::helper("bpost_shm");
|
270 |
-
$pdfName = null;
|
271 |
-
|
272 |
-
$webserviceModel = Mage::getModel('bpost_shm/api');
|
273 |
-
$webserviceModel->initialize($order->getStoreId());
|
274 |
-
$response = $webserviceModel->createLabelByOrder($order, $this->_addReturnLabels);
|
275 |
-
|
276 |
-
if ($response) {
|
277 |
-
$parsedResponse = $bpostHelper->parseLabelApiResponse($response, $order);
|
278 |
-
|
279 |
-
if (empty($parsedResponse) || !isset($parsedResponse["pdfString"])) {
|
280 |
-
$message = $bpostHelper->__("No label response received for Magento order #%s.", $order->getIncrementId());
|
281 |
-
$bpostHelper->log($message, Zend_Log::ERR);
|
282 |
-
return false;
|
283 |
-
}
|
284 |
-
|
285 |
-
$this->_barcodeArray = $parsedResponse["barcodeString"];
|
286 |
-
|
287 |
-
if (array_key_exists("returnBarcodeString", $parsedResponse)) {
|
288 |
-
$this->_returnBarcodeArray = $parsedResponse["returnBarcodeString"];
|
289 |
-
}
|
290 |
-
|
291 |
-
//loop array and save pdf files
|
292 |
-
$loopNr = 0;
|
293 |
-
$pdfName = "";
|
294 |
-
foreach ($parsedResponse["pdfString"] as $pdfString) {
|
295 |
-
if ($loopNr) {
|
296 |
-
$pdfName .= ":";
|
297 |
-
}
|
298 |
-
|
299 |
-
$pdfName .= $bpostHelper->generatePdfAndSave($pdfString, "orderlabels", $order->getIncrementId());
|
300 |
-
$pdfName .= ".pdf";
|
301 |
-
|
302 |
-
if ($this->_addReturnLabels) {
|
303 |
-
$order->setBpostReturnLabelExists(true);
|
304 |
-
}
|
305 |
-
|
306 |
-
$loopNr++;
|
307 |
-
}
|
308 |
-
|
309 |
-
return $pdfName;
|
310 |
-
}
|
311 |
-
|
312 |
-
return false;
|
313 |
-
}
|
314 |
-
|
315 |
-
|
316 |
-
/**
|
317 |
-
* function returns the current transaction
|
318 |
-
*/
|
319 |
-
protected function _getTransaction()
|
320 |
-
{
|
321 |
-
if (is_null($this->_transaction)) {
|
322 |
-
$this->_transaction = Mage::getModel('core/resource_transaction');
|
323 |
-
}
|
324 |
-
|
325 |
-
return $this->_transaction;
|
326 |
-
}
|
327 |
-
|
328 |
-
|
329 |
-
/**
|
330 |
-
* function will save the current transaction
|
331 |
-
*/
|
332 |
-
public function saveTransaction()
|
333 |
-
{
|
334 |
-
//make sure we have an object first before saving it
|
335 |
-
if (is_object($this->_transaction)) {
|
336 |
-
$this->_transaction->save();
|
337 |
-
}
|
338 |
-
}
|
339 |
-
|
340 |
-
|
341 |
-
/**
|
342 |
-
* Processes the undownloadable labels. (set mark and zip)
|
343 |
-
*
|
344 |
-
* @param $orderIds
|
345 |
-
* @return bool|string
|
346 |
-
*/
|
347 |
-
public function processUndownloadedLabels($orderIds)
|
348 |
-
{
|
349 |
-
$file = new Varien_Io_File();
|
350 |
-
$labelPdfArray = array();
|
351 |
-
$i = 0;
|
352 |
-
|
353 |
-
$orderCollection = Mage::getModel("sales/order")->getCollection()
|
354 |
-
->addFieldToFilter("entity_id", array("in" => $orderIds));
|
355 |
-
|
356 |
-
$exportedOrderIds = array();
|
357 |
-
|
358 |
-
foreach ($orderCollection as $order) {
|
359 |
-
$exported = false;
|
360 |
-
|
361 |
-
if (!$order->getBpostLabelExported()) {
|
362 |
-
$shippingCollection = Mage::getResourceModel('sales/order_shipment_collection')
|
363 |
-
->setOrderFilter($order)
|
364 |
-
->load();
|
365 |
-
|
366 |
-
if (count($shippingCollection)) {
|
367 |
-
foreach ($shippingCollection as $shipment) {
|
368 |
-
if ($shipment->getBpostLabelPath() != "" && !$exported) {
|
369 |
-
$labelPaths = explode(":", $shipment->getBpostLabelPath());
|
370 |
-
foreach ($labelPaths as $labelPath) {
|
371 |
-
$filePath = Mage::getBaseDir('media') . self::MEDIA_LABEL_PATH . $labelPath;
|
372 |
-
if ($file->fileExists($filePath)) {
|
373 |
-
$labelPdfArray[] = $filePath;
|
374 |
-
$exported = true;
|
375 |
-
}
|
376 |
-
}
|
377 |
-
}
|
378 |
-
}
|
379 |
-
|
380 |
-
if ($exported) {
|
381 |
-
$exportedOrderIds[] = $order->getId();
|
382 |
-
$order->setBpostLabelExported(true);
|
383 |
-
}
|
384 |
-
}
|
385 |
-
} else {
|
386 |
-
$i++;
|
387 |
-
}
|
388 |
-
}
|
389 |
-
|
390 |
-
$orderCollection->save();
|
391 |
-
|
392 |
-
//we save data to all shipments, performance change
|
393 |
-
$shippingCollection = Mage::getModel('sales/order_shipment')->getCollection();
|
394 |
-
$shippingCollection->addFieldToFilter("order_id", array("in" => $exportedOrderIds));
|
395 |
-
$shippingCollection->setDataToAll("bpost_label_exported", true)->save();
|
396 |
-
|
397 |
-
if (!count($labelPdfArray)) {
|
398 |
-
return false;
|
399 |
-
}
|
400 |
-
if ($i > 0) {
|
401 |
-
$message = Mage::helper('bpost_shm')->__('%s orders already had downloaded labels.', $i);
|
402 |
-
Mage::getSingleton('core/session')->addNotice($message);
|
403 |
-
}
|
404 |
-
|
405 |
-
$generatedName = date("Y_m_d_H_i_s") . "_undownloaded.zip";
|
406 |
-
|
407 |
-
$file = new Varien_Io_File();
|
408 |
-
$file->checkAndCreateFolder(Mage::getBaseDir('media') . self::MEDIA_LABEL_PATH . "zips/");
|
409 |
-
|
410 |
-
return $this->_zipLabelPdfArray($labelPdfArray, $generatedName, true, true);
|
411 |
-
}
|
412 |
-
|
413 |
-
|
414 |
-
/**
|
415 |
-
* Zips the labels.
|
416 |
-
*
|
417 |
-
* @param array $files
|
418 |
-
* @param string $generatedName
|
419 |
-
* @param bool $overwrite
|
420 |
-
* @return bool|string
|
421 |
-
*/
|
422 |
-
protected function _zipLabelPdfArray($files = array(), $generatedName = '', $overwrite = false, $mergePdfFiles = false)
|
423 |
-
{
|
424 |
-
$destination = Mage::getBaseDir('media') . self::MEDIA_LABEL_PATH . "zips/" . $generatedName;
|
425 |
-
$varienFile = new Varien_Io_File();
|
426 |
-
$bpostHelper = Mage::helper("bpost_shm");
|
427 |
-
|
428 |
-
|
429 |
-
if ($varienFile->fileExists($destination) && !$overwrite) {
|
430 |
-
return false;
|
431 |
-
}
|
432 |
-
|
433 |
-
$validFiles = array();
|
434 |
-
$pdfMerged = new Zend_Pdf();
|
435 |
-
|
436 |
-
if (is_array($files)) {
|
437 |
-
foreach ($files as $file) {
|
438 |
-
if ($varienFile->fileExists($file)) {
|
439 |
-
$validFiles[] = $file;
|
440 |
-
|
441 |
-
if ($mergePdfFiles) {
|
442 |
-
$tmpPdf = Zend_Pdf::load($file);
|
443 |
-
foreach ($tmpPdf->pages as $page) {
|
444 |
-
$clonedPage = clone $page;
|
445 |
-
$pdfMerged->pages[] = $clonedPage;
|
446 |
-
}
|
447 |
-
}
|
448 |
-
}
|
449 |
-
}
|
450 |
-
|
451 |
-
//save new pdf file is necessary
|
452 |
-
if ($mergePdfFiles) {
|
453 |
-
$mergedPdfName = $bpostHelper->generatePdfAndSave($pdfMerged->render(), "orderlabels", "merged");
|
454 |
-
$mergedPdfName = $mergedPdfName . ".pdf";
|
455 |
-
|
456 |
-
if ($mergedPdfName) {
|
457 |
-
$validFiles = array($mergedPdfName);
|
458 |
-
}
|
459 |
-
}
|
460 |
-
|
461 |
-
$validFilesCount = count($validFiles);
|
462 |
-
if ($validFilesCount && $validFilesCount > 1) {
|
463 |
-
$zip = new ZipArchive();
|
464 |
-
|
465 |
-
if ($zip->open($destination, $overwrite ? ZIPARCHIVE::OVERWRITE : ZIPARCHIVE::CREATE) !== true) {
|
466 |
-
return false;
|
467 |
-
}
|
468 |
-
|
469 |
-
foreach ($validFiles as $file) {
|
470 |
-
$fileName = $bpostHelper->getFileNameByPath($file);
|
471 |
-
$zip->addFile($file, $fileName);
|
472 |
-
}
|
473 |
-
|
474 |
-
$zip->close();
|
475 |
-
return $generatedName;
|
476 |
-
} elseif ($validFilesCount) {
|
477 |
-
//we return the pdf path instead of creating a zip file
|
478 |
-
$pdfName = $validFiles[0];
|
479 |
-
return $pdfName;
|
480 |
-
}
|
481 |
-
}
|
482 |
-
|
483 |
-
return false;
|
484 |
-
}
|
485 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Created by PHPro
|
5 |
+
*
|
6 |
+
* @package Bpost
|
7 |
+
* @subpackage ShM
|
8 |
+
* @author PHPro (info@phpro.be)
|
9 |
+
*/
|
10 |
+
class Bpost_ShM_Model_Adminhtml_Bpostgrid extends Varien_Event_Observer
|
11 |
+
{
|
12 |
+
|
13 |
+
const MEDIA_LABEL_PATH = "/bpost/orderlabels/";
|
14 |
+
protected $_transaction = null;
|
15 |
+
protected $_addReturnLabels = false;
|
16 |
+
protected $_returnBarcodeArray = array();
|
17 |
+
protected $_barcodeArray = array();
|
18 |
+
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Generates and completes an order, reference: generateAndCompleteAction.
|
22 |
+
* @param $order
|
23 |
+
* @return bool
|
24 |
+
*/
|
25 |
+
public function generateAndCompleteOrder($order)
|
26 |
+
{
|
27 |
+
$shipmentCollection = $order->getShipmentsCollection();
|
28 |
+
$collectionCount = $shipmentCollection->count();
|
29 |
+
$shipment = false;
|
30 |
+
|
31 |
+
$retryAutoShipment = false;
|
32 |
+
if ($collectionCount == 1 && $shipmentCollection->getFirstItem()->getBpostShipmentAutomated() == 1) {
|
33 |
+
$retryAutoShipment = true;
|
34 |
+
}
|
35 |
+
|
36 |
+
if ($collectionCount > 0 && !$order->getBpostLabelExists() && !$retryAutoShipment) {
|
37 |
+
return $this->_processAvailableShipments($order);
|
38 |
+
|
39 |
+
} elseif (!$order->getBpostLabelExists()) {
|
40 |
+
|
41 |
+
if ($retryAutoShipment) {
|
42 |
+
$shipment = $shipmentCollection->getFirstItem();
|
43 |
+
}
|
44 |
+
return $this->_createBpostShipment($order, $shipment);
|
45 |
+
} else {
|
46 |
+
$message = Mage::helper('bpost_shm')->__("The order with id %s is not ready to be shipped or has already been shipped.", $order->getIncrementId());
|
47 |
+
Mage::getSingleton('core/session')->addNotice($message);
|
48 |
+
return false;
|
49 |
+
}
|
50 |
+
}
|
51 |
+
|
52 |
+
|
53 |
+
/**
|
54 |
+
* @param $order
|
55 |
+
* @return bool
|
56 |
+
*/
|
57 |
+
protected function _processAvailableShipments(&$order)
|
58 |
+
{
|
59 |
+
$configHelper = Mage::helper('bpost_shm/system_config');
|
60 |
+
$bpostHelper = Mage::helper('bpost_shm');
|
61 |
+
|
62 |
+
$this->_addReturnLabels = (bool)$configHelper->getBpostShippingConfig("automatic_retour_labels", $order->getStoreId());
|
63 |
+
$locale = strtolower($bpostHelper->getLocaleByOrder($order, true));
|
64 |
+
|
65 |
+
$trackCollection = Mage::getResourceModel('sales/order_shipment_track_collection')
|
66 |
+
->addFieldToFilter('order_id', $order->getId())
|
67 |
+
->addFieldToFilter('carrier_code', 'bpostshm');
|
68 |
+
|
69 |
+
|
70 |
+
if ($trackCollection->count() > 0) {
|
71 |
+
$counter = 0;
|
72 |
+
|
73 |
+
$shipmentsArray = array();
|
74 |
+
foreach ($trackCollection as $tracker) {
|
75 |
+
if (!array_key_exists($tracker->getParentId(), $shipmentsArray)) {
|
76 |
+
$shipmentsArray[$tracker->getParentId()] = Mage::getResourceModel('sales/order_shipment_collection')->addFieldToFilter('entity_id', $tracker->getParentId())->setPageSize(1)->getFirstItem();
|
77 |
+
}
|
78 |
+
|
79 |
+
//first we create a bpost order
|
80 |
+
$this->_createBpostOrder($order);
|
81 |
+
$counter++;
|
82 |
+
}
|
83 |
+
|
84 |
+
$pdfBaseName = $this->_generateLabelAndReturnLabelIfEnabled($order);
|
85 |
+
|
86 |
+
if (!$pdfBaseName) {
|
87 |
+
$message = Mage::helper('bpost_shm')->__("Something went wrong while processing order #%s, please check your error logs.", $order->getIncrementId());
|
88 |
+
Mage::getSingleton('core/session')->addError($message);
|
89 |
+
return false;
|
90 |
+
}
|
91 |
+
|
92 |
+
$tmpCounter = 0;
|
93 |
+
foreach ($trackCollection as $tracker) {
|
94 |
+
$shipment = $shipmentsArray[$tracker->getParentId()];
|
95 |
+
$label = $this->_parseLabelData($order, $tmpCounter);
|
96 |
+
$barcode = $label['barcode'];
|
97 |
+
|
98 |
+
try {
|
99 |
+
if (array_key_exists('returnBarcode', $label)) {
|
100 |
+
$shipment->setBpostReturnBarcode($label['returnBarcode']);
|
101 |
+
}
|
102 |
+
|
103 |
+
$shipment->setBpostLabelPath($pdfBaseName);
|
104 |
+
$shipment->setBpostTrackingUrl('<a target="_blank" href="' . Bpost_ShM_Model_Shipping_Carrier_BpostShM::SHIPMENT_TRACK_DOMAIN . "etr/light/performSearch.do?searchByItemCode=true&oss_language='" . $locale . "&itemCodes=" . $barcode . '">' . Mage::helper('bpost_shm')->__('Track this shipment') . '</a>');
|
105 |
+
$tracker->setData("number", $barcode);
|
106 |
+
|
107 |
+
//add data to transaction
|
108 |
+
$this->_getTransaction()
|
109 |
+
->addObject($shipment)
|
110 |
+
->addObject($tracker);
|
111 |
+
|
112 |
+
} catch (Exception $e) {
|
113 |
+
Mage::helper('bpost_shm')->log($e->getMessage(), Zend_Log::ERR);
|
114 |
+
continue;
|
115 |
+
}
|
116 |
+
|
117 |
+
$tmpCounter++;
|
118 |
+
}
|
119 |
+
|
120 |
+
$order->addStatusHistoryComment(Mage::helper('bpost_shm')->__('Shipped with bpost generateLabelAndComplete'), true);
|
121 |
+
|
122 |
+
if ($this->_addReturnLabels) {
|
123 |
+
$order->setBpostReturnLabelExists(true);
|
124 |
+
}
|
125 |
+
|
126 |
+
$order->setBpostLabelExists(true);
|
127 |
+
$this->_getTransaction()->addObject($order);
|
128 |
+
|
129 |
+
return $counter;
|
130 |
+
} else {
|
131 |
+
$message = Mage::helper('bpost_shm')->__("The order with id %s only has non-bpost shipments.", $order->getIncrementId());
|
132 |
+
Mage::getSingleton('core/session')->addNotice($message);
|
133 |
+
return false;
|
134 |
+
}
|
135 |
+
}
|
136 |
+
|
137 |
+
|
138 |
+
/**
|
139 |
+
* @param $order
|
140 |
+
* @return bool
|
141 |
+
*/
|
142 |
+
protected function _createBpostShipment(&$order, $shipment = false)
|
143 |
+
{
|
144 |
+
$configHelper = Mage::helper('bpost_shm/system_config');
|
145 |
+
$bpostHelper = Mage::helper('bpost_shm');
|
146 |
+
|
147 |
+
$this->_addReturnLabels = (bool)$configHelper->getBpostShippingConfig("automatic_retour_labels", $order->getStoreId());
|
148 |
+
$locale = strtolower($bpostHelper->getLocaleByOrder($order, true));
|
149 |
+
|
150 |
+
if (!$shipment) {
|
151 |
+
$shipment = $order->prepareShipment();
|
152 |
+
$shipment->register()->setBpostShipmentAutomated(true)->save();
|
153 |
+
}
|
154 |
+
|
155 |
+
$weight = Mage::helper('bpost_shm')->calculateTotalShippingWeight($shipment);
|
156 |
+
$shipment->setTotalWeight($weight);
|
157 |
+
|
158 |
+
//first create the bpost order
|
159 |
+
$this->_createBpostOrder($order);
|
160 |
+
|
161 |
+
//then create label for order
|
162 |
+
$pdfBaseName = $this->_generateLabelAndReturnLabelIfEnabled($order);
|
163 |
+
$label = $this->_parseLabelData($order);
|
164 |
+
$barcode = $label['barcode'];
|
165 |
+
|
166 |
+
if (!$pdfBaseName) {
|
167 |
+
$message = Mage::helper('bpost_shm')->__("Something went wrong while processing order #%s, please check your error logs.", $order->getIncrementId());
|
168 |
+
Mage::getSingleton('core/session')->addError($message);
|
169 |
+
return false;
|
170 |
+
} else {
|
171 |
+
if (array_key_exists('returnBarcode', $label)) {
|
172 |
+
$shipment->setBpostReturnBarcode($label['returnBarcode']);
|
173 |
+
}
|
174 |
+
$shipment->setBpostLabelPath($pdfBaseName);
|
175 |
+
$shipment->setBpostTrackingUrl('<a target="_blank" href="' . Bpost_ShM_Model_Shipping_Carrier_BpostShM::SHIPMENT_TRACK_DOMAIN . "etr/light/performSearch.do?searchByItemCode=true&oss_language='" . $locale . "&itemCodes=" . $barcode . '">' . Mage::helper('bpost_shm')->__('Track this shipment') . '</a>');
|
176 |
+
|
177 |
+
$order->setIsInProcess(true);
|
178 |
+
$order->addStatusHistoryComment(Mage::helper('bpost_shm')->__('Shipped with bpost generateLabelAndComplete'), true);
|
179 |
+
$order->setBpostLabelExists(true);
|
180 |
+
|
181 |
+
if ($this->_addReturnLabels) {
|
182 |
+
$order->setBpostReturnLabelExists(true);
|
183 |
+
}
|
184 |
+
|
185 |
+
$tracker = Mage::getModel('sales/order_shipment_track')
|
186 |
+
->setShipment($shipment)
|
187 |
+
->setData('title', 'bpost')
|
188 |
+
->setData('number', $barcode)
|
189 |
+
->setData('carrier_code', "bpostshm")
|
190 |
+
->setData('order_id', $shipment->getData('order_id'));
|
191 |
+
|
192 |
+
try {
|
193 |
+
$shipment->save();
|
194 |
+
$order->save();
|
195 |
+
$tracker->save();
|
196 |
+
if (Mage::getStoreConfig(Mage_Sales_Model_Order_Shipment::XML_PATH_EMAIL_ENABLED, $order->getStoreId())) {
|
197 |
+
$shipment->sendEmail(true, '');
|
198 |
+
}
|
199 |
+
} catch (Exception $e) {
|
200 |
+
Mage::helper('bpost_shm')->log($e->getMessage(), Zend_Log::ERR);
|
201 |
+
}
|
202 |
+
|
203 |
+
return 1;
|
204 |
+
}
|
205 |
+
}
|
206 |
+
|
207 |
+
|
208 |
+
/**
|
209 |
+
* @param $labelData
|
210 |
+
* function parses label data and returns it
|
211 |
+
*/
|
212 |
+
protected function _parseLabelData($order, $barcodeIndex = 0)
|
213 |
+
{
|
214 |
+
$bpostHelper = Mage::helper('bpost_shm');
|
215 |
+
|
216 |
+
$returnData = array();
|
217 |
+
$locale = $bpostHelper->getLocaleByOrder($order, true);
|
218 |
+
|
219 |
+
$returnData["locale"] = $locale;
|
220 |
+
|
221 |
+
if (!isset($this->_barcodeArray[$barcodeIndex])) {
|
222 |
+
$returnData["barcode"] = "no-barcode";
|
223 |
+
} else {
|
224 |
+
$returnData["barcode"] = $this->_barcodeArray[$barcodeIndex];
|
225 |
+
}
|
226 |
+
|
227 |
+
//check if the barcode index isset
|
228 |
+
//if so, a return barcode is available
|
229 |
+
if (isset($this->_returnBarcodeArray[$barcodeIndex])) {
|
230 |
+
$returnData["returnBarcode"] = $this->_returnBarcodeArray[$barcodeIndex];
|
231 |
+
}
|
232 |
+
|
233 |
+
return $returnData;
|
234 |
+
}
|
235 |
+
|
236 |
+
|
237 |
+
/**
|
238 |
+
* function generates bpost API order
|
239 |
+
* @param $order
|
240 |
+
* @throws Mage_Core_Exception
|
241 |
+
*/
|
242 |
+
protected function _createBpostOrder(&$order)
|
243 |
+
{
|
244 |
+
$bpostHelper = Mage::helper("bpost_shm");
|
245 |
+
|
246 |
+
$webserviceModel = Mage::getModel('bpost_shm/api');
|
247 |
+
$webserviceModel->initialize($order->getStoreId());
|
248 |
+
$response = $webserviceModel->createOrder($order);
|
249 |
+
|
250 |
+
if (!$response) {
|
251 |
+
Mage::throwException($bpostHelper->__("Error while creating a bpost order for Magento order #%s. Please check your API log.", $order->getIncrementId()));
|
252 |
+
}
|
253 |
+
|
254 |
+
if (!$order->getBpostReference()) {
|
255 |
+
$order->setBpostReference($order->getIncrementId());
|
256 |
+
}
|
257 |
+
}
|
258 |
+
|
259 |
+
|
260 |
+
/**
|
261 |
+
* Generates a shipment label and saves it on the harddisk.
|
262 |
+
*
|
263 |
+
* @param $order
|
264 |
+
* @param $shipment
|
265 |
+
* @return mixed
|
266 |
+
*/
|
267 |
+
protected function _generateLabelAndReturnLabelIfEnabled(&$order)
|
268 |
+
{
|
269 |
+
$bpostHelper = Mage::helper("bpost_shm");
|
270 |
+
$pdfName = null;
|
271 |
+
|
272 |
+
$webserviceModel = Mage::getModel('bpost_shm/api');
|
273 |
+
$webserviceModel->initialize($order->getStoreId());
|
274 |
+
$response = $webserviceModel->createLabelByOrder($order, $this->_addReturnLabels);
|
275 |
+
|
276 |
+
if ($response) {
|
277 |
+
$parsedResponse = $bpostHelper->parseLabelApiResponse($response, $order);
|
278 |
+
|
279 |
+
if (empty($parsedResponse) || !isset($parsedResponse["pdfString"])) {
|
280 |
+
$message = $bpostHelper->__("No label response received for Magento order #%s.", $order->getIncrementId());
|
281 |
+
$bpostHelper->log($message, Zend_Log::ERR);
|
282 |
+
return false;
|
283 |
+
}
|
284 |
+
|
285 |
+
$this->_barcodeArray = $parsedResponse["barcodeString"];
|
286 |
+
|
287 |
+
if (array_key_exists("returnBarcodeString", $parsedResponse)) {
|
288 |
+
$this->_returnBarcodeArray = $parsedResponse["returnBarcodeString"];
|
289 |
+
}
|
290 |
+
|
291 |
+
//loop array and save pdf files
|
292 |
+
$loopNr = 0;
|
293 |
+
$pdfName = "";
|
294 |
+
foreach ($parsedResponse["pdfString"] as $pdfString) {
|
295 |
+
if ($loopNr) {
|
296 |
+
$pdfName .= ":";
|
297 |
+
}
|
298 |
+
|
299 |
+
$pdfName .= $bpostHelper->generatePdfAndSave($pdfString, "orderlabels", $order->getIncrementId());
|
300 |
+
$pdfName .= ".pdf";
|
301 |
+
|
302 |
+
if ($this->_addReturnLabels) {
|
303 |
+
$order->setBpostReturnLabelExists(true);
|
304 |
+
}
|
305 |
+
|
306 |
+
$loopNr++;
|
307 |
+
}
|
308 |
+
|
309 |
+
return $pdfName;
|
310 |
+
}
|
311 |
+
|
312 |
+
return false;
|
313 |
+
}
|
314 |
+
|
315 |
+
|
316 |
+
/**
|
317 |
+
* function returns the current transaction
|
318 |
+
*/
|
319 |
+
protected function _getTransaction()
|
320 |
+
{
|
321 |
+
if (is_null($this->_transaction)) {
|
322 |
+
$this->_transaction = Mage::getModel('core/resource_transaction');
|
323 |
+
}
|
324 |
+
|
325 |
+
return $this->_transaction;
|
326 |
+
}
|
327 |
+
|
328 |
+
|
329 |
+
/**
|
330 |
+
* function will save the current transaction
|
331 |
+
*/
|
332 |
+
public function saveTransaction()
|
333 |
+
{
|
334 |
+
//make sure we have an object first before saving it
|
335 |
+
if (is_object($this->_transaction)) {
|
336 |
+
$this->_transaction->save();
|
337 |
+
}
|
338 |
+
}
|
339 |
+
|
340 |
+
|
341 |
+
/**
|
342 |
+
* Processes the undownloadable labels. (set mark and zip)
|
343 |
+
*
|
344 |
+
* @param $orderIds
|
345 |
+
* @return bool|string
|
346 |
+
*/
|
347 |
+
public function processUndownloadedLabels($orderIds)
|
348 |
+
{
|
349 |
+
$file = new Varien_Io_File();
|
350 |
+
$labelPdfArray = array();
|
351 |
+
$i = 0;
|
352 |
+
|
353 |
+
$orderCollection = Mage::getModel("sales/order")->getCollection()
|
354 |
+
->addFieldToFilter("entity_id", array("in" => $orderIds));
|
355 |
+
|
356 |
+
$exportedOrderIds = array();
|
357 |
+
|
358 |
+
foreach ($orderCollection as $order) {
|
359 |
+
$exported = false;
|
360 |
+
|
361 |
+
if (!$order->getBpostLabelExported()) {
|
362 |
+
$shippingCollection = Mage::getResourceModel('sales/order_shipment_collection')
|
363 |
+
->setOrderFilter($order)
|
364 |
+
->load();
|
365 |
+
|
366 |
+
if (count($shippingCollection)) {
|
367 |
+
foreach ($shippingCollection as $shipment) {
|
368 |
+
if ($shipment->getBpostLabelPath() != "" && !$exported) {
|
369 |
+
$labelPaths = explode(":", $shipment->getBpostLabelPath());
|
370 |
+
foreach ($labelPaths as $labelPath) {
|
371 |
+
$filePath = Mage::getBaseDir('media') . self::MEDIA_LABEL_PATH . $labelPath;
|
372 |
+
if ($file->fileExists($filePath)) {
|
373 |
+
$labelPdfArray[] = $filePath;
|
374 |
+
$exported = true;
|
375 |
+
}
|
376 |
+
}
|
377 |
+
}
|
378 |
+
}
|
379 |
+
|
380 |
+
if ($exported) {
|
381 |
+
$exportedOrderIds[] = $order->getId();
|
382 |
+
$order->setBpostLabelExported(true);
|
383 |
+
}
|
384 |
+
}
|
385 |
+
} else {
|
386 |
+
$i++;
|
387 |
+
}
|
388 |
+
}
|
389 |
+
|
390 |
+
$orderCollection->save();
|
391 |
+
|
392 |
+
//we save data to all shipments, performance change
|
393 |
+
$shippingCollection = Mage::getModel('sales/order_shipment')->getCollection();
|
394 |
+
$shippingCollection->addFieldToFilter("order_id", array("in" => $exportedOrderIds));
|
395 |
+
$shippingCollection->setDataToAll("bpost_label_exported", true)->save();
|
396 |
+
|
397 |
+
if (!count($labelPdfArray)) {
|
398 |
+
return false;
|
399 |
+
}
|
400 |
+
if ($i > 0) {
|
401 |
+
$message = Mage::helper('bpost_shm')->__('%s orders already had downloaded labels.', $i);
|
402 |
+
Mage::getSingleton('core/session')->addNotice($message);
|
403 |
+
}
|
404 |
+
|
405 |
+
$generatedName = date("Y_m_d_H_i_s") . "_undownloaded.zip";
|
406 |
+
|
407 |
+
$file = new Varien_Io_File();
|
408 |
+
$file->checkAndCreateFolder(Mage::getBaseDir('media') . self::MEDIA_LABEL_PATH . "zips/");
|
409 |
+
|
410 |
+
return $this->_zipLabelPdfArray($labelPdfArray, $generatedName, true, true);
|
411 |
+
}
|
412 |
+
|
413 |
+
|
414 |
+
/**
|
415 |
+
* Zips the labels.
|
416 |
+
*
|
417 |
+
* @param array $files
|
418 |
+
* @param string $generatedName
|
419 |
+
* @param bool $overwrite
|
420 |
+
* @return bool|string
|
421 |
+
*/
|
422 |
+
protected function _zipLabelPdfArray($files = array(), $generatedName = '', $overwrite = false, $mergePdfFiles = false)
|
423 |
+
{
|
424 |
+
$destination = Mage::getBaseDir('media') . self::MEDIA_LABEL_PATH . "zips/" . $generatedName;
|
425 |
+
$varienFile = new Varien_Io_File();
|
426 |
+
$bpostHelper = Mage::helper("bpost_shm");
|
427 |
+
|
428 |
+
|
429 |
+
if ($varienFile->fileExists($destination) && !$overwrite) {
|
430 |
+
return false;
|
431 |
+
}
|
432 |
+
|
433 |
+
$validFiles = array();
|
434 |
+
$pdfMerged = new Zend_Pdf();
|
435 |
+
|
436 |
+
if (is_array($files)) {
|
437 |
+
foreach ($files as $file) {
|
438 |
+
if ($varienFile->fileExists($file)) {
|
439 |
+
$validFiles[] = $file;
|
440 |
+
|
441 |
+
if ($mergePdfFiles) {
|
442 |
+
$tmpPdf = Zend_Pdf::load($file);
|
443 |
+
foreach ($tmpPdf->pages as $page) {
|
444 |
+
$clonedPage = clone $page;
|
445 |
+
$pdfMerged->pages[] = $clonedPage;
|
446 |
+
}
|
447 |
+
}
|
448 |
+
}
|
449 |
+
}
|
450 |
+
|
451 |
+
//save new pdf file is necessary
|
452 |
+
if ($mergePdfFiles) {
|
453 |
+
$mergedPdfName = $bpostHelper->generatePdfAndSave($pdfMerged->render(), "orderlabels", "merged");
|
454 |
+
$mergedPdfName = $mergedPdfName . ".pdf";
|
455 |
+
|
456 |
+
if ($mergedPdfName) {
|
457 |
+
$validFiles = array($mergedPdfName);
|
458 |
+
}
|
459 |
+
}
|
460 |
+
|
461 |
+
$validFilesCount = count($validFiles);
|
462 |
+
if ($validFilesCount && $validFilesCount > 1) {
|
463 |
+
$zip = new ZipArchive();
|
464 |
+
|
465 |
+
if ($zip->open($destination, $overwrite ? ZIPARCHIVE::OVERWRITE : ZIPARCHIVE::CREATE) !== true) {
|
466 |
+
return false;
|
467 |
+
}
|
468 |
+
|
469 |
+
foreach ($validFiles as $file) {
|
470 |
+
$fileName = $bpostHelper->getFileNameByPath($file);
|
471 |
+
$zip->addFile($file, $fileName);
|
472 |
+
}
|
473 |
+
|
474 |
+
$zip->close();
|
475 |
+
return $generatedName;
|
476 |
+
} elseif ($validFilesCount) {
|
477 |
+
//we return the pdf path instead of creating a zip file
|
478 |
+
$pdfName = $validFiles[0];
|
479 |
+
return $pdfName;
|
480 |
+
}
|
481 |
+
}
|
482 |
+
|
483 |
+
return false;
|
484 |
+
}
|
485 |
}
|
app/code/community/Bpost/ShM/Model/Adminhtml/Observer.php
CHANGED
@@ -1,218 +1,218 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Class Bpost_ShM_Model_Adminhtml_Observer
|
5 |
-
*/
|
6 |
-
class Bpost_ShM_Model_Adminhtml_Observer extends Varien_Event_Observer
|
7 |
-
{
|
8 |
-
/**
|
9 |
-
* @param $observer
|
10 |
-
* @return bool
|
11 |
-
*/
|
12 |
-
public function core_block_abstract_to_html_before($observer)
|
13 |
-
{
|
14 |
-
if(Mage::helper('core')->isModuleEnabled('Bpost_ShippingManager') && !Mage::getSingleton('adminhtml/session')->getOldExtensionMessageShown() && Mage::helper('adminhtml')->getCurrentUserId() != "") {
|
15 |
-
$popupMessage = Mage::helper('bpost_shm')->__('Please remove or disable the old bpost extension prior to the installation of the new one.');
|
16 |
-
Mage::getSingleton('adminhtml/session')->addNotice($popupMessage);
|
17 |
-
Mage::getSingleton('adminhtml/session')->setOldExtensionMessageShown(true);
|
18 |
-
}
|
19 |
-
|
20 |
-
$block = $observer->getBlock();
|
21 |
-
|
22 |
-
//add download bpost label on shipment view page
|
23 |
-
if ($block instanceof Mage_Adminhtml_Block_Sales_Order_Shipment_View && $block->getRequest()->getControllerName() == "sales_order_shipment") {
|
24 |
-
$shipment = Mage::registry('current_shipment');
|
25 |
-
$shipmentId = $shipment->getId();
|
26 |
-
$order = Mage::getModel('sales/order')->load($shipment->getOrderId());
|
27 |
-
|
28 |
-
if (strpos($order->getShippingMethod(), 'bpost') !== false && ($shipment->getBpostLabelPath() && $shipment->getBpostLabelExported())) {
|
29 |
-
$block->addButton('download', array(
|
30 |
-
'label' => Mage::helper('bpost_shm')->__('Download bpost label'),
|
31 |
-
'onclick' => 'setLocation(\'' . Mage::helper("adminhtml")->getUrl('adminhtml/bpost_shM_download/label/shipment_id/' . $shipmentId) .'\')',
|
32 |
-
'class' => 'scalable save',
|
33 |
-
), 1, 0);
|
34 |
-
}
|
35 |
-
}
|
36 |
-
|
37 |
-
//add bpost return label on order view page
|
38 |
-
if ($block instanceof Mage_Adminhtml_Block_Sales_Order_View && $block->getRequest()->getControllerName() == "sales_order") {
|
39 |
-
$order = Mage::registry('current_order');
|
40 |
-
|
41 |
-
if(strpos($order->getShippingMethod(), 'bpostshm') !== false){
|
42 |
-
$block->addButton('download', array(
|
43 |
-
'label' => Mage::helper('bpost_shm')->__('bpost Return Label'),
|
44 |
-
'onclick' => 'setLocation(\'' . Mage::helper("adminhtml")->getUrl('adminhtml/bpost_shM_download/returnLabel/order_id/' . $order->getId()) .'\')',
|
45 |
-
'class' => 'scalable save',
|
46 |
-
), 1, 0);
|
47 |
-
}
|
48 |
-
}
|
49 |
-
|
50 |
-
return false;
|
51 |
-
}
|
52 |
-
|
53 |
-
|
54 |
-
/**
|
55 |
-
* @param $observer
|
56 |
-
* @return bool
|
57 |
-
*/
|
58 |
-
public function bpost_shm_prepare_grid_collection_after($observer){
|
59 |
-
$collection = $observer->getCollection();
|
60 |
-
$transaction = Mage::getModel('core/resource_transaction');
|
61 |
-
|
62 |
-
//we only need to update the bpost status for orders that does not have the status “pending“, “completed”, “closed” or “cancelled”
|
63 |
-
$stateArray = array(
|
64 |
-
Mage_Sales_Model_Order::STATE_NEW,
|
65 |
-
Mage_Sales_Model_Order::STATE_PENDING_PAYMENT,
|
66 |
-
Mage_Sales_Model_Order::STATE_CLOSED,
|
67 |
-
Mage_Sales_Model_Order::STATE_COMPLETE,
|
68 |
-
Mage_Sales_Model_Order::STATE_CANCELED,
|
69 |
-
);
|
70 |
-
|
71 |
-
$collection->addAttributeToSelect('bpost_reference');
|
72 |
-
$bpostHelper = Mage::helper("bpost_shm");
|
73 |
-
|
74 |
-
//loop collection and get statuses
|
75 |
-
foreach($collection as $order){
|
76 |
-
if(in_array($order->getState(), $stateArray)){
|
77 |
-
continue;
|
78 |
-
}
|
79 |
-
|
80 |
-
$dataChanged = false;
|
81 |
-
$orderStatus = false;
|
82 |
-
|
83 |
-
if($order->getBpostReference()){
|
84 |
-
try{
|
85 |
-
$shipmentStatuses = $bpostHelper->getBpostStatus($order);
|
86 |
-
|
87 |
-
if(!$shipmentStatuses){
|
88 |
-
continue;
|
89 |
-
}
|
90 |
-
|
91 |
-
$trackCollection = Mage::getResourceModel('sales/order_shipment_track_collection')
|
92 |
-
->addFieldToFilter('order_id', $order->getId())
|
93 |
-
->addFieldToFilter('carrier_code', 'bpostshm');
|
94 |
-
|
95 |
-
|
96 |
-
//extra count check
|
97 |
-
//normally not necessary. If the bpost reference exists a shipment track must exists too.
|
98 |
-
if($trackCollection->count() == 0){
|
99 |
-
continue;
|
100 |
-
}
|
101 |
-
|
102 |
-
foreach($trackCollection as $track){
|
103 |
-
$trackNumber = $track->getTrackNumber();
|
104 |
-
|
105 |
-
if($trackNumber && isset($shipmentStatuses[$trackNumber])){
|
106 |
-
$status = $shipmentStatuses[$trackNumber];
|
107 |
-
$shipment = $track->getShipment();
|
108 |
-
$shipment->setBpostStatus($status);
|
109 |
-
$transaction->addObject($shipment);
|
110 |
-
|
111 |
-
if($orderStatus && $status != $orderStatus){
|
112 |
-
$orderStatus = "multiple_statuses";
|
113 |
-
}elseif(!$orderStatus){
|
114 |
-
$orderStatus = $status;
|
115 |
-
}
|
116 |
-
|
117 |
-
$dataChanged = true;
|
118 |
-
}
|
119 |
-
}
|
120 |
-
|
121 |
-
$order->setBpostStatus($orderStatus);
|
122 |
-
|
123 |
-
//we use a transaction for saving our data
|
124 |
-
//need to save shipment and order
|
125 |
-
if($dataChanged){
|
126 |
-
$transaction->addObject($order);
|
127 |
-
}
|
128 |
-
}catch(Exception $e){
|
129 |
-
Mage::helper("bpost_shm")->ApiLog($e->getMessage(), Zend_Log::ERR);
|
130 |
-
}
|
131 |
-
}
|
132 |
-
}
|
133 |
-
|
134 |
-
//save transaction
|
135 |
-
$transaction->save();
|
136 |
-
}
|
137 |
-
|
138 |
-
|
139 |
-
/**
|
140 |
-
* @return $this
|
141 |
-
* function triggered when saving shipping settings bpost module
|
142 |
-
* checks if authentication is valid
|
143 |
-
*/
|
144 |
-
public function admin_system_config_changed_section_shipping()
|
145 |
-
{
|
146 |
-
/** @var Bpost_ShM_Model_Api $api */
|
147 |
-
$session = Mage::getSingleton("adminhtml/session");
|
148 |
-
$configHelper = Mage::helper("bpost_shm/system_config");
|
149 |
-
|
150 |
-
try{
|
151 |
-
$api = Mage::getModel( 'bpost_shm/api', true );
|
152 |
-
$apiResponse = $api->getProductConfig();
|
153 |
-
|
154 |
-
if(!$apiResponse) {
|
155 |
-
Mage::throwException("Failed to authenticate with bpost, please check your credentials.");
|
156 |
-
}
|
157 |
-
|
158 |
-
//check if click & collect is allowed and trigger
|
159 |
-
$this->_checkAndTriggerClickCollect($apiResponse->getBody());
|
160 |
-
|
161 |
-
$session->addSuccess($configHelper->__("Successfully authenticated with bpost."));
|
162 |
-
}catch(Exception $e){
|
163 |
-
$session->addError($configHelper->__($e->getMessage()));
|
164 |
-
}
|
165 |
-
|
166 |
-
return $this;
|
167 |
-
}
|
168 |
-
|
169 |
-
|
170 |
-
protected function _checkAndTriggerClickCollect($apiResponseBody){
|
171 |
-
$xml = simplexml_load_string($apiResponseBody);
|
172 |
-
$configHelper = Mage::helper('bpost_shm/system_config');
|
173 |
-
foreach ($xml->deliveryMethod as $deliveryMethodData) {
|
174 |
-
if($deliveryMethodData['name'] == "Click & Collect" && $deliveryMethodData['visiblity'] == "VISIBLE"){
|
175 |
-
Mage::getConfig()->saveConfig('carriers/bpost_clickcollect/activated', '1');
|
176 |
-
Mage::getConfig()->saveConfig('carriers/bpost_clickcollect/active', '1');
|
177 |
-
if($configHelper->getBpostCarriersConfig('marker', 'bpost_clickcollect') == ""){
|
178 |
-
|
179 |
-
$src = Mage::getBaseDir('skin') .
|
180 |
-
DS . 'frontend' .
|
181 |
-
DS . 'base' .
|
182 |
-
DS . 'default' .
|
183 |
-
DS . 'images' . DS . 'bpost' . DS . 'location_clickcollect_default.png';
|
184 |
-
|
185 |
-
$dest = Mage::getBaseDir('media') .
|
186 |
-
DS . 'bpost' . DS . 'default' . DS . 'location_clickcollect_default.png';
|
187 |
-
|
188 |
-
$io = new Varien_Io_File();
|
189 |
-
$io->cp($src, $dest);
|
190 |
-
Mage::getConfig()
|
191 |
-
->saveConfig('carriers/bpost_clickcollect/marker', 'default/location_clickcollect_default.png');
|
192 |
-
}
|
193 |
-
Mage::app()->getCacheInstance()->cleanType('config');
|
194 |
-
return $this;
|
195 |
-
}
|
196 |
-
elseif($configHelper->getBpostCarriersConfig('activated', 'bpost_clickcollect') == 1){
|
197 |
-
Mage::getConfig()->saveConfig('carriers/bpost_clickcollect/activated', '0');
|
198 |
-
Mage::getConfig()->saveConfig('carriers/bpost_clickcollect/active', '0');
|
199 |
-
Mage::app()->getCacheInstance()->cleanType('config');
|
200 |
-
}
|
201 |
-
}
|
202 |
-
}
|
203 |
-
|
204 |
-
/**
|
205 |
-
* Calculate and set the weight on the shipping to pass it to the webservice after a standard shipment save.
|
206 |
-
*
|
207 |
-
* @param $observer
|
208 |
-
*/
|
209 |
-
public function sales_order_shipment_save_before($observer)
|
210 |
-
{
|
211 |
-
$shipment = $observer->getEvent()->getShipment();
|
212 |
-
if (!$shipment->hasId() && !$shipment->getTotalWeight()) {
|
213 |
-
$weight = Mage::helper('bpost_shm')->calculateTotalShippingWeight($shipment);
|
214 |
-
$shipment->setTotalWeight($weight);
|
215 |
-
}
|
216 |
-
}
|
217 |
-
|
218 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class Bpost_ShM_Model_Adminhtml_Observer
|
5 |
+
*/
|
6 |
+
class Bpost_ShM_Model_Adminhtml_Observer extends Varien_Event_Observer
|
7 |
+
{
|
8 |
+
/**
|
9 |
+
* @param $observer
|
10 |
+
* @return bool
|
11 |
+
*/
|
12 |
+
public function core_block_abstract_to_html_before($observer)
|
13 |
+
{
|
14 |
+
if(Mage::helper('core')->isModuleEnabled('Bpost_ShippingManager') && !Mage::getSingleton('adminhtml/session')->getOldExtensionMessageShown() && Mage::helper('adminhtml')->getCurrentUserId() != "") {
|
15 |
+
$popupMessage = Mage::helper('bpost_shm')->__('Please remove or disable the old bpost extension prior to the installation of the new one.');
|
16 |
+
Mage::getSingleton('adminhtml/session')->addNotice($popupMessage);
|
17 |
+
Mage::getSingleton('adminhtml/session')->setOldExtensionMessageShown(true);
|
18 |
+
}
|
19 |
+
|
20 |
+
$block = $observer->getBlock();
|
21 |
+
|
22 |
+
//add download bpost label on shipment view page
|
23 |
+
if ($block instanceof Mage_Adminhtml_Block_Sales_Order_Shipment_View && $block->getRequest()->getControllerName() == "sales_order_shipment") {
|
24 |
+
$shipment = Mage::registry('current_shipment');
|
25 |
+
$shipmentId = $shipment->getId();
|
26 |
+
$order = Mage::getModel('sales/order')->load($shipment->getOrderId());
|
27 |
+
|
28 |
+
if (strpos($order->getShippingMethod(), 'bpost') !== false && ($shipment->getBpostLabelPath() && $shipment->getBpostLabelExported())) {
|
29 |
+
$block->addButton('download', array(
|
30 |
+
'label' => Mage::helper('bpost_shm')->__('Download bpost label'),
|
31 |
+
'onclick' => 'setLocation(\'' . Mage::helper("adminhtml")->getUrl('adminhtml/bpost_shM_download/label/shipment_id/' . $shipmentId) .'\')',
|
32 |
+
'class' => 'scalable save',
|
33 |
+
), 1, 0);
|
34 |
+
}
|
35 |
+
}
|
36 |
+
|
37 |
+
//add bpost return label on order view page
|
38 |
+
if ($block instanceof Mage_Adminhtml_Block_Sales_Order_View && $block->getRequest()->getControllerName() == "sales_order") {
|
39 |
+
$order = Mage::registry('current_order');
|
40 |
+
|
41 |
+
if(strpos($order->getShippingMethod(), 'bpostshm') !== false){
|
42 |
+
$block->addButton('download', array(
|
43 |
+
'label' => Mage::helper('bpost_shm')->__('bpost Return Label'),
|
44 |
+
'onclick' => 'setLocation(\'' . Mage::helper("adminhtml")->getUrl('adminhtml/bpost_shM_download/returnLabel/order_id/' . $order->getId()) .'\')',
|
45 |
+
'class' => 'scalable save',
|
46 |
+
), 1, 0);
|
47 |
+
}
|
48 |
+
}
|
49 |
+
|
50 |
+
return false;
|
51 |
+
}
|
52 |
+
|
53 |
+
|
54 |
+
/**
|
55 |
+
* @param $observer
|
56 |
+
* @return bool
|
57 |
+
*/
|
58 |
+
public function bpost_shm_prepare_grid_collection_after($observer){
|
59 |
+
$collection = $observer->getCollection();
|
60 |
+
$transaction = Mage::getModel('core/resource_transaction');
|
61 |
+
|
62 |
+
//we only need to update the bpost status for orders that does not have the status “pending“, “completed”, “closed” or “cancelled”
|
63 |
+
$stateArray = array(
|
64 |
+
Mage_Sales_Model_Order::STATE_NEW,
|
65 |
+
Mage_Sales_Model_Order::STATE_PENDING_PAYMENT,
|
66 |
+
Mage_Sales_Model_Order::STATE_CLOSED,
|
67 |
+
Mage_Sales_Model_Order::STATE_COMPLETE,
|
68 |
+
Mage_Sales_Model_Order::STATE_CANCELED,
|
69 |
+
);
|
70 |
+
|
71 |
+
$collection->addAttributeToSelect('bpost_reference');
|
72 |
+
$bpostHelper = Mage::helper("bpost_shm");
|
73 |
+
|
74 |
+
//loop collection and get statuses
|
75 |
+
foreach($collection as $order){
|
76 |
+
if(in_array($order->getState(), $stateArray)){
|
77 |
+
continue;
|
78 |
+
}
|
79 |
+
|
80 |
+
$dataChanged = false;
|
81 |
+
$orderStatus = false;
|
82 |
+
|
83 |
+
if($order->getBpostReference()){
|
84 |
+
try{
|
85 |
+
$shipmentStatuses = $bpostHelper->getBpostStatus($order);
|
86 |
+
|
87 |
+
if(!$shipmentStatuses){
|
88 |
+
continue;
|
89 |
+
}
|
90 |
+
|
91 |
+
$trackCollection = Mage::getResourceModel('sales/order_shipment_track_collection')
|
92 |
+
->addFieldToFilter('order_id', $order->getId())
|
93 |
+
->addFieldToFilter('carrier_code', 'bpostshm');
|
94 |
+
|
95 |
+
|
96 |
+
//extra count check
|
97 |
+
//normally not necessary. If the bpost reference exists a shipment track must exists too.
|
98 |
+
if($trackCollection->count() == 0){
|
99 |
+
continue;
|
100 |
+
}
|
101 |
+
|
102 |
+
foreach($trackCollection as $track){
|
103 |
+
$trackNumber = $track->getTrackNumber();
|
104 |
+
|
105 |
+
if($trackNumber && isset($shipmentStatuses[$trackNumber])){
|
106 |
+
$status = $shipmentStatuses[$trackNumber];
|
107 |
+
$shipment = $track->getShipment();
|
108 |
+
$shipment->setBpostStatus($status);
|
109 |
+
$transaction->addObject($shipment);
|
110 |
+
|
111 |
+
if($orderStatus && $status != $orderStatus){
|
112 |
+
$orderStatus = "multiple_statuses";
|
113 |
+
}elseif(!$orderStatus){
|
114 |
+
$orderStatus = $status;
|
115 |
+
}
|
116 |
+
|
117 |
+
$dataChanged = true;
|
118 |
+
}
|
119 |
+
}
|
120 |
+
|
121 |
+
$order->setBpostStatus($orderStatus);
|
122 |
+
|
123 |
+
//we use a transaction for saving our data
|
124 |
+
//need to save shipment and order
|
125 |
+
if($dataChanged){
|
126 |
+
$transaction->addObject($order);
|
127 |
+
}
|
128 |
+
}catch(Exception $e){
|
129 |
+
Mage::helper("bpost_shm")->ApiLog($e->getMessage(), Zend_Log::ERR);
|
130 |
+
}
|
131 |
+
}
|
132 |
+
}
|
133 |
+
|
134 |
+
//save transaction
|
135 |
+
$transaction->save();
|
136 |
+
}
|
137 |
+
|
138 |
+
|
139 |
+
/**
|
140 |
+
* @return $this
|
141 |
+
* function triggered when saving shipping settings bpost module
|
142 |
+
* checks if authentication is valid
|
143 |
+
*/
|
144 |
+
public function admin_system_config_changed_section_shipping()
|
145 |
+
{
|
146 |
+
/** @var Bpost_ShM_Model_Api $api */
|
147 |
+
$session = Mage::getSingleton("adminhtml/session");
|
148 |
+
$configHelper = Mage::helper("bpost_shm/system_config");
|
149 |
+
|
150 |
+
try{
|
151 |
+
$api = Mage::getModel( 'bpost_shm/api', true );
|
152 |
+
$apiResponse = $api->getProductConfig();
|
153 |
+
|
154 |
+
if(!$apiResponse) {
|
155 |
+
Mage::throwException("Failed to authenticate with bpost, please check your credentials.");
|
156 |
+
}
|
157 |
+
|
158 |
+
//check if click & collect is allowed and trigger
|
159 |
+
$this->_checkAndTriggerClickCollect($apiResponse->getBody());
|
160 |
+
|
161 |
+
$session->addSuccess($configHelper->__("Successfully authenticated with bpost."));
|
162 |
+
}catch(Exception $e){
|
163 |
+
$session->addError($configHelper->__($e->getMessage()));
|
164 |
+
}
|
165 |
+
|
166 |
+
return $this;
|
167 |
+
}
|
168 |
+
|
169 |
+
|
170 |
+
protected function _checkAndTriggerClickCollect($apiResponseBody){
|
171 |
+
$xml = simplexml_load_string($apiResponseBody);
|
172 |
+
$configHelper = Mage::helper('bpost_shm/system_config');
|
173 |
+
foreach ($xml->deliveryMethod as $deliveryMethodData) {
|
174 |
+
if($deliveryMethodData['name'] == "Click & Collect" && $deliveryMethodData['visiblity'] == "VISIBLE"){
|
175 |
+
Mage::getConfig()->saveConfig('carriers/bpost_clickcollect/activated', '1');
|
176 |
+
Mage::getConfig()->saveConfig('carriers/bpost_clickcollect/active', '1');
|
177 |
+
if($configHelper->getBpostCarriersConfig('marker', 'bpost_clickcollect') == ""){
|
178 |
+
|
179 |
+
$src = Mage::getBaseDir('skin') .
|
180 |
+
DS . 'frontend' .
|
181 |
+
DS . 'base' .
|
182 |
+
DS . 'default' .
|
183 |
+
DS . 'images' . DS . 'bpost' . DS . 'location_clickcollect_default.png';
|
184 |
+
|
185 |
+
$dest = Mage::getBaseDir('media') .
|
186 |
+
DS . 'bpost' . DS . 'default' . DS . 'location_clickcollect_default.png';
|
187 |
+
|
188 |
+
$io = new Varien_Io_File();
|
189 |
+
$io->cp($src, $dest);
|
190 |
+
Mage::getConfig()
|
191 |
+
->saveConfig('carriers/bpost_clickcollect/marker', 'default/location_clickcollect_default.png');
|
192 |
+
}
|
193 |
+
Mage::app()->getCacheInstance()->cleanType('config');
|
194 |
+
return $this;
|
195 |
+
}
|
196 |
+
elseif($configHelper->getBpostCarriersConfig('activated', 'bpost_clickcollect') == 1){
|
197 |
+
Mage::getConfig()->saveConfig('carriers/bpost_clickcollect/activated', '0');
|
198 |
+
Mage::getConfig()->saveConfig('carriers/bpost_clickcollect/active', '0');
|
199 |
+
Mage::app()->getCacheInstance()->cleanType('config');
|
200 |
+
}
|
201 |
+
}
|
202 |
+
}
|
203 |
+
|
204 |
+
/**
|
205 |
+
* Calculate and set the weight on the shipping to pass it to the webservice after a standard shipment save.
|
206 |
+
*
|
207 |
+
* @param $observer
|
208 |
+
*/
|
209 |
+
public function sales_order_shipment_save_before($observer)
|
210 |
+
{
|
211 |
+
$shipment = $observer->getEvent()->getShipment();
|
212 |
+
if (!$shipment->hasId() && !$shipment->getTotalWeight()) {
|
213 |
+
$weight = Mage::helper('bpost_shm')->calculateTotalShippingWeight($shipment);
|
214 |
+
$shipment->setTotalWeight($weight);
|
215 |
+
}
|
216 |
+
}
|
217 |
+
|
218 |
}
|
app/code/community/Bpost/ShM/Model/Adminhtml/System/Config/Backend/Shipping/Tablerates/Clickcollect.php
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
-
<?php
|
2 |
-
class Bpost_ShM_Model_Adminhtml_System_Config_Backend_Shipping_Tablerates_Clickcollect extends Mage_Core_Model_Config_Data
|
3 |
-
{
|
4 |
-
/**
|
5 |
-
* Call the uploadAndImport function from the clickcollect tablerate recourcemodel.
|
6 |
-
*/
|
7 |
-
public function _afterSave()
|
8 |
-
{
|
9 |
-
Mage::getResourceModel('bpost_shm/tablerates_clickcollect')->uploadAndImport($this);
|
10 |
-
}
|
11 |
}
|
1 |
+
<?php
|
2 |
+
class Bpost_ShM_Model_Adminhtml_System_Config_Backend_Shipping_Tablerates_Clickcollect extends Mage_Core_Model_Config_Data
|
3 |
+
{
|
4 |
+
/**
|
5 |
+
* Call the uploadAndImport function from the clickcollect tablerate recourcemodel.
|
6 |
+
*/
|
7 |
+
public function _afterSave()
|
8 |
+
{
|
9 |
+
Mage::getResourceModel('bpost_shm/tablerates_clickcollect')->uploadAndImport($this);
|
10 |
+
}
|
11 |
}
|
app/code/community/Bpost/ShM/Model/Adminhtml/System/Config/Backend/Shipping/Tablerates/Homedelivery.php
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
-
<?php
|
2 |
-
class Bpost_ShM_Model_Adminhtml_System_Config_Backend_Shipping_Tablerates_Homedelivery extends Mage_Core_Model_Config_Data
|
3 |
-
{
|
4 |
-
/**
|
5 |
-
* Call the uploadAndImport function from the homedelivery tablerate recourcemodel.
|
6 |
-
*/
|
7 |
-
public function _afterSave()
|
8 |
-
{
|
9 |
-
Mage::getResourceModel('bpost_shm/tablerates_homedelivery')->uploadAndImport($this);
|
10 |
-
}
|
11 |
}
|
1 |
+
<?php
|
2 |
+
class Bpost_ShM_Model_Adminhtml_System_Config_Backend_Shipping_Tablerates_Homedelivery extends Mage_Core_Model_Config_Data
|
3 |
+
{
|
4 |
+
/**
|
5 |
+
* Call the uploadAndImport function from the homedelivery tablerate recourcemodel.
|
6 |
+
*/
|
7 |
+
public function _afterSave()
|
8 |
+
{
|
9 |
+
Mage::getResourceModel('bpost_shm/tablerates_homedelivery')->uploadAndImport($this);
|
10 |
+
}
|
11 |
}
|
app/code/community/Bpost/ShM/Model/Adminhtml/System/Config/Backend/Shipping/Tablerates/International.php
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
-
<?php
|
2 |
-
class Bpost_ShM_Model_Adminhtml_System_Config_Backend_Shipping_Tablerates_International extends Mage_Core_Model_Config_Data
|
3 |
-
{
|
4 |
-
/**
|
5 |
-
* Call the uploadAndImport function from the international tablerate recourcemodel.
|
6 |
-
*/
|
7 |
-
public function _afterSave()
|
8 |
-
{
|
9 |
-
Mage::getResourceModel('bpost_shm/tablerates_international')->uploadAndImport($this);
|
10 |
-
}
|
11 |
}
|
1 |
+
<?php
|
2 |
+
class Bpost_ShM_Model_Adminhtml_System_Config_Backend_Shipping_Tablerates_International extends Mage_Core_Model_Config_Data
|
3 |
+
{
|
4 |
+
/**
|
5 |
+
* Call the uploadAndImport function from the international tablerate recourcemodel.
|
6 |
+
*/
|
7 |
+
public function _afterSave()
|
8 |
+
{
|
9 |
+
Mage::getResourceModel('bpost_shm/tablerates_international')->uploadAndImport($this);
|
10 |
+
}
|
11 |
}
|
app/code/community/Bpost/ShM/Model/Adminhtml/System/Config/Backend/Shipping/Tablerates/Parcellocker.php
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
-
<?php
|
2 |
-
class Bpost_ShM_Model_Adminhtml_System_Config_Backend_Shipping_Tablerates_Parcellocker extends Mage_Core_Model_Config_Data
|
3 |
-
{
|
4 |
-
/**
|
5 |
-
* Call the uploadAndImport function from the parcellocker tablerate recourcemodel.
|
6 |
-
*/
|
7 |
-
public function _afterSave()
|
8 |
-
{
|
9 |
-
Mage::getResourceModel('bpost_shm/tablerates_parcellocker')->uploadAndImport($this);
|
10 |
-
}
|
11 |
}
|
1 |
+
<?php
|
2 |
+
class Bpost_ShM_Model_Adminhtml_System_Config_Backend_Shipping_Tablerates_Parcellocker extends Mage_Core_Model_Config_Data
|
3 |
+
{
|
4 |
+
/**
|
5 |
+
* Call the uploadAndImport function from the parcellocker tablerate recourcemodel.
|
6 |
+
*/
|
7 |
+
public function _afterSave()
|
8 |
+
{
|
9 |
+
Mage::getResourceModel('bpost_shm/tablerates_parcellocker')->uploadAndImport($this);
|
10 |
+
}
|
11 |
}
|
app/code/community/Bpost/ShM/Model/Adminhtml/System/Config/Backend/Shipping/Tablerates/Pickuppoint.php
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
-
<?php
|
2 |
-
class Bpost_ShM_Model_Adminhtml_System_Config_Backend_Shipping_Tablerates_Pickuppoint extends Mage_Core_Model_Config_Data
|
3 |
-
{
|
4 |
-
/**
|
5 |
-
* Call the uploadAndImport function from the pickuppoint tablerate recourcemodel.
|
6 |
-
*/
|
7 |
-
public function _afterSave()
|
8 |
-
{
|
9 |
-
Mage::getResourceModel('bpost_shm/tablerates_pickuppoint')->uploadAndImport($this);
|
10 |
-
}
|
11 |
}
|
1 |
+
<?php
|
2 |
+
class Bpost_ShM_Model_Adminhtml_System_Config_Backend_Shipping_Tablerates_Pickuppoint extends Mage_Core_Model_Config_Data
|
3 |
+
{
|
4 |
+
/**
|
5 |
+
* Call the uploadAndImport function from the pickuppoint tablerate recourcemodel.
|
6 |
+
*/
|
7 |
+
public function _afterSave()
|
8 |
+
{
|
9 |
+
Mage::getResourceModel('bpost_shm/tablerates_pickuppoint')->uploadAndImport($this);
|
10 |
+
}
|
11 |
}
|
app/code/community/Bpost/ShM/Model/Adminhtml/System/Config/Source/Datecomment.php
CHANGED
@@ -1,30 +1,30 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Created by PHPro
|
4 |
-
*
|
5 |
-
* @package Bpost
|
6 |
-
* @subpackage ShM
|
7 |
-
* @author PHPro (info@phpro.be)
|
8 |
-
*/
|
9 |
-
|
10 |
-
/**
|
11 |
-
* Class Bpost_ShM_Model_Adminhtml_System_Config_Source_Datecomment
|
12 |
-
*/
|
13 |
-
class Bpost_ShM_Model_Adminhtml_System_Config_Source_Datecomment extends Mage_Core_Model_Config_Data
|
14 |
-
{
|
15 |
-
|
16 |
-
public function getCommentText()
|
17 |
-
{
|
18 |
-
$bpostHelper = Mage::helper("bpost_shm");
|
19 |
-
$popupUrl = "'" . Mage::helper("adminhtml")->getUrl('adminhtml/bpost_shM_config/screenshotpopup') . "'";
|
20 |
-
|
21 |
-
$html = $bpostHelper->__("Displays calculated delivery date in the frontend:");
|
22 |
-
$html .= "<br/>";
|
23 |
-
$html .= '<a href="#" onclick="openPopup(' . $popupUrl . ',400,600);">';
|
24 |
-
$html .= '<span>' . $bpostHelper->__("Example") . '</span> ';
|
25 |
-
$html .= '</a>';
|
26 |
-
|
27 |
-
return $html;
|
28 |
-
}
|
29 |
-
|
30 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Created by PHPro
|
4 |
+
*
|
5 |
+
* @package Bpost
|
6 |
+
* @subpackage ShM
|
7 |
+
* @author PHPro (info@phpro.be)
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Class Bpost_ShM_Model_Adminhtml_System_Config_Source_Datecomment
|
12 |
+
*/
|
13 |
+
class Bpost_ShM_Model_Adminhtml_System_Config_Source_Datecomment extends Mage_Core_Model_Config_Data
|
14 |
+
{
|
15 |
+
|
16 |
+
public function getCommentText()
|
17 |
+
{
|
18 |
+
$bpostHelper = Mage::helper("bpost_shm");
|
19 |
+
$popupUrl = "'" . Mage::helper("adminhtml")->getUrl('adminhtml/bpost_shM_config/screenshotpopup') . "'";
|
20 |
+
|
21 |
+
$html = $bpostHelper->__("Displays calculated delivery date in the frontend:");
|
22 |
+
$html .= "<br/>";
|
23 |
+
$html .= '<a href="#" onclick="openPopup(' . $popupUrl . ',400,600);">';
|
24 |
+
$html .= '<span>' . $bpostHelper->__("Example") . '</span> ';
|
25 |
+
$html .= '</a>';
|
26 |
+
|
27 |
+
return $html;
|
28 |
+
}
|
29 |
+
|
30 |
+
}
|
app/code/community/Bpost/ShM/Model/Adminhtml/System/Config/Source/Shipping.php
CHANGED
@@ -1,52 +1,52 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Created by PHPro
|
4 |
-
*
|
5 |
-
* @package Bpost
|
6 |
-
* @subpackage ShM
|
7 |
-
* @author PHPro (info@phpro.be)
|
8 |
-
*/
|
9 |
-
class Bpost_ShM_Model_Adminhtml_System_Config_Source_Shipping
|
10 |
-
{
|
11 |
-
|
12 |
-
/**
|
13 |
-
* standard option array function
|
14 |
-
* if no function is added to the source model, this function will be called
|
15 |
-
*/
|
16 |
-
public function toOptionArray(){
|
17 |
-
|
18 |
-
}
|
19 |
-
|
20 |
-
/**
|
21 |
-
* @return array
|
22 |
-
* function returns the available label sizes
|
23 |
-
*/
|
24 |
-
public function getLabelSizesOptionsArray(){
|
25 |
-
return array("a4" => "A4", "a6" => "A6");
|
26 |
-
}
|
27 |
-
|
28 |
-
/**
|
29 |
-
* @return array
|
30 |
-
*/
|
31 |
-
public function nrOfDeliveryDaysShownOptionsArray(){
|
32 |
-
return array(2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7);
|
33 |
-
}
|
34 |
-
|
35 |
-
/**
|
36 |
-
* @return array
|
37 |
-
* function returns an array with all available log levels
|
38 |
-
*/
|
39 |
-
public function getLogLevels(){
|
40 |
-
return array(0 => "Emergency", 1 => "Alert", 2 => "Critical", 3 => "Error", 4 => "Warning", 5 => "Notice", 6 => "Informational", 7 => "Debug");
|
41 |
-
}
|
42 |
-
|
43 |
-
|
44 |
-
/**
|
45 |
-
* @return array
|
46 |
-
*/
|
47 |
-
public function getCountries(){
|
48 |
-
return array("BE" => Mage::helper("bpost_shm")->__("Belgium"));
|
49 |
-
}
|
50 |
-
|
51 |
-
|
52 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Created by PHPro
|
4 |
+
*
|
5 |
+
* @package Bpost
|
6 |
+
* @subpackage ShM
|
7 |
+
* @author PHPro (info@phpro.be)
|
8 |
+
*/
|
9 |
+
class Bpost_ShM_Model_Adminhtml_System_Config_Source_Shipping
|
10 |
+
{
|
11 |
+
|
12 |
+
/**
|
13 |
+
* standard option array function
|
14 |
+
* if no function is added to the source model, this function will be called
|
15 |
+
*/
|
16 |
+
public function toOptionArray(){
|
17 |
+
|
18 |
+
}
|
19 |
+
|
20 |
+
/**
|
21 |
+
* @return array
|
22 |
+
* function returns the available label sizes
|
23 |
+
*/
|
24 |
+
public function getLabelSizesOptionsArray(){
|
25 |
+
return array("a4" => "A4", "a6" => "A6");
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* @return array
|
30 |
+
*/
|
31 |
+
public function nrOfDeliveryDaysShownOptionsArray(){
|
32 |
+
return array(2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7);
|
33 |
+
}
|
34 |
+
|
35 |
+
/**
|
36 |
+
* @return array
|
37 |
+
* function returns an array with all available log levels
|
38 |
+
*/
|
39 |
+
public function getLogLevels(){
|
40 |
+
return array(0 => "Emergency", 1 => "Alert", 2 => "Critical", 3 => "Error", 4 => "Warning", 5 => "Notice", 6 => "Informational", 7 => "Debug");
|
41 |
+
}
|
42 |
+
|
43 |
+
|
44 |
+
/**
|
45 |
+
* @return array
|
46 |
+
*/
|
47 |
+
public function getCountries(){
|
48 |
+
return array("BE" => Mage::helper("bpost_shm")->__("Belgium"));
|
49 |
+
}
|
50 |
+
|
51 |
+
|
52 |
+
}
|
app/code/community/Bpost/ShM/Model/Api.php
CHANGED
@@ -1,312 +1,312 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Created by PHPro
|
5 |
-
*
|
6 |
-
* @package Bpost
|
7 |
-
* @subpackage ShM
|
8 |
-
* @author PHPro (info@phpro.be)
|
9 |
-
*/
|
10 |
-
|
11 |
-
class Bpost_ShM_Model_Api extends Bpost_ShM_Model_Api_Abstract
|
12 |
-
{
|
13 |
-
CONST TYPE_PICKUP_POINT = 3;
|
14 |
-
CONST TYPE_PARCEL_LOCKER = 4;
|
15 |
-
CONST TYPE_CLICK_COLLECT = 8;
|
16 |
-
|
17 |
-
|
18 |
-
/**
|
19 |
-
* function returns the product configuration for a specific customer
|
20 |
-
*/
|
21 |
-
public function getProductConfig(){
|
22 |
-
$path = $this->_accountId.DS."productconfig";
|
23 |
-
$headers = array("Accept:application/vnd.bpost.shm-productConfiguration-v3.1+XML");
|
24 |
-
|
25 |
-
$response = $this->_call($path, $headers);
|
26 |
-
return $response;
|
27 |
-
}
|
28 |
-
|
29 |
-
|
30 |
-
/**
|
31 |
-
* @param $order
|
32 |
-
* @param bool $shipment
|
33 |
-
* @return bool|Zend_Http_Response
|
34 |
-
*
|
35 |
-
* function returns the API response of creating a RETURN label
|
36 |
-
* this response can be passed to the parse label response helper function
|
37 |
-
* and later on be saved
|
38 |
-
*/
|
39 |
-
public function createReturnLabel($order){
|
40 |
-
//first we need to create a return order
|
41 |
-
//otherwise no label can be created
|
42 |
-
$response = $this->createOrder($order, true);
|
43 |
-
|
44 |
-
if(!$response) {
|
45 |
-
return false;
|
46 |
-
}
|
47 |
-
|
48 |
-
//now we create the label
|
49 |
-
return $this->createLabelByOrder($order);
|
50 |
-
}
|
51 |
-
|
52 |
-
|
53 |
-
/**
|
54 |
-
* @param $order
|
55 |
-
* @param bool $shipment
|
56 |
-
* @param bool $returnOrder
|
57 |
-
* @return bool|Zend_Http_Response
|
58 |
-
* @throws Mage_Core_Exception
|
59 |
-
* function creates an order/label for bpost orders
|
60 |
-
*/
|
61 |
-
|
62 |
-
public function createOrder($order, $returnOrder = false){
|
63 |
-
$path = $this->_accountId.DS."orders";
|
64 |
-
$headers = array("Content-Type:application/vnd.bpost.shm-order-v3.3+XML");
|
65 |
-
|
66 |
-
$shippingMethod = $order->getShippingMethod();
|
67 |
-
|
68 |
-
//check to make sure we only handle bpost orders
|
69 |
-
if(!$returnOrder && strpos($shippingMethod,"bpost_") === false){
|
70 |
-
Mage::throwException("Only orders with delivery method 'bpost_*' can be send to bpost.");
|
71 |
-
}
|
72 |
-
|
73 |
-
//now we create a new dom element
|
74 |
-
//we use the domcreator class for this
|
75 |
-
$domCreator = Mage::getModel("bpost_shm/api_domcreator");
|
76 |
-
$domCreator->initialize($order->getStoreId());
|
77 |
-
$document = $domCreator->getCreateOrderDomDocument($order, $returnOrder);
|
78 |
-
|
79 |
-
$errorHandlingData = array("request_name" => "createOrder", "order_id" => $order->getIncrementId());
|
80 |
-
$response = $this->_call($path, $headers, $errorHandlingData, "post", $document);
|
81 |
-
|
82 |
-
return $response;
|
83 |
-
}
|
84 |
-
|
85 |
-
|
86 |
-
/**
|
87 |
-
* @param bool $order
|
88 |
-
* @param bool $withReturnLabels
|
89 |
-
* @param string $format
|
90 |
-
* @return bool|Zend_Http_Response
|
91 |
-
* function calls the createLabelByShipmentOrInBulk function with reference prefix empty
|
92 |
-
*/
|
93 |
-
public function createLabelByOrder($order, $withReturnLabels = false, $format = "pdf"){
|
94 |
-
return $this->createLabelByShipmentOrInBulk($order, $withReturnLabels, $format, "");
|
95 |
-
}
|
96 |
-
|
97 |
-
|
98 |
-
/**
|
99 |
-
* @param $orderObject
|
100 |
-
* @param bool $withReturnLabels
|
101 |
-
* @param string $format
|
102 |
-
* @return bool|Zend_Http_Response
|
103 |
-
* function returns the API response of creating a label (with or without return label)
|
104 |
-
* this response can be passed to the parse label response helper function
|
105 |
-
* and later on be saved
|
106 |
-
|
107 |
-
* if no shipment is given, we will download in bulk
|
108 |
-
*/
|
109 |
-
public function createLabelByShipmentOrInBulk($orderObject = false, $withReturnLabels = false, $format = "pdf", $referencePrefix = "S"){
|
110 |
-
if($format === "pdf"){
|
111 |
-
$headers = array("Content-Type:application/vnd.bpost.shm-labelRequest-v3+XML","Accept:application/vnd.bpost.shm-label-pdf-v3+XML");
|
112 |
-
}else{
|
113 |
-
$headers = array("Content-Type:application/vnd.bpost.shm-labelRequest-v3+XML","Accept:application/vnd.bpost.shm-label-image-v3+XML");
|
114 |
-
}
|
115 |
-
|
116 |
-
$configHelper = Mage::helper("bpost_shm/system_config");
|
117 |
-
|
118 |
-
if($orderObject){
|
119 |
-
$storeId = $orderObject->getStoreId();
|
120 |
-
$referenceId = $referencePrefix.$orderObject->getIncrementId();
|
121 |
-
|
122 |
-
if($orderObject->getNewReference()){
|
123 |
-
$referenceId = $orderObject->getNewReference();
|
124 |
-
}
|
125 |
-
|
126 |
-
$labelFormat = strtoupper($configHelper->getBpostShippingConfig("label_format", $storeId));
|
127 |
-
$path = $this->_accountId.DS."orders".DS.$referenceId.DS."labels".DS.$labelFormat;
|
128 |
-
}else{
|
129 |
-
$labelFormat = strtoupper($configHelper->getBpostShippingConfig("label_format"));
|
130 |
-
$path = $this->_accountId.DS."orders".DS."labels".DS.$labelFormat;
|
131 |
-
}
|
132 |
-
|
133 |
-
if($withReturnLabels){
|
134 |
-
$path .= DS."withReturnLabels";
|
135 |
-
}
|
136 |
-
|
137 |
-
$errorHandlingData = array("request_name" => "createLabel");
|
138 |
-
$response = $this->_call($path, $headers, $errorHandlingData);
|
139 |
-
|
140 |
-
return $response;
|
141 |
-
}
|
142 |
-
|
143 |
-
|
144 |
-
/**
|
145 |
-
* @param $order
|
146 |
-
* API function returns order details by reference
|
147 |
-
* @return mixed
|
148 |
-
*/
|
149 |
-
public function retrieveOrderDetails($order){
|
150 |
-
$headers = array("Accept:application/vnd.bpost.shm-order-v3.3+XML");
|
151 |
-
$referenceId = $order->getIncrementId();
|
152 |
-
|
153 |
-
$path = $this->_accountId.DS."orders".DS.$referenceId;
|
154 |
-
$errorHandlingData = array("request_name" => "orderDetails");
|
155 |
-
|
156 |
-
$response = $this->_call($path, $headers, $errorHandlingData);
|
157 |
-
return $response;
|
158 |
-
}
|
159 |
-
|
160 |
-
|
161 |
-
/**
|
162 |
-
* GEO6 webservice call
|
163 |
-
* function delivers the nearest bpost pick-up points to a location given as argument.
|
164 |
-
* @param $addressData
|
165 |
-
* addressData = array that contains: street, number & zone
|
166 |
-
* street
|
167 |
-
* number
|
168 |
-
* zone: can be postcode or city
|
169 |
-
* @param $type
|
170 |
-
* type:
|
171 |
-
* Type 1 = Post Office
|
172 |
-
* Type 2 = Post Point
|
173 |
-
* Type 4 = bpack 24/7
|
174 |
-
* for example type 3 = type1 & type2
|
175 |
-
* @param $limit
|
176 |
-
* limit: max number of service points you want to get
|
177 |
-
* @param $language
|
178 |
-
* language nl or fr
|
179 |
-
* @return bool|Zend_Http_Response
|
180 |
-
*/
|
181 |
-
public function getNearestServicePoints($addressData = array(), $type = self::TYPE_PICKUP_POINT, $limit = 10, $language = false){
|
182 |
-
$function = "search";
|
183 |
-
$format = "xml";
|
184 |
-
|
185 |
-
if(!array_key_exists("zone", $addressData)){
|
186 |
-
Mage::throwException("Your address data must contain a zone index (can be a postcode or city).");
|
187 |
-
}
|
188 |
-
|
189 |
-
$language = $this->_getCurrentLanguage($language);
|
190 |
-
|
191 |
-
$params = array(
|
192 |
-
"Type" => $type,
|
193 |
-
"Limit" => $limit,
|
194 |
-
"Language" => $language,
|
195 |
-
"Function" => $function,
|
196 |
-
"Format" => $format,
|
197 |
-
"Zone" => $addressData["zone"],
|
198 |
-
"Partner" => $this->_getTaxiPostPartnerForType($type)
|
199 |
-
);
|
200 |
-
//fixing PEBKAC issue (see Confluence)
|
201 |
-
//$params["Street"] = $addressData["street"];
|
202 |
-
//$params["Number"] = $addressData["number"];
|
203 |
-
|
204 |
-
if ($type == self::TYPE_CLICK_COLLECT) {
|
205 |
-
$params["CheckOpen"] = 0;
|
206 |
-
}
|
207 |
-
|
208 |
-
$response = $this->_callTaxipostApi($params);
|
209 |
-
|
210 |
-
return $response->getBody();
|
211 |
-
}
|
212 |
-
|
213 |
-
|
214 |
-
/**
|
215 |
-
* GEO6 webservice call
|
216 |
-
* delivers the details for a bpost pick-up point referred to by its identifier.
|
217 |
-
* @param $servicePointId
|
218 |
-
* identifier
|
219 |
-
* @param $type
|
220 |
-
* type:
|
221 |
-
* Type 1 = Post Office
|
222 |
-
* Type 2 = Post Point
|
223 |
-
* Type 4 = bpack 24/7
|
224 |
-
* for example type 3 = type1 & type2
|
225 |
-
* @param $language
|
226 |
-
* language nl or fr
|
227 |
-
* @return bool|Zend_Http_Response
|
228 |
-
*/
|
229 |
-
public function getServicePointDetails($servicePointId, $type = self::TYPE_PICKUP_POINT, $language = false){
|
230 |
-
$format = "xml";
|
231 |
-
|
232 |
-
$language = $this->_getCurrentLanguage($language);
|
233 |
-
|
234 |
-
$params = array(
|
235 |
-
"Type" => $type,
|
236 |
-
"Format" => $format,
|
237 |
-
"Language" => $language,
|
238 |
-
"Function" => "info",
|
239 |
-
"Id" => $servicePointId,
|
240 |
-
"Partner" => $this->_getTaxiPostPartnerForType($type)
|
241 |
-
);
|
242 |
-
|
243 |
-
$response = $this->_callTaxipostApi($params);
|
244 |
-
|
245 |
-
return $response->getBody();
|
246 |
-
}
|
247 |
-
|
248 |
-
|
249 |
-
/**
|
250 |
-
* GEO6 webservice call
|
251 |
-
* delivers the details for a bpost Corner referred to by its identifier, presented in an HTML page.
|
252 |
-
* @param $servicePointId
|
253 |
-
* identifier
|
254 |
-
* @param $type
|
255 |
-
* type:
|
256 |
-
* Type 1 = Post Office
|
257 |
-
* Type 2 = Post Point
|
258 |
-
* Type 4 = bpack 24/7
|
259 |
-
* for example type 3 = type1 & type2
|
260 |
-
* @param $language
|
261 |
-
* language nl or fr
|
262 |
-
* @return bool|Zend_Http_Response
|
263 |
-
*/
|
264 |
-
public function getServicePointPage($servicePointId, $type = self::TYPE_PICKUP_POINT, $language = false){
|
265 |
-
$language = $this->_getCurrentLanguage($language);
|
266 |
-
$params = array(
|
267 |
-
"Type" => $type,
|
268 |
-
"Language" => $language,
|
269 |
-
"Function" => "page",
|
270 |
-
"Id" => $servicePointId,
|
271 |
-
"Partner" => $this->_getTaxiPostPartnerForType($type)
|
272 |
-
);
|
273 |
-
|
274 |
-
$response = $this->_callTaxipostApi($params);
|
275 |
-
|
276 |
-
return $response->getBody();
|
277 |
-
}
|
278 |
-
|
279 |
-
|
280 |
-
/**
|
281 |
-
* @return string
|
282 |
-
*/
|
283 |
-
protected function _getCurrentLanguage($language = false){
|
284 |
-
|
285 |
-
if(!$language) {
|
286 |
-
$language = strtolower(substr(Mage::app()->getLocale()->getLocaleCode(), 0, 2));
|
287 |
-
}
|
288 |
-
|
289 |
-
if($language != "nl" && $language != "fr"){
|
290 |
-
$language = "fr";
|
291 |
-
}
|
292 |
-
|
293 |
-
return $language;
|
294 |
-
}
|
295 |
-
|
296 |
-
/**
|
297 |
-
* @param int $type
|
298 |
-
* @return string
|
299 |
-
*/
|
300 |
-
protected function _getTaxiPostPartnerForType($type)
|
301 |
-
{
|
302 |
-
if ($type == self::TYPE_CLICK_COLLECT) {
|
303 |
-
$configHelper = Mage::helper("bpost_shm/system_config");
|
304 |
-
$storeId = Mage::app()->getStore()->getId();
|
305 |
-
|
306 |
-
return $configHelper->getBpostShippingConfig('accountid', $storeId);
|
307 |
-
}
|
308 |
-
|
309 |
-
return self::API_TAXIPOST_PARTNER;
|
310 |
-
}
|
311 |
-
|
312 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Created by PHPro
|
5 |
+
*
|
6 |
+
* @package Bpost
|
7 |
+
* @subpackage ShM
|
8 |
+
* @author PHPro (info@phpro.be)
|
9 |
+
*/
|
10 |
+
|
11 |
+
class Bpost_ShM_Model_Api extends Bpost_ShM_Model_Api_Abstract
|
12 |
+
{
|
13 |
+
CONST TYPE_PICKUP_POINT = 3;
|
14 |
+
CONST TYPE_PARCEL_LOCKER = 4;
|
15 |
+
CONST TYPE_CLICK_COLLECT = 8;
|
16 |
+
|
17 |
+
|
18 |
+
/**
|
19 |
+
* function returns the product configuration for a specific customer
|
20 |
+
*/
|
21 |
+
public function getProductConfig(){
|
22 |
+
$path = $this->_accountId.DS."productconfig";
|
23 |
+
$headers = array("Accept:application/vnd.bpost.shm-productConfiguration-v3.1+XML");
|
24 |
+
|
25 |
+
$response = $this->_call($path, $headers);
|
26 |
+
return $response;
|
27 |
+
}
|
28 |
+
|
29 |
+
|
30 |
+
/**
|
31 |
+
* @param $order
|
32 |
+
* @param bool $shipment
|
33 |
+
* @return bool|Zend_Http_Response
|
34 |
+
*
|
35 |
+
* function returns the API response of creating a RETURN label
|
36 |
+
* this response can be passed to the parse label response helper function
|
37 |
+
* and later on be saved
|
38 |
+
*/
|
39 |
+
public function createReturnLabel($order){
|
40 |
+
//first we need to create a return order
|
41 |
+
//otherwise no label can be created
|
42 |
+
$response = $this->createOrder($order, true);
|
43 |
+
|
44 |
+
if(!$response) {
|
45 |
+
return false;
|
46 |
+
}
|
47 |
+
|
48 |
+
//now we create the label
|
49 |
+
return $this->createLabelByOrder($order);
|
50 |
+
}
|
51 |
+
|
52 |
+
|
53 |
+
/**
|
54 |
+
* @param $order
|
55 |
+
* @param bool $shipment
|
56 |
+
* @param bool $returnOrder
|
57 |
+
* @return bool|Zend_Http_Response
|
58 |
+
* @throws Mage_Core_Exception
|
59 |
+
* function creates an order/label for bpost orders
|
60 |
+
*/
|
61 |
+
|
62 |
+
public function createOrder($order, $returnOrder = false){
|
63 |
+
$path = $this->_accountId.DS."orders";
|
64 |
+
$headers = array("Content-Type:application/vnd.bpost.shm-order-v3.3+XML");
|
65 |
+
|
66 |
+
$shippingMethod = $order->getShippingMethod();
|
67 |
+
|
68 |
+
//check to make sure we only handle bpost orders
|
69 |
+
if(!$returnOrder && strpos($shippingMethod,"bpost_") === false){
|
70 |
+
Mage::throwException("Only orders with delivery method 'bpost_*' can be send to bpost.");
|
71 |
+
}
|
72 |
+
|
73 |
+
//now we create a new dom element
|
74 |
+
//we use the domcreator class for this
|
75 |
+
$domCreator = Mage::getModel("bpost_shm/api_domcreator");
|
76 |
+
$domCreator->initialize($order->getStoreId());
|
77 |
+
$document = $domCreator->getCreateOrderDomDocument($order, $returnOrder);
|
78 |
+
|
79 |
+
$errorHandlingData = array("request_name" => "createOrder", "order_id" => $order->getIncrementId());
|
80 |
+
$response = $this->_call($path, $headers, $errorHandlingData, "post", $document);
|
81 |
+
|
82 |
+
return $response;
|
83 |
+
}
|
84 |
+
|
85 |
+
|
86 |
+
/**
|
87 |
+
* @param bool $order
|
88 |
+
* @param bool $withReturnLabels
|
89 |
+
* @param string $format
|
90 |
+
* @return bool|Zend_Http_Response
|
91 |
+
* function calls the createLabelByShipmentOrInBulk function with reference prefix empty
|
92 |
+
*/
|
93 |
+
public function createLabelByOrder($order, $withReturnLabels = false, $format = "pdf"){
|
94 |
+
return $this->createLabelByShipmentOrInBulk($order, $withReturnLabels, $format, "");
|
95 |
+
}
|
96 |
+
|
97 |
+
|
98 |
+
/**
|
99 |
+
* @param $orderObject
|
100 |
+
* @param bool $withReturnLabels
|
101 |
+
* @param string $format
|
102 |
+
* @return bool|Zend_Http_Response
|
103 |
+
* function returns the API response of creating a label (with or without return label)
|
104 |
+
* this response can be passed to the parse label response helper function
|
105 |
+
* and later on be saved
|
106 |
+
|
107 |
+
* if no shipment is given, we will download in bulk
|
108 |
+
*/
|
109 |
+
public function createLabelByShipmentOrInBulk($orderObject = false, $withReturnLabels = false, $format = "pdf", $referencePrefix = "S"){
|
110 |
+
if($format === "pdf"){
|
111 |
+
$headers = array("Content-Type:application/vnd.bpost.shm-labelRequest-v3+XML","Accept:application/vnd.bpost.shm-label-pdf-v3+XML");
|
112 |
+
}else{
|
113 |
+
$headers = array("Content-Type:application/vnd.bpost.shm-labelRequest-v3+XML","Accept:application/vnd.bpost.shm-label-image-v3+XML");
|
114 |
+
}
|
115 |
+
|
116 |
+
$configHelper = Mage::helper("bpost_shm/system_config");
|
117 |
+
|
118 |
+
if($orderObject){
|
119 |
+
$storeId = $orderObject->getStoreId();
|
120 |
+
$referenceId = $referencePrefix.$orderObject->getIncrementId();
|
121 |
+
|
122 |
+
if($orderObject->getNewReference()){
|
123 |
+
$referenceId = $orderObject->getNewReference();
|
124 |
+
}
|
125 |
+
|
126 |
+
$labelFormat = strtoupper($configHelper->getBpostShippingConfig("label_format", $storeId));
|
127 |
+
$path = $this->_accountId.DS."orders".DS.$referenceId.DS."labels".DS.$labelFormat;
|
128 |
+
}else{
|
129 |
+
$labelFormat = strtoupper($configHelper->getBpostShippingConfig("label_format"));
|
130 |
+
$path = $this->_accountId.DS."orders".DS."labels".DS.$labelFormat;
|
131 |
+
}
|
132 |
+
|
133 |
+
if($withReturnLabels){
|
134 |
+
$path .= DS."withReturnLabels";
|
135 |
+
}
|
136 |
+
|
137 |
+
$errorHandlingData = array("request_name" => "createLabel");
|
138 |
+
$response = $this->_call($path, $headers, $errorHandlingData);
|
139 |
+
|
140 |
+
return $response;
|
141 |
+
}
|
142 |
+
|
143 |
+
|
144 |
+
/**
|
145 |
+
* @param $order
|
146 |
+
* API function returns order details by reference
|
147 |
+
* @return mixed
|
148 |
+
*/
|
149 |
+
public function retrieveOrderDetails($order){
|
150 |
+
$headers = array("Accept:application/vnd.bpost.shm-order-v3.3+XML");
|
151 |
+
$referenceId = $order->getIncrementId();
|
152 |
+
|
153 |
+
$path = $this->_accountId.DS."orders".DS.$referenceId;
|
154 |
+
$errorHandlingData = array("request_name" => "orderDetails");
|
155 |
+
|
156 |
+
$response = $this->_call($path, $headers, $errorHandlingData);
|
157 |
+
return $response;
|
158 |
+
}
|
159 |
+
|
160 |
+
|
161 |
+
/**
|
162 |
+
* GEO6 webservice call
|
163 |
+
* function delivers the nearest bpost pick-up points to a location given as argument.
|
164 |
+
* @param $addressData
|
165 |
+
* addressData = array that contains: street, number & zone
|
166 |
+
* street
|
167 |
+
* number
|
168 |
+
* zone: can be postcode or city
|
169 |
+
* @param $type
|
170 |
+
* type:
|
171 |
+
* Type 1 = Post Office
|
172 |
+
* Type 2 = Post Point
|
173 |
+
* Type 4 = bpack 24/7
|
174 |
+
* for example type 3 = type1 & type2
|
175 |
+
* @param $limit
|
176 |
+
* limit: max number of service points you want to get
|
177 |
+
* @param $language
|
178 |
+
* language nl or fr
|
179 |
+
* @return bool|Zend_Http_Response
|
180 |
+
*/
|
181 |
+
public function getNearestServicePoints($addressData = array(), $type = self::TYPE_PICKUP_POINT, $limit = 10, $language = false){
|
182 |
+
$function = "search";
|
183 |
+
$format = "xml";
|
184 |
+
|
185 |
+
if(!array_key_exists("zone", $addressData)){
|
186 |
+
Mage::throwException("Your address data must contain a zone index (can be a postcode or city).");
|
187 |
+
}
|
188 |
+
|
189 |
+
$language = $this->_getCurrentLanguage($language);
|
190 |
+
|
191 |
+
$params = array(
|
192 |
+
"Type" => $type,
|
193 |
+
"Limit" => $limit,
|
194 |
+
"Language" => $language,
|
195 |
+
"Function" => $function,
|
196 |
+
"Format" => $format,
|
197 |
+
"Zone" => $addressData["zone"],
|
198 |
+
"Partner" => $this->_getTaxiPostPartnerForType($type)
|
199 |
+
);
|
200 |
+
//fixing PEBKAC issue (see Confluence)
|
201 |
+
//$params["Street"] = $addressData["street"];
|
202 |
+
//$params["Number"] = $addressData["number"];
|
203 |
+
|
204 |
+
if ($type == self::TYPE_CLICK_COLLECT) {
|
205 |
+
$params["CheckOpen"] = 0;
|
206 |
+
}
|
207 |
+
|
208 |
+
$response = $this->_callTaxipostApi($params);
|
209 |
+
|
210 |
+
return $response->getBody();
|
211 |
+
}
|
212 |
+
|
213 |
+
|
214 |
+
/**
|
215 |
+
* GEO6 webservice call
|
216 |
+
* delivers the details for a bpost pick-up point referred to by its identifier.
|
217 |
+
* @param $servicePointId
|
218 |
+
* identifier
|
219 |
+
* @param $type
|
220 |
+
* type:
|
221 |
+
* Type 1 = Post Office
|
222 |
+
* Type 2 = Post Point
|
223 |
+
* Type 4 = bpack 24/7
|
224 |
+
* for example type 3 = type1 & type2
|
225 |
+
* @param $language
|
226 |
+
* language nl or fr
|
227 |
+
* @return bool|Zend_Http_Response
|
228 |
+
*/
|
229 |
+
public function getServicePointDetails($servicePointId, $type = self::TYPE_PICKUP_POINT, $language = false){
|
230 |
+
$format = "xml";
|
231 |
+
|
232 |
+
$language = $this->_getCurrentLanguage($language);
|
233 |
+
|
234 |
+
$params = array(
|
235 |
+
"Type" => $type,
|
236 |
+
"Format" => $format,
|
237 |
+
"Language" => $language,
|
238 |
+
"Function" => "info",
|
239 |
+
"Id" => $servicePointId,
|
240 |
+
"Partner" => $this->_getTaxiPostPartnerForType($type)
|
241 |
+
);
|
242 |
+
|
243 |
+
$response = $this->_callTaxipostApi($params);
|
244 |
+
|
245 |
+
return $response->getBody();
|
246 |
+
}
|
247 |
+
|
248 |
+
|
249 |
+
/**
|
250 |
+
* GEO6 webservice call
|
251 |
+
* delivers the details for a bpost Corner referred to by its identifier, presented in an HTML page.
|
252 |
+
* @param $servicePointId
|
253 |
+
* identifier
|
254 |
+
* @param $type
|
255 |
+
* type:
|
256 |
+
* Type 1 = Post Office
|
257 |
+
* Type 2 = Post Point
|
258 |
+
* Type 4 = bpack 24/7
|
259 |
+
* for example type 3 = type1 & type2
|
260 |
+
* @param $language
|
261 |
+
* language nl or fr
|
262 |
+
* @return bool|Zend_Http_Response
|
263 |
+
*/
|
264 |
+
public function getServicePointPage($servicePointId, $type = self::TYPE_PICKUP_POINT, $language = false){
|
265 |
+
$language = $this->_getCurrentLanguage($language);
|
266 |
+
$params = array(
|
267 |
+
"Type" => $type,
|
268 |
+
"Language" => $language,
|
269 |
+
"Function" => "page",
|
270 |
+
"Id" => $servicePointId,
|
271 |
+
"Partner" => $this->_getTaxiPostPartnerForType($type)
|
272 |
+
);
|
273 |
+
|
274 |
+
$response = $this->_callTaxipostApi($params);
|
275 |
+
|
276 |
+
return $response->getBody();
|
277 |
+
}
|
278 |
+
|
279 |
+
|
280 |
+
/**
|
281 |
+
* @return string
|
282 |
+
*/
|
283 |
+
protected function _getCurrentLanguage($language = false){
|
284 |
+
|
285 |
+
if(!$language) {
|
286 |
+
$language = strtolower(substr(Mage::app()->getLocale()->getLocaleCode(), 0, 2));
|
287 |
+
}
|
288 |
+
|
289 |
+
if($language != "nl" && $language != "fr"){
|
290 |
+
$language = "fr";
|
291 |
+
}
|
292 |
+
|
293 |
+
return $language;
|
294 |
+
}
|
295 |
+
|
296 |
+
/**
|
297 |
+
* @param int $type
|
298 |
+
* @return string
|
299 |
+
*/
|
300 |
+
protected function _getTaxiPostPartnerForType($type)
|
301 |
+
{
|
302 |
+
if ($type == self::TYPE_CLICK_COLLECT) {
|
303 |
+
$configHelper = Mage::helper("bpost_shm/system_config");
|
304 |
+
$storeId = Mage::app()->getStore()->getId();
|
305 |
+
|
306 |
+
return $configHelper->getBpostShippingConfig('accountid', $storeId);
|
307 |
+
}
|
308 |
+
|
309 |
+
return self::API_TAXIPOST_PARTNER;
|
310 |
+
}
|
311 |
+
|
312 |
+
}
|
app/code/community/Bpost/ShM/Model/Api/Abstract.php
CHANGED
@@ -1,285 +1,285 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Created by PHPro
|
4 |
-
*
|
5 |
-
* @package Bpost
|
6 |
-
* @subpackage ShM
|
7 |
-
* @author PHPro (info@phpro.be)
|
8 |
-
*/
|
9 |
-
|
10 |
-
class Bpost_ShM_Model_Api_Abstract extends Mage_Core_Model_Abstract
|
11 |
-
{
|
12 |
-
const API_PATH_PREFIX = '/services/shm';
|
13 |
-
const API_URI_TAXIPOST_BASE = "http://taxipost.geo6.be";
|
14 |
-
const API_TAXIPOST_APPID = "A001";
|
15 |
-
const API_TAXIPOST_PARTNER = '107444';
|
16 |
-
|
17 |
-
protected $_apiUriBase;
|
18 |
-
protected $_accountId;
|
19 |
-
protected $_passphrase;
|
20 |
-
protected $_initialized = false;
|
21 |
-
protected $_bpostConfigHelper;
|
22 |
-
protected $_path = "";
|
23 |
-
|
24 |
-
/**
|
25 |
-
* Http client that is curently used.
|
26 |
-
*
|
27 |
-
* @var Zend_Http_Client
|
28 |
-
* @access protected
|
29 |
-
*/
|
30 |
-
protected $_httpClient;
|
31 |
-
|
32 |
-
/**
|
33 |
-
* Authorization key
|
34 |
-
*
|
35 |
-
* @var string
|
36 |
-
* @access protected
|
37 |
-
*/
|
38 |
-
protected $_authorization;
|
39 |
-
|
40 |
-
|
41 |
-
//constructor
|
42 |
-
public function __construct($initialize = false){
|
43 |
-
|
44 |
-
//first we set the helper as variable
|
45 |
-
//easier to access it
|
46 |
-
$this->_bpostConfigHelper = Mage::helper("bpost_shm/system_config");
|
47 |
-
|
48 |
-
//check if we need to initialize immediately
|
49 |
-
if($initialize){
|
50 |
-
$this->initialize();
|
51 |
-
}
|
52 |
-
}
|
53 |
-
|
54 |
-
|
55 |
-
/**
|
56 |
-
* Set the api domain, account id and passphrase of the given store
|
57 |
-
*
|
58 |
-
* @param null|int $storeId
|
59 |
-
*/
|
60 |
-
public function initialize($storeId = null)
|
61 |
-
{
|
62 |
-
if (!$storeId) {
|
63 |
-
$storeId = Mage::app()->getStore()->getId();
|
64 |
-
}
|
65 |
-
|
66 |
-
$this->_apiUriBase = $this->_bpostConfigHelper->getBpostShippingConfig('api_url', $storeId);
|
67 |
-
$this->_accountId = $this->_bpostConfigHelper->getBpostShippingConfig('accountid', $storeId);
|
68 |
-
$this->_passphrase = $this->_bpostConfigHelper->getBpostShippingConfig('passphrase', $storeId);
|
69 |
-
$this->_authorization = base64_encode($this->_accountId . ':' . $this->_passphrase);
|
70 |
-
$this->_initialized = true;
|
71 |
-
}
|
72 |
-
|
73 |
-
/**
|
74 |
-
* @return bool
|
75 |
-
* function checks if the current object is initialized or not
|
76 |
-
*/
|
77 |
-
public function isInitialized(){
|
78 |
-
if($this->_initialized){
|
79 |
-
return true;
|
80 |
-
}
|
81 |
-
|
82 |
-
return false;
|
83 |
-
}
|
84 |
-
|
85 |
-
/**
|
86 |
-
* Returns a REST client we can use for connecting to the webservice.
|
87 |
-
* @param array $headers
|
88 |
-
*
|
89 |
-
* @return Zend_Rest_Client
|
90 |
-
*/
|
91 |
-
protected function _getRestClient($headers = null){
|
92 |
-
try{
|
93 |
-
//first make sure the current model is initialized
|
94 |
-
if(!$this->isInitialized()){
|
95 |
-
Mage::throwException('Please initialize your API model first by calling the initialize() function.');
|
96 |
-
}
|
97 |
-
|
98 |
-
$restClient = new Zend_Rest_Client($this->_apiUriBase);
|
99 |
-
$this->_httpClient = new Zend_Http_Client($this->_apiUriBase, array('useragent' => 'Magento, with bpost Shipping Manager module.'));
|
100 |
-
$this->_httpClient->setHeaders('Authorization', 'Basic ' . $this->_authorization);
|
101 |
-
|
102 |
-
if ($headers) {
|
103 |
-
$this->_httpClient->setHeaders($headers);
|
104 |
-
}
|
105 |
-
|
106 |
-
$restClient->setHttpClient($this->_httpClient);
|
107 |
-
return $restClient;
|
108 |
-
}catch(Exception $e){
|
109 |
-
Mage::helper("bpost_shm")->ApiLog($e->getMessage(), Zend_Log::ERR);
|
110 |
-
}
|
111 |
-
|
112 |
-
return false;
|
113 |
-
}
|
114 |
-
|
115 |
-
|
116 |
-
/**
|
117 |
-
* Returns a Http client we can use for connecting to the taxipost webservice.
|
118 |
-
* @param array $headers
|
119 |
-
*
|
120 |
-
* @return Zend_Http_Client
|
121 |
-
*/
|
122 |
-
protected function _getTaxipostHttpClient($urlExtension = false){
|
123 |
-
try{
|
124 |
-
$url = self::API_URI_TAXIPOST_BASE;
|
125 |
-
|
126 |
-
if($urlExtension){
|
127 |
-
$url .= DS.$urlExtension;
|
128 |
-
}
|
129 |
-
|
130 |
-
$httpClient = new Zend_Http_Client($url, array('useragent' => 'Magento, with bpost Shipping Manager module.'));
|
131 |
-
|
132 |
-
return $httpClient;
|
133 |
-
}catch(Exception $e){
|
134 |
-
Mage::helper("bpost_shm")->ApiLog($e->getMessage(), Zend_Log::ERR);
|
135 |
-
}
|
136 |
-
|
137 |
-
return false;
|
138 |
-
}
|
139 |
-
|
140 |
-
|
141 |
-
/**
|
142 |
-
* @param $path
|
143 |
-
* @param $headers
|
144 |
-
* function sends request
|
145 |
-
*/
|
146 |
-
protected function _call($path, $headers, $errorHandlingData = array(), $action = "get", $document = null){
|
147 |
-
$bpostHelper = Mage::helper("bpost_shm");
|
148 |
-
$path = self::API_PATH_PREFIX.DS.$path;
|
149 |
-
$restClient = $this->_getRestClient($headers);
|
150 |
-
|
151 |
-
$bpostHelper->ApiLog("HEADERS:", Zend_Log::DEBUG, false);
|
152 |
-
$bpostHelper->ApiLog("\n".implode("\n", $headers), Zend_Log::DEBUG, false);
|
153 |
-
|
154 |
-
$bpostHelper->ApiLog("PATH:", Zend_Log::DEBUG,false);
|
155 |
-
$bpostHelper->ApiLog($path, Zend_Log::DEBUG, false);
|
156 |
-
|
157 |
-
|
158 |
-
if($restClient){
|
159 |
-
if($action === "get"){
|
160 |
-
$response = $restClient->restGet($path);
|
161 |
-
}else{
|
162 |
-
$data = trim($document->saveXml());
|
163 |
-
$bpostHelper->ApiLog("DATA:", Zend_Log::DEBUG, false);
|
164 |
-
$bpostHelper->ApiLog($data, Zend_Log::DEBUG, false);
|
165 |
-
|
166 |
-
$httpClient = $restClient->getHttpClient();
|
167 |
-
$httpClient->setRawData($data, 'text/xml');
|
168 |
-
$httpClient->getUri()->setPath($path);
|
169 |
-
|
170 |
-
$response = $httpClient->request('POST');
|
171 |
-
}
|
172 |
-
|
173 |
-
try{
|
174 |
-
$bpostHelper->ApiLog("RESPONSE:", Zend_Log::DEBUG, false);
|
175 |
-
$bpostHelper->ApiLog($response, Zend_Log::DEBUG, false);
|
176 |
-
|
177 |
-
$this->_checkApiResponse($path, $response);
|
178 |
-
|
179 |
-
return $response;
|
180 |
-
}catch (Exception $e){
|
181 |
-
$errorMessage = $e->getMessage();
|
182 |
-
|
183 |
-
//we first check if we need to do something with this error
|
184 |
-
$this->_errorHandling($errorHandlingData, $errorMessage);
|
185 |
-
|
186 |
-
$bpostHelper->ApiLog("ERROR:", Zend_Log::ERR, false);
|
187 |
-
$bpostHelper->ApiLog($errorMessage, Zend_Log::ERR);
|
188 |
-
return false;
|
189 |
-
}
|
190 |
-
}
|
191 |
-
|
192 |
-
return false;
|
193 |
-
}
|
194 |
-
|
195 |
-
|
196 |
-
/**
|
197 |
-
* Function calls the taxipost api (for GE06 calls)
|
198 |
-
*
|
199 |
-
* @param array $params
|
200 |
-
* @return bool
|
201 |
-
*/
|
202 |
-
protected function _callTaxipostApi($params){
|
203 |
-
$urlExtension = "Locator";
|
204 |
-
|
205 |
-
if (!isset($params["Partner"])) {
|
206 |
-
$params["Partner"] = self::API_TAXIPOST_PARTNER;
|
207 |
-
}
|
208 |
-
|
209 |
-
$params["AppId"] = self::API_TAXIPOST_APPID;
|
210 |
-
|
211 |
-
$httpClient = $this->_getTaxipostHttpClient($urlExtension);
|
212 |
-
$httpClient->setParameterGet($params);
|
213 |
-
$response = $httpClient->request('GET');
|
214 |
-
try{
|
215 |
-
$this->_checkApiResponse($httpClient->getLastRequest(), $response);
|
216 |
-
|
217 |
-
return $response;
|
218 |
-
}catch (Exception $e){
|
219 |
-
$errorMessage = $e->getMessage();
|
220 |
-
|
221 |
-
Mage::helper("bpost_shm")->ApiLog($errorMessage, Zend_Log::ERR);
|
222 |
-
return false;
|
223 |
-
}
|
224 |
-
}
|
225 |
-
|
226 |
-
|
227 |
-
//function checks if we need to do something with this error
|
228 |
-
//for example sending an email
|
229 |
-
protected function _errorHandling($errorHandlingData, $errorMessage){
|
230 |
-
$configHelper = Mage::helper("bpost_shm/system_config");
|
231 |
-
|
232 |
-
if(!empty($errorHandlingData) && isset($errorHandlingData["request_name"])){
|
233 |
-
|
234 |
-
switch($errorHandlingData["request_name"]){
|
235 |
-
case "createOrder":
|
236 |
-
//only send error email if 'use Magento to manage labels' is false
|
237 |
-
$manageLabels = $configHelper->getBpostShippingConfig("manage_labels_with_magento");
|
238 |
-
|
239 |
-
if(!$manageLabels){
|
240 |
-
//require email template, add error message, and send it to the shopmanager
|
241 |
-
$receiver = Mage::getStoreConfig('trans_email/ident_general/email');
|
242 |
-
$receiverName = Mage::getStoreConfig('trans_email/ident_general/name');
|
243 |
-
|
244 |
-
if($receiver && $receiver != ""){
|
245 |
-
$emailTemplate = Mage::getModel('core/email_template')->loadDefault('bpost_shm_errorhandling_create_order_email_template');
|
246 |
-
|
247 |
-
//Create an array of email variables
|
248 |
-
$emailVars = array();
|
249 |
-
$orderId = $errorHandlingData["order_id"];
|
250 |
-
|
251 |
-
$emailVars["order_id"] = $orderId;
|
252 |
-
$emailVars["receiver_name"] = " ".$receiverName;
|
253 |
-
$emailVars["error_message"] = $errorMessage;
|
254 |
-
|
255 |
-
$emailTemplate->setTemplateSubject(Mage::helper('bpost_shm')->__('Error creating bpost order'));
|
256 |
-
$emailTemplate->setSenderName("Magento - bpost shipping manager");
|
257 |
-
|
258 |
-
//send mail to yourself from, to
|
259 |
-
$emailTemplate->setSenderEmail($receiver);
|
260 |
-
|
261 |
-
if($emailTemplate->send(array($receiver), null, $emailVars)){
|
262 |
-
Mage::helper("bpost_shm")->ApiLog("Error email sent", Zend_Log::DEBUG);
|
263 |
-
}
|
264 |
-
}
|
265 |
-
}
|
266 |
-
break;
|
267 |
-
}
|
268 |
-
}
|
269 |
-
}
|
270 |
-
|
271 |
-
|
272 |
-
/**
|
273 |
-
* @param Zend_Http_Response $response
|
274 |
-
* function checks response for errors
|
275 |
-
*/
|
276 |
-
protected static function _checkApiResponse($path = "", Zend_Http_Response $response){
|
277 |
-
if ($response->isError()) {
|
278 |
-
if ($response->getStatus() == 401) {
|
279 |
-
Mage::throwException('401 Unauthorized: the account id or/and pass-phrase are not set correctly.');
|
280 |
-
}
|
281 |
-
|
282 |
-
Mage::throwException(sprintf('Request path: %s - Invalid response status code (HTTP/%s %s %s) - response body: %s', $path, $response->getVersion(), $response->getStatus(), $response->getMessage(), $response->getBody()));
|
283 |
-
}
|
284 |
-
}
|
285 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Created by PHPro
|
4 |
+
*
|
5 |
+
* @package Bpost
|
6 |
+
* @subpackage ShM
|
7 |
+
* @author PHPro (info@phpro.be)
|
8 |
+
*/
|
9 |
+
|
10 |
+
class Bpost_ShM_Model_Api_Abstract extends Mage_Core_Model_Abstract
|
11 |
+
{
|
12 |
+
const API_PATH_PREFIX = '/services/shm';
|
13 |
+
const API_URI_TAXIPOST_BASE = "http://taxipost.geo6.be";
|
14 |
+
const API_TAXIPOST_APPID = "A001";
|
15 |
+
const API_TAXIPOST_PARTNER = '107444';
|
16 |
+
|
17 |
+
protected $_apiUriBase;
|
18 |
+
protected $_accountId;
|
19 |
+
protected $_passphrase;
|
20 |
+
protected $_initialized = false;
|
21 |
+
protected $_bpostConfigHelper;
|
22 |
+
protected $_path = "";
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Http client that is curently used.
|
26 |
+
*
|
27 |
+
* @var Zend_Http_Client
|
28 |
+
* @access protected
|
29 |
+
*/
|
30 |
+
protected $_httpClient;
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Authorization key
|
34 |
+
*
|
35 |
+
* @var string
|
36 |
+
* @access protected
|
37 |
+
*/
|
38 |
+
protected $_authorization;
|
39 |
+
|
40 |
+
|
41 |
+
//constructor
|
42 |
+
public function __construct($initialize = false){
|
43 |
+
|
44 |
+
//first we set the helper as variable
|
45 |
+
//easier to access it
|
46 |
+
$this->_bpostConfigHelper = Mage::helper("bpost_shm/system_config");
|
47 |
+
|
48 |
+
//check if we need to initialize immediately
|
49 |
+
if($initialize){
|
50 |
+
$this->initialize();
|
51 |
+
}
|
52 |
+
}
|
53 |
+
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Set the api domain, account id and passphrase of the given store
|
57 |
+
*
|
58 |
+
* @param null|int $storeId
|
59 |
+
*/
|
60 |
+
public function initialize($storeId = null)
|
61 |
+
{
|
62 |
+
if (!$storeId) {
|
63 |
+
$storeId = Mage::app()->getStore()->getId();
|
64 |
+
}
|
65 |
+
|
66 |
+
$this->_apiUriBase = $this->_bpostConfigHelper->getBpostShippingConfig('api_url', $storeId);
|
67 |
+
$this->_accountId = $this->_bpostConfigHelper->getBpostShippingConfig('accountid', $storeId);
|
68 |
+
$this->_passphrase = $this->_bpostConfigHelper->getBpostShippingConfig('passphrase', $storeId);
|
69 |
+
$this->_authorization = base64_encode($this->_accountId . ':' . $this->_passphrase);
|
70 |
+
$this->_initialized = true;
|
71 |
+
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* @return bool
|
75 |
+
* function checks if the current object is initialized or not
|
76 |
+
*/
|
77 |
+
public function isInitialized(){
|
78 |
+
if($this->_initialized){
|
79 |
+
return true;
|
80 |
+
}
|
81 |
+
|
82 |
+
return false;
|
83 |
+
}
|
84 |
+
|
85 |
+
/**
|
86 |
+
* Returns a REST client we can use for connecting to the webservice.
|
87 |
+
* @param array $headers
|
88 |
+
*
|
89 |
+
* @return Zend_Rest_Client
|
90 |
+
*/
|
91 |
+
protected function _getRestClient($headers = null){
|
92 |
+
try{
|
93 |
+
//first make sure the current model is initialized
|
94 |
+
if(!$this->isInitialized()){
|
95 |
+
Mage::throwException('Please initialize your API model first by calling the initialize() function.');
|
96 |
+
}
|
97 |
+
|
98 |
+
$restClient = new Zend_Rest_Client($this->_apiUriBase);
|
99 |
+
$this->_httpClient = new Zend_Http_Client($this->_apiUriBase, array('useragent' => 'Magento, with bpost Shipping Manager module.'));
|
100 |
+
$this->_httpClient->setHeaders('Authorization', 'Basic ' . $this->_authorization);
|
101 |
+
|
102 |
+
if ($headers) {
|
103 |
+
$this->_httpClient->setHeaders($headers);
|
104 |
+
}
|
105 |
+
|
106 |
+
$restClient->setHttpClient($this->_httpClient);
|
107 |
+
return $restClient;
|
108 |
+
}catch(Exception $e){
|
109 |
+
Mage::helper("bpost_shm")->ApiLog($e->getMessage(), Zend_Log::ERR);
|
110 |
+
}
|
111 |
+
|
112 |
+
return false;
|
113 |
+
}
|
114 |
+
|
115 |
+
|
116 |
+
/**
|
117 |
+
* Returns a Http client we can use for connecting to the taxipost webservice.
|
118 |
+
* @param array $headers
|
119 |
+
*
|
120 |
+
* @return Zend_Http_Client
|
121 |
+
*/
|
122 |
+
protected function _getTaxipostHttpClient($urlExtension = false){
|
123 |
+
try{
|
124 |
+
$url = self::API_URI_TAXIPOST_BASE;
|
125 |
+
|
126 |
+
if($urlExtension){
|
127 |
+
$url .= DS.$urlExtension;
|
128 |
+
}
|
129 |
+
|
130 |
+
$httpClient = new Zend_Http_Client($url, array('useragent' => 'Magento, with bpost Shipping Manager module.'));
|
131 |
+
|
132 |
+
return $httpClient;
|
133 |
+
}catch(Exception $e){
|
134 |
+
Mage::helper("bpost_shm")->ApiLog($e->getMessage(), Zend_Log::ERR);
|
135 |
+
}
|
136 |
+
|
137 |
+
return false;
|
138 |
+
}
|
139 |
+
|
140 |
+
|
141 |
+
/**
|
142 |
+
* @param $path
|
143 |
+
* @param $headers
|
144 |
+
* function sends request
|
145 |
+
*/
|
146 |
+
protected function _call($path, $headers, $errorHandlingData = array(), $action = "get", $document = null){
|
147 |
+
$bpostHelper = Mage::helper("bpost_shm");
|
148 |
+
$path = self::API_PATH_PREFIX.DS.$path;
|
149 |
+
$restClient = $this->_getRestClient($headers);
|
150 |
+
|
151 |
+
$bpostHelper->ApiLog("HEADERS:", Zend_Log::DEBUG, false);
|
152 |
+
$bpostHelper->ApiLog("\n".implode("\n", $headers), Zend_Log::DEBUG, false);
|
153 |
+
|
154 |
+
$bpostHelper->ApiLog("PATH:", Zend_Log::DEBUG,false);
|
155 |
+
$bpostHelper->ApiLog($path, Zend_Log::DEBUG, false);
|
156 |
+
|
157 |
+
|
158 |
+
if($restClient){
|
159 |
+
if($action === "get"){
|
160 |
+
$response = $restClient->restGet($path);
|
161 |
+
}else{
|
162 |
+
$data = trim($document->saveXml());
|
163 |
+
$bpostHelper->ApiLog("DATA:", Zend_Log::DEBUG, false);
|
164 |
+
$bpostHelper->ApiLog($data, Zend_Log::DEBUG, false);
|
165 |
+
|
166 |
+
$httpClient = $restClient->getHttpClient();
|
167 |
+
$httpClient->setRawData($data, 'text/xml');
|
168 |
+
$httpClient->getUri()->setPath($path);
|
169 |
+
|
170 |
+
$response = $httpClient->request('POST');
|
171 |
+
}
|
172 |
+
|
173 |
+
try{
|
174 |
+
$bpostHelper->ApiLog("RESPONSE:", Zend_Log::DEBUG, false);
|
175 |
+
$bpostHelper->ApiLog($response, Zend_Log::DEBUG, false);
|
176 |
+
|
177 |
+
$this->_checkApiResponse($path, $response);
|
178 |
+
|
179 |
+
return $response;
|
180 |
+
}catch (Exception $e){
|
181 |
+
$errorMessage = $e->getMessage();
|
182 |
+
|
183 |
+
//we first check if we need to do something with this error
|
184 |
+
$this->_errorHandling($errorHandlingData, $errorMessage);
|
185 |
+
|
186 |
+
$bpostHelper->ApiLog("ERROR:", Zend_Log::ERR, false);
|
187 |
+
$bpostHelper->ApiLog($errorMessage, Zend_Log::ERR);
|
188 |
+
return false;
|
189 |
+
}
|
190 |
+
}
|
191 |
+
|
192 |
+
return false;
|
193 |
+
}
|
194 |
+
|
195 |
+
|
196 |
+
/**
|
197 |
+
* Function calls the taxipost api (for GE06 calls)
|
198 |
+
*
|
199 |
+
* @param array $params
|
200 |
+
* @return bool
|
201 |
+
*/
|
202 |
+
protected function _callTaxipostApi($params){
|
203 |
+
$urlExtension = "Locator";
|
204 |
+
|
205 |
+
if (!isset($params["Partner"])) {
|
206 |
+
$params["Partner"] = self::API_TAXIPOST_PARTNER;
|
207 |
+
}
|
208 |
+
|
209 |
+
$params["AppId"] = self::API_TAXIPOST_APPID;
|
210 |
+
|
211 |
+
$httpClient = $this->_getTaxipostHttpClient($urlExtension);
|
212 |
+
$httpClient->setParameterGet($params);
|
213 |
+
$response = $httpClient->request('GET');
|
214 |
+
try{
|
215 |
+
$this->_checkApiResponse($httpClient->getLastRequest(), $response);
|
216 |
+
|
217 |
+
return $response;
|
218 |
+
}catch (Exception $e){
|
219 |
+
$errorMessage = $e->getMessage();
|
220 |
+
|
221 |
+
Mage::helper("bpost_shm")->ApiLog($errorMessage, Zend_Log::ERR);
|
222 |
+
return false;
|
223 |
+
}
|
224 |
+
}
|
225 |
+
|
226 |
+
|
227 |
+
//function checks if we need to do something with this error
|
228 |
+
//for example sending an email
|
229 |
+
protected function _errorHandling($errorHandlingData, $errorMessage){
|
230 |
+
$configHelper = Mage::helper("bpost_shm/system_config");
|
231 |
+
|
232 |
+
if(!empty($errorHandlingData) && isset($errorHandlingData["request_name"])){
|
233 |
+
|
234 |
+
switch($errorHandlingData["request_name"]){
|
235 |
+
case "createOrder":
|
236 |
+
//only send error email if 'use Magento to manage labels' is false
|
237 |
+
$manageLabels = $configHelper->getBpostShippingConfig("manage_labels_with_magento");
|
238 |
+
|
239 |
+
if(!$manageLabels){
|
240 |
+
//require email template, add error message, and send it to the shopmanager
|
241 |
+
$receiver = Mage::getStoreConfig('trans_email/ident_general/email');
|
242 |
+
$receiverName = Mage::getStoreConfig('trans_email/ident_general/name');
|
243 |
+
|
244 |
+
if($receiver && $receiver != ""){
|
245 |
+
$emailTemplate = Mage::getModel('core/email_template')->loadDefault('bpost_shm_errorhandling_create_order_email_template');
|
246 |
+
|
247 |
+
//Create an array of email variables
|
248 |
+
$emailVars = array();
|
249 |
+
$orderId = $errorHandlingData["order_id"];
|
250 |
+
|
251 |
+
$emailVars["order_id"] = $orderId;
|
252 |
+
$emailVars["receiver_name"] = " ".$receiverName;
|
253 |
+
$emailVars["error_message"] = $errorMessage;
|
254 |
+
|
255 |
+
$emailTemplate->setTemplateSubject(Mage::helper('bpost_shm')->__('Error creating bpost order'));
|
256 |
+
$emailTemplate->setSenderName("Magento - bpost shipping manager");
|
257 |
+
|
258 |
+
//send mail to yourself from, to
|
259 |
+
$emailTemplate->setSenderEmail($receiver);
|
260 |
+
|
261 |
+
if($emailTemplate->send(array($receiver), null, $emailVars)){
|
262 |
+
Mage::helper("bpost_shm")->ApiLog("Error email sent", Zend_Log::DEBUG);
|
263 |
+
}
|
264 |
+
}
|
265 |
+
}
|
266 |
+
break;
|
267 |
+
}
|
268 |
+
}
|
269 |
+
}
|
270 |
+
|
271 |
+
|
272 |
+
/**
|
273 |
+
* @param Zend_Http_Response $response
|
274 |
+
* function checks response for errors
|
275 |
+
*/
|
276 |
+
protected static function _checkApiResponse($path = "", Zend_Http_Response $response){
|
277 |
+
if ($response->isError()) {
|
278 |
+
if ($response->getStatus() == 401) {
|
279 |
+
Mage::throwException('401 Unauthorized: the account id or/and pass-phrase are not set correctly.');
|
280 |
+
}
|
281 |
+
|
282 |
+
Mage::throwException(sprintf('Request path: %s - Invalid response status code (HTTP/%s %s %s) - response body: %s', $path, $response->getVersion(), $response->getStatus(), $response->getMessage(), $response->getBody()));
|
283 |
+
}
|
284 |
+
}
|
285 |
+
}
|
app/code/community/Bpost/ShM/Model/Api/Domcreator.php
CHANGED
@@ -1,779 +1,785 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Bpost_ShM_Model_Api_Domcreator extends Bpost_ShM_Model_Api_Abstract
|
4 |
-
{
|
5 |
-
protected $_xmlnsValue = "http://schema.post.be/shm/deepintegration/v3/national";
|
6 |
-
protected $_xmlnsCommonValue = "http://schema.post.be/shm/deepintegration/v3/common";
|
7 |
-
protected $_xmlnsTnsValue = "http://schema.post.be/shm/deepintegration/v3/";
|
8 |
-
protected $_xmlnsInternational = "http://schema.post.be/shm/deepintegration/v3/international";
|
9 |
-
protected $_xmlnsXsiValue = "http://www.w3.org/2001/XMLSchema-instance";
|
10 |
-
protected $_xsiSchemaLocation = "http://schema.post.be/shm/deepintegration/v3/";
|
11 |
-
|
12 |
-
protected $_shippingAddress;
|
13 |
-
protected $_billingAddress;
|
14 |
-
|
15 |
-
/**
|
16 |
-
* @param Mage_Sales_Model_Order $order
|
17 |
-
* function builds the necessary DOM document and returns it
|
18 |
-
* this result will be used in the API calls as post data
|
19 |
-
* @return DOMDocument
|
20 |
-
*/
|
21 |
-
public function getCreateOrderDomDocument($order, $returnOrder = false){
|
22 |
-
//initialize helper
|
23 |
-
$configHelper = Mage::helper("bpost_shm/system_config");
|
24 |
-
$bpostHelper = Mage::helper("bpost_shm");
|
25 |
-
$shippingMethod = $order->getShippingMethod();
|
26 |
-
$storeId = $order->getStoreId();
|
27 |
-
|
28 |
-
//get sender
|
29 |
-
$senderData = new Varien_Object();
|
30 |
-
$senderData->setBpostName($configHelper->getBpostShippingConfig("sender_name", $storeId));
|
31 |
-
$senderData->setBpostCompany($configHelper->getBpostShippingConfig("sender_company", $storeId));
|
32 |
-
$senderData->setBpostStreet($configHelper->getBpostShippingConfig("sender_streetname", $storeId));
|
33 |
-
$senderData->setBpostHouseNumber($configHelper->getBpostShippingConfig("sender_streetnumber", $storeId));
|
34 |
-
$senderData->setBoxNumber($configHelper->getBpostShippingConfig("sender_boxnumber", $storeId));
|
35 |
-
$senderData->setPostcode($configHelper->getBpostShippingConfig("sender_postal_code", $storeId));
|
36 |
-
$senderData->setCity($configHelper->getBpostShippingConfig("sender_city", $storeId));
|
37 |
-
$senderData->setCountryId($configHelper->getBpostShippingConfig("sender_country", $storeId));
|
38 |
-
$senderData->setEmail($configHelper->getBpostShippingConfig("sender_email", $storeId));
|
39 |
-
$senderData->setTelephone(preg_replace('/[^0-9]/s', '',$configHelper->getBpostShippingConfig("sender_phonenumber", $storeId)));
|
40 |
-
|
41 |
-
//get receiver
|
42 |
-
$this->_shippingAddress = $order->getShippingAddress();
|
43 |
-
$this->_shippingAddress = $bpostHelper->formatAddress($this->_shippingAddress);
|
44 |
-
$this->_billingAddress = $order->getBillingAddress();
|
45 |
-
|
46 |
-
//if return order, we switch the sender and receiver data
|
47 |
-
if($returnOrder){
|
48 |
-
$tmpShippingAddress = $this->_shippingAddress;
|
49 |
-
$this->_shippingAddress = $senderData;
|
50 |
-
$senderData = $tmpShippingAddress;
|
51 |
-
|
52 |
-
if($shippingMethod != "bpostshm_bpost_international" && $shippingMethod != "bpostshm_bpost_homedelivery"){
|
53 |
-
$senderData->setBpostName($this->_billingAddress->getFirstname()." ".$this->_billingAddress->getLastname());
|
54 |
-
}
|
55 |
-
|
56 |
-
if($shippingMethod != "bpostshm_bpost_international"){
|
57 |
-
//we force shipping to 'bpostshm_bpost_homedelivery' method because we are creating a return order
|
58 |
-
$shippingMethod = "bpostshm_bpost_homedelivery";
|
59 |
-
}
|
60 |
-
}
|
61 |
-
|
62 |
-
$document = new DOMDocument('1.0','UTF-8');
|
63 |
-
$document->formatOutput = true;
|
64 |
-
$orderElement = $document->createElement('tns:order');
|
65 |
-
|
66 |
-
//we add the extra attributes to the order element
|
67 |
-
$xmlnsAttribute = $document->createAttribute("xmlns");
|
68 |
-
$xmlnsAttribute->value = $this->_xmlnsValue;
|
69 |
-
|
70 |
-
$xmlnsCommonAttribute = $document->createAttribute("xmlns:common");
|
71 |
-
$xmlnsCommonAttribute->value = $this->_xmlnsCommonValue;
|
72 |
-
|
73 |
-
$xmlnsTnsAttribute = $document->createAttribute("xmlns:tns");
|
74 |
-
$xmlnsTnsAttribute->value = $this->_xmlnsTnsValue;
|
75 |
-
|
76 |
-
$xmlnsIAttribute = $document->createAttribute("xmlns:international");
|
77 |
-
$xmlnsIAttribute->value = $this->_xmlnsInternational;
|
78 |
-
|
79 |
-
$xmlnsXsiAttribute = $document->createAttribute("xmlns:xsi");
|
80 |
-
$xmlnsXsiAttribute->value = $this->_xmlnsXsiValue;
|
81 |
-
|
82 |
-
$xsiSchemaLocation = $document->createAttribute("xsi:schemaLocation");
|
83 |
-
$xsiSchemaLocation->value = $this->_xsiSchemaLocation;
|
84 |
-
|
85 |
-
$orderElement->appendChild($xmlnsAttribute);
|
86 |
-
$orderElement->appendChild($xmlnsCommonAttribute);
|
87 |
-
$orderElement->appendChild($xmlnsTnsAttribute);
|
88 |
-
$orderElement->appendChild($xmlnsIAttribute);
|
89 |
-
$orderElement->appendChild($xmlnsXsiAttribute);
|
90 |
-
$orderElement->appendChild($xsiSchemaLocation);
|
91 |
-
//end adding order attributes
|
92 |
-
|
93 |
-
$document->appendChild($orderElement);
|
94 |
-
|
95 |
-
//add order elements
|
96 |
-
$accountId = $document->createElement('tns:accountId');
|
97 |
-
$accountId->appendChild($document->createTextNode($this->_accountId));
|
98 |
-
$orderElement->appendChild($accountId);
|
99 |
-
|
100 |
-
$reference = $document->createElement('tns:reference');
|
101 |
-
$referenceId = $order->getIncrementId();
|
102 |
-
|
103 |
-
$items = $order->getAllItems();
|
104 |
-
$reference->appendChild($document->createTextNode($referenceId));
|
105 |
-
$orderElement->appendChild($reference);
|
106 |
-
|
107 |
-
//calculate weight
|
108 |
-
$totalShipmentsWeight = $bpostHelper->processShipmentsWeight($order);
|
109 |
-
|
110 |
-
//we add all order items to the document
|
111 |
-
foreach ($items as $item) {
|
112 |
-
if ($item->getParentItem()) {
|
113 |
-
continue;
|
114 |
-
}
|
115 |
-
|
116 |
-
$nbOfItems = $document->createElement('tns:nbOfItems');
|
117 |
-
$nbOfItems->appendChild($document->createTextNode((int)$item->getQtyOrdered()));
|
118 |
-
|
119 |
-
$text = $document->createElement('tns:text');
|
120 |
-
$text->appendChild($document->createTextNode($item->getName()));
|
121 |
-
|
122 |
-
$orderLine = $document->createElement('tns:orderLine');
|
123 |
-
$orderLine->appendChild($text);
|
124 |
-
$orderLine->appendChild($nbOfItems);
|
125 |
-
$orderElement->appendChild($orderLine);
|
126 |
-
}
|
127 |
-
|
128 |
-
$weightInGrams = round($totalShipmentsWeight);
|
129 |
-
|
130 |
-
if(!$weightInGrams){
|
131 |
-
$weightInGrams = 1;
|
132 |
-
}
|
133 |
-
|
134 |
-
if(($shippingMethod == "bpostshm_bpost_parcellocker" || $shippingMethod == "bpostshm_bpost_international" || $shippingMethod == "bpostshm_bpost_clickcollect") && $weightInGrams < 10){
|
135 |
-
$weightInGrams = 10;
|
136 |
-
}
|
137 |
-
//end weight
|
138 |
-
|
139 |
-
$senderName = $document->createElement('common:name');
|
140 |
-
$senderName->appendChild($document->createTextNode($senderData->getBpostName()));
|
141 |
-
|
142 |
-
$senderCompany = $document->createElement('common:company');
|
143 |
-
$senderCompany->appendChild($document->createTextNode($senderData->getBpostCompany()));
|
144 |
-
//sender address fields here
|
145 |
-
$addressStreetName = $document->createElement('common:streetName');
|
146 |
-
$addressStreetName->appendChild($document->createTextNode($senderData->getBpostStreet()));
|
147 |
-
|
148 |
-
$addressNumber = $document->createElement('common:number');
|
149 |
-
$addressNumber->appendChild($document->createTextNode($senderData->getBpostHouseNumber()));
|
150 |
-
|
151 |
-
//only add element if available
|
152 |
-
$boxNumber = $configHelper->getBpostShippingConfig($senderData->getBoxNumber(), $storeId);
|
153 |
-
|
154 |
-
if($boxNumber && $boxNumber != ''){
|
155 |
-
$addressBox = $document->createElement('common:box');
|
156 |
-
$addressBox->appendChild($document->createTextNode($boxNumber));
|
157 |
-
}
|
158 |
-
|
159 |
-
$addressPostalCode = $document->createElement('common:postalCode');
|
160 |
-
$addressPostalCode->appendChild($document->createTextNode($senderData->getPostcode()));
|
161 |
-
|
162 |
-
$addressLocality = $document->createElement('common:locality');
|
163 |
-
$addressLocality->appendChild($document->createTextNode($senderData->getCity()));
|
164 |
-
|
165 |
-
$addressCountryCode = $document->createElement('common:countryCode');
|
166 |
-
$addressCountryCode->appendChild($document->createTextNode($senderData->getCountryId()));
|
167 |
-
//end sender address fields
|
168 |
-
|
169 |
-
//add fields to address
|
170 |
-
$senderAddress = $document->createElement('common:address');
|
171 |
-
$senderAddress->appendChild($addressStreetName);
|
172 |
-
$senderAddress->appendChild($addressNumber);
|
173 |
-
|
174 |
-
if(isset($addressBox)){
|
175 |
-
$senderAddress->appendChild($addressBox);
|
176 |
-
}
|
177 |
-
|
178 |
-
$senderAddress->appendChild($addressPostalCode);
|
179 |
-
$senderAddress->appendChild($addressLocality);
|
180 |
-
$senderAddress->appendChild($addressCountryCode);
|
181 |
-
|
182 |
-
$senderEmail = $document->createElement('common:emailAddress');
|
183 |
-
$senderEmail->appendChild($document->createTextNode($senderData->getEmail()));
|
184 |
-
|
185 |
-
$senderPhoneNumber = $document->createElement('common:phoneNumber');
|
186 |
-
$senderPhoneNumber->appendChild($document->createTextNode(preg_replace('/[^0-9]/s', '',$senderData->getTelephone())));
|
187 |
-
|
188 |
-
//add all sender info to the sender element
|
189 |
-
$sender = $document->createElement('tns:sender');
|
190 |
-
$sender->appendChild($senderName);
|
191 |
-
$sender->appendChild($senderCompany);
|
192 |
-
$sender->appendChild($senderAddress);
|
193 |
-
$sender->appendChild($senderEmail);
|
194 |
-
$sender->appendChild($senderPhoneNumber);
|
195 |
-
|
196 |
-
//we create the box element
|
197 |
-
$box = $document->createElement('tns:box');
|
198 |
-
$box->appendChild($sender);
|
199 |
-
|
200 |
-
//add the national or international box element tags
|
201 |
-
if($shippingMethod != "bpostshm_bpost_international"){
|
202 |
-
$nationalBoxElements = $this->_getNationalBoxElements($document, $order, $returnOrder, $weightInGrams, $shippingMethod);
|
203 |
-
$box->appendChild($nationalBoxElements);
|
204 |
-
}else{
|
205 |
-
$internationalElements = $this->_getInternationalBoxElements($document, $order, $returnOrder, $weightInGrams);
|
206 |
-
$box->appendChild($internationalElements);
|
207 |
-
}
|
208 |
-
|
209 |
-
//we do the same for additionalCustomerRef
|
210 |
-
//Free text. If not submitted, it will indicate the channel used for creating this order. Best used by integrators to indicate the origin of the order.
|
211 |
-
|
212 |
-
$additionalCustomerRef = $document->createElement('tns:additionalCustomerReference');
|
213 |
-
$additionalCustomerRef->appendChild($document->createTextNode("Magento_".Mage::getVersion()));
|
214 |
-
$box->appendChild($additionalCustomerRef);
|
215 |
-
|
216 |
-
//finally we add the box element to the order element
|
217 |
-
$orderElement->appendChild($box);
|
218 |
-
|
219 |
-
//we save the xml so we can check the file
|
220 |
-
return $document;
|
221 |
-
}
|
222 |
-
|
223 |
-
//function adds the national box element tags based on the shipping method
|
224 |
-
protected function _getNationalBoxElements(DOMDocument $document, $order, $returnOrder, $weightInGrams, $shippingMethod){
|
225 |
-
$bpostHelper = Mage::helper("bpost_shm");
|
226 |
-
$configHelper = Mage::helper("bpost_shm/system_config");
|
227 |
-
$nationalBox = $document->createElement('tns:nationalBox');
|
228 |
-
$manageLabels = $configHelper->getBpostShippingConfig("manage_labels_with_magento");
|
229 |
-
|
230 |
-
$reqDeliveryDate = false;
|
231 |
-
$dropDate = new DateTime($order->getBpostDeliveryDate());
|
232 |
-
$currentDate = new DateTime();
|
233 |
-
|
234 |
-
if($dropDate && $dropDate > $currentDate && !$returnOrder) {
|
235 |
-
$reqDeliveryDate = $document->createElement('requestedDeliveryDate');
|
236 |
-
$reqDeliveryDate->appendChild($document->createTextNode($order->getBpostDeliveryDate()));
|
237 |
-
}
|
238 |
-
|
239 |
-
//add product
|
240 |
-
$product = $document->createElement('product');
|
241 |
-
|
242 |
-
//add options
|
243 |
-
$options = $document->createElement('options');
|
244 |
-
|
245 |
-
//add weight
|
246 |
-
$weight = $document->createElement('weight');
|
247 |
-
$weight->appendChild($document->createTextNode($weightInGrams));
|
248 |
-
|
249 |
-
//add address variables
|
250 |
-
$streetName = $document->createElement('common:streetName');
|
251 |
-
$streetNumber = $document->createElement('common:number');
|
252 |
-
$streetPostalCode = $document->createElement('common:postalCode');
|
253 |
-
$locality = $document->createElement('common:locality');
|
254 |
-
$countryCode = $document->createElement('common:countryCode');
|
255 |
-
|
256 |
-
//add receiver info
|
257 |
-
$receiverName = $document->createElement('receiverName');
|
258 |
-
$receiverCompany = $document->createElement('receiverCompany');
|
259 |
-
$receiverCompany->appendChild($document->createTextNode($this->_shippingAddress->getCompany()));
|
260 |
-
|
261 |
-
//we use the receivername from billing address instead of shipping address
|
262 |
-
//this way we have the customer name and not the pickup point name
|
263 |
-
$receiverName->appendChild($document->createTextNode($this->_billingAddress->getFirstname()." ".$this->_billingAddress->getLastname()));
|
264 |
-
|
265 |
-
switch($shippingMethod){
|
266 |
-
case "bpostshm_bpost_homedelivery":
|
267 |
-
if(!$returnOrder){
|
268 |
-
$product->appendChild($document->createTextNode("bpack 24h Pro"));
|
269 |
-
|
270 |
-
//then get config the option settings
|
271 |
-
$options = $this->_checkIfOptionIsValid($document, $options, $order, "bpost_homedelivery", "second_presentation", "automaticSecondPresentation");
|
272 |
-
$options = $this->_checkIfOptionIsValid($document, $options, $order, "bpost_homedelivery", "insurance", "insured");
|
273 |
-
$options = $this->_checkIfOptionIsValid($document, $options, $order, "bpost_homedelivery", "signature", "signed");
|
274 |
-
$options = $this->_checkIfOptionIsValid($document, $options, $order, "bpost_homedelivery", "saturday_delivery", "saturdayDelivery");
|
275 |
-
|
276 |
-
}else{
|
277 |
-
$product->appendChild($document->createTextNode("bpack Easy Retour"));
|
278 |
-
}
|
279 |
-
|
280 |
-
//add receiver info
|
281 |
-
$receiverName = $document->createElement('common:name');
|
282 |
-
$receiverName->appendChild($document->createTextNode($this->_shippingAddress->getBpostName()));
|
283 |
-
|
284 |
-
$receiverCompany = $document->createElement('common:company');
|
285 |
-
$receiverCompany->appendChild($document->createTextNode($this->_shippingAddress->getBpostCompany()));
|
286 |
-
|
287 |
-
$receiverEmailAddress = $document->createElement('common:emailAddress');
|
288 |
-
$receiverEmailAddress->appendChild($document->createTextNode($this->_billingAddress->getEmail()));
|
289 |
-
|
290 |
-
$receiverPhoneNumber = $document->createElement('common:phoneNumber');
|
291 |
-
$receiverPhoneNumber->appendChild($document->createTextNode(preg_replace('/[^0-9]/s', '',$this->_shippingAddress->getTelephone())));
|
292 |
-
|
293 |
-
//we add the receiver address data
|
294 |
-
$streetName->appendChild($document->createTextNode($this->_shippingAddress->getBpostStreet()));
|
295 |
-
$streetNumber->appendChild($document->createTextNode($this->_shippingAddress->getBpostHouseNumber()));
|
296 |
-
|
297 |
-
$streetPostalCode->appendChild($document->createTextNode($this->_shippingAddress->getPostcode()));
|
298 |
-
$locality->appendChild($document->createTextNode($this->_shippingAddress->getCity()));
|
299 |
-
$countryCode->appendChild($document->createTextNode($this->_shippingAddress->getCountryId()));
|
300 |
-
|
301 |
-
$receiverAddress = $document->createElement('common:address');
|
302 |
-
$receiverAddress->appendChild($streetName);
|
303 |
-
$receiverAddress->appendChild($streetNumber);
|
304 |
-
|
305 |
-
//only add element if available
|
306 |
-
if($this->_shippingAddress->getBoxNumber()){
|
307 |
-
$streetBox = $document->createElement('common:box');
|
308 |
-
$streetBox->appendChild($document->createTextNode($this->_shippingAddress->getBoxNumber()));
|
309 |
-
$receiverAddress->appendChild($streetBox);
|
310 |
-
}
|
311 |
-
|
312 |
-
$receiverAddress->appendChild($streetPostalCode);
|
313 |
-
$receiverAddress->appendChild($locality);
|
314 |
-
$receiverAddress->appendChild($countryCode);
|
315 |
-
|
316 |
-
$receiver = $document->createElement('receiver');
|
317 |
-
$receiver->appendChild($receiverName);
|
318 |
-
$receiver->appendChild($receiverCompany);
|
319 |
-
$receiver->appendChild($receiverAddress);
|
320 |
-
$receiver->appendChild($receiverEmailAddress);
|
321 |
-
$receiver->appendChild($receiverPhoneNumber);
|
322 |
-
//end receiver
|
323 |
-
|
324 |
-
$atHome = $document->createElement('atHome');
|
325 |
-
$atHome->appendChild($product);
|
326 |
-
|
327 |
-
if($options->hasChildNodes()){
|
328 |
-
$atHome->appendChild($options);
|
329 |
-
}
|
330 |
-
|
331 |
-
$atHome->appendChild($weight);
|
332 |
-
$atHome->appendChild($receiver);
|
333 |
-
|
334 |
-
if($reqDeliveryDate){
|
335 |
-
$atHome->appendChild($reqDeliveryDate);
|
336 |
-
}
|
337 |
-
|
338 |
-
$nationalBox->appendChild($atHome);
|
339 |
-
break;
|
340 |
-
|
341 |
-
case "bpostshm_bpost_pickuppoint":
|
342 |
-
if(!$order->getBpostPickuplocationId()){
|
343 |
-
//only throw error in backend
|
344 |
-
if($manageLabels){
|
345 |
-
Mage::throwException("No pickup location order data found.");
|
346 |
-
}
|
347 |
-
}
|
348 |
-
|
349 |
-
$product->appendChild($document->createTextNode("bpack@bpost"));
|
350 |
-
|
351 |
-
//add the notification options
|
352 |
-
//check if bpost notification sms or mail isset
|
353 |
-
if($order->getBpostNotificationSms() || $order->getBpostNotificationEmail()){
|
354 |
-
if($order->getBpostNotificationSms()){
|
355 |
-
$options->appendChild($this->_addNotificationMessageOption($document, $order, "keepMeInformed", "sms"));
|
356 |
-
}else{
|
357 |
-
$options->appendChild($this->_addNotificationMessageOption($document, $order, "keepMeInformed"));
|
358 |
-
}
|
359 |
-
}
|
360 |
-
|
361 |
-
//then get the config option settings
|
362 |
-
$options = $this->_checkIfOptionIsValid($document, $options, $order, "bpost_pickuppoint", "insurance", "insured");
|
363 |
-
$options = $this->_checkIfOptionIsValid($document, $options, $order, "bpost_pickuppoint", "saturday_delivery", "saturdayDelivery");
|
364 |
-
|
365 |
-
$formattedAddress = $bpostHelper->formatShippingAddress($this->_shippingAddress);
|
366 |
-
|
367 |
-
$pugoId = $document->createElement('pugoId');
|
368 |
-
$pugoId->appendChild($document->createTextNode($order->getBpostPickuplocationId()));
|
369 |
-
|
370 |
-
$pugoName = $document->createElement('pugoName');
|
371 |
-
$pugoName->appendChild($document->createTextNode($this->_shippingAddress->getLastname()));
|
372 |
-
|
373 |
-
//Address tags
|
374 |
-
$streetName->appendChild($document->createTextNode($formattedAddress["street"]));
|
375 |
-
$streetNumber->appendChild($document->createTextNode($formattedAddress["number"]));
|
376 |
-
|
377 |
-
$streetPostalCode->appendChild($document->createTextNode($formattedAddress["postcode"]));
|
378 |
-
$locality->appendChild($document->createTextNode($formattedAddress["city"]));
|
379 |
-
$countryCode->appendChild($document->createTextNode($this->_shippingAddress->getCountryId()));
|
380 |
-
|
381 |
-
$pugoAddress = $document->createElement('pugoAddress');
|
382 |
-
$pugoAddress->appendChild($streetName);
|
383 |
-
$pugoAddress->appendChild($streetNumber);
|
384 |
-
$pugoAddress->appendChild($streetPostalCode);
|
385 |
-
$pugoAddress->appendChild($locality);
|
386 |
-
$pugoAddress->appendChild($countryCode);
|
387 |
-
//end address tags
|
388 |
-
|
389 |
-
$atBpost = $document->createElement('atBpost');
|
390 |
-
$atBpost->appendChild($product);
|
391 |
-
|
392 |
-
if($options->hasChildNodes()){
|
393 |
-
$atBpost->appendChild($options);
|
394 |
-
}
|
395 |
-
|
396 |
-
$atBpost->appendChild($weight);
|
397 |
-
$atBpost->appendChild($pugoId);
|
398 |
-
$atBpost->appendChild($pugoName);
|
399 |
-
$atBpost->appendChild($pugoAddress);
|
400 |
-
$atBpost->appendChild($receiverName);
|
401 |
-
$atBpost->appendChild($receiverCompany);
|
402 |
-
|
403 |
-
if($reqDeliveryDate) {
|
404 |
-
$atBpost->appendChild($reqDeliveryDate);
|
405 |
-
}
|
406 |
-
|
407 |
-
$nationalBox->appendChild($atBpost);
|
408 |
-
|
409 |
-
break;
|
410 |
-
|
411 |
-
case "bpostshm_bpost_parcellocker":
|
412 |
-
|
413 |
-
if(!$order->getBpostPickuplocationId() && $manageLabels){
|
414 |
-
Mage::throwException("No parcel locker data found.");
|
415 |
-
}
|
416 |
-
|
417 |
-
$product->appendChild($document->createTextNode("bpack 24h Pro"));
|
418 |
-
|
419 |
-
//then get the config option settings
|
420 |
-
$options = $this->_checkIfOptionIsValid($document, $options, $order, "bpost_parcellocker", "insurance", "insured");
|
421 |
-
$options = $this->_checkIfOptionIsValid($document, $options, $order, "bpost_parcellocker", "saturday_delivery", "saturdayDelivery");
|
422 |
-
|
423 |
-
$formattedAddress = $bpostHelper->formatShippingAddress($this->_shippingAddress);
|
424 |
-
|
425 |
-
$parcelsDepotId = $document->createElement('parcelsDepotId');
|
426 |
-
$parcelsDepotId->appendChild($document->createTextNode($order->getBpostPickuplocationId()));
|
427 |
-
|
428 |
-
$parcelsDepotName = $document->createElement('parcelsDepotName');
|
429 |
-
$parcelsDepotName->appendChild($document->createTextNode($this->_shippingAddress->getLastname()));
|
430 |
-
|
431 |
-
//Address tags
|
432 |
-
$streetName->appendChild($document->createTextNode($formattedAddress["street"]));
|
433 |
-
$streetNumber->appendChild($document->createTextNode($formattedAddress["number"]));
|
434 |
-
|
435 |
-
$streetPostalCode->appendChild($document->createTextNode($formattedAddress["postcode"]));
|
436 |
-
$locality->appendChild($document->createTextNode($formattedAddress["city"]));
|
437 |
-
$countryCode->appendChild($document->createTextNode($this->_shippingAddress->getCountryId()));
|
438 |
-
|
439 |
-
$parcelsDepotAddress = $document->createElement('parcelsDepotAddress');
|
440 |
-
$parcelsDepotAddress->appendChild($streetName);
|
441 |
-
$parcelsDepotAddress->appendChild($streetNumber);
|
442 |
-
$parcelsDepotAddress->appendChild($streetPostalCode);
|
443 |
-
$parcelsDepotAddress->appendChild($locality);
|
444 |
-
$parcelsDepotAddress->appendChild($countryCode);
|
445 |
-
//end address tags
|
446 |
-
|
447 |
-
//add unregistered element
|
448 |
-
$unregistered = $document->createElement('unregistered');
|
449 |
-
|
450 |
-
//message language
|
451 |
-
//we take the locale from the store where the order is placed from
|
452 |
-
$locale = $bpostHelper->getLocaleByOrder($order);
|
453 |
-
$messageLanguage = $document->createElement('language');
|
454 |
-
$messageLanguage->appendChild($document->createTextNode($locale));
|
455 |
-
|
456 |
-
$email = $document->createElement('emailAddress');
|
457 |
-
$email->appendChild($document->createTextNode($this->_billingAddress->getEmail()));
|
458 |
-
|
459 |
-
//Indication if this user has reduced mobility Y/N
|
460 |
-
//comes from frontend
|
461 |
-
$reducedMobilityZone = $document->createElement('reducedMobilityZone');
|
462 |
-
$unregistered->appendChild($messageLanguage);
|
463 |
-
|
464 |
-
if($order->getBpostNotificationSms()){
|
465 |
-
$mobilePhone = $document->createElement('mobilePhone');
|
466 |
-
$mobilePhone->appendChild($document->createTextNode(preg_replace('/[^0-9]/s', '',$this->_shippingAddress->getTelephone())));
|
467 |
-
$unregistered->appendChild($mobilePhone);
|
468 |
-
}
|
469 |
-
|
470 |
-
$unregistered->appendChild($email);
|
471 |
-
|
472 |
-
if($order->getBpostReducedMobility()){
|
473 |
-
$unregistered->appendChild($reducedMobilityZone);
|
474 |
-
}
|
475 |
-
//end unregistered element
|
476 |
-
|
477 |
-
$atTwentyFourSeven = $document->createElement('at24-7');
|
478 |
-
$atTwentyFourSeven->appendChild($product);
|
479 |
-
|
480 |
-
if($options->hasChildNodes()){
|
481 |
-
$atTwentyFourSeven->appendChild($options);
|
482 |
-
}
|
483 |
-
|
484 |
-
|
485 |
-
$atTwentyFourSeven->appendChild($weight);
|
486 |
-
$atTwentyFourSeven->appendChild($parcelsDepotId);
|
487 |
-
$atTwentyFourSeven->appendChild($parcelsDepotName);
|
488 |
-
$atTwentyFourSeven->appendChild($parcelsDepotAddress);
|
489 |
-
|
490 |
-
//add unregistered element
|
491 |
-
$atTwentyFourSeven->appendChild($unregistered);
|
492 |
-
$atTwentyFourSeven->appendChild($receiverName);
|
493 |
-
$atTwentyFourSeven->appendChild($receiverCompany);
|
494 |
-
|
495 |
-
if($reqDeliveryDate) {
|
496 |
-
$atTwentyFourSeven->appendChild($reqDeliveryDate);
|
497 |
-
}
|
498 |
-
|
499 |
-
$nationalBox->appendChild($atTwentyFourSeven);
|
500 |
-
break;
|
501 |
-
|
502 |
-
case "bpostshm_bpost_clickcollect":
|
503 |
-
if(!$order->getBpostPickuplocationId()){
|
504 |
-
//only throw error in backend
|
505 |
-
if($manageLabels){
|
506 |
-
Mage::throwException("No pickup location order data found.");
|
507 |
-
}
|
508 |
-
}
|
509 |
-
|
510 |
-
$product->appendChild($document->createTextNode("bpack Click & Collect"));
|
511 |
-
|
512 |
-
//add the notification options
|
513 |
-
//check if bpost notification sms or mail isset
|
514 |
-
if($order->getBpostNotificationSms() || $order->getBpostNotificationEmail()){
|
515 |
-
if($order->getBpostNotificationSms()){
|
516 |
-
$options->appendChild($this->_addNotificationMessageOption($document, $order, "keepMeInformed", "sms"));
|
517 |
-
}else{
|
518 |
-
$options->appendChild($this->_addNotificationMessageOption($document, $order, "keepMeInformed"));
|
519 |
-
}
|
520 |
-
}
|
521 |
-
|
522 |
-
//then get the config option settings
|
523 |
-
$options = $this->_checkIfOptionIsValid($document, $options, $order, "bpost_clickcollect", "insurance", "insured");
|
524 |
-
$options = $this->_checkIfOptionIsValid($document, $options, $order, "bpost_clickcollect", "saturday_delivery", "saturdayDelivery");
|
525 |
-
|
526 |
-
$formattedAddress = $bpostHelper->formatShippingAddress($this->_shippingAddress);
|
527 |
-
|
528 |
-
$pugoId = $document->createElement('pugoId');
|
529 |
-
$pugoId->appendChild($document->createTextNode($order->getBpostPickuplocationId()));
|
530 |
-
|
531 |
-
$pugoName = $document->createElement('pugoName');
|
532 |
-
$pugoName->appendChild($document->createTextNode($this->_shippingAddress->getLastname()));
|
533 |
-
|
534 |
-
//Address tags
|
535 |
-
$streetName->appendChild($document->createTextNode($formattedAddress["street"]));
|
536 |
-
$streetNumber->appendChild($document->createTextNode($formattedAddress["number"]));
|
537 |
-
|
538 |
-
$streetPostalCode->appendChild($document->createTextNode($formattedAddress["postcode"]));
|
539 |
-
$locality->appendChild($document->createTextNode($formattedAddress["city"]));
|
540 |
-
$countryCode->appendChild($document->createTextNode($this->_shippingAddress->getCountryId()));
|
541 |
-
|
542 |
-
$pugoAddress = $document->createElement('pugoAddress');
|
543 |
-
$pugoAddress->appendChild($streetName);
|
544 |
-
$pugoAddress->appendChild($streetNumber);
|
545 |
-
$pugoAddress->appendChild($streetPostalCode);
|
546 |
-
$pugoAddress->appendChild($locality);
|
547 |
-
$pugoAddress->appendChild($countryCode);
|
548 |
-
//end address tags
|
549 |
-
|
550 |
-
$atBpost = $document->createElement('atBpost');
|
551 |
-
$atBpost->appendChild($product);
|
552 |
-
|
553 |
-
if($options->hasChildNodes()){
|
554 |
-
$atBpost->appendChild($options);
|
555 |
-
}
|
556 |
-
|
557 |
-
$atBpost->appendChild($weight);
|
558 |
-
$atBpost->appendChild($pugoId);
|
559 |
-
$atBpost->appendChild($pugoName);
|
560 |
-
$atBpost->appendChild($pugoAddress);
|
561 |
-
$atBpost->appendChild($receiverName);
|
562 |
-
$atBpost->appendChild($receiverCompany);
|
563 |
-
|
564 |
-
if($reqDeliveryDate) {
|
565 |
-
$atBpost->appendChild($reqDeliveryDate);
|
566 |
-
}
|
567 |
-
|
568 |
-
$nationalBox->appendChild($atBpost);
|
569 |
-
|
570 |
-
break;
|
571 |
-
}
|
572 |
-
|
573 |
-
return $nationalBox;
|
574 |
-
}
|
575 |
-
|
576 |
-
//function adds the international box element tags
|
577 |
-
protected function _getInternationalBoxElements(DOMDocument $document, $order, $returnOrder, $weightInGrams){
|
578 |
-
$configHelper = Mage::helper("bpost_shm/system_config");
|
579 |
-
$storeId = $order->getStoreId();
|
580 |
-
|
581 |
-
//start creating xml
|
582 |
-
$internationalBox = $document->createElement('tns:internationalBox');
|
583 |
-
$internationalWrapper = $document->createElement('international:international');
|
584 |
-
|
585 |
-
if(!$returnOrder){
|
586 |
-
$productType = $configHelper->getBpostCarriersConfig("product", "bpost_international", $storeId);
|
587 |
-
($productType == 0 ? $productType = "bpack World Business" : $productType = "bpack World Express Pro");
|
588 |
-
}else{
|
589 |
-
$productType = "bpack World Easy Return";
|
590 |
-
}
|
591 |
-
|
592 |
-
//add product
|
593 |
-
$internationalProduct = $document->createElement('international:product');
|
594 |
-
$internationalProduct->appendChild($document->createTextNode($productType));
|
595 |
-
|
596 |
-
//add options
|
597 |
-
$options = $document->createElement('international:options');
|
598 |
-
|
599 |
-
//not possible yet, maybe in feature
|
600 |
-
if($productType == "bpack Europe Business"){
|
601 |
-
$options = $this->_checkIfOptionIsValid($document, $options, $order, "bpost_international", "second_presentation", "automaticSecondPresentation");
|
602 |
-
}
|
603 |
-
|
604 |
-
$options = $this->_checkIfOptionIsValid($document, $options, $order, "bpost_international", "insurance", "insured");
|
605 |
-
|
606 |
-
//add receiver info
|
607 |
-
$receiverName = $document->createElement('common:name');
|
608 |
-
$receiverName->appendChild($document->createTextNode($this->_shippingAddress->getBpostName()));
|
609 |
-
|
610 |
-
$receiverCompany = $document->createElement('common:company');
|
611 |
-
$receiverCompany->appendChild($document->createTextNode($this->_shippingAddress->getBpostCompany()));
|
612 |
-
|
613 |
-
$receiverEmailAddress = $document->createElement('common:emailAddress');
|
614 |
-
$receiverEmailAddress->appendChild($document->createTextNode($this->_billingAddress->getEmail()));
|
615 |
-
|
616 |
-
$receiverPhoneNumber = $document->createElement('common:phoneNumber');
|
617 |
-
$receiverPhoneNumber->appendChild($document->createTextNode(preg_replace('/[^0-9]/s', '',$this->_shippingAddress->getTelephone())));
|
618 |
-
|
619 |
-
//add address info
|
620 |
-
$streetName = $document->createElement('common:streetName');
|
621 |
-
$streetName->appendChild($document->createTextNode($this->_shippingAddress->getBpostStreet()));
|
622 |
-
|
623 |
-
$streetNumber = $document->createElement('common:number');
|
624 |
-
$streetNumber->appendChild($document->createTextNode($this->_shippingAddress->getBpostHouseNumber()));
|
625 |
-
|
626 |
-
$streetPostalCode = $document->createElement('common:postalCode');
|
627 |
-
$streetPostalCode->appendChild($document->createTextNode($this->_shippingAddress->getPostcode()));
|
628 |
-
|
629 |
-
$locality = $document->createElement('common:locality');
|
630 |
-
$locality->appendChild($document->createTextNode($this->_shippingAddress->getCity()));
|
631 |
-
|
632 |
-
$countryCode = $document->createElement('common:countryCode');
|
633 |
-
$countryCode->appendChild($document->createTextNode($this->_shippingAddress->getCountryId()));
|
634 |
-
|
635 |
-
$receiverAddress = $document->createElement('common:address');
|
636 |
-
$receiverAddress->appendChild($streetName);
|
637 |
-
$receiverAddress->appendChild($streetNumber);
|
638 |
-
|
639 |
-
//only add element if available
|
640 |
-
if($this->_shippingAddress->getBoxNumber()){
|
641 |
-
$streetBox = $document->createElement('common:box');
|
642 |
-
$streetBox->appendChild($document->createTextNode($this->_shippingAddress->getBoxNumber()));
|
643 |
-
$receiverAddress->appendChild($streetBox);
|
644 |
-
}
|
645 |
-
|
646 |
-
$receiverAddress->appendChild($streetPostalCode);
|
647 |
-
$receiverAddress->appendChild($locality);
|
648 |
-
$receiverAddress->appendChild($countryCode);
|
649 |
-
//end address info
|
650 |
-
|
651 |
-
//add receiver
|
652 |
-
$receiver = $document->createElement('international:receiver');
|
653 |
-
|
654 |
-
$receiver->appendChild($receiverName);
|
655 |
-
$receiver->appendChild($receiverCompany);
|
656 |
-
$receiver->appendChild($receiverAddress);
|
657 |
-
$receiver->appendChild($receiverEmailAddress);
|
658 |
-
$receiver->appendChild($receiverPhoneNumber);
|
659 |
-
|
660 |
-
//create weight element
|
661 |
-
$weight = $document->createElement('international:parcelWeight');
|
662 |
-
$weight->appendChild($document->createTextNode($weightInGrams));
|
663 |
-
|
664 |
-
//create customsInfo element
|
665 |
-
$customsInfo = $document->createElement('international:customsInfo');
|
666 |
-
|
667 |
-
//create customsInfo child elements
|
668 |
-
$parcelValue = $document->createElement('international:parcelValue');
|
669 |
-
|
670 |
-
|
671 |
-
$
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
$
|
676 |
-
|
677 |
-
$
|
678 |
-
$
|
679 |
-
|
680 |
-
$
|
681 |
-
$
|
682 |
-
|
683 |
-
$
|
684 |
-
$
|
685 |
-
|
686 |
-
$
|
687 |
-
$
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
$
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
$internationalWrapper->appendChild($
|
698 |
-
|
699 |
-
$
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
if($
|
723 |
-
$
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
$
|
762 |
-
|
763 |
-
$
|
764 |
-
$
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Bpost_ShM_Model_Api_Domcreator extends Bpost_ShM_Model_Api_Abstract
|
4 |
+
{
|
5 |
+
protected $_xmlnsValue = "http://schema.post.be/shm/deepintegration/v3/national";
|
6 |
+
protected $_xmlnsCommonValue = "http://schema.post.be/shm/deepintegration/v3/common";
|
7 |
+
protected $_xmlnsTnsValue = "http://schema.post.be/shm/deepintegration/v3/";
|
8 |
+
protected $_xmlnsInternational = "http://schema.post.be/shm/deepintegration/v3/international";
|
9 |
+
protected $_xmlnsXsiValue = "http://www.w3.org/2001/XMLSchema-instance";
|
10 |
+
protected $_xsiSchemaLocation = "http://schema.post.be/shm/deepintegration/v3/";
|
11 |
+
|
12 |
+
protected $_shippingAddress;
|
13 |
+
protected $_billingAddress;
|
14 |
+
|
15 |
+
/**
|
16 |
+
* @param Mage_Sales_Model_Order $order
|
17 |
+
* function builds the necessary DOM document and returns it
|
18 |
+
* this result will be used in the API calls as post data
|
19 |
+
* @return DOMDocument
|
20 |
+
*/
|
21 |
+
public function getCreateOrderDomDocument($order, $returnOrder = false){
|
22 |
+
//initialize helper
|
23 |
+
$configHelper = Mage::helper("bpost_shm/system_config");
|
24 |
+
$bpostHelper = Mage::helper("bpost_shm");
|
25 |
+
$shippingMethod = $order->getShippingMethod();
|
26 |
+
$storeId = $order->getStoreId();
|
27 |
+
|
28 |
+
//get sender
|
29 |
+
$senderData = new Varien_Object();
|
30 |
+
$senderData->setBpostName($configHelper->getBpostShippingConfig("sender_name", $storeId));
|
31 |
+
$senderData->setBpostCompany($configHelper->getBpostShippingConfig("sender_company", $storeId));
|
32 |
+
$senderData->setBpostStreet($configHelper->getBpostShippingConfig("sender_streetname", $storeId));
|
33 |
+
$senderData->setBpostHouseNumber($configHelper->getBpostShippingConfig("sender_streetnumber", $storeId));
|
34 |
+
$senderData->setBoxNumber($configHelper->getBpostShippingConfig("sender_boxnumber", $storeId));
|
35 |
+
$senderData->setPostcode($configHelper->getBpostShippingConfig("sender_postal_code", $storeId));
|
36 |
+
$senderData->setCity($configHelper->getBpostShippingConfig("sender_city", $storeId));
|
37 |
+
$senderData->setCountryId($configHelper->getBpostShippingConfig("sender_country", $storeId));
|
38 |
+
$senderData->setEmail($configHelper->getBpostShippingConfig("sender_email", $storeId));
|
39 |
+
$senderData->setTelephone(preg_replace('/[^0-9]/s', '',$configHelper->getBpostShippingConfig("sender_phonenumber", $storeId)));
|
40 |
+
|
41 |
+
//get receiver
|
42 |
+
$this->_shippingAddress = $order->getShippingAddress();
|
43 |
+
$this->_shippingAddress = $bpostHelper->formatAddress($this->_shippingAddress);
|
44 |
+
$this->_billingAddress = $order->getBillingAddress();
|
45 |
+
|
46 |
+
//if return order, we switch the sender and receiver data
|
47 |
+
if($returnOrder){
|
48 |
+
$tmpShippingAddress = $this->_shippingAddress;
|
49 |
+
$this->_shippingAddress = $senderData;
|
50 |
+
$senderData = $tmpShippingAddress;
|
51 |
+
|
52 |
+
if($shippingMethod != "bpostshm_bpost_international" && $shippingMethod != "bpostshm_bpost_homedelivery"){
|
53 |
+
$senderData->setBpostName($this->_billingAddress->getFirstname()." ".$this->_billingAddress->getLastname());
|
54 |
+
}
|
55 |
+
|
56 |
+
if($shippingMethod != "bpostshm_bpost_international"){
|
57 |
+
//we force shipping to 'bpostshm_bpost_homedelivery' method because we are creating a return order
|
58 |
+
$shippingMethod = "bpostshm_bpost_homedelivery";
|
59 |
+
}
|
60 |
+
}
|
61 |
+
|
62 |
+
$document = new DOMDocument('1.0','UTF-8');
|
63 |
+
$document->formatOutput = true;
|
64 |
+
$orderElement = $document->createElement('tns:order');
|
65 |
+
|
66 |
+
//we add the extra attributes to the order element
|
67 |
+
$xmlnsAttribute = $document->createAttribute("xmlns");
|
68 |
+
$xmlnsAttribute->value = $this->_xmlnsValue;
|
69 |
+
|
70 |
+
$xmlnsCommonAttribute = $document->createAttribute("xmlns:common");
|
71 |
+
$xmlnsCommonAttribute->value = $this->_xmlnsCommonValue;
|
72 |
+
|
73 |
+
$xmlnsTnsAttribute = $document->createAttribute("xmlns:tns");
|
74 |
+
$xmlnsTnsAttribute->value = $this->_xmlnsTnsValue;
|
75 |
+
|
76 |
+
$xmlnsIAttribute = $document->createAttribute("xmlns:international");
|
77 |
+
$xmlnsIAttribute->value = $this->_xmlnsInternational;
|
78 |
+
|
79 |
+
$xmlnsXsiAttribute = $document->createAttribute("xmlns:xsi");
|
80 |
+
$xmlnsXsiAttribute->value = $this->_xmlnsXsiValue;
|
81 |
+
|
82 |
+
$xsiSchemaLocation = $document->createAttribute("xsi:schemaLocation");
|
83 |
+
$xsiSchemaLocation->value = $this->_xsiSchemaLocation;
|
84 |
+
|
85 |
+
$orderElement->appendChild($xmlnsAttribute);
|
86 |
+
$orderElement->appendChild($xmlnsCommonAttribute);
|
87 |
+
$orderElement->appendChild($xmlnsTnsAttribute);
|
88 |
+
$orderElement->appendChild($xmlnsIAttribute);
|
89 |
+
$orderElement->appendChild($xmlnsXsiAttribute);
|
90 |
+
$orderElement->appendChild($xsiSchemaLocation);
|
91 |
+
//end adding order attributes
|
92 |
+
|
93 |
+
$document->appendChild($orderElement);
|
94 |
+
|
95 |
+
//add order elements
|
96 |
+
$accountId = $document->createElement('tns:accountId');
|
97 |
+
$accountId->appendChild($document->createTextNode($this->_accountId));
|
98 |
+
$orderElement->appendChild($accountId);
|
99 |
+
|
100 |
+
$reference = $document->createElement('tns:reference');
|
101 |
+
$referenceId = $order->getIncrementId();
|
102 |
+
|
103 |
+
$items = $order->getAllItems();
|
104 |
+
$reference->appendChild($document->createTextNode($referenceId));
|
105 |
+
$orderElement->appendChild($reference);
|
106 |
+
|
107 |
+
//calculate weight
|
108 |
+
$totalShipmentsWeight = $bpostHelper->processShipmentsWeight($order);
|
109 |
+
|
110 |
+
//we add all order items to the document
|
111 |
+
foreach ($items as $item) {
|
112 |
+
if ($item->getParentItem()) {
|
113 |
+
continue;
|
114 |
+
}
|
115 |
+
|
116 |
+
$nbOfItems = $document->createElement('tns:nbOfItems');
|
117 |
+
$nbOfItems->appendChild($document->createTextNode((int)$item->getQtyOrdered()));
|
118 |
+
|
119 |
+
$text = $document->createElement('tns:text');
|
120 |
+
$text->appendChild($document->createTextNode($item->getName()));
|
121 |
+
|
122 |
+
$orderLine = $document->createElement('tns:orderLine');
|
123 |
+
$orderLine->appendChild($text);
|
124 |
+
$orderLine->appendChild($nbOfItems);
|
125 |
+
$orderElement->appendChild($orderLine);
|
126 |
+
}
|
127 |
+
|
128 |
+
$weightInGrams = round($totalShipmentsWeight);
|
129 |
+
|
130 |
+
if(!$weightInGrams){
|
131 |
+
$weightInGrams = 1;
|
132 |
+
}
|
133 |
+
|
134 |
+
if(($shippingMethod == "bpostshm_bpost_parcellocker" || $shippingMethod == "bpostshm_bpost_international" || $shippingMethod == "bpostshm_bpost_clickcollect") && $weightInGrams < 10){
|
135 |
+
$weightInGrams = 10;
|
136 |
+
}
|
137 |
+
//end weight
|
138 |
+
|
139 |
+
$senderName = $document->createElement('common:name');
|
140 |
+
$senderName->appendChild($document->createTextNode($senderData->getBpostName()));
|
141 |
+
|
142 |
+
$senderCompany = $document->createElement('common:company');
|
143 |
+
$senderCompany->appendChild($document->createTextNode($senderData->getBpostCompany()));
|
144 |
+
//sender address fields here
|
145 |
+
$addressStreetName = $document->createElement('common:streetName');
|
146 |
+
$addressStreetName->appendChild($document->createTextNode($senderData->getBpostStreet()));
|
147 |
+
|
148 |
+
$addressNumber = $document->createElement('common:number');
|
149 |
+
$addressNumber->appendChild($document->createTextNode($senderData->getBpostHouseNumber()));
|
150 |
+
|
151 |
+
//only add element if available
|
152 |
+
$boxNumber = $configHelper->getBpostShippingConfig($senderData->getBoxNumber(), $storeId);
|
153 |
+
|
154 |
+
if($boxNumber && $boxNumber != ''){
|
155 |
+
$addressBox = $document->createElement('common:box');
|
156 |
+
$addressBox->appendChild($document->createTextNode($boxNumber));
|
157 |
+
}
|
158 |
+
|
159 |
+
$addressPostalCode = $document->createElement('common:postalCode');
|
160 |
+
$addressPostalCode->appendChild($document->createTextNode($senderData->getPostcode()));
|
161 |
+
|
162 |
+
$addressLocality = $document->createElement('common:locality');
|
163 |
+
$addressLocality->appendChild($document->createTextNode($senderData->getCity()));
|
164 |
+
|
165 |
+
$addressCountryCode = $document->createElement('common:countryCode');
|
166 |
+
$addressCountryCode->appendChild($document->createTextNode($senderData->getCountryId()));
|
167 |
+
//end sender address fields
|
168 |
+
|
169 |
+
//add fields to address
|
170 |
+
$senderAddress = $document->createElement('common:address');
|
171 |
+
$senderAddress->appendChild($addressStreetName);
|
172 |
+
$senderAddress->appendChild($addressNumber);
|
173 |
+
|
174 |
+
if(isset($addressBox)){
|
175 |
+
$senderAddress->appendChild($addressBox);
|
176 |
+
}
|
177 |
+
|
178 |
+
$senderAddress->appendChild($addressPostalCode);
|
179 |
+
$senderAddress->appendChild($addressLocality);
|
180 |
+
$senderAddress->appendChild($addressCountryCode);
|
181 |
+
|
182 |
+
$senderEmail = $document->createElement('common:emailAddress');
|
183 |
+
$senderEmail->appendChild($document->createTextNode($senderData->getEmail()));
|
184 |
+
|
185 |
+
$senderPhoneNumber = $document->createElement('common:phoneNumber');
|
186 |
+
$senderPhoneNumber->appendChild($document->createTextNode(preg_replace('/[^0-9]/s', '',$senderData->getTelephone())));
|
187 |
+
|
188 |
+
//add all sender info to the sender element
|
189 |
+
$sender = $document->createElement('tns:sender');
|
190 |
+
$sender->appendChild($senderName);
|
191 |
+
$sender->appendChild($senderCompany);
|
192 |
+
$sender->appendChild($senderAddress);
|
193 |
+
$sender->appendChild($senderEmail);
|
194 |
+
$sender->appendChild($senderPhoneNumber);
|
195 |
+
|
196 |
+
//we create the box element
|
197 |
+
$box = $document->createElement('tns:box');
|
198 |
+
$box->appendChild($sender);
|
199 |
+
|
200 |
+
//add the national or international box element tags
|
201 |
+
if($shippingMethod != "bpostshm_bpost_international"){
|
202 |
+
$nationalBoxElements = $this->_getNationalBoxElements($document, $order, $returnOrder, $weightInGrams, $shippingMethod);
|
203 |
+
$box->appendChild($nationalBoxElements);
|
204 |
+
}else{
|
205 |
+
$internationalElements = $this->_getInternationalBoxElements($document, $order, $returnOrder, $weightInGrams);
|
206 |
+
$box->appendChild($internationalElements);
|
207 |
+
}
|
208 |
+
|
209 |
+
//we do the same for additionalCustomerRef
|
210 |
+
//Free text. If not submitted, it will indicate the channel used for creating this order. Best used by integrators to indicate the origin of the order.
|
211 |
+
|
212 |
+
$additionalCustomerRef = $document->createElement('tns:additionalCustomerReference');
|
213 |
+
$additionalCustomerRef->appendChild($document->createTextNode("Magento_".Mage::getVersion()));
|
214 |
+
$box->appendChild($additionalCustomerRef);
|
215 |
+
|
216 |
+
//finally we add the box element to the order element
|
217 |
+
$orderElement->appendChild($box);
|
218 |
+
|
219 |
+
//we save the xml so we can check the file
|
220 |
+
return $document;
|
221 |
+
}
|
222 |
+
|
223 |
+
//function adds the national box element tags based on the shipping method
|
224 |
+
protected function _getNationalBoxElements(DOMDocument $document, $order, $returnOrder, $weightInGrams, $shippingMethod){
|
225 |
+
$bpostHelper = Mage::helper("bpost_shm");
|
226 |
+
$configHelper = Mage::helper("bpost_shm/system_config");
|
227 |
+
$nationalBox = $document->createElement('tns:nationalBox');
|
228 |
+
$manageLabels = $configHelper->getBpostShippingConfig("manage_labels_with_magento");
|
229 |
+
|
230 |
+
$reqDeliveryDate = false;
|
231 |
+
$dropDate = new DateTime($order->getBpostDeliveryDate());
|
232 |
+
$currentDate = new DateTime();
|
233 |
+
|
234 |
+
if($dropDate && $dropDate > $currentDate && !$returnOrder) {
|
235 |
+
$reqDeliveryDate = $document->createElement('requestedDeliveryDate');
|
236 |
+
$reqDeliveryDate->appendChild($document->createTextNode($order->getBpostDeliveryDate()));
|
237 |
+
}
|
238 |
+
|
239 |
+
//add product
|
240 |
+
$product = $document->createElement('product');
|
241 |
+
|
242 |
+
//add options
|
243 |
+
$options = $document->createElement('options');
|
244 |
+
|
245 |
+
//add weight
|
246 |
+
$weight = $document->createElement('weight');
|
247 |
+
$weight->appendChild($document->createTextNode($weightInGrams));
|
248 |
+
|
249 |
+
//add address variables
|
250 |
+
$streetName = $document->createElement('common:streetName');
|
251 |
+
$streetNumber = $document->createElement('common:number');
|
252 |
+
$streetPostalCode = $document->createElement('common:postalCode');
|
253 |
+
$locality = $document->createElement('common:locality');
|
254 |
+
$countryCode = $document->createElement('common:countryCode');
|
255 |
+
|
256 |
+
//add receiver info
|
257 |
+
$receiverName = $document->createElement('receiverName');
|
258 |
+
$receiverCompany = $document->createElement('receiverCompany');
|
259 |
+
$receiverCompany->appendChild($document->createTextNode($this->_shippingAddress->getCompany()));
|
260 |
+
|
261 |
+
//we use the receivername from billing address instead of shipping address
|
262 |
+
//this way we have the customer name and not the pickup point name
|
263 |
+
$receiverName->appendChild($document->createTextNode($this->_billingAddress->getFirstname()." ".$this->_billingAddress->getLastname()));
|
264 |
+
|
265 |
+
switch($shippingMethod){
|
266 |
+
case "bpostshm_bpost_homedelivery":
|
267 |
+
if(!$returnOrder){
|
268 |
+
$product->appendChild($document->createTextNode("bpack 24h Pro"));
|
269 |
+
|
270 |
+
//then get config the option settings
|
271 |
+
$options = $this->_checkIfOptionIsValid($document, $options, $order, "bpost_homedelivery", "second_presentation", "automaticSecondPresentation");
|
272 |
+
$options = $this->_checkIfOptionIsValid($document, $options, $order, "bpost_homedelivery", "insurance", "insured");
|
273 |
+
$options = $this->_checkIfOptionIsValid($document, $options, $order, "bpost_homedelivery", "signature", "signed");
|
274 |
+
$options = $this->_checkIfOptionIsValid($document, $options, $order, "bpost_homedelivery", "saturday_delivery", "saturdayDelivery");
|
275 |
+
|
276 |
+
}else{
|
277 |
+
$product->appendChild($document->createTextNode("bpack Easy Retour"));
|
278 |
+
}
|
279 |
+
|
280 |
+
//add receiver info
|
281 |
+
$receiverName = $document->createElement('common:name');
|
282 |
+
$receiverName->appendChild($document->createTextNode($this->_shippingAddress->getBpostName()));
|
283 |
+
|
284 |
+
$receiverCompany = $document->createElement('common:company');
|
285 |
+
$receiverCompany->appendChild($document->createTextNode($this->_shippingAddress->getBpostCompany()));
|
286 |
+
|
287 |
+
$receiverEmailAddress = $document->createElement('common:emailAddress');
|
288 |
+
$receiverEmailAddress->appendChild($document->createTextNode($this->_billingAddress->getEmail()));
|
289 |
+
|
290 |
+
$receiverPhoneNumber = $document->createElement('common:phoneNumber');
|
291 |
+
$receiverPhoneNumber->appendChild($document->createTextNode(preg_replace('/[^0-9]/s', '',$this->_shippingAddress->getTelephone())));
|
292 |
+
|
293 |
+
//we add the receiver address data
|
294 |
+
$streetName->appendChild($document->createTextNode($this->_shippingAddress->getBpostStreet()));
|
295 |
+
$streetNumber->appendChild($document->createTextNode($this->_shippingAddress->getBpostHouseNumber()));
|
296 |
+
|
297 |
+
$streetPostalCode->appendChild($document->createTextNode($this->_shippingAddress->getPostcode()));
|
298 |
+
$locality->appendChild($document->createTextNode($this->_shippingAddress->getCity()));
|
299 |
+
$countryCode->appendChild($document->createTextNode($this->_shippingAddress->getCountryId()));
|
300 |
+
|
301 |
+
$receiverAddress = $document->createElement('common:address');
|
302 |
+
$receiverAddress->appendChild($streetName);
|
303 |
+
$receiverAddress->appendChild($streetNumber);
|
304 |
+
|
305 |
+
//only add element if available
|
306 |
+
if($this->_shippingAddress->getBoxNumber()){
|
307 |
+
$streetBox = $document->createElement('common:box');
|
308 |
+
$streetBox->appendChild($document->createTextNode($this->_shippingAddress->getBoxNumber()));
|
309 |
+
$receiverAddress->appendChild($streetBox);
|
310 |
+
}
|
311 |
+
|
312 |
+
$receiverAddress->appendChild($streetPostalCode);
|
313 |
+
$receiverAddress->appendChild($locality);
|
314 |
+
$receiverAddress->appendChild($countryCode);
|
315 |
+
|
316 |
+
$receiver = $document->createElement('receiver');
|
317 |
+
$receiver->appendChild($receiverName);
|
318 |
+
$receiver->appendChild($receiverCompany);
|
319 |
+
$receiver->appendChild($receiverAddress);
|
320 |
+
$receiver->appendChild($receiverEmailAddress);
|
321 |
+
$receiver->appendChild($receiverPhoneNumber);
|
322 |
+
//end receiver
|
323 |
+
|
324 |
+
$atHome = $document->createElement('atHome');
|
325 |
+
$atHome->appendChild($product);
|
326 |
+
|
327 |
+
if($options->hasChildNodes()){
|
328 |
+
$atHome->appendChild($options);
|
329 |
+
}
|
330 |
+
|
331 |
+
$atHome->appendChild($weight);
|
332 |
+
$atHome->appendChild($receiver);
|
333 |
+
|
334 |
+
if($reqDeliveryDate){
|
335 |
+
$atHome->appendChild($reqDeliveryDate);
|
336 |
+
}
|
337 |
+
|
338 |
+
$nationalBox->appendChild($atHome);
|
339 |
+
break;
|
340 |
+
|
341 |
+
case "bpostshm_bpost_pickuppoint":
|
342 |
+
if(!$order->getBpostPickuplocationId()){
|
343 |
+
//only throw error in backend
|
344 |
+
if($manageLabels){
|
345 |
+
Mage::throwException("No pickup location order data found.");
|
346 |
+
}
|
347 |
+
}
|
348 |
+
|
349 |
+
$product->appendChild($document->createTextNode("bpack@bpost"));
|
350 |
+
|
351 |
+
//add the notification options
|
352 |
+
//check if bpost notification sms or mail isset
|
353 |
+
if($order->getBpostNotificationSms() || $order->getBpostNotificationEmail()){
|
354 |
+
if($order->getBpostNotificationSms()){
|
355 |
+
$options->appendChild($this->_addNotificationMessageOption($document, $order, "keepMeInformed", "sms"));
|
356 |
+
}else{
|
357 |
+
$options->appendChild($this->_addNotificationMessageOption($document, $order, "keepMeInformed"));
|
358 |
+
}
|
359 |
+
}
|
360 |
+
|
361 |
+
//then get the config option settings
|
362 |
+
$options = $this->_checkIfOptionIsValid($document, $options, $order, "bpost_pickuppoint", "insurance", "insured");
|
363 |
+
$options = $this->_checkIfOptionIsValid($document, $options, $order, "bpost_pickuppoint", "saturday_delivery", "saturdayDelivery");
|
364 |
+
|
365 |
+
$formattedAddress = $bpostHelper->formatShippingAddress($this->_shippingAddress);
|
366 |
+
|
367 |
+
$pugoId = $document->createElement('pugoId');
|
368 |
+
$pugoId->appendChild($document->createTextNode($order->getBpostPickuplocationId()));
|
369 |
+
|
370 |
+
$pugoName = $document->createElement('pugoName');
|
371 |
+
$pugoName->appendChild($document->createTextNode($this->_shippingAddress->getLastname()));
|
372 |
+
|
373 |
+
//Address tags
|
374 |
+
$streetName->appendChild($document->createTextNode($formattedAddress["street"]));
|
375 |
+
$streetNumber->appendChild($document->createTextNode($formattedAddress["number"]));
|
376 |
+
|
377 |
+
$streetPostalCode->appendChild($document->createTextNode($formattedAddress["postcode"]));
|
378 |
+
$locality->appendChild($document->createTextNode($formattedAddress["city"]));
|
379 |
+
$countryCode->appendChild($document->createTextNode($this->_shippingAddress->getCountryId()));
|
380 |
+
|
381 |
+
$pugoAddress = $document->createElement('pugoAddress');
|
382 |
+
$pugoAddress->appendChild($streetName);
|
383 |
+
$pugoAddress->appendChild($streetNumber);
|
384 |
+
$pugoAddress->appendChild($streetPostalCode);
|
385 |
+
$pugoAddress->appendChild($locality);
|
386 |
+
$pugoAddress->appendChild($countryCode);
|
387 |
+
//end address tags
|
388 |
+
|
389 |
+
$atBpost = $document->createElement('atBpost');
|
390 |
+
$atBpost->appendChild($product);
|
391 |
+
|
392 |
+
if($options->hasChildNodes()){
|
393 |
+
$atBpost->appendChild($options);
|
394 |
+
}
|
395 |
+
|
396 |
+
$atBpost->appendChild($weight);
|
397 |
+
$atBpost->appendChild($pugoId);
|
398 |
+
$atBpost->appendChild($pugoName);
|
399 |
+
$atBpost->appendChild($pugoAddress);
|
400 |
+
$atBpost->appendChild($receiverName);
|
401 |
+
$atBpost->appendChild($receiverCompany);
|
402 |
+
|
403 |
+
if($reqDeliveryDate) {
|
404 |
+
$atBpost->appendChild($reqDeliveryDate);
|
405 |
+
}
|
406 |
+
|
407 |
+
$nationalBox->appendChild($atBpost);
|
408 |
+
|
409 |
+
break;
|
410 |
+
|
411 |
+
case "bpostshm_bpost_parcellocker":
|
412 |
+
|
413 |
+
if(!$order->getBpostPickuplocationId() && $manageLabels){
|
414 |
+
Mage::throwException("No parcel locker data found.");
|
415 |
+
}
|
416 |
+
|
417 |
+
$product->appendChild($document->createTextNode("bpack 24h Pro"));
|
418 |
+
|
419 |
+
//then get the config option settings
|
420 |
+
$options = $this->_checkIfOptionIsValid($document, $options, $order, "bpost_parcellocker", "insurance", "insured");
|
421 |
+
$options = $this->_checkIfOptionIsValid($document, $options, $order, "bpost_parcellocker", "saturday_delivery", "saturdayDelivery");
|
422 |
+
|
423 |
+
$formattedAddress = $bpostHelper->formatShippingAddress($this->_shippingAddress);
|
424 |
+
|
425 |
+
$parcelsDepotId = $document->createElement('parcelsDepotId');
|
426 |
+
$parcelsDepotId->appendChild($document->createTextNode($order->getBpostPickuplocationId()));
|
427 |
+
|
428 |
+
$parcelsDepotName = $document->createElement('parcelsDepotName');
|
429 |
+
$parcelsDepotName->appendChild($document->createTextNode($this->_shippingAddress->getLastname()));
|
430 |
+
|
431 |
+
//Address tags
|
432 |
+
$streetName->appendChild($document->createTextNode($formattedAddress["street"]));
|
433 |
+
$streetNumber->appendChild($document->createTextNode($formattedAddress["number"]));
|
434 |
+
|
435 |
+
$streetPostalCode->appendChild($document->createTextNode($formattedAddress["postcode"]));
|
436 |
+
$locality->appendChild($document->createTextNode($formattedAddress["city"]));
|
437 |
+
$countryCode->appendChild($document->createTextNode($this->_shippingAddress->getCountryId()));
|
438 |
+
|
439 |
+
$parcelsDepotAddress = $document->createElement('parcelsDepotAddress');
|
440 |
+
$parcelsDepotAddress->appendChild($streetName);
|
441 |
+
$parcelsDepotAddress->appendChild($streetNumber);
|
442 |
+
$parcelsDepotAddress->appendChild($streetPostalCode);
|
443 |
+
$parcelsDepotAddress->appendChild($locality);
|
444 |
+
$parcelsDepotAddress->appendChild($countryCode);
|
445 |
+
//end address tags
|
446 |
+
|
447 |
+
//add unregistered element
|
448 |
+
$unregistered = $document->createElement('unregistered');
|
449 |
+
|
450 |
+
//message language
|
451 |
+
//we take the locale from the store where the order is placed from
|
452 |
+
$locale = $bpostHelper->getLocaleByOrder($order);
|
453 |
+
$messageLanguage = $document->createElement('language');
|
454 |
+
$messageLanguage->appendChild($document->createTextNode($locale));
|
455 |
+
|
456 |
+
$email = $document->createElement('emailAddress');
|
457 |
+
$email->appendChild($document->createTextNode($this->_billingAddress->getEmail()));
|
458 |
+
|
459 |
+
//Indication if this user has reduced mobility Y/N
|
460 |
+
//comes from frontend
|
461 |
+
$reducedMobilityZone = $document->createElement('reducedMobilityZone');
|
462 |
+
$unregistered->appendChild($messageLanguage);
|
463 |
+
|
464 |
+
if($order->getBpostNotificationSms()){
|
465 |
+
$mobilePhone = $document->createElement('mobilePhone');
|
466 |
+
$mobilePhone->appendChild($document->createTextNode(preg_replace('/[^0-9]/s', '',$this->_shippingAddress->getTelephone())));
|
467 |
+
$unregistered->appendChild($mobilePhone);
|
468 |
+
}
|
469 |
+
|
470 |
+
$unregistered->appendChild($email);
|
471 |
+
|
472 |
+
if($order->getBpostReducedMobility()){
|
473 |
+
$unregistered->appendChild($reducedMobilityZone);
|
474 |
+
}
|
475 |
+
//end unregistered element
|
476 |
+
|
477 |
+
$atTwentyFourSeven = $document->createElement('at24-7');
|
478 |
+
$atTwentyFourSeven->appendChild($product);
|
479 |
+
|
480 |
+
if($options->hasChildNodes()){
|
481 |
+
$atTwentyFourSeven->appendChild($options);
|
482 |
+
}
|
483 |
+
|
484 |
+
|
485 |
+
$atTwentyFourSeven->appendChild($weight);
|
486 |
+
$atTwentyFourSeven->appendChild($parcelsDepotId);
|
487 |
+
$atTwentyFourSeven->appendChild($parcelsDepotName);
|
488 |
+
$atTwentyFourSeven->appendChild($parcelsDepotAddress);
|
489 |
+
|
490 |
+
//add unregistered element
|
491 |
+
$atTwentyFourSeven->appendChild($unregistered);
|
492 |
+
$atTwentyFourSeven->appendChild($receiverName);
|
493 |
+
$atTwentyFourSeven->appendChild($receiverCompany);
|
494 |
+
|
495 |
+
if($reqDeliveryDate) {
|
496 |
+
$atTwentyFourSeven->appendChild($reqDeliveryDate);
|
497 |
+
}
|
498 |
+
|
499 |
+
$nationalBox->appendChild($atTwentyFourSeven);
|
500 |
+
break;
|
501 |
+
|
502 |
+
case "bpostshm_bpost_clickcollect":
|
503 |
+
if(!$order->getBpostPickuplocationId()){
|
504 |
+
//only throw error in backend
|
505 |
+
if($manageLabels){
|
506 |
+
Mage::throwException("No pickup location order data found.");
|
507 |
+
}
|
508 |
+
}
|
509 |
+
|
510 |
+
$product->appendChild($document->createTextNode("bpack Click & Collect"));
|
511 |
+
|
512 |
+
//add the notification options
|
513 |
+
//check if bpost notification sms or mail isset
|
514 |
+
if($order->getBpostNotificationSms() || $order->getBpostNotificationEmail()){
|
515 |
+
if($order->getBpostNotificationSms()){
|
516 |
+
$options->appendChild($this->_addNotificationMessageOption($document, $order, "keepMeInformed", "sms"));
|
517 |
+
}else{
|
518 |
+
$options->appendChild($this->_addNotificationMessageOption($document, $order, "keepMeInformed"));
|
519 |
+
}
|
520 |
+
}
|
521 |
+
|
522 |
+
//then get the config option settings
|
523 |
+
$options = $this->_checkIfOptionIsValid($document, $options, $order, "bpost_clickcollect", "insurance", "insured");
|
524 |
+
$options = $this->_checkIfOptionIsValid($document, $options, $order, "bpost_clickcollect", "saturday_delivery", "saturdayDelivery");
|
525 |
+
|
526 |
+
$formattedAddress = $bpostHelper->formatShippingAddress($this->_shippingAddress);
|
527 |
+
|
528 |
+
$pugoId = $document->createElement('pugoId');
|
529 |
+
$pugoId->appendChild($document->createTextNode($order->getBpostPickuplocationId()));
|
530 |
+
|
531 |
+
$pugoName = $document->createElement('pugoName');
|
532 |
+
$pugoName->appendChild($document->createTextNode($this->_shippingAddress->getLastname()));
|
533 |
+
|
534 |
+
//Address tags
|
535 |
+
$streetName->appendChild($document->createTextNode($formattedAddress["street"]));
|
536 |
+
$streetNumber->appendChild($document->createTextNode($formattedAddress["number"]));
|
537 |
+
|
538 |
+
$streetPostalCode->appendChild($document->createTextNode($formattedAddress["postcode"]));
|
539 |
+
$locality->appendChild($document->createTextNode($formattedAddress["city"]));
|
540 |
+
$countryCode->appendChild($document->createTextNode($this->_shippingAddress->getCountryId()));
|
541 |
+
|
542 |
+
$pugoAddress = $document->createElement('pugoAddress');
|
543 |
+
$pugoAddress->appendChild($streetName);
|
544 |
+
$pugoAddress->appendChild($streetNumber);
|
545 |
+
$pugoAddress->appendChild($streetPostalCode);
|
546 |
+
$pugoAddress->appendChild($locality);
|
547 |
+
$pugoAddress->appendChild($countryCode);
|
548 |
+
//end address tags
|
549 |
+
|
550 |
+
$atBpost = $document->createElement('atBpost');
|
551 |
+
$atBpost->appendChild($product);
|
552 |
+
|
553 |
+
if($options->hasChildNodes()){
|
554 |
+
$atBpost->appendChild($options);
|
555 |
+
}
|
556 |
+
|
557 |
+
$atBpost->appendChild($weight);
|
558 |
+
$atBpost->appendChild($pugoId);
|
559 |
+
$atBpost->appendChild($pugoName);
|
560 |
+
$atBpost->appendChild($pugoAddress);
|
561 |
+
$atBpost->appendChild($receiverName);
|
562 |
+
$atBpost->appendChild($receiverCompany);
|
563 |
+
|
564 |
+
if($reqDeliveryDate) {
|
565 |
+
$atBpost->appendChild($reqDeliveryDate);
|
566 |
+
}
|
567 |
+
|
568 |
+
$nationalBox->appendChild($atBpost);
|
569 |
+
|
570 |
+
break;
|
571 |
+
}
|
572 |
+
|
573 |
+
return $nationalBox;
|
574 |
+
}
|
575 |
+
|
576 |
+
//function adds the international box element tags
|
577 |
+
protected function _getInternationalBoxElements(DOMDocument $document, $order, $returnOrder, $weightInGrams){
|
578 |
+
$configHelper = Mage::helper("bpost_shm/system_config");
|
579 |
+
$storeId = $order->getStoreId();
|
580 |
+
|
581 |
+
//start creating xml
|
582 |
+
$internationalBox = $document->createElement('tns:internationalBox');
|
583 |
+
$internationalWrapper = $document->createElement('international:international');
|
584 |
+
|
585 |
+
if(!$returnOrder){
|
586 |
+
$productType = $configHelper->getBpostCarriersConfig("product", "bpost_international", $storeId);
|
587 |
+
($productType == 0 ? $productType = "bpack World Business" : $productType = "bpack World Express Pro");
|
588 |
+
}else{
|
589 |
+
$productType = "bpack World Easy Return";
|
590 |
+
}
|
591 |
+
|
592 |
+
//add product
|
593 |
+
$internationalProduct = $document->createElement('international:product');
|
594 |
+
$internationalProduct->appendChild($document->createTextNode($productType));
|
595 |
+
|
596 |
+
//add options
|
597 |
+
$options = $document->createElement('international:options');
|
598 |
+
|
599 |
+
//not possible yet, maybe in feature
|
600 |
+
if($productType == "bpack Europe Business"){
|
601 |
+
$options = $this->_checkIfOptionIsValid($document, $options, $order, "bpost_international", "second_presentation", "automaticSecondPresentation");
|
602 |
+
}
|
603 |
+
|
604 |
+
$options = $this->_checkIfOptionIsValid($document, $options, $order, "bpost_international", "insurance", "insured");
|
605 |
+
|
606 |
+
//add receiver info
|
607 |
+
$receiverName = $document->createElement('common:name');
|
608 |
+
$receiverName->appendChild($document->createTextNode($this->_shippingAddress->getBpostName()));
|
609 |
+
|
610 |
+
$receiverCompany = $document->createElement('common:company');
|
611 |
+
$receiverCompany->appendChild($document->createTextNode($this->_shippingAddress->getBpostCompany()));
|
612 |
+
|
613 |
+
$receiverEmailAddress = $document->createElement('common:emailAddress');
|
614 |
+
$receiverEmailAddress->appendChild($document->createTextNode($this->_billingAddress->getEmail()));
|
615 |
+
|
616 |
+
$receiverPhoneNumber = $document->createElement('common:phoneNumber');
|
617 |
+
$receiverPhoneNumber->appendChild($document->createTextNode(preg_replace('/[^0-9]/s', '',$this->_shippingAddress->getTelephone())));
|
618 |
+
|
619 |
+
//add address info
|
620 |
+
$streetName = $document->createElement('common:streetName');
|
621 |
+
$streetName->appendChild($document->createTextNode($this->_shippingAddress->getBpostStreet()));
|
622 |
+
|
623 |
+
$streetNumber = $document->createElement('common:number');
|
624 |
+
$streetNumber->appendChild($document->createTextNode($this->_shippingAddress->getBpostHouseNumber()));
|
625 |
+
|
626 |
+
$streetPostalCode = $document->createElement('common:postalCode');
|
627 |
+
$streetPostalCode->appendChild($document->createTextNode($this->_shippingAddress->getPostcode()));
|
628 |
+
|
629 |
+
$locality = $document->createElement('common:locality');
|
630 |
+
$locality->appendChild($document->createTextNode($this->_shippingAddress->getCity()));
|
631 |
+
|
632 |
+
$countryCode = $document->createElement('common:countryCode');
|
633 |
+
$countryCode->appendChild($document->createTextNode($this->_shippingAddress->getCountryId()));
|
634 |
+
|
635 |
+
$receiverAddress = $document->createElement('common:address');
|
636 |
+
$receiverAddress->appendChild($streetName);
|
637 |
+
$receiverAddress->appendChild($streetNumber);
|
638 |
+
|
639 |
+
//only add element if available
|
640 |
+
if($this->_shippingAddress->getBoxNumber()){
|
641 |
+
$streetBox = $document->createElement('common:box');
|
642 |
+
$streetBox->appendChild($document->createTextNode($this->_shippingAddress->getBoxNumber()));
|
643 |
+
$receiverAddress->appendChild($streetBox);
|
644 |
+
}
|
645 |
+
|
646 |
+
$receiverAddress->appendChild($streetPostalCode);
|
647 |
+
$receiverAddress->appendChild($locality);
|
648 |
+
$receiverAddress->appendChild($countryCode);
|
649 |
+
//end address info
|
650 |
+
|
651 |
+
//add receiver
|
652 |
+
$receiver = $document->createElement('international:receiver');
|
653 |
+
|
654 |
+
$receiver->appendChild($receiverName);
|
655 |
+
$receiver->appendChild($receiverCompany);
|
656 |
+
$receiver->appendChild($receiverAddress);
|
657 |
+
$receiver->appendChild($receiverEmailAddress);
|
658 |
+
$receiver->appendChild($receiverPhoneNumber);
|
659 |
+
|
660 |
+
//create weight element
|
661 |
+
$weight = $document->createElement('international:parcelWeight');
|
662 |
+
$weight->appendChild($document->createTextNode($weightInGrams));
|
663 |
+
|
664 |
+
//create customsInfo element
|
665 |
+
$customsInfo = $document->createElement('international:customsInfo');
|
666 |
+
|
667 |
+
//create customsInfo child elements
|
668 |
+
$parcelValue = $document->createElement('international:parcelValue');
|
669 |
+
|
670 |
+
$grandTotalExclDiscount = (round(($order->getGrandTotal()+abs($order->getDiscountAmount())), 2) * 100);
|
671 |
+
if ($grandTotalExclDiscount < 100) {
|
672 |
+
$grandTotalExclDiscount = 100;
|
673 |
+
}
|
674 |
+
|
675 |
+
$parcelValue->appendChild($document->createTextNode($grandTotalExclDiscount));
|
676 |
+
|
677 |
+
$contentDescription = $document->createElement('international:contentDescription');
|
678 |
+
$contentDescription->appendChild($document->createTextNode("no description"));
|
679 |
+
|
680 |
+
$shipmentType = $document->createElement('international:shipmentType');
|
681 |
+
$shipmentType->appendChild($document->createTextNode("OTHER"));
|
682 |
+
|
683 |
+
$returnInstructions = $document->createElement('international:parcelReturnInstructions');
|
684 |
+
$returnInstructions->appendChild($document->createTextNode("RTS"));
|
685 |
+
|
686 |
+
$privateAddress = $document->createElement('international:privateAddress');
|
687 |
+
$privateAddress->appendChild($document->createTextNode("false"));
|
688 |
+
|
689 |
+
$customsInfo->appendChild($parcelValue);
|
690 |
+
$customsInfo->appendChild($contentDescription);
|
691 |
+
$customsInfo->appendChild($shipmentType);
|
692 |
+
$customsInfo->appendChild($returnInstructions);
|
693 |
+
$customsInfo->appendChild($privateAddress);
|
694 |
+
//end customsInfo element
|
695 |
+
|
696 |
+
//add elements to the international wrapper
|
697 |
+
$internationalWrapper->appendChild($internationalProduct);
|
698 |
+
|
699 |
+
if($options->hasChildNodes()){
|
700 |
+
$internationalWrapper->appendChild($options);
|
701 |
+
}
|
702 |
+
|
703 |
+
$internationalWrapper->appendChild($receiver);
|
704 |
+
$internationalWrapper->appendChild($weight);
|
705 |
+
$internationalWrapper->appendChild($customsInfo);
|
706 |
+
|
707 |
+
$internationalBox->appendChild($internationalWrapper);
|
708 |
+
return $internationalBox;
|
709 |
+
}
|
710 |
+
|
711 |
+
/**
|
712 |
+
* function checks if the an option is active / valid
|
713 |
+
* and add it's if necessary
|
714 |
+
*/
|
715 |
+
protected function _checkIfOptionIsValid(DOMDocument $document, $options, $order, $carrier, $configName, $bpostValue){
|
716 |
+
$helper = Mage::helper("bpost_shm/system_config");
|
717 |
+
$storeId = $order->getStoreId();
|
718 |
+
$option = $helper->getBpostCarriersConfig($configName, $carrier, $storeId);
|
719 |
+
$deliveryDate = $order->getBpostDeliveryDate();
|
720 |
+
$dateModel = Mage::getSingleton('core/date');
|
721 |
+
|
722 |
+
if($dateModel->date('N', strtotime($deliveryDate)) != 6 &&
|
723 |
+
$bpostValue == "saturdayDelivery" &&
|
724 |
+
Mage::helper("bpost_shm/system_config")->getBpostShippingConfig("display_delivery_date",$storeId)){
|
725 |
+
return $options;
|
726 |
+
}
|
727 |
+
|
728 |
+
if($option){
|
729 |
+
$optionFrom = $helper->getBpostCarriersConfig($configName."_from", $carrier, $storeId);
|
730 |
+
$addOption = false;
|
731 |
+
|
732 |
+
if($optionFrom && $optionFrom > 0){
|
733 |
+
if($order->getGrandTotal() >= $optionFrom){
|
734 |
+
$addOption = true;
|
735 |
+
}
|
736 |
+
}else{
|
737 |
+
$addOption = true;
|
738 |
+
}
|
739 |
+
|
740 |
+
if($addOption){
|
741 |
+
$option = $document->createElement("common:$bpostValue");
|
742 |
+
|
743 |
+
//check for insurance option
|
744 |
+
//if so, we need to add an extra child
|
745 |
+
if($bpostValue == "insured"){
|
746 |
+
$insuranceElement = $document->createElement("common:basicInsurance");
|
747 |
+
$option->appendChild($insuranceElement);
|
748 |
+
}
|
749 |
+
|
750 |
+
$options->appendChild($option);
|
751 |
+
}
|
752 |
+
}
|
753 |
+
|
754 |
+
return $options;
|
755 |
+
}
|
756 |
+
|
757 |
+
/**
|
758 |
+
* function adds a notification child element to the options element
|
759 |
+
*/
|
760 |
+
protected function _addNotificationMessageOption(DOMDocument $document, $order, $notificationType, $communicationBy = "email"){
|
761 |
+
$bpostHelper = Mage::helper("bpost_shm");
|
762 |
+
|
763 |
+
$notificationElement = $document->createElement("common:$notificationType");
|
764 |
+
$language = $bpostHelper->getLocaleByOrder($order, true);
|
765 |
+
|
766 |
+
$shippingAddress = $order->getShippingAddress();
|
767 |
+
$billingAddress = $order->getBillingAddress();
|
768 |
+
|
769 |
+
$languageAttribute = $document->createAttribute("language");
|
770 |
+
$languageAttribute->value = $language;
|
771 |
+
$notificationElement->appendChild($languageAttribute);
|
772 |
+
|
773 |
+
if($communicationBy === "email"){
|
774 |
+
$childElement = $document->createElement("common:emailAddress");
|
775 |
+
$childElement->appendChild($document->createTextNode($billingAddress->getEmail()));
|
776 |
+
}else{
|
777 |
+
$childElement = $document->createElement("common:mobilePhone");
|
778 |
+
$childElement->appendChild($document->createTextNode(preg_replace('/[^0-9]/s', '',$shippingAddress->getTelephone())));
|
779 |
+
}
|
780 |
+
|
781 |
+
$notificationElement->appendChild($childElement);
|
782 |
+
|
783 |
+
return $notificationElement;
|
784 |
+
}
|
785 |
+
}
|
app/code/community/Bpost/ShM/Model/Country.php
CHANGED
@@ -1,23 +1,23 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Created by PHPro
|
5 |
-
*
|
6 |
-
* @package Bpost
|
7 |
-
* @subpackage ShM
|
8 |
-
* @author PHPro (info@phpro.be)
|
9 |
-
*/
|
10 |
-
|
11 |
-
/**
|
12 |
-
* Class Bpost_ShM_Model_Country
|
13 |
-
*/
|
14 |
-
class Bpost_ShM_Model_Country extends Mage_Core_Model_Abstract
|
15 |
-
{
|
16 |
-
/**
|
17 |
-
* Initialise the model.
|
18 |
-
*/
|
19 |
-
protected function _construct()
|
20 |
-
{
|
21 |
-
$this->_init("bpost_shm/country");
|
22 |
-
}
|
23 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Created by PHPro
|
5 |
+
*
|
6 |
+
* @package Bpost
|
7 |
+
* @subpackage ShM
|
8 |
+
* @author PHPro (info@phpro.be)
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Class Bpost_ShM_Model_Country
|
13 |
+
*/
|
14 |
+
class Bpost_ShM_Model_Country extends Mage_Core_Model_Abstract
|
15 |
+
{
|
16 |
+
/**
|
17 |
+
* Initialise the model.
|
18 |
+
*/
|
19 |
+
protected function _construct()
|
20 |
+
{
|
21 |
+
$this->_init("bpost_shm/country");
|
22 |
+
}
|
23 |
+
}
|
app/code/community/Bpost/ShM/Model/Holidays.php
CHANGED
@@ -1,23 +1,23 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Created by PHPro
|
5 |
-
*
|
6 |
-
* @package Bpost
|
7 |
-
* @subpackage ShM
|
8 |
-
* @author PHPro (info@phpro.be)
|
9 |
-
*/
|
10 |
-
|
11 |
-
/**
|
12 |
-
* Class Bpost_ShM_Model_Holidays
|
13 |
-
*/
|
14 |
-
class Bpost_ShM_Model_Holidays extends Mage_Core_Model_Abstract
|
15 |
-
{
|
16 |
-
/**
|
17 |
-
* Initialise the model.
|
18 |
-
*/
|
19 |
-
protected function _construct()
|
20 |
-
{
|
21 |
-
$this->_init("bpost_shm/holidays");
|
22 |
-
}
|
23 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Created by PHPro
|
5 |
+
*
|
6 |
+
* @package Bpost
|
7 |
+
* @subpackage ShM
|
8 |
+
* @author PHPro (info@phpro.be)
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Class Bpost_ShM_Model_Holidays
|
13 |
+
*/
|
14 |
+
class Bpost_ShM_Model_Holidays extends Mage_Core_Model_Abstract
|
15 |
+
{
|
16 |
+
/**
|
17 |
+
* Initialise the model.
|
18 |
+
*/
|
19 |
+
protected function _construct()
|
20 |
+
{
|
21 |
+
$this->_init("bpost_shm/holidays");
|
22 |
+
}
|
23 |
+
}
|
app/code/community/Bpost/ShM/Model/Observer.php
CHANGED
@@ -1,365 +1,365 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Created by PHPro
|
5 |
-
*
|
6 |
-
* @package Bpost
|
7 |
-
* @subpackage ShM
|
8 |
-
* @author PHPro (info@phpro.be)
|
9 |
-
*/
|
10 |
-
|
11 |
-
/**
|
12 |
-
* Class Bpost_ShM_Model_Observer
|
13 |
-
*/
|
14 |
-
class Bpost_ShM_Model_Observer extends Varien_Event_Observer
|
15 |
-
{
|
16 |
-
/**
|
17 |
-
* @param $observer
|
18 |
-
* @return $this
|
19 |
-
*/
|
20 |
-
public function core_block_abstract_to_html_after($observer)
|
21 |
-
{
|
22 |
-
$checkoutSession = Mage::getSingleton('checkout/session');
|
23 |
-
$quote = $checkoutSession->getQuote();
|
24 |
-
|
25 |
-
if ($observer->getBlock() instanceof Mage_Checkout_Block_Onepage_Shipping_Method_Available) {
|
26 |
-
$availablerates = $observer->getBlock()->getShippingRates();
|
27 |
-
|
28 |
-
if (array_key_exists("bpostshm", $availablerates)) {
|
29 |
-
//get HTML
|
30 |
-
$html = $observer->getTransport()->getHtml();
|
31 |
-
|
32 |
-
//add logo to carrier
|
33 |
-
$logo = Mage::getDesign()->getSkinUrl("images/bpost/bpost_sym_RGB72_S.png");
|
34 |
-
|
35 |
-
$html = str_replace('<dt>bpost</dt>', '<dt><img src="'.$logo.'" class="bpost-carrier-logo" />bpost</dt>', $html);
|
36 |
-
//if onestepcheckout dd's are used instead of dt's
|
37 |
-
$html = str_replace('<dd>bpost</dd>', '<dd><img src="'.$logo.'" class="bpost-carrier-logo" />bpost</dd>', $html);
|
38 |
-
|
39 |
-
//intercept html and append block
|
40 |
-
if(strpos($html, 'bpost-carrier-logo')){
|
41 |
-
$html .= Mage::app()->getLayout()->createBlock("bpost_shm/carrier_bpost")->setQuote($quote)->setTemplate("bpost/shm/append_bpost_shippingmethod.phtml")->toHtml();
|
42 |
-
}
|
43 |
-
//set HTML
|
44 |
-
$observer->getTransport()->setHtml($html);
|
45 |
-
}
|
46 |
-
}
|
47 |
-
|
48 |
-
if ($observer->getBlock() instanceof Mage_Checkout_Block_Onepage_Payment_Methods) {
|
49 |
-
if (Mage::getSingleton('checkout/session')->getBpostReloadProgress()) {
|
50 |
-
$html = $observer->getTransport()->getHtml();
|
51 |
-
$html .= "<script>checkout.reloadProgressBlock('shipping');</script>";
|
52 |
-
$observer->getTransport()->setHtml($html);
|
53 |
-
Mage::getSingleton('checkout/session')->unsBpostReloadProgress();
|
54 |
-
}
|
55 |
-
}
|
56 |
-
|
57 |
-
return $this;
|
58 |
-
}
|
59 |
-
|
60 |
-
/**
|
61 |
-
* Observe shipping address and create alternative shipping address in the session. (we select only the necessary data to keep the object small)
|
62 |
-
*
|
63 |
-
* @param $observer
|
64 |
-
* @return $this
|
65 |
-
*/
|
66 |
-
public function controller_action_postdispatch_checkout_onepage_saveAddress($observer)
|
67 |
-
{
|
68 |
-
$checkoutSession = Mage::getSingleton('checkout/session');
|
69 |
-
$shippingAddress = $checkoutSession->getQuote()->getShippingAddress();
|
70 |
-
if (((bool)$shippingAddress->getSameAsBilling() &&
|
71 |
-
strtolower($observer->getEvent()->getName()) == "controller_action_postdispatch_checkout_onepage_savebilling") ||
|
72 |
-
strtolower($observer->getEvent()->getName()) == "controller_action_postdispatch_checkout_onepage_saveshipping") {
|
73 |
-
|
74 |
-
$originalAddress = new Varien_Object();
|
75 |
-
$street = $shippingAddress->getStreet(1);
|
76 |
-
|
77 |
-
if($shippingAddress->getStreet(2) && $shippingAddress->getStreet(2) != ""){
|
78 |
-
$street .= "\n" . $shippingAddress->getStreet(2);
|
79 |
-
}
|
80 |
-
|
81 |
-
$originalAddress
|
82 |
-
->setFirstname($shippingAddress->getFirstname())
|
83 |
-
->setLastname($shippingAddress->getLastname())
|
84 |
-
->setCompany($shippingAddress->getCompany())
|
85 |
-
->setStreet($street)
|
86 |
-
->setCity($shippingAddress->getCity())
|
87 |
-
->setRegion($shippingAddress->getRegion())
|
88 |
-
->setPostcode($shippingAddress->getPostcode())
|
89 |
-
->setCountryId($shippingAddress->getCountryId())
|
90 |
-
->setTelephone($shippingAddress->getTelephone())
|
91 |
-
->setFax($shippingAddress->getFax());
|
92 |
-
|
93 |
-
if($shippingAddress->getAddressId() != "" && $shippingAddress->hasAddressId()){
|
94 |
-
$originalAddress->setAddressId($shippingAddress->getAddressId());
|
95 |
-
}
|
96 |
-
|
97 |
-
$checkoutSession->setBpostOriginalShippingAddress($originalAddress);
|
98 |
-
}
|
99 |
-
return $this;
|
100 |
-
}
|
101 |
-
|
102 |
-
/**
|
103 |
-
* Reset saturday delivery option so rate calculation doesn't show saturday incl. shipping rates
|
104 |
-
*
|
105 |
-
* @return $this
|
106 |
-
*/
|
107 |
-
public function controller_action_predispatch_checkout_onepage_saveAddress()
|
108 |
-
{
|
109 |
-
$checkoutSession = Mage::getSingleton('checkout/session');
|
110 |
-
//always reset the saturday delivery option so we don't see multiplied rates
|
111 |
-
$checkoutSession->getQuote()->setBpostDisableSaturdayDelivery(true);
|
112 |
-
|
113 |
-
return $this;
|
114 |
-
}
|
115 |
-
|
116 |
-
/**
|
117 |
-
* Change shipping address if needed, save previous shipping method, add progress bar reload flag.
|
118 |
-
*
|
119 |
-
* @return $this
|
120 |
-
*/
|
121 |
-
public function checkout_controller_onepage_save_shipping_method()
|
122 |
-
{
|
123 |
-
//init all necessary data
|
124 |
-
$checkoutSession = Mage::getSingleton('checkout/session');
|
125 |
-
$quote = $checkoutSession->getQuote();
|
126 |
-
$address = $quote->getShippingAddress();
|
127 |
-
|
128 |
-
//get the bpost data
|
129 |
-
$params = Mage::app()->getRequest()->getPost();
|
130 |
-
|
131 |
-
//add notifications to quote
|
132 |
-
if($address->getShippingMethod() == "bpostshm_bpost_pickuppoint" ||
|
133 |
-
$address->getShippingMethod() == "bpostshm_bpost_clickcollect"){
|
134 |
-
if(isset($params["notification"])){
|
135 |
-
if($params["notification"] == "email"){
|
136 |
-
$quote->setBpostNotificationEmail($address->getEmail());
|
137 |
-
$quote->setBpostNotificationSms("");
|
138 |
-
|
139 |
-
}else{
|
140 |
-
$quote->setBpostNotificationSms($address->getTelephone());
|
141 |
-
$quote->setBpostNotificationEmail("");
|
142 |
-
}
|
143 |
-
}
|
144 |
-
}elseif($address->getShippingMethod() == "bpostshm_bpost_parcellocker"){
|
145 |
-
if(isset($params["parcel-notification"])){
|
146 |
-
$quote->setBpostNotificationSms($address->getTelephone());
|
147 |
-
}else{
|
148 |
-
$quote->setBpostNotificationSms("");
|
149 |
-
$quote->setBpostNotificationEmail("");
|
150 |
-
}
|
151 |
-
|
152 |
-
//check for reduced mobility
|
153 |
-
if(isset($params["reduced-mobility"])){
|
154 |
-
$quote->setBpostReducedMobility(true);
|
155 |
-
}else{
|
156 |
-
$quote->setBpostReducedMobility(false);
|
157 |
-
}
|
158 |
-
}
|
159 |
-
|
160 |
-
//set the delivery date in the quote
|
161 |
-
if(isset($params["bpost"]["deliverydate"])) {
|
162 |
-
if($address->getShippingMethod() != "bpostshm_bpost_international" && $params["bpost"]["deliverydate"] != ""){
|
163 |
-
$bpostHelper = Mage::helper("bpost_shm");
|
164 |
-
|
165 |
-
$deliveryDate = $params["bpost"]["deliverydate"];
|
166 |
-
$dropdate = $bpostHelper->getPrevDeliveryDate($deliveryDate);
|
167 |
-
|
168 |
-
$quote->setBpostDropDate($dropdate);
|
169 |
-
$quote->setBpostDeliveryDate($deliveryDate);
|
170 |
-
}
|
171 |
-
}
|
172 |
-
|
173 |
-
//if all necessary fields are filled in.
|
174 |
-
$validShippingMethods = array("bpostshm_bpost_pickuppoint", "bpostshm_bpost_parcellocker", "bpostshm_bpost_clickcollect");
|
175 |
-
|
176 |
-
if (in_array($address->getShippingMethod(), $validShippingMethods) && $params["bpost"]["id"] && $params["bpost"]["name"] && $params["bpost"]["street"]
|
177 |
-
&& $params["bpost"]["city"] && $params["bpost"]["postcode"]
|
178 |
-
) {
|
179 |
-
//set it in the quote
|
180 |
-
$quote->setBpostPickuplocationId($params["bpost"]["id"]);
|
181 |
-
|
182 |
-
if($address->getShippingMethod() == "bpostshm_bpost_pickuppoint") {
|
183 |
-
$firstname = "bpost pick-up point: ";
|
184 |
-
} elseif($address->getShippingMethod() == "bpostshm_bpost_parcellocker") {
|
185 |
-
$firstname = "bpost parcel locker: ";
|
186 |
-
} elseif($address->getShippingMethod() == "bpostshm_bpost_clickcollect") {
|
187 |
-
$firstname = "bpost Click & Collect point: ";
|
188 |
-
}
|
189 |
-
|
190 |
-
//now set the current address to the bpost-spot
|
191 |
-
$address->unsetAddressId()
|
192 |
-
->setSaveInAddressBook(0)
|
193 |
-
->setFirstname($firstname)
|
194 |
-
->setLastname($params["bpost"]["name"])
|
195 |
-
->setStreet($params["bpost"]["street"])
|
196 |
-
->setCity($params["bpost"]["city"])
|
197 |
-
->setPostcode($params["bpost"]["postcode"])
|
198 |
-
->save();
|
199 |
-
} else {
|
200 |
-
//revert to original shipping address if no pickup point or parcel locker is chosen
|
201 |
-
if($checkoutSession->hasBpostOriginalShippingAddress()) {
|
202 |
-
$originalAddress = $checkoutSession->getBpostOriginalShippingAddress();
|
203 |
-
$address->unsetAddressId()
|
204 |
-
->setSaveInAddressBook(0)
|
205 |
-
->setFirstname($originalAddress->getFirstname())
|
206 |
-
->setLastname($originalAddress->getLastname())
|
207 |
-
->setStreet($originalAddress->getStreet())
|
208 |
-
->setCity($originalAddress->getCity())
|
209 |
-
->setPostcode($originalAddress->getPostcode())
|
210 |
-
->save();
|
211 |
-
}
|
212 |
-
}
|
213 |
-
|
214 |
-
|
215 |
-
//set saturday delivery option flag so shipping prices incl. saturday delivery are calculated
|
216 |
-
$dateModel = Mage::getSingleton('core/date');
|
217 |
-
if(isset($params['bpost']['deliverydate']) && ($dateModel->date('N', strtotime($params['bpost']['deliverydate'])) == 6)){
|
218 |
-
$quote->setData("bpost_disable_saturday_delivery", false);
|
219 |
-
}elseif(isset($params['bpost']['deliverydate']) && !($dateModel->date('N', strtotime($params['bpost']['deliverydate'])) == 6)){
|
220 |
-
$quote->setData("bpost_disable_saturday_delivery", true);
|
221 |
-
}
|
222 |
-
elseif(isset($params['bpost_saturday_delivery']) && !$params['bpost_saturday_delivery']) {
|
223 |
-
$quote->setData("bpost_disable_saturday_delivery", false);
|
224 |
-
} elseif(isset($params['bpost_saturday_delivery']) && $params['bpost_saturday_delivery']) {
|
225 |
-
$quote->setData("bpost_disable_saturday_delivery", true);
|
226 |
-
}
|
227 |
-
|
228 |
-
//re-collect our rates
|
229 |
-
$address->setCollectShippingRates(true);
|
230 |
-
|
231 |
-
//add a flag for progress reload
|
232 |
-
$checkoutSession->setBpostReloadProgress(true);
|
233 |
-
|
234 |
-
//set this so we know what the previous method was.
|
235 |
-
$checkoutSession->setAlternativeShippingMethod($address->getShippingMethod());
|
236 |
-
|
237 |
-
return $this;
|
238 |
-
}
|
239 |
-
|
240 |
-
/**
|
241 |
-
* @param $observer
|
242 |
-
* @return $this
|
243 |
-
*/
|
244 |
-
public function checkout_submit_all_after($observer)
|
245 |
-
{
|
246 |
-
$checkoutSession = Mage::getSingleton('checkout/session');
|
247 |
-
$quote = $checkoutSession->getQuote();
|
248 |
-
|
249 |
-
if (strpos($quote->getShippingAddress()->getShippingMethod(), "bpostshm_bpost") !== false) {
|
250 |
-
$order = $observer->getEvent()->getOrder();
|
251 |
-
|
252 |
-
$configHelper = Mage::helper("bpost_shm/system_config");
|
253 |
-
|
254 |
-
$displayDeliveryDates = $configHelper->getBpostShippingConfig("display_delivery_date", Mage::app()->getStore()->getId());
|
255 |
-
$order->setBpostPickuplocationId($quote->getBpostPickuplocationId());
|
256 |
-
|
257 |
-
if ($displayDeliveryDates) {
|
258 |
-
$order->setBpostDisableSaturdayDelivery($quote->getBpostDisableSaturdayDelivery());
|
259 |
-
}
|
260 |
-
|
261 |
-
//function checks if manage labels with Magento is disabled
|
262 |
-
//if so, we need to call the create order api function
|
263 |
-
$manageLabels = $configHelper->getBpostShippingConfig("manage_labels_with_magento");
|
264 |
-
|
265 |
-
if (!$manageLabels) {
|
266 |
-
$apiModel = Mage::getModel("bpost_shm/api");
|
267 |
-
$apiModel->initialize($order->getStoreId());
|
268 |
-
$apiModel->createOrder($order);
|
269 |
-
$order->setBpostReference($order->getIncrementId());
|
270 |
-
}
|
271 |
-
$order->save();
|
272 |
-
}
|
273 |
-
|
274 |
-
return $this;
|
275 |
-
}
|
276 |
-
|
277 |
-
|
278 |
-
/**
|
279 |
-
* function sets default data on our quote
|
280 |
-
* we need to do this for the onestepcheckout
|
281 |
-
*
|
282 |
-
* @param $observer
|
283 |
-
* @return $this
|
284 |
-
*/
|
285 |
-
public function sales_quote_collect_totals_before($observer)
|
286 |
-
{
|
287 |
-
$checkoutSession = Mage::getSingleton('checkout/session');
|
288 |
-
$quote = $observer->getEvent()->getQuote();
|
289 |
-
|
290 |
-
$params = Mage::app()->getRequest()->getParams();
|
291 |
-
$originalRatePrices = $checkoutSession->getOriginalRatePrices();
|
292 |
-
|
293 |
-
if(isset($params["shipping_method"]) && $originalRatePrices){
|
294 |
-
$bpostConfigHelper = Mage::helper("bpost_shm/system_config");
|
295 |
-
$bpostHelper = Mage::helper("bpost_shm");
|
296 |
-
$shippingMethod = str_replace('bpostshm_', '', $params["shipping_method"]);
|
297 |
-
|
298 |
-
foreach($quote->getShippingAddress()->getShippingRatesCollection() as $_rate){
|
299 |
-
if($_rate->getCode() == $params["shipping_method"] && isset($originalRatePrices[$params["shipping_method"]])){
|
300 |
-
$saturdayDeliveryCost = $bpostHelper->formatSaturdayDeliveryCost($bpostConfigHelper->getBpostShippingConfig("saturday_delivery_cost", Mage::app()->getStore()->getId()));
|
301 |
-
|
302 |
-
if(isset($params["disable_saturday_delivery"]) && $params["disable_saturday_delivery"] == 1 && Mage::helper("bpost_shm/system_config")->getBpostShippingConfig("display_delivery_date", Mage::app()->getStore()->getId())){
|
303 |
-
//check if the option saturday delivery is active for the current shipping method
|
304 |
-
if($bpostConfigHelper->getBpostCarriersConfig("saturday_delivery", $shippingMethod, Mage::app()->getStore()->getId())){
|
305 |
-
//remove extra cost
|
306 |
-
$_rate->setPrice($originalRatePrices[$params["shipping_method"]]);
|
307 |
-
$_rate->setSaturdayDelivery(0);
|
308 |
-
$quote->setBpostDisableSaturdayDelivery(true);
|
309 |
-
}
|
310 |
-
|
311 |
-
}elseif(isset($params["disable_saturday_delivery"]) && $params["disable_saturday_delivery"] == 0 && Mage::helper("bpost_shm/system_config")->getBpostShippingConfig("display_delivery_date", Mage::app()->getStore()->getId())){
|
312 |
-
//add extra cost
|
313 |
-
if($bpostConfigHelper->getBpostCarriersConfig("saturday_delivery", $shippingMethod, Mage::app()->getStore()->getId())){
|
314 |
-
$_rate->setPrice($originalRatePrices[$params["shipping_method"]]+$saturdayDeliveryCost);
|
315 |
-
$_rate->setSaturdayDelivery(1);
|
316 |
-
//make sure the original prices are applied
|
317 |
-
$quote->setBpostDisableSaturdayDelivery(false);
|
318 |
-
}
|
319 |
-
}
|
320 |
-
}
|
321 |
-
}
|
322 |
-
|
323 |
-
$quote->getShippingAddress()->setCollectShippingrates(true)->save();
|
324 |
-
}
|
325 |
-
|
326 |
-
|
327 |
-
if(Mage::getStoreConfig('onestepcheckout/general/rewrite_checkout_links', $quote->getStore())) {
|
328 |
-
if (Mage::getSingleton('customer/session')->isLoggedIn() && (!$quote->getBpostNotificationSms() || !$quote->getBpostNotificationEmail())) {
|
329 |
-
$customer = $quote->getCustomer();
|
330 |
-
|
331 |
-
if(!$quote->getBpostNotificationEmail()){
|
332 |
-
$email = $customer->getEmail();
|
333 |
-
$quote->getShippingAddress()->setEmail($email);
|
334 |
-
}
|
335 |
-
|
336 |
-
if(!$quote->getBpostNotificationSms()){
|
337 |
-
$primaryShipping = $customer->getPrimaryShippingAddress();
|
338 |
-
if(is_object($primaryShipping)){
|
339 |
-
$telephone = $primaryShipping->getTelephone();
|
340 |
-
$quote->getShippingAddress()->setTelephone($telephone);
|
341 |
-
}
|
342 |
-
}
|
343 |
-
}
|
344 |
-
}
|
345 |
-
|
346 |
-
return $this;
|
347 |
-
}
|
348 |
-
|
349 |
-
|
350 |
-
public function controller_action_predispatch_onestepcheckout_index_index(){
|
351 |
-
$checkoutSession = Mage::getSingleton('checkout/session');
|
352 |
-
$quote = $checkoutSession->getQuote();
|
353 |
-
$shippingMethod = str_replace("bpostshm_", "",$quote->getShippingAddress()->getShippingMethod());
|
354 |
-
$configHelper = Mage::helper("bpost_shm/system_config");
|
355 |
-
if(!$shippingMethod){
|
356 |
-
Mage::getSingleton('checkout/session')->getQuote()->setData("bpost_disable_saturday_delivery", true);
|
357 |
-
}elseif($configHelper->getBpostShippingConfig("choose_delivery_date", Mage::app()->getStore()->getId())){
|
358 |
-
Mage::getSingleton('checkout/session')->getQuote()->setData("bpost_disable_saturday_delivery", true);
|
359 |
-
}
|
360 |
-
else{
|
361 |
-
$dates = Mage::helper('bpost_shm')->getBpostShippingDates();
|
362 |
-
Mage::getSingleton('checkout/session')->getQuote()->setData("bpost_disable_saturday_delivery", !(bool)$dates[$shippingMethod]["is_saturday"]);
|
363 |
-
}
|
364 |
-
}
|
365 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Created by PHPro
|
5 |
+
*
|
6 |
+
* @package Bpost
|
7 |
+
* @subpackage ShM
|
8 |
+
* @author PHPro (info@phpro.be)
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Class Bpost_ShM_Model_Observer
|
13 |
+
*/
|
14 |
+
class Bpost_ShM_Model_Observer extends Varien_Event_Observer
|
15 |
+
{
|
16 |
+
/**
|
17 |
+
* @param $observer
|
18 |
+
* @return $this
|
19 |
+
*/
|
20 |
+
public function core_block_abstract_to_html_after($observer)
|
21 |
+
{
|
22 |
+
$checkoutSession = Mage::getSingleton('checkout/session');
|
23 |
+
$quote = $checkoutSession->getQuote();
|
24 |
+
|
25 |
+
if ($observer->getBlock() instanceof Mage_Checkout_Block_Onepage_Shipping_Method_Available) {
|
26 |
+
$availablerates = $observer->getBlock()->getShippingRates();
|
27 |
+
|
28 |
+
if (array_key_exists("bpostshm", $availablerates)) {
|
29 |
+
//get HTML
|
30 |
+
$html = $observer->getTransport()->getHtml();
|
31 |
+
|
32 |
+
//add logo to carrier
|
33 |
+
$logo = Mage::getDesign()->getSkinUrl("images/bpost/bpost_sym_RGB72_S.png");
|
34 |
+
|
35 |
+
$html = str_replace('<dt>bpost</dt>', '<dt><img src="'.$logo.'" class="bpost-carrier-logo" />bpost</dt>', $html);
|
36 |
+
//if onestepcheckout dd's are used instead of dt's
|
37 |
+
$html = str_replace('<dd>bpost</dd>', '<dd><img src="'.$logo.'" class="bpost-carrier-logo" />bpost</dd>', $html);
|
38 |
+
|
39 |
+
//intercept html and append block
|
40 |
+
if(strpos($html, 'bpost-carrier-logo')){
|
41 |
+
$html .= Mage::app()->getLayout()->createBlock("bpost_shm/carrier_bpost")->setQuote($quote)->setTemplate("bpost/shm/append_bpost_shippingmethod.phtml")->toHtml();
|
42 |
+
}
|
43 |
+
//set HTML
|
44 |
+
$observer->getTransport()->setHtml($html);
|
45 |
+
}
|
46 |
+
}
|
47 |
+
|
48 |
+
if ($observer->getBlock() instanceof Mage_Checkout_Block_Onepage_Payment_Methods) {
|
49 |
+
if (Mage::getSingleton('checkout/session')->getBpostReloadProgress()) {
|
50 |
+
$html = $observer->getTransport()->getHtml();
|
51 |
+
$html .= "<script>checkout.reloadProgressBlock('shipping');</script>";
|
52 |
+
$observer->getTransport()->setHtml($html);
|
53 |
+
Mage::getSingleton('checkout/session')->unsBpostReloadProgress();
|
54 |
+
}
|
55 |
+
}
|
56 |
+
|
57 |
+
return $this;
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Observe shipping address and create alternative shipping address in the session. (we select only the necessary data to keep the object small)
|
62 |
+
*
|
63 |
+
* @param $observer
|
64 |
+
* @return $this
|
65 |
+
*/
|
66 |
+
public function controller_action_postdispatch_checkout_onepage_saveAddress($observer)
|
67 |
+
{
|
68 |
+
$checkoutSession = Mage::getSingleton('checkout/session');
|
69 |
+
$shippingAddress = $checkoutSession->getQuote()->getShippingAddress();
|
70 |
+
if (((bool)$shippingAddress->getSameAsBilling() &&
|
71 |
+
strtolower($observer->getEvent()->getName()) == "controller_action_postdispatch_checkout_onepage_savebilling") ||
|
72 |
+
strtolower($observer->getEvent()->getName()) == "controller_action_postdispatch_checkout_onepage_saveshipping") {
|
73 |
+
|
74 |
+
$originalAddress = new Varien_Object();
|
75 |
+
$street = $shippingAddress->getStreet(1);
|
76 |
+
|
77 |
+
if($shippingAddress->getStreet(2) && $shippingAddress->getStreet(2) != ""){
|
78 |
+
$street .= "\n" . $shippingAddress->getStreet(2);
|
79 |
+
}
|
80 |
+
|
81 |
+
$originalAddress
|
82 |
+
->setFirstname($shippingAddress->getFirstname())
|
83 |
+
->setLastname($shippingAddress->getLastname())
|
84 |
+
->setCompany($shippingAddress->getCompany())
|
85 |
+
->setStreet($street)
|
86 |
+
->setCity($shippingAddress->getCity())
|
87 |
+
->setRegion($shippingAddress->getRegion())
|
88 |
+
->setPostcode($shippingAddress->getPostcode())
|
89 |
+
->setCountryId($shippingAddress->getCountryId())
|
90 |
+
->setTelephone($shippingAddress->getTelephone())
|
91 |
+
->setFax($shippingAddress->getFax());
|
92 |
+
|
93 |
+
if($shippingAddress->getAddressId() != "" && $shippingAddress->hasAddressId()){
|
94 |
+
$originalAddress->setAddressId($shippingAddress->getAddressId());
|
95 |
+
}
|
96 |
+
|
97 |
+
$checkoutSession->setBpostOriginalShippingAddress($originalAddress);
|
98 |
+
}
|
99 |
+
return $this;
|
100 |
+
}
|
101 |
+
|
102 |
+
/**
|
103 |
+
* Reset saturday delivery option so rate calculation doesn't show saturday incl. shipping rates
|
104 |
+
*
|
105 |
+
* @return $this
|
106 |
+
*/
|
107 |
+
public function controller_action_predispatch_checkout_onepage_saveAddress()
|
108 |
+
{
|
109 |
+
$checkoutSession = Mage::getSingleton('checkout/session');
|
110 |
+
//always reset the saturday delivery option so we don't see multiplied rates
|
111 |
+
$checkoutSession->getQuote()->setBpostDisableSaturdayDelivery(true);
|
112 |
+
|
113 |
+
return $this;
|
114 |
+
}
|
115 |
+
|
116 |
+
/**
|
117 |
+
* Change shipping address if needed, save previous shipping method, add progress bar reload flag.
|
118 |
+
*
|
119 |
+
* @return $this
|
120 |
+
*/
|
121 |
+
public function checkout_controller_onepage_save_shipping_method()
|
122 |
+
{
|
123 |
+
//init all necessary data
|
124 |
+
$checkoutSession = Mage::getSingleton('checkout/session');
|
125 |
+
$quote = $checkoutSession->getQuote();
|
126 |
+
$address = $quote->getShippingAddress();
|
127 |
+
|
128 |
+
//get the bpost data
|
129 |
+
$params = Mage::app()->getRequest()->getPost();
|
130 |
+
|
131 |
+
//add notifications to quote
|
132 |
+
if($address->getShippingMethod() == "bpostshm_bpost_pickuppoint" ||
|
133 |
+
$address->getShippingMethod() == "bpostshm_bpost_clickcollect"){
|
134 |
+
if(isset($params["notification"])){
|
135 |
+
if($params["notification"] == "email"){
|
136 |
+
$quote->setBpostNotificationEmail($address->getEmail());
|
137 |
+
$quote->setBpostNotificationSms("");
|
138 |
+
|
139 |
+
}else{
|
140 |
+
$quote->setBpostNotificationSms($address->getTelephone());
|
141 |
+
$quote->setBpostNotificationEmail("");
|
142 |
+
}
|
143 |
+
}
|
144 |
+
}elseif($address->getShippingMethod() == "bpostshm_bpost_parcellocker"){
|
145 |
+
if(isset($params["parcel-notification"])){
|
146 |
+
$quote->setBpostNotificationSms($address->getTelephone());
|
147 |
+
}else{
|
148 |
+
$quote->setBpostNotificationSms("");
|
149 |
+
$quote->setBpostNotificationEmail("");
|
150 |
+
}
|
151 |
+
|
152 |
+
//check for reduced mobility
|
153 |
+
if(isset($params["reduced-mobility"])){
|
154 |
+
$quote->setBpostReducedMobility(true);
|
155 |
+
}else{
|
156 |
+
$quote->setBpostReducedMobility(false);
|
157 |
+
}
|
158 |
+
}
|
159 |
+
|
160 |
+
//set the delivery date in the quote
|
161 |
+
if(isset($params["bpost"]["deliverydate"])) {
|
162 |
+
if($address->getShippingMethod() != "bpostshm_bpost_international" && $params["bpost"]["deliverydate"] != ""){
|
163 |
+
$bpostHelper = Mage::helper("bpost_shm");
|
164 |
+
|
165 |
+
$deliveryDate = $params["bpost"]["deliverydate"];
|
166 |
+
$dropdate = $bpostHelper->getPrevDeliveryDate($deliveryDate);
|
167 |
+
|
168 |
+
$quote->setBpostDropDate($dropdate);
|
169 |
+
$quote->setBpostDeliveryDate($deliveryDate);
|
170 |
+
}
|
171 |
+
}
|
172 |
+
|
173 |
+
//if all necessary fields are filled in.
|
174 |
+
$validShippingMethods = array("bpostshm_bpost_pickuppoint", "bpostshm_bpost_parcellocker", "bpostshm_bpost_clickcollect");
|
175 |
+
|
176 |
+
if (in_array($address->getShippingMethod(), $validShippingMethods) && $params["bpost"]["id"] && $params["bpost"]["name"] && $params["bpost"]["street"]
|
177 |
+
&& $params["bpost"]["city"] && $params["bpost"]["postcode"]
|
178 |
+
) {
|
179 |
+
//set it in the quote
|
180 |
+
$quote->setBpostPickuplocationId($params["bpost"]["id"]);
|
181 |
+
|
182 |
+
if($address->getShippingMethod() == "bpostshm_bpost_pickuppoint") {
|
183 |
+
$firstname = "bpost pick-up point: ";
|
184 |
+
} elseif($address->getShippingMethod() == "bpostshm_bpost_parcellocker") {
|
185 |
+
$firstname = "bpost parcel locker: ";
|
186 |
+
} elseif($address->getShippingMethod() == "bpostshm_bpost_clickcollect") {
|
187 |
+
$firstname = "bpost Click & Collect point: ";
|
188 |
+
}
|
189 |
+
|
190 |
+
//now set the current address to the bpost-spot
|
191 |
+
$address->unsetAddressId()
|
192 |
+
->setSaveInAddressBook(0)
|
193 |
+
->setFirstname($firstname)
|
194 |
+
->setLastname($params["bpost"]["name"])
|
195 |
+
->setStreet($params["bpost"]["street"])
|
196 |
+
->setCity($params["bpost"]["city"])
|
197 |
+
->setPostcode($params["bpost"]["postcode"])
|
198 |
+
->save();
|
199 |
+
} else {
|
200 |
+
//revert to original shipping address if no pickup point or parcel locker is chosen
|
201 |
+
if($checkoutSession->hasBpostOriginalShippingAddress()) {
|
202 |
+
$originalAddress = $checkoutSession->getBpostOriginalShippingAddress();
|
203 |
+
$address->unsetAddressId()
|
204 |
+
->setSaveInAddressBook(0)
|
205 |
+
->setFirstname($originalAddress->getFirstname())
|
206 |
+
->setLastname($originalAddress->getLastname())
|
207 |
+
->setStreet($originalAddress->getStreet())
|
208 |
+
->setCity($originalAddress->getCity())
|
209 |
+
->setPostcode($originalAddress->getPostcode())
|
210 |
+
->save();
|
211 |
+
}
|
212 |
+
}
|
213 |
+
|
214 |
+
|
215 |
+
//set saturday delivery option flag so shipping prices incl. saturday delivery are calculated
|
216 |
+
$dateModel = Mage::getSingleton('core/date');
|
217 |
+
if(isset($params['bpost']['deliverydate']) && ($dateModel->date('N', strtotime($params['bpost']['deliverydate'])) == 6)){
|
218 |
+
$quote->setData("bpost_disable_saturday_delivery", false);
|
219 |
+
}elseif(isset($params['bpost']['deliverydate']) && !($dateModel->date('N', strtotime($params['bpost']['deliverydate'])) == 6)){
|
220 |
+
$quote->setData("bpost_disable_saturday_delivery", true);
|
221 |
+
}
|
222 |
+
elseif(isset($params['bpost_saturday_delivery']) && !$params['bpost_saturday_delivery']) {
|
223 |
+
$quote->setData("bpost_disable_saturday_delivery", false);
|
224 |
+
} elseif(isset($params['bpost_saturday_delivery']) && $params['bpost_saturday_delivery']) {
|
225 |
+
$quote->setData("bpost_disable_saturday_delivery", true);
|
226 |
+
}
|
227 |
+
|
228 |
+
//re-collect our rates
|
229 |
+
$address->setCollectShippingRates(true);
|
230 |
+
|
231 |
+
//add a flag for progress reload
|
232 |
+
$checkoutSession->setBpostReloadProgress(true);
|
233 |
+
|
234 |
+
//set this so we know what the previous method was.
|
235 |
+
$checkoutSession->setAlternativeShippingMethod($address->getShippingMethod());
|
236 |
+
|
237 |
+
return $this;
|
238 |
+
}
|
239 |
+
|
240 |
+
/**
|
241 |
+
* @param $observer
|
242 |
+
* @return $this
|
243 |
+
*/
|
244 |
+
public function checkout_submit_all_after($observer)
|
245 |
+
{
|
246 |
+
$checkoutSession = Mage::getSingleton('checkout/session');
|
247 |
+
$quote = $checkoutSession->getQuote();
|
248 |
+
|
249 |
+
if (strpos($quote->getShippingAddress()->getShippingMethod(), "bpostshm_bpost") !== false) {
|
250 |
+
$order = $observer->getEvent()->getOrder();
|
251 |
+
|
252 |
+
$configHelper = Mage::helper("bpost_shm/system_config");
|
253 |
+
|
254 |
+
$displayDeliveryDates = $configHelper->getBpostShippingConfig("display_delivery_date", Mage::app()->getStore()->getId());
|
255 |
+
$order->setBpostPickuplocationId($quote->getBpostPickuplocationId());
|
256 |
+
|
257 |
+
if ($displayDeliveryDates) {
|
258 |
+
$order->setBpostDisableSaturdayDelivery($quote->getBpostDisableSaturdayDelivery());
|
259 |
+
}
|
260 |
+
|
261 |
+
//function checks if manage labels with Magento is disabled
|
262 |
+
//if so, we need to call the create order api function
|
263 |
+
$manageLabels = $configHelper->getBpostShippingConfig("manage_labels_with_magento");
|
264 |
+
|
265 |
+
if (!$manageLabels) {
|
266 |
+
$apiModel = Mage::getModel("bpost_shm/api");
|
267 |
+
$apiModel->initialize($order->getStoreId());
|
268 |
+
$apiModel->createOrder($order);
|
269 |
+
$order->setBpostReference($order->getIncrementId());
|
270 |
+
}
|
271 |
+
$order->save();
|
272 |
+
}
|
273 |
+
|
274 |
+
return $this;
|
275 |
+
}
|
276 |
+
|
277 |
+
|
278 |
+
/**
|
279 |
+
* function sets default data on our quote
|
280 |
+
* we need to do this for the onestepcheckout
|
281 |
+
*
|
282 |
+
* @param $observer
|
283 |
+
* @return $this
|
284 |
+
*/
|
285 |
+
public function sales_quote_collect_totals_before($observer)
|
286 |
+
{
|
287 |
+
$checkoutSession = Mage::getSingleton('checkout/session');
|
288 |
+
$quote = $observer->getEvent()->getQuote();
|
289 |
+
|
290 |
+
$params = Mage::app()->getRequest()->getParams();
|
291 |
+
$originalRatePrices = $checkoutSession->getOriginalRatePrices();
|
292 |
+
|
293 |
+
if(isset($params["shipping_method"]) && $originalRatePrices){
|
294 |
+
$bpostConfigHelper = Mage::helper("bpost_shm/system_config");
|
295 |
+
$bpostHelper = Mage::helper("bpost_shm");
|
296 |
+
$shippingMethod = str_replace('bpostshm_', '', $params["shipping_method"]);
|
297 |
+
|
298 |
+
foreach($quote->getShippingAddress()->getShippingRatesCollection() as $_rate){
|
299 |
+
if($_rate->getCode() == $params["shipping_method"] && isset($originalRatePrices[$params["shipping_method"]])){
|
300 |
+
$saturdayDeliveryCost = $bpostHelper->formatSaturdayDeliveryCost($bpostConfigHelper->getBpostShippingConfig("saturday_delivery_cost", Mage::app()->getStore()->getId()));
|
301 |
+
|
302 |
+
if(isset($params["disable_saturday_delivery"]) && $params["disable_saturday_delivery"] == 1 && Mage::helper("bpost_shm/system_config")->getBpostShippingConfig("display_delivery_date", Mage::app()->getStore()->getId())){
|
303 |
+
//check if the option saturday delivery is active for the current shipping method
|
304 |
+
if($bpostConfigHelper->getBpostCarriersConfig("saturday_delivery", $shippingMethod, Mage::app()->getStore()->getId())){
|
305 |
+
//remove extra cost
|
306 |
+
$_rate->setPrice($originalRatePrices[$params["shipping_method"]]);
|
307 |
+
$_rate->setSaturdayDelivery(0);
|
308 |
+
$quote->setBpostDisableSaturdayDelivery(true);
|
309 |
+
}
|
310 |
+
|
311 |
+
}elseif(isset($params["disable_saturday_delivery"]) && $params["disable_saturday_delivery"] == 0 && Mage::helper("bpost_shm/system_config")->getBpostShippingConfig("display_delivery_date", Mage::app()->getStore()->getId())){
|
312 |
+
//add extra cost
|
313 |
+
if($bpostConfigHelper->getBpostCarriersConfig("saturday_delivery", $shippingMethod, Mage::app()->getStore()->getId())){
|
314 |
+
$_rate->setPrice($originalRatePrices[$params["shipping_method"]]+$saturdayDeliveryCost);
|
315 |
+
$_rate->setSaturdayDelivery(1);
|
316 |
+
//make sure the original prices are applied
|
317 |
+
$quote->setBpostDisableSaturdayDelivery(false);
|
318 |
+
}
|
319 |
+
}
|
320 |
+
}
|
321 |
+
}
|
322 |
+
|
323 |
+
$quote->getShippingAddress()->setCollectShippingrates(true)->save();
|
324 |
+
}
|
325 |
+
|
326 |
+
|
327 |
+
if(Mage::getStoreConfig('onestepcheckout/general/rewrite_checkout_links', $quote->getStore())) {
|
328 |
+
if (Mage::getSingleton('customer/session')->isLoggedIn() && (!$quote->getBpostNotificationSms() || !$quote->getBpostNotificationEmail())) {
|
329 |
+
$customer = $quote->getCustomer();
|
330 |
+
|
331 |
+
if(!$quote->getBpostNotificationEmail()){
|
332 |
+
$email = $customer->getEmail();
|
333 |
+
$quote->getShippingAddress()->setEmail($email);
|
334 |
+
}
|
335 |
+
|
336 |
+
if(!$quote->getBpostNotificationSms()){
|
337 |
+
$primaryShipping = $customer->getPrimaryShippingAddress();
|
338 |
+
if(is_object($primaryShipping)){
|
339 |
+
$telephone = $primaryShipping->getTelephone();
|
340 |
+
$quote->getShippingAddress()->setTelephone($telephone);
|
341 |
+
}
|
342 |
+
}
|
343 |
+
}
|
344 |
+
}
|
345 |
+
|
346 |
+
return $this;
|
347 |
+
}
|
348 |
+
|
349 |
+
|
350 |
+
public function controller_action_predispatch_onestepcheckout_index_index(){
|
351 |
+
$checkoutSession = Mage::getSingleton('checkout/session');
|
352 |
+
$quote = $checkoutSession->getQuote();
|
353 |
+
$shippingMethod = str_replace("bpostshm_", "",$quote->getShippingAddress()->getShippingMethod());
|
354 |
+
$configHelper = Mage::helper("bpost_shm/system_config");
|
355 |
+
if(!$shippingMethod){
|
356 |
+
Mage::getSingleton('checkout/session')->getQuote()->setData("bpost_disable_saturday_delivery", true);
|
357 |
+
}elseif($configHelper->getBpostShippingConfig("choose_delivery_date", Mage::app()->getStore()->getId())){
|
358 |
+
Mage::getSingleton('checkout/session')->getQuote()->setData("bpost_disable_saturday_delivery", true);
|
359 |
+
}
|
360 |
+
else{
|
361 |
+
$dates = Mage::helper('bpost_shm')->getBpostShippingDates();
|
362 |
+
Mage::getSingleton('checkout/session')->getQuote()->setData("bpost_disable_saturday_delivery", !(bool)$dates[$shippingMethod]["is_saturday"]);
|
363 |
+
}
|
364 |
+
}
|
365 |
+
}
|
app/code/community/Bpost/ShM/Model/Resource/Country.php
CHANGED
@@ -1,31 +1,31 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Created by PHPro
|
5 |
-
*
|
6 |
-
* @package Bpost
|
7 |
-
* @subpackage ShM
|
8 |
-
* @author PHPro (info@phpro.be)
|
9 |
-
*/
|
10 |
-
|
11 |
-
/**
|
12 |
-
* Class Bpost_ShM_Model_Resource_Country
|
13 |
-
*/
|
14 |
-
class Bpost_ShM_Model_Resource_Country extends Mage_Core_Model_Mysql4_Abstract
|
15 |
-
{
|
16 |
-
/**
|
17 |
-
* Sets model primary key.
|
18 |
-
*/
|
19 |
-
protected function _construct()
|
20 |
-
{
|
21 |
-
$this->_init("bpost_shm/bpost_country", "country_id");
|
22 |
-
}
|
23 |
-
|
24 |
-
/**
|
25 |
-
* we truncate our table
|
26 |
-
*/
|
27 |
-
public function truncateTable(){
|
28 |
-
$this->_getWriteAdapter()->query('TRUNCATE TABLE '.$this->getMainTable());
|
29 |
-
return $this;
|
30 |
-
}
|
31 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Created by PHPro
|
5 |
+
*
|
6 |
+
* @package Bpost
|
7 |
+
* @subpackage ShM
|
8 |
+
* @author PHPro (info@phpro.be)
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Class Bpost_ShM_Model_Resource_Country
|
13 |
+
*/
|
14 |
+
class Bpost_ShM_Model_Resource_Country extends Mage_Core_Model_Mysql4_Abstract
|
15 |
+
{
|
16 |
+
/**
|
17 |
+
* Sets model primary key.
|
18 |
+
*/
|
19 |
+
protected function _construct()
|
20 |
+
{
|
21 |
+
$this->_init("bpost_shm/bpost_country", "country_id");
|
22 |
+
}
|
23 |
+
|
24 |
+
/**
|
25 |
+
* we truncate our table
|
26 |
+
*/
|
27 |
+
public function truncateTable(){
|
28 |
+
$this->_getWriteAdapter()->query('TRUNCATE TABLE '.$this->getMainTable());
|
29 |
+
return $this;
|
30 |
+
}
|
31 |
+
}
|
app/code/community/Bpost/ShM/Model/Resource/Country/Collection.php
CHANGED
@@ -1,54 +1,54 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Created by PHPro
|
5 |
-
*
|
6 |
-
* @package Bpost
|
7 |
-
* @subpackage ShM
|
8 |
-
* @author PHPro (info@phpro.be)
|
9 |
-
*/
|
10 |
-
|
11 |
-
/**
|
12 |
-
* Class Bpost_ShM_Model_Resource_Country_Collection
|
13 |
-
*/
|
14 |
-
class Bpost_ShM_Model_Resource_Country_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
15 |
-
{
|
16 |
-
/**
|
17 |
-
* Initialises the model, the abstract file will render a collection from it.
|
18 |
-
*/
|
19 |
-
public function _construct()
|
20 |
-
{
|
21 |
-
$this->_init("bpost_shm/country");
|
22 |
-
}
|
23 |
-
|
24 |
-
|
25 |
-
/**
|
26 |
-
* Convert collection items to select options array
|
27 |
-
*
|
28 |
-
* @return array
|
29 |
-
*/
|
30 |
-
public function toOptionArray()
|
31 |
-
{
|
32 |
-
$options = $this->_toOptionArray('country_id', 'country_code');
|
33 |
-
$sort = array();
|
34 |
-
|
35 |
-
foreach ($options as $data) {
|
36 |
-
$name = Mage::app()->getLocale()->getCountryTranslation($data['label']);
|
37 |
-
if (!empty($name)) {
|
38 |
-
$sort[$name] = $data['label'];
|
39 |
-
}
|
40 |
-
}
|
41 |
-
|
42 |
-
Mage::helper('core/string')->ksortMultibyte($sort);
|
43 |
-
|
44 |
-
$options = array();
|
45 |
-
foreach ($sort as $label => $value) {
|
46 |
-
$options[] = array(
|
47 |
-
'value' => $value,
|
48 |
-
'label' => $label
|
49 |
-
);
|
50 |
-
}
|
51 |
-
|
52 |
-
return $options;
|
53 |
-
}
|
54 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Created by PHPro
|
5 |
+
*
|
6 |
+
* @package Bpost
|
7 |
+
* @subpackage ShM
|
8 |
+
* @author PHPro (info@phpro.be)
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Class Bpost_ShM_Model_Resource_Country_Collection
|
13 |
+
*/
|
14 |
+
class Bpost_ShM_Model_Resource_Country_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
15 |
+
{
|
16 |
+
/**
|
17 |
+
* Initialises the model, the abstract file will render a collection from it.
|
18 |
+
*/
|
19 |
+
public function _construct()
|
20 |
+
{
|
21 |
+
$this->_init("bpost_shm/country");
|
22 |
+
}
|
23 |
+
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Convert collection items to select options array
|
27 |
+
*
|
28 |
+
* @return array
|
29 |
+
*/
|
30 |
+
public function toOptionArray()
|
31 |
+
{
|
32 |
+
$options = $this->_toOptionArray('country_id', 'country_code');
|
33 |
+
$sort = array();
|
34 |
+
|
35 |
+
foreach ($options as $data) {
|
36 |
+
$name = Mage::app()->getLocale()->getCountryTranslation($data['label']);
|
37 |
+
if (!empty($name)) {
|
38 |
+
$sort[$name] = $data['label'];
|
39 |
+
}
|
40 |
+
}
|
41 |
+
|
42 |
+
Mage::helper('core/string')->ksortMultibyte($sort);
|
43 |
+
|
44 |
+
$options = array();
|
45 |
+
foreach ($sort as $label => $value) {
|
46 |
+
$options[] = array(
|
47 |
+
'value' => $value,
|
48 |
+
'label' => $label
|
49 |
+
);
|
50 |
+
}
|
51 |
+
|
52 |
+
return $options;
|
53 |
+
}
|
54 |
+
}
|
app/code/community/Bpost/ShM/Model/Resource/Holidays.php
CHANGED
@@ -1,23 +1,23 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Created by PHPro
|
5 |
-
*
|
6 |
-
* @package Bpost
|
7 |
-
* @subpackage ShM
|
8 |
-
* @author PHPro (info@phpro.be)
|
9 |
-
*/
|
10 |
-
|
11 |
-
/**
|
12 |
-
* Class Bpost_ShM_Model_Resource_Holidays
|
13 |
-
*/
|
14 |
-
class Bpost_ShM_Model_Resource_Holidays extends Mage_Core_Model_Mysql4_Abstract
|
15 |
-
{
|
16 |
-
/**
|
17 |
-
* Sets model primary key.
|
18 |
-
*/
|
19 |
-
protected function _construct()
|
20 |
-
{
|
21 |
-
$this->_init("bpost_shm/bpost_holidays", "holiday_id");
|
22 |
-
}
|
23 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Created by PHPro
|
5 |
+
*
|
6 |
+
* @package Bpost
|
7 |
+
* @subpackage ShM
|
8 |
+
* @author PHPro (info@phpro.be)
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Class Bpost_ShM_Model_Resource_Holidays
|
13 |
+
*/
|
14 |
+
class Bpost_ShM_Model_Resource_Holidays extends Mage_Core_Model_Mysql4_Abstract
|
15 |
+
{
|
16 |
+
/**
|
17 |
+
* Sets model primary key.
|
18 |
+
*/
|
19 |
+
protected function _construct()
|
20 |
+
{
|
21 |
+
$this->_init("bpost_shm/bpost_holidays", "holiday_id");
|
22 |
+
}
|
23 |
+
}
|
app/code/community/Bpost/ShM/Model/Resource/Holidays/Collection.php
CHANGED
@@ -1,40 +1,40 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Created by PHPro
|
5 |
-
*
|
6 |
-
* @package Bpost
|
7 |
-
* @subpackage ShM
|
8 |
-
* @author PHPro (info@phpro.be)
|
9 |
-
*/
|
10 |
-
|
11 |
-
/**
|
12 |
-
* Class Bpost_ShM_Model_Resource_Holidays_Collection
|
13 |
-
*/
|
14 |
-
class Bpost_ShM_Model_Resource_Holidays_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
15 |
-
{
|
16 |
-
/**
|
17 |
-
* Initialises the model, the abstract file will render a collection from it.
|
18 |
-
*/
|
19 |
-
public function _construct()
|
20 |
-
{
|
21 |
-
$this->_init("bpost_shm/holidays");
|
22 |
-
}
|
23 |
-
|
24 |
-
/**
|
25 |
-
* Convert collection items to array with holidays
|
26 |
-
*
|
27 |
-
* @return array
|
28 |
-
*/
|
29 |
-
public function getHolidays()
|
30 |
-
{
|
31 |
-
$options = $this->_toOptionArray('holiday_id', 'date');
|
32 |
-
$dates = array();
|
33 |
-
|
34 |
-
foreach ($options as $record) {
|
35 |
-
$dates[] = date('Y-m-d', strtotime($record['label']));
|
36 |
-
}
|
37 |
-
|
38 |
-
return $dates;
|
39 |
-
}
|
40 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Created by PHPro
|
5 |
+
*
|
6 |
+
* @package Bpost
|
7 |
+
* @subpackage ShM
|
8 |
+
* @author PHPro (info@phpro.be)
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Class Bpost_ShM_Model_Resource_Holidays_Collection
|
13 |
+
*/
|
14 |
+
class Bpost_ShM_Model_Resource_Holidays_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
15 |
+
{
|
16 |
+
/**
|
17 |
+
* Initialises the model, the abstract file will render a collection from it.
|
18 |
+
*/
|
19 |
+
public function _construct()
|
20 |
+
{
|
21 |
+
$this->_init("bpost_shm/holidays");
|
22 |
+
}
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Convert collection items to array with holidays
|
26 |
+
*
|
27 |
+
* @return array
|
28 |
+
*/
|
29 |
+
public function getHolidays()
|
30 |
+
{
|
31 |
+
$options = $this->_toOptionArray('holiday_id', 'date');
|
32 |
+
$dates = array();
|
33 |
+
|
34 |
+
foreach ($options as $record) {
|
35 |
+
$dates[] = date('Y-m-d', strtotime($record['label']));
|
36 |
+
}
|
37 |
+
|
38 |
+
return $dates;
|
39 |
+
}
|
40 |
+
}
|
app/code/community/Bpost/ShM/Model/Resource/Returnlabel.php
CHANGED
@@ -1,23 +1,23 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Created by PHPro
|
5 |
-
*
|
6 |
-
* @package Bpost
|
7 |
-
* @subpackage ShM
|
8 |
-
* @author PHPro (info@phpro.be)
|
9 |
-
*/
|
10 |
-
|
11 |
-
/**
|
12 |
-
* Class Bpost_ShM_Model_Resource_Returnlabel
|
13 |
-
*/
|
14 |
-
class Bpost_ShM_Model_Resource_Returnlabel extends Mage_Core_Model_Mysql4_Abstract
|
15 |
-
{
|
16 |
-
/**
|
17 |
-
* Sets model primary key.
|
18 |
-
*/
|
19 |
-
protected function _construct()
|
20 |
-
{
|
21 |
-
$this->_init("bpost_shm/returnlabel", "label_id");
|
22 |
-
}
|
23 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Created by PHPro
|
5 |
+
*
|
6 |
+
* @package Bpost
|
7 |
+
* @subpackage ShM
|
8 |
+
* @author PHPro (info@phpro.be)
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Class Bpost_ShM_Model_Resource_Returnlabel
|
13 |
+
*/
|
14 |
+
class Bpost_ShM_Model_Resource_Returnlabel extends Mage_Core_Model_Mysql4_Abstract
|
15 |
+
{
|
16 |
+
/**
|
17 |
+
* Sets model primary key.
|
18 |
+
*/
|
19 |
+
protected function _construct()
|
20 |
+
{
|
21 |
+
$this->_init("bpost_shm/returnlabel", "label_id");
|
22 |
+
}
|
23 |
+
}
|
app/code/community/Bpost/ShM/Model/Resource/Returnlabel/Collection.php
CHANGED
@@ -1,23 +1,23 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Created by PHPro
|
5 |
-
*
|
6 |
-
* @package Bpost
|
7 |
-
* @subpackage ShM
|
8 |
-
* @author PHPro (info@phpro.be)
|
9 |
-
*/
|
10 |
-
|
11 |
-
/**
|
12 |
-
* Class Bpost_ShM_Model_Resource_Returnlabel_Collection
|
13 |
-
*/
|
14 |
-
class Bpost_ShM_Model_Resource_Returnlabel_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
15 |
-
{
|
16 |
-
/**
|
17 |
-
* Initialises the model, the abstract file will render a collection from it.
|
18 |
-
*/
|
19 |
-
public function _construct()
|
20 |
-
{
|
21 |
-
$this->_init("bpost_shm/returnlabel");
|
22 |
-
}
|
23 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Created by PHPro
|
5 |
+
*
|
6 |
+
* @package Bpost
|
7 |
+
* @subpackage ShM
|
8 |
+
* @author PHPro (info@phpro.be)
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Class Bpost_ShM_Model_Resource_Returnlabel_Collection
|
13 |
+
*/
|
14 |
+
class Bpost_ShM_Model_Resource_Returnlabel_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
15 |
+
{
|
16 |
+
/**
|
17 |
+
* Initialises the model, the abstract file will render a collection from it.
|
18 |
+
*/
|
19 |
+
public function _construct()
|
20 |
+
{
|
21 |
+
$this->_init("bpost_shm/returnlabel");
|
22 |
+
}
|
23 |
+
}
|
app/code/community/Bpost/ShM/Model/Resource/Tablerates/Clickcollect.php
CHANGED
@@ -1,421 +1,421 @@
|
|
1 |
-
<?php
|
2 |
-
class Bpost_ShM_Model_Resource_Tablerates_Clickcollect extends Mage_Core_Model_Resource_Db_Abstract{
|
3 |
-
|
4 |
-
/**
|
5 |
-
* Website Id selected in scope.
|
6 |
-
*
|
7 |
-
* @var int
|
8 |
-
*/
|
9 |
-
protected $_importWebsiteId = 0;
|
10 |
-
|
11 |
-
/**
|
12 |
-
* Array to fill with possible errors.
|
13 |
-
*
|
14 |
-
* @var array
|
15 |
-
*/
|
16 |
-
protected $_importErrors = array();
|
17 |
-
|
18 |
-
/**
|
19 |
-
* Number of rows imported.
|
20 |
-
*
|
21 |
-
* @var int
|
22 |
-
*/
|
23 |
-
protected $_importedRows = 0;
|
24 |
-
|
25 |
-
/**
|
26 |
-
* Conversion.
|
27 |
-
*
|
28 |
-
* @var array
|
29 |
-
*/
|
30 |
-
protected $_importUniqueHash = array();
|
31 |
-
|
32 |
-
/**
|
33 |
-
* Conversion.
|
34 |
-
*
|
35 |
-
* @var
|
36 |
-
*/
|
37 |
-
protected $_importIso2Countries;
|
38 |
-
|
39 |
-
/**
|
40 |
-
* Conversion.
|
41 |
-
*
|
42 |
-
* @var
|
43 |
-
*/
|
44 |
-
protected $_importIso3Countries;
|
45 |
-
|
46 |
-
/**
|
47 |
-
* Regions to import.
|
48 |
-
*
|
49 |
-
* @var
|
50 |
-
*/
|
51 |
-
protected $_importRegions;
|
52 |
-
|
53 |
-
/**
|
54 |
-
* Condition name selected in sysconfig.
|
55 |
-
*
|
56 |
-
* @var
|
57 |
-
*/
|
58 |
-
protected $_importConditionName;
|
59 |
-
|
60 |
-
/**
|
61 |
-
* Full name of condition selected in sysconfig.
|
62 |
-
*
|
63 |
-
* @var array
|
64 |
-
*/
|
65 |
-
protected $_conditionFullNames = array();
|
66 |
-
|
67 |
-
|
68 |
-
/**
|
69 |
-
* Initialise the model.
|
70 |
-
*/
|
71 |
-
protected function _construct()
|
72 |
-
{
|
73 |
-
$this->_init("bpost_shm/bpost_tablerates_clickcollect", "pk");
|
74 |
-
}
|
75 |
-
|
76 |
-
|
77 |
-
/**
|
78 |
-
* Fetch rate from the table for selected shipping address.
|
79 |
-
*
|
80 |
-
* @param Mage_Shipping_Model_Rate_Request $request
|
81 |
-
* @return array
|
82 |
-
*/
|
83 |
-
public function getRate(Mage_Shipping_Model_Rate_Request $request)
|
84 |
-
{
|
85 |
-
$adapter = $this->_getReadAdapter();
|
86 |
-
$bind = array(
|
87 |
-
':website_id' => (int) $request->getWebsiteId(),
|
88 |
-
':country_id' => $request->getDestCountryId(),
|
89 |
-
':region_id' => (int) $request->getDestRegionId(),
|
90 |
-
':postcode' => $request->getDestPostcode()
|
91 |
-
);
|
92 |
-
$select = $adapter->select()
|
93 |
-
->from($this->getMainTable())
|
94 |
-
->where('website_id = :website_id')
|
95 |
-
->order(array('dest_country_id DESC', 'dest_region_id DESC', 'dest_zip DESC', 'condition_value DESC'))
|
96 |
-
->limit(1);
|
97 |
-
|
98 |
-
// Render destination condition
|
99 |
-
$orWhere = '(' . implode(') OR (', array(
|
100 |
-
"dest_country_id = :country_id AND dest_region_id = :region_id AND dest_zip = :postcode",
|
101 |
-
"dest_country_id = :country_id AND dest_region_id = :region_id AND dest_zip = ''",
|
102 |
-
|
103 |
-
// Handle asterix in dest_zip field
|
104 |
-
"dest_country_id = :country_id AND dest_region_id = :region_id AND dest_zip = '*'",
|
105 |
-
"dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = '*'",
|
106 |
-
"dest_country_id = '0' AND dest_region_id = :region_id AND dest_zip = '*'",
|
107 |
-
"dest_country_id = '0' AND dest_region_id = 0 AND dest_zip = '*'",
|
108 |
-
|
109 |
-
"dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = ''",
|
110 |
-
"dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = :postcode",
|
111 |
-
"dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = '*'",
|
112 |
-
)) . ')';
|
113 |
-
$select->where($orWhere);
|
114 |
-
|
115 |
-
// Render condition by condition name
|
116 |
-
if (is_array($request->getConditionName())) {
|
117 |
-
$orWhere = array();
|
118 |
-
$i = 0;
|
119 |
-
foreach ($request->getConditionName() as $conditionName) {
|
120 |
-
$bindNameKey = sprintf(':condition_name_%d', $i);
|
121 |
-
$bindValueKey = sprintf(':condition_value_%d', $i);
|
122 |
-
$orWhere[] = "(condition_name = {$bindNameKey} AND condition_value <= {$bindValueKey})";
|
123 |
-
$bind[$bindNameKey] = $conditionName;
|
124 |
-
$bind[$bindValueKey] = $request->getData($conditionName);
|
125 |
-
$i++;
|
126 |
-
}
|
127 |
-
|
128 |
-
if ($orWhere) {
|
129 |
-
$select->where(implode(' OR ', $orWhere));
|
130 |
-
}
|
131 |
-
} else {
|
132 |
-
$bind[':condition_name'] = $request->getConditionName();
|
133 |
-
$bind[':condition_value'] = $request->getData($request->getConditionName());
|
134 |
-
|
135 |
-
$select->where('condition_name = :condition_name');
|
136 |
-
$select->where('condition_value <= :condition_value');
|
137 |
-
}
|
138 |
-
|
139 |
-
$result = $adapter->fetchRow($select, $bind);
|
140 |
-
// Normalize destination zip code
|
141 |
-
if ($result && $result['dest_zip'] == '*') {
|
142 |
-
$result['dest_zip'] = '';
|
143 |
-
}
|
144 |
-
return $result;
|
145 |
-
}
|
146 |
-
|
147 |
-
|
148 |
-
/**
|
149 |
-
* Upload and import table rates csv.
|
150 |
-
*
|
151 |
-
* @param Varien_Object $object
|
152 |
-
* @return $this
|
153 |
-
*/
|
154 |
-
public function uploadAndImport(Varien_Object $object)
|
155 |
-
{
|
156 |
-
if (empty($_FILES['groups']['tmp_name']['bpost_clickcollect']['fields']['import_clickcollect']['value'])) {
|
157 |
-
return $this;
|
158 |
-
}
|
159 |
-
|
160 |
-
$csvFile = $_FILES['groups']['tmp_name']['bpost_clickcollect']['fields']['import_clickcollect']['value'];
|
161 |
-
$website = Mage::app()->getWebsite($object->getScopeId());
|
162 |
-
|
163 |
-
$this->_importWebsiteId = (int)$website->getId();
|
164 |
-
$this->_importUniqueHash = array();
|
165 |
-
$this->_importErrors = array();
|
166 |
-
$this->_importedRows = 0;
|
167 |
-
|
168 |
-
$io = new Varien_Io_File();
|
169 |
-
$info = pathinfo($csvFile);
|
170 |
-
$io->open(array('path' => $info['dirname']));
|
171 |
-
$io->streamOpen($info['basename'], 'r');
|
172 |
-
|
173 |
-
// check and skip headers
|
174 |
-
$headers = $io->streamReadCsv();
|
175 |
-
if ($headers === false || count($headers) < 5) {
|
176 |
-
$io->streamClose();
|
177 |
-
Mage::throwException(Mage::helper('bpost_shm')->__('Invalid Table Rates File Format'));
|
178 |
-
}
|
179 |
-
if ($object->getData('groups/bpost_clickcollect/fields/condition_name/inherit') == '1') {
|
180 |
-
$conditionName = (string)Mage::getConfig()->getNode('default/carriers/bpost_clickcollect/condition_name');
|
181 |
-
} else {
|
182 |
-
$conditionName = $object->getData('groups/bpost_clickcollect/fields/condition_name/value');
|
183 |
-
}
|
184 |
-
$this->_importConditionName = $conditionName;
|
185 |
-
$adapter = $this->_getWriteAdapter();
|
186 |
-
$adapter->beginTransaction();
|
187 |
-
|
188 |
-
try {
|
189 |
-
$rowNumber = 1;
|
190 |
-
$importData = array();
|
191 |
-
|
192 |
-
$this->_loadDirectoryCountries();
|
193 |
-
$this->_loadDirectoryRegions();
|
194 |
-
|
195 |
-
// delete old data by website and condition name
|
196 |
-
$condition = array(
|
197 |
-
'website_id = ?' => $this->_importWebsiteId,
|
198 |
-
'condition_name = ?' => $this->_importConditionName
|
199 |
-
);
|
200 |
-
$adapter->delete($this->getMainTable(), $condition);
|
201 |
-
|
202 |
-
while (false !== ($csvLine = $io->streamReadCsv())) {
|
203 |
-
$rowNumber ++;
|
204 |
-
|
205 |
-
if (empty($csvLine)) {
|
206 |
-
continue;
|
207 |
-
}
|
208 |
-
|
209 |
-
$row = $this->_getImportRow($csvLine, $rowNumber);
|
210 |
-
if ($row !== false) {
|
211 |
-
$importData[] = $row;
|
212 |
-
}
|
213 |
-
|
214 |
-
if (count($importData) == 5000) {
|
215 |
-
$this->_saveImportData($importData);
|
216 |
-
$importData = array();
|
217 |
-
}
|
218 |
-
}
|
219 |
-
$this->_saveImportData($importData);
|
220 |
-
$io->streamClose();
|
221 |
-
} catch (Mage_Core_Exception $e) {
|
222 |
-
$adapter->rollback();
|
223 |
-
$io->streamClose();
|
224 |
-
Mage::throwException($e->getMessage());
|
225 |
-
} catch (Exception $e) {
|
226 |
-
$adapter->rollback();
|
227 |
-
$io->streamClose();
|
228 |
-
Mage::helper('bpost_shm')->log($e,Zend_Log::ERR);
|
229 |
-
Mage::throwException(Mage::helper('bpost_shm')->__('An error occurred while importing table rates.'));
|
230 |
-
}
|
231 |
-
|
232 |
-
$adapter->commit();
|
233 |
-
|
234 |
-
if ($this->_importErrors) {
|
235 |
-
$error = Mage::helper('bpost_shm')->__('File has not been imported. See the following list of errors: %s', implode(" \n", $this->_importErrors));
|
236 |
-
Mage::throwException($error);
|
237 |
-
}
|
238 |
-
|
239 |
-
return $this;
|
240 |
-
}
|
241 |
-
|
242 |
-
/**
|
243 |
-
* Load directory countries.
|
244 |
-
*
|
245 |
-
* @return Mage_Shipping_Model_Resource_Carrier_Tablerate
|
246 |
-
*/
|
247 |
-
protected function _loadDirectoryCountries()
|
248 |
-
{
|
249 |
-
if (!is_null($this->_importIso2Countries) && !is_null($this->_importIso3Countries)) {
|
250 |
-
return $this;
|
251 |
-
}
|
252 |
-
|
253 |
-
$this->_importIso2Countries = array();
|
254 |
-
$this->_importIso3Countries = array();
|
255 |
-
|
256 |
-
/** @var $collection Mage_Directory_Model_Resource_Country_Collection */
|
257 |
-
$collection = Mage::getResourceModel('directory/country_collection');
|
258 |
-
foreach ($collection->getData() as $row) {
|
259 |
-
$this->_importIso2Countries[$row['iso2_code']] = $row['country_id'];
|
260 |
-
$this->_importIso3Countries[$row['iso3_code']] = $row['country_id'];
|
261 |
-
}
|
262 |
-
|
263 |
-
return $this;
|
264 |
-
}
|
265 |
-
|
266 |
-
/**
|
267 |
-
* Load directory regions.
|
268 |
-
*
|
269 |
-
* @return Mage_Shipping_Model_Resource_Carrier_Tablerate
|
270 |
-
*/
|
271 |
-
protected function _loadDirectoryRegions()
|
272 |
-
{
|
273 |
-
if (!is_null($this->_importRegions)) {
|
274 |
-
return $this;
|
275 |
-
}
|
276 |
-
|
277 |
-
$this->_importRegions = array();
|
278 |
-
|
279 |
-
/** @var $collection Mage_Directory_Model_Resource_Region_Collection */
|
280 |
-
$collection = Mage::getResourceModel('directory/region_collection');
|
281 |
-
foreach ($collection->getData() as $row) {
|
282 |
-
$this->_importRegions[$row['country_id']][$row['code']] = (int)$row['region_id'];
|
283 |
-
}
|
284 |
-
|
285 |
-
return $this;
|
286 |
-
}
|
287 |
-
|
288 |
-
/**
|
289 |
-
* Return import condition full name by condition name code.
|
290 |
-
*
|
291 |
-
* @param string $conditionName
|
292 |
-
* @return string
|
293 |
-
*/
|
294 |
-
protected function _getConditionFullName($conditionName)
|
295 |
-
{
|
296 |
-
if (!isset($this->_conditionFullNames[$conditionName])) {
|
297 |
-
$name = Mage::getSingleton('shipping/carrier_tablerate')->getCode('condition_name_short', $conditionName);
|
298 |
-
$this->_conditionFullNames[$conditionName] = $name;
|
299 |
-
}
|
300 |
-
return $this->_conditionFullNames[$conditionName];
|
301 |
-
}
|
302 |
-
|
303 |
-
/**
|
304 |
-
* Validate row for import and return table rate array or false.
|
305 |
-
* Error will be add to _importErrors array.
|
306 |
-
*
|
307 |
-
* @param array $row
|
308 |
-
* @param int $rowNumber
|
309 |
-
* @return array|false
|
310 |
-
*/
|
311 |
-
protected function _getImportRow($row, $rowNumber = 0)
|
312 |
-
{
|
313 |
-
// validate row
|
314 |
-
if (count($row) < 5) {
|
315 |
-
$this->_importErrors[] = Mage::helper('bpost_shm')->__('Invalid Table Rates format in the Row #%s', $rowNumber);
|
316 |
-
return false;
|
317 |
-
}
|
318 |
-
|
319 |
-
// strip whitespace from the beginning and end of each row
|
320 |
-
foreach ($row as $k => $v) {
|
321 |
-
$row[$k] = trim($v);
|
322 |
-
}
|
323 |
-
|
324 |
-
// validate country
|
325 |
-
if (isset($this->_importIso2Countries[$row[0]])){
|
326 |
-
$countryId = $this->_importIso2Countries[$row[0]];
|
327 |
-
} elseif (isset($this->_importIso3Countries[$row[0]])) {
|
328 |
-
$countryId = $this->_importIso3Countries[$row[0]];
|
329 |
-
} elseif ($row[0] == '*' || $row[0] == '') {
|
330 |
-
$countryId = '0';
|
331 |
-
} else {
|
332 |
-
$this->_importErrors[] = Mage::helper('bpost_shm')->__('Invalid Country "%s" in the Row #%s.', $row[0], $rowNumber);
|
333 |
-
return false;
|
334 |
-
}
|
335 |
-
|
336 |
-
// validate region
|
337 |
-
if ($countryId != '0' && isset($this->_importRegions[$countryId][$row[1]])) {
|
338 |
-
$regionId = $this->_importRegions[$countryId][$row[1]];
|
339 |
-
} elseif ($row[1] == '*' || $row[1] == '') {
|
340 |
-
$regionId = 0;
|
341 |
-
} else {
|
342 |
-
$this->_importErrors[] = Mage::helper('bpost_shm')->__('Invalid Region/State "%s" in the Row #%s.', $row[1], $rowNumber);
|
343 |
-
return false;
|
344 |
-
}
|
345 |
-
|
346 |
-
// detect zip code
|
347 |
-
if ($row[2] == '*' || $row[2] == '') {
|
348 |
-
$zipCode = '*';
|
349 |
-
} else {
|
350 |
-
$zipCode = $row[2];
|
351 |
-
}
|
352 |
-
|
353 |
-
// validate condition value
|
354 |
-
$value = $this->_parseDecimalValue($row[3]);
|
355 |
-
if ($value === false) {
|
356 |
-
$this->_importErrors[] = Mage::helper('bpost_shm')->__('Invalid %s "%s" in the Row #%s.', $this->_getConditionFullName($this->_importConditionName), $row[3], $rowNumber);
|
357 |
-
return false;
|
358 |
-
}
|
359 |
-
|
360 |
-
// validate price
|
361 |
-
$price = $this->_parseDecimalValue($row[4]);
|
362 |
-
if ($price === false) {
|
363 |
-
$this->_importErrors[] = Mage::helper('bpost_shm')->__('Invalid Shipping Price "%s" in the Row #%s.', $row[4], $rowNumber);
|
364 |
-
return false;
|
365 |
-
}
|
366 |
-
|
367 |
-
// protect from duplicate
|
368 |
-
$hash = sprintf("%s-%d-%s-%F", $countryId, $regionId, $zipCode, $value);
|
369 |
-
if (isset($this->_importUniqueHash[$hash])) {
|
370 |
-
$this->_importErrors[] = Mage::helper('bpost_shm')->__('Duplicate Row #%s (Country "%s", Region/State "%s", Zip "%s" and Value "%s").', $rowNumber, $row[0], $row[1], $zipCode, $value);
|
371 |
-
return false;
|
372 |
-
}
|
373 |
-
$this->_importUniqueHash[$hash] = true;
|
374 |
-
|
375 |
-
return array(
|
376 |
-
$this->_importWebsiteId, // website_id
|
377 |
-
$countryId, // dest_country_id
|
378 |
-
$regionId, // dest_region_id,
|
379 |
-
$zipCode, // dest_zip
|
380 |
-
$this->_importConditionName,// condition_name,
|
381 |
-
$value, // condition_value
|
382 |
-
$price // price
|
383 |
-
);
|
384 |
-
}
|
385 |
-
|
386 |
-
/**
|
387 |
-
* Save all import data.
|
388 |
-
*
|
389 |
-
* @param array $data
|
390 |
-
* @return $this
|
391 |
-
*/
|
392 |
-
protected function _saveImportData(array $data)
|
393 |
-
{
|
394 |
-
if (!empty($data)) {
|
395 |
-
$columns = array('website_id', 'dest_country_id', 'dest_region_id', 'dest_zip',
|
396 |
-
'condition_name', 'condition_value', 'price');
|
397 |
-
$this->_getWriteAdapter()->insertArray($this->getMainTable(), $columns, $data);
|
398 |
-
$this->_importedRows += count($data);
|
399 |
-
}
|
400 |
-
|
401 |
-
return $this;
|
402 |
-
}
|
403 |
-
|
404 |
-
/**
|
405 |
-
* Conversion.
|
406 |
-
*
|
407 |
-
* @param $value
|
408 |
-
* @return bool|float
|
409 |
-
*/
|
410 |
-
protected function _parseDecimalValue($value)
|
411 |
-
{
|
412 |
-
if (!is_numeric($value)) {
|
413 |
-
return false;
|
414 |
-
}
|
415 |
-
$value = (float)sprintf('%.4F', $value);
|
416 |
-
if ($value < 0.0000) {
|
417 |
-
return false;
|
418 |
-
}
|
419 |
-
return $value;
|
420 |
-
}
|
421 |
}
|
1 |
+
<?php
|
2 |
+
class Bpost_ShM_Model_Resource_Tablerates_Clickcollect extends Mage_Core_Model_Resource_Db_Abstract{
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Website Id selected in scope.
|
6 |
+
*
|
7 |
+
* @var int
|
8 |
+
*/
|
9 |
+
protected $_importWebsiteId = 0;
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Array to fill with possible errors.
|
13 |
+
*
|
14 |
+
* @var array
|
15 |
+
*/
|
16 |
+
protected $_importErrors = array();
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Number of rows imported.
|
20 |
+
*
|
21 |
+
* @var int
|
22 |
+
*/
|
23 |
+
protected $_importedRows = 0;
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Conversion.
|
27 |
+
*
|
28 |
+
* @var array
|
29 |
+
*/
|
30 |
+
protected $_importUniqueHash = array();
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Conversion.
|
34 |
+
*
|
35 |
+
* @var
|
36 |
+
*/
|
37 |
+
protected $_importIso2Countries;
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Conversion.
|
41 |
+
*
|
42 |
+
* @var
|
43 |
+
*/
|
44 |
+
protected $_importIso3Countries;
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Regions to import.
|
48 |
+
*
|
49 |
+
* @var
|
50 |
+
*/
|
51 |
+
protected $_importRegions;
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Condition name selected in sysconfig.
|
55 |
+
*
|
56 |
+
* @var
|
57 |
+
*/
|
58 |
+
protected $_importConditionName;
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Full name of condition selected in sysconfig.
|
62 |
+
*
|
63 |
+
* @var array
|
64 |
+
*/
|
65 |
+
protected $_conditionFullNames = array();
|
66 |
+
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Initialise the model.
|
70 |
+
*/
|
71 |
+
protected function _construct()
|
72 |
+
{
|
73 |
+
$this->_init("bpost_shm/bpost_tablerates_clickcollect", "pk");
|
74 |
+
}
|
75 |
+
|
76 |
+
|
77 |
+
/**
|
78 |
+
* Fetch rate from the table for selected shipping address.
|
79 |
+
*
|
80 |
+
* @param Mage_Shipping_Model_Rate_Request $request
|
81 |
+
* @return array
|
82 |
+
*/
|
83 |
+
public function getRate(Mage_Shipping_Model_Rate_Request $request)
|
84 |
+
{
|
85 |
+
$adapter = $this->_getReadAdapter();
|
86 |
+
$bind = array(
|
87 |
+
':website_id' => (int) $request->getWebsiteId(),
|
88 |
+
':country_id' => $request->getDestCountryId(),
|
89 |
+
':region_id' => (int) $request->getDestRegionId(),
|
90 |
+
':postcode' => $request->getDestPostcode()
|
91 |
+
);
|
92 |
+
$select = $adapter->select()
|
93 |
+
->from($this->getMainTable())
|
94 |
+
->where('website_id = :website_id')
|
95 |
+
->order(array('dest_country_id DESC', 'dest_region_id DESC', 'dest_zip DESC', 'condition_value DESC'))
|
96 |
+
->limit(1);
|
97 |
+
|
98 |
+
// Render destination condition
|
99 |
+
$orWhere = '(' . implode(') OR (', array(
|
100 |
+
"dest_country_id = :country_id AND dest_region_id = :region_id AND dest_zip = :postcode",
|
101 |
+
"dest_country_id = :country_id AND dest_region_id = :region_id AND dest_zip = ''",
|
102 |
+
|
103 |
+
// Handle asterix in dest_zip field
|
104 |
+
"dest_country_id = :country_id AND dest_region_id = :region_id AND dest_zip = '*'",
|
105 |
+
"dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = '*'",
|
106 |
+
"dest_country_id = '0' AND dest_region_id = :region_id AND dest_zip = '*'",
|
107 |
+
"dest_country_id = '0' AND dest_region_id = 0 AND dest_zip = '*'",
|
108 |
+
|
109 |
+
"dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = ''",
|
110 |
+
"dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = :postcode",
|
111 |
+
"dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = '*'",
|
112 |
+
)) . ')';
|
113 |
+
$select->where($orWhere);
|
114 |
+
|
115 |
+
// Render condition by condition name
|
116 |
+
if (is_array($request->getConditionName())) {
|
117 |
+
$orWhere = array();
|
118 |
+
$i = 0;
|
119 |
+
foreach ($request->getConditionName() as $conditionName) {
|
120 |
+
$bindNameKey = sprintf(':condition_name_%d', $i);
|
121 |
+
$bindValueKey = sprintf(':condition_value_%d', $i);
|
122 |
+
$orWhere[] = "(condition_name = {$bindNameKey} AND condition_value <= {$bindValueKey})";
|
123 |
+
$bind[$bindNameKey] = $conditionName;
|
124 |
+
$bind[$bindValueKey] = $request->getData($conditionName);
|
125 |
+
$i++;
|
126 |
+
}
|
127 |
+
|
128 |
+
if ($orWhere) {
|
129 |
+
$select->where(implode(' OR ', $orWhere));
|
130 |
+
}
|
131 |
+
} else {
|
132 |
+
$bind[':condition_name'] = $request->getConditionName();
|
133 |
+
$bind[':condition_value'] = $request->getData($request->getConditionName());
|
134 |
+
|
135 |
+
$select->where('condition_name = :condition_name');
|
136 |
+
$select->where('condition_value <= :condition_value');
|
137 |
+
}
|
138 |
+
|
139 |
+
$result = $adapter->fetchRow($select, $bind);
|
140 |
+
// Normalize destination zip code
|
141 |
+
if ($result && $result['dest_zip'] == '*') {
|
142 |
+
$result['dest_zip'] = '';
|
143 |
+
}
|
144 |
+
return $result;
|
145 |
+
}
|
146 |
+
|
147 |
+
|
148 |
+
/**
|
149 |
+
* Upload and import table rates csv.
|
150 |
+
*
|
151 |
+
* @param Varien_Object $object
|
152 |
+
* @return $this
|
153 |
+
*/
|
154 |
+
public function uploadAndImport(Varien_Object $object)
|
155 |
+
{
|
156 |
+
if (empty($_FILES['groups']['tmp_name']['bpost_clickcollect']['fields']['import_clickcollect']['value'])) {
|
157 |
+
return $this;
|
158 |
+
}
|
159 |
+
|
160 |
+
$csvFile = $_FILES['groups']['tmp_name']['bpost_clickcollect']['fields']['import_clickcollect']['value'];
|
161 |
+
$website = Mage::app()->getWebsite($object->getScopeId());
|
162 |
+
|
163 |
+
$this->_importWebsiteId = (int)$website->getId();
|
164 |
+
$this->_importUniqueHash = array();
|
165 |
+
$this->_importErrors = array();
|
166 |
+
$this->_importedRows = 0;
|
167 |
+
|
168 |
+
$io = new Varien_Io_File();
|
169 |
+
$info = pathinfo($csvFile);
|
170 |
+
$io->open(array('path' => $info['dirname']));
|
171 |
+
$io->streamOpen($info['basename'], 'r');
|
172 |
+
|
173 |
+
// check and skip headers
|
174 |
+
$headers = $io->streamReadCsv();
|
175 |
+
if ($headers === false || count($headers) < 5) {
|
176 |
+
$io->streamClose();
|
177 |
+
Mage::throwException(Mage::helper('bpost_shm')->__('Invalid Table Rates File Format'));
|
178 |
+
}
|
179 |
+
if ($object->getData('groups/bpost_clickcollect/fields/condition_name/inherit') == '1') {
|
180 |
+
$conditionName = (string)Mage::getConfig()->getNode('default/carriers/bpost_clickcollect/condition_name');
|
181 |
+
} else {
|
182 |
+
$conditionName = $object->getData('groups/bpost_clickcollect/fields/condition_name/value');
|
183 |
+
}
|
184 |
+
$this->_importConditionName = $conditionName;
|
185 |
+
$adapter = $this->_getWriteAdapter();
|
186 |
+
$adapter->beginTransaction();
|
187 |
+
|
188 |
+
try {
|
189 |
+
$rowNumber = 1;
|
190 |
+
$importData = array();
|
191 |
+
|
192 |
+
$this->_loadDirectoryCountries();
|
193 |
+
$this->_loadDirectoryRegions();
|
194 |
+
|
195 |
+
// delete old data by website and condition name
|
196 |
+
$condition = array(
|
197 |
+
'website_id = ?' => $this->_importWebsiteId,
|
198 |
+
'condition_name = ?' => $this->_importConditionName
|
199 |
+
);
|
200 |
+
$adapter->delete($this->getMainTable(), $condition);
|
201 |
+
|
202 |
+
while (false !== ($csvLine = $io->streamReadCsv())) {
|
203 |
+
$rowNumber ++;
|
204 |
+
|
205 |
+
if (empty($csvLine)) {
|
206 |
+
continue;
|
207 |
+
}
|
208 |
+
|
209 |
+
$row = $this->_getImportRow($csvLine, $rowNumber);
|
210 |
+
if ($row !== false) {
|
211 |
+
$importData[] = $row;
|
212 |
+
}
|
213 |
+
|
214 |
+
if (count($importData) == 5000) {
|
215 |
+
$this->_saveImportData($importData);
|
216 |
+
$importData = array();
|
217 |
+
}
|
218 |
+
}
|
219 |
+
$this->_saveImportData($importData);
|
220 |
+
$io->streamClose();
|
221 |
+
} catch (Mage_Core_Exception $e) {
|
222 |
+
$adapter->rollback();
|
223 |
+
$io->streamClose();
|
224 |
+
Mage::throwException($e->getMessage());
|
225 |
+
} catch (Exception $e) {
|
226 |
+
$adapter->rollback();
|
227 |
+
$io->streamClose();
|
228 |
+
Mage::helper('bpost_shm')->log($e,Zend_Log::ERR);
|
229 |
+
Mage::throwException(Mage::helper('bpost_shm')->__('An error occurred while importing table rates.'));
|
230 |
+
}
|
231 |
+
|
232 |
+
$adapter->commit();
|
233 |
+
|
234 |
+
if ($this->_importErrors) {
|
235 |
+
$error = Mage::helper('bpost_shm')->__('File has not been imported. See the following list of errors: %s', implode(" \n", $this->_importErrors));
|
236 |
+
Mage::throwException($error);
|
237 |
+
}
|
238 |
+
|
239 |
+
return $this;
|
240 |
+
}
|
241 |
+
|
242 |
+
/**
|
243 |
+
* Load directory countries.
|
244 |
+
*
|
245 |
+
* @return Mage_Shipping_Model_Resource_Carrier_Tablerate
|
246 |
+
*/
|
247 |
+
protected function _loadDirectoryCountries()
|
248 |
+
{
|
249 |
+
if (!is_null($this->_importIso2Countries) && !is_null($this->_importIso3Countries)) {
|
250 |
+
return $this;
|
251 |
+
}
|
252 |
+
|
253 |
+
$this->_importIso2Countries = array();
|
254 |
+
$this->_importIso3Countries = array();
|
255 |
+
|
256 |
+
/** @var $collection Mage_Directory_Model_Resource_Country_Collection */
|
257 |
+
$collection = Mage::getResourceModel('directory/country_collection');
|
258 |
+
foreach ($collection->getData() as $row) {
|
259 |
+
$this->_importIso2Countries[$row['iso2_code']] = $row['country_id'];
|
260 |
+
$this->_importIso3Countries[$row['iso3_code']] = $row['country_id'];
|
261 |
+
}
|
262 |
+
|
263 |
+
return $this;
|
264 |
+
}
|
265 |
+
|
266 |
+
/**
|
267 |
+
* Load directory regions.
|
268 |
+
*
|
269 |
+
* @return Mage_Shipping_Model_Resource_Carrier_Tablerate
|
270 |
+
*/
|
271 |
+
protected function _loadDirectoryRegions()
|
272 |
+
{
|
273 |
+
if (!is_null($this->_importRegions)) {
|
274 |
+
return $this;
|
275 |
+
}
|
276 |
+
|
277 |
+
$this->_importRegions = array();
|
278 |
+
|
279 |
+
/** @var $collection Mage_Directory_Model_Resource_Region_Collection */
|
280 |
+
$collection = Mage::getResourceModel('directory/region_collection');
|
281 |
+
foreach ($collection->getData() as $row) {
|
282 |
+
$this->_importRegions[$row['country_id']][$row['code']] = (int)$row['region_id'];
|
283 |
+
}
|
284 |
+
|
285 |
+
return $this;
|
286 |
+
}
|
287 |
+
|
288 |
+
/**
|
289 |
+
* Return import condition full name by condition name code.
|
290 |
+
*
|
291 |
+
* @param string $conditionName
|
292 |
+
* @return string
|
293 |
+
*/
|
294 |
+
protected function _getConditionFullName($conditionName)
|
295 |
+
{
|
296 |
+
if (!isset($this->_conditionFullNames[$conditionName])) {
|
297 |
+
$name = Mage::getSingleton('shipping/carrier_tablerate')->getCode('condition_name_short', $conditionName);
|
298 |
+
$this->_conditionFullNames[$conditionName] = $name;
|
299 |
+
}
|
300 |
+
return $this->_conditionFullNames[$conditionName];
|
301 |
+
}
|
302 |
+
|
303 |
+
/**
|
304 |
+
* Validate row for import and return table rate array or false.
|
305 |
+
* Error will be add to _importErrors array.
|
306 |
+
*
|
307 |
+
* @param array $row
|
308 |
+
* @param int $rowNumber
|
309 |
+
* @return array|false
|
310 |
+
*/
|
311 |
+
protected function _getImportRow($row, $rowNumber = 0)
|
312 |
+
{
|
313 |
+
// validate row
|
314 |
+
if (count($row) < 5) {
|
315 |
+
$this->_importErrors[] = Mage::helper('bpost_shm')->__('Invalid Table Rates format in the Row #%s', $rowNumber);
|
316 |
+
return false;
|
317 |
+
}
|
318 |
+
|
319 |
+
// strip whitespace from the beginning and end of each row
|
320 |
+
foreach ($row as $k => $v) {
|
321 |
+
$row[$k] = trim($v);
|
322 |
+
}
|
323 |
+
|
324 |
+
// validate country
|
325 |
+
if (isset($this->_importIso2Countries[$row[0]])){
|
326 |
+
$countryId = $this->_importIso2Countries[$row[0]];
|
327 |
+
} elseif (isset($this->_importIso3Countries[$row[0]])) {
|
328 |
+
$countryId = $this->_importIso3Countries[$row[0]];
|
329 |
+
} elseif ($row[0] == '*' || $row[0] == '') {
|
330 |
+
$countryId = '0';
|
331 |
+
} else {
|
332 |
+
$this->_importErrors[] = Mage::helper('bpost_shm')->__('Invalid Country "%s" in the Row #%s.', $row[0], $rowNumber);
|
333 |
+
return false;
|
334 |
+
}
|
335 |
+
|
336 |
+
// validate region
|
337 |
+
if ($countryId != '0' && isset($this->_importRegions[$countryId][$row[1]])) {
|
338 |
+
$regionId = $this->_importRegions[$countryId][$row[1]];
|
339 |
+
} elseif ($row[1] == '*' || $row[1] == '') {
|
340 |
+
$regionId = 0;
|
341 |
+
} else {
|
342 |
+
$this->_importErrors[] = Mage::helper('bpost_shm')->__('Invalid Region/State "%s" in the Row #%s.', $row[1], $rowNumber);
|
343 |
+
return false;
|
344 |
+
}
|
345 |
+
|
346 |
+
// detect zip code
|
347 |
+
if ($row[2] == '*' || $row[2] == '') {
|
348 |
+
$zipCode = '*';
|
349 |
+
} else {
|
350 |
+
$zipCode = $row[2];
|
351 |
+
}
|
352 |
+
|
353 |
+
// validate condition value
|
354 |
+
$value = $this->_parseDecimalValue($row[3]);
|
355 |
+
if ($value === false) {
|
356 |
+
$this->_importErrors[] = Mage::helper('bpost_shm')->__('Invalid %s "%s" in the Row #%s.', $this->_getConditionFullName($this->_importConditionName), $row[3], $rowNumber);
|
357 |
+
return false;
|
358 |
+
}
|
359 |
+
|
360 |
+
// validate price
|
361 |
+
$price = $this->_parseDecimalValue($row[4]);
|
362 |
+
if ($price === false) {
|
363 |
+
$this->_importErrors[] = Mage::helper('bpost_shm')->__('Invalid Shipping Price "%s" in the Row #%s.', $row[4], $rowNumber);
|
364 |
+
return false;
|
365 |
+
}
|
366 |
+
|
367 |
+
// protect from duplicate
|
368 |
+
$hash = sprintf("%s-%d-%s-%F", $countryId, $regionId, $zipCode, $value);
|
369 |
+
if (isset($this->_importUniqueHash[$hash])) {
|
370 |
+
$this->_importErrors[] = Mage::helper('bpost_shm')->__('Duplicate Row #%s (Country "%s", Region/State "%s", Zip "%s" and Value "%s").', $rowNumber, $row[0], $row[1], $zipCode, $value);
|
371 |
+
return false;
|
372 |
+
}
|
373 |
+
$this->_importUniqueHash[$hash] = true;
|
374 |
+
|
375 |
+
return array(
|
376 |
+
$this->_importWebsiteId, // website_id
|
377 |
+
$countryId, // dest_country_id
|
378 |
+
$regionId, // dest_region_id,
|
379 |
+
$zipCode, // dest_zip
|
380 |
+
$this->_importConditionName,// condition_name,
|
381 |
+
$value, // condition_value
|
382 |
+
$price // price
|
383 |
+
);
|
384 |
+
}
|
385 |
+
|
386 |
+
/**
|
387 |
+
* Save all import data.
|
388 |
+
*
|
389 |
+
* @param array $data
|
390 |
+
* @return $this
|
391 |
+
*/
|
392 |
+
protected function _saveImportData(array $data)
|
393 |
+
{
|
394 |
+
if (!empty($data)) {
|
395 |
+
$columns = array('website_id', 'dest_country_id', 'dest_region_id', 'dest_zip',
|
396 |
+
'condition_name', 'condition_value', 'price');
|
397 |
+
$this->_getWriteAdapter()->insertArray($this->getMainTable(), $columns, $data);
|
398 |
+
$this->_importedRows += count($data);
|
399 |
+
}
|
400 |
+
|
401 |
+
return $this;
|
402 |
+
}
|
403 |
+
|
404 |
+
/**
|
405 |
+
* Conversion.
|
406 |
+
*
|
407 |
+
* @param $value
|
408 |
+
* @return bool|float
|
409 |
+
*/
|
410 |
+
protected function _parseDecimalValue($value)
|
411 |
+
{
|
412 |
+
if (!is_numeric($value)) {
|
413 |
+
return false;
|
414 |
+
}
|
415 |
+
$value = (float)sprintf('%.4F', $value);
|
416 |
+
if ($value < 0.0000) {
|
417 |
+
return false;
|
418 |
+
}
|
419 |
+
return $value;
|
420 |
+
}
|
421 |
}
|
app/code/community/Bpost/ShM/Model/Resource/Tablerates/Clickcollect/Collection.php
CHANGED
@@ -1,95 +1,95 @@
|
|
1 |
-
<?php
|
2 |
-
class Bpost_ShM_Model_Resource_Tablerates_Clickcollect_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
|
3 |
-
{
|
4 |
-
/**
|
5 |
-
* main table name
|
6 |
-
*
|
7 |
-
* @deprecated since 1.4.1.0
|
8 |
-
* @var string
|
9 |
-
*/
|
10 |
-
protected $_shipTable;
|
11 |
-
|
12 |
-
/**
|
13 |
-
* directory/country table name
|
14 |
-
*
|
15 |
-
* @var string
|
16 |
-
*/
|
17 |
-
protected $_countryTable;
|
18 |
-
|
19 |
-
/**
|
20 |
-
* directory/country_region table name
|
21 |
-
*
|
22 |
-
* @var string
|
23 |
-
*/
|
24 |
-
protected $_regionTable;
|
25 |
-
|
26 |
-
/**
|
27 |
-
* Define resource model and item
|
28 |
-
*
|
29 |
-
*/
|
30 |
-
protected function _construct()
|
31 |
-
{
|
32 |
-
$this->_init('bpost_shm/tablerates_clickcollect');
|
33 |
-
$this->_shipTable = $this->getMainTable();
|
34 |
-
$this->_countryTable = $this->getTable('directory/country');
|
35 |
-
$this->_regionTable = $this->getTable('directory/country_region');
|
36 |
-
}
|
37 |
-
|
38 |
-
/**
|
39 |
-
* Initialize select, add country iso3 code and region name
|
40 |
-
*
|
41 |
-
* @return void
|
42 |
-
*/
|
43 |
-
public function _initSelect()
|
44 |
-
{
|
45 |
-
parent::_initSelect();
|
46 |
-
|
47 |
-
$this->_select
|
48 |
-
->joinLeft(
|
49 |
-
array('country_table' => $this->_countryTable),
|
50 |
-
'country_table.country_id = main_table.dest_country_id',
|
51 |
-
array('dest_country' => 'iso3_code'))
|
52 |
-
->joinLeft(
|
53 |
-
array('region_table' => $this->_regionTable),
|
54 |
-
'region_table.region_id = main_table.dest_region_id',
|
55 |
-
array('dest_region' => 'code'));
|
56 |
-
|
57 |
-
$this->addOrder('dest_country', self::SORT_ORDER_ASC);
|
58 |
-
$this->addOrder('dest_region', self::SORT_ORDER_ASC);
|
59 |
-
$this->addOrder('dest_zip', self::SORT_ORDER_ASC);
|
60 |
-
$this->addOrder('condition_value', self::SORT_ORDER_ASC);
|
61 |
-
}
|
62 |
-
|
63 |
-
/**
|
64 |
-
* Add website filter to collection
|
65 |
-
*
|
66 |
-
* @param int $websiteId
|
67 |
-
* @return Mage_Shipping_Model_Resource_Carrier_Tablerate_Collection
|
68 |
-
*/
|
69 |
-
public function setWebsiteFilter($websiteId)
|
70 |
-
{
|
71 |
-
return $this->addFieldToFilter('website_id', $websiteId);
|
72 |
-
}
|
73 |
-
|
74 |
-
/**
|
75 |
-
* Add condition name (code) filter to collection
|
76 |
-
*
|
77 |
-
* @param string $conditionName
|
78 |
-
* @return Mage_Shipping_Model_Resource_Carrier_Tablerate_Collection
|
79 |
-
*/
|
80 |
-
public function setConditionFilter($conditionName)
|
81 |
-
{
|
82 |
-
return $this->addFieldToFilter('condition_name', $conditionName);
|
83 |
-
}
|
84 |
-
|
85 |
-
/**
|
86 |
-
* Add country filter to collection
|
87 |
-
*
|
88 |
-
* @param string $countryId
|
89 |
-
* @return Mage_Shipping_Model_Resource_Carrier_Tablerate_Collection
|
90 |
-
*/
|
91 |
-
public function setCountryFilter($countryId)
|
92 |
-
{
|
93 |
-
return $this->addFieldToFilter('dest_country_id', $countryId);
|
94 |
-
}
|
95 |
}
|
1 |
+
<?php
|
2 |
+
class Bpost_ShM_Model_Resource_Tablerates_Clickcollect_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
|
3 |
+
{
|
4 |
+
/**
|
5 |
+
* main table name
|
6 |
+
*
|
7 |
+
* @deprecated since 1.4.1.0
|
8 |
+
* @var string
|
9 |
+
*/
|
10 |
+
protected $_shipTable;
|
11 |
+
|
12 |
+
/**
|
13 |
+
* directory/country table name
|
14 |
+
*
|
15 |
+
* @var string
|
16 |
+
*/
|
17 |
+
protected $_countryTable;
|
18 |
+
|
19 |
+
/**
|
20 |
+
* directory/country_region table name
|
21 |
+
*
|
22 |
+
* @var string
|
23 |
+
*/
|
24 |
+
protected $_regionTable;
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Define resource model and item
|
28 |
+
*
|
29 |
+
*/
|
30 |
+
protected function _construct()
|
31 |
+
{
|
32 |
+
$this->_init('bpost_shm/tablerates_clickcollect');
|
33 |
+
$this->_shipTable = $this->getMainTable();
|
34 |
+
$this->_countryTable = $this->getTable('directory/country');
|
35 |
+
$this->_regionTable = $this->getTable('directory/country_region');
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Initialize select, add country iso3 code and region name
|
40 |
+
*
|
41 |
+
* @return void
|
42 |
+
*/
|
43 |
+
public function _initSelect()
|
44 |
+
{
|
45 |
+
parent::_initSelect();
|
46 |
+
|
47 |
+
$this->_select
|
48 |
+
->joinLeft(
|
49 |
+
array('country_table' => $this->_countryTable),
|
50 |
+
'country_table.country_id = main_table.dest_country_id',
|
51 |
+
array('dest_country' => 'iso3_code'))
|
52 |
+
->joinLeft(
|
53 |
+
array('region_table' => $this->_regionTable),
|
54 |
+
'region_table.region_id = main_table.dest_region_id',
|
55 |
+
array('dest_region' => 'code'));
|
56 |
+
|
57 |
+
$this->addOrder('dest_country', self::SORT_ORDER_ASC);
|
58 |
+
$this->addOrder('dest_region', self::SORT_ORDER_ASC);
|
59 |
+
$this->addOrder('dest_zip', self::SORT_ORDER_ASC);
|
60 |
+
$this->addOrder('condition_value', self::SORT_ORDER_ASC);
|
61 |
+
}
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Add website filter to collection
|
65 |
+
*
|
66 |
+
* @param int $websiteId
|
67 |
+
* @return Mage_Shipping_Model_Resource_Carrier_Tablerate_Collection
|
68 |
+
*/
|
69 |
+
public function setWebsiteFilter($websiteId)
|
70 |
+
{
|
71 |
+
return $this->addFieldToFilter('website_id', $websiteId);
|
72 |
+
}
|
73 |
+
|
74 |
+
/**
|
75 |
+
* Add condition name (code) filter to collection
|
76 |
+
*
|
77 |
+
* @param string $conditionName
|
78 |
+
* @return Mage_Shipping_Model_Resource_Carrier_Tablerate_Collection
|
79 |
+
*/
|
80 |
+
public function setConditionFilter($conditionName)
|
81 |
+
{
|
82 |
+
return $this->addFieldToFilter('condition_name', $conditionName);
|
83 |
+
}
|
84 |
+
|
85 |
+
/**
|
86 |
+
* Add country filter to collection
|
87 |
+
*
|
88 |
+
* @param string $countryId
|
89 |
+
* @return Mage_Shipping_Model_Resource_Carrier_Tablerate_Collection
|
90 |
+
*/
|
91 |
+
public function setCountryFilter($countryId)
|
92 |
+
{
|
93 |
+
return $this->addFieldToFilter('dest_country_id', $countryId);
|
94 |
+
}
|
95 |
}
|
app/code/community/Bpost/ShM/Model/Resource/Tablerates/Homedelivery.php
CHANGED
@@ -1,421 +1,421 @@
|
|
1 |
-
<?php
|
2 |
-
class Bpost_ShM_Model_Resource_Tablerates_Homedelivery extends Mage_Core_Model_Resource_Db_Abstract{
|
3 |
-
|
4 |
-
/**
|
5 |
-
* Website Id selected in scope.
|
6 |
-
*
|
7 |
-
* @var int
|
8 |
-
*/
|
9 |
-
protected $_importWebsiteId = 0;
|
10 |
-
|
11 |
-
/**
|
12 |
-
* Array to fill with possible errors.
|
13 |
-
*
|
14 |
-
* @var array
|
15 |
-
*/
|
16 |
-
protected $_importErrors = array();
|
17 |
-
|
18 |
-
/**
|
19 |
-
* Number of rows imported.
|
20 |
-
*
|
21 |
-
* @var int
|
22 |
-
*/
|
23 |
-
protected $_importedRows = 0;
|
24 |
-
|
25 |
-
/**
|
26 |
-
* Conversion.
|
27 |
-
*
|
28 |
-
* @var array
|
29 |
-
*/
|
30 |
-
protected $_importUniqueHash = array();
|
31 |
-
|
32 |
-
/**
|
33 |
-
* Conversion.
|
34 |
-
*
|
35 |
-
* @var
|
36 |
-
*/
|
37 |
-
protected $_importIso2Countries;
|
38 |
-
|
39 |
-
/**
|
40 |
-
* Conversion.
|
41 |
-
*
|
42 |
-
* @var
|
43 |
-
*/
|
44 |
-
protected $_importIso3Countries;
|
45 |
-
|
46 |
-
/**
|
47 |
-
* Regions to import.
|
48 |
-
*
|
49 |
-
* @var
|
50 |
-
*/
|
51 |
-
protected $_importRegions;
|
52 |
-
|
53 |
-
/**
|
54 |
-
* Condition name selected in sysconfig.
|
55 |
-
*
|
56 |
-
* @var
|
57 |
-
*/
|
58 |
-
protected $_importConditionName;
|
59 |
-
|
60 |
-
/**
|
61 |
-
* Full name of condition selected in sysconfig.
|
62 |
-
*
|
63 |
-
* @var array
|
64 |
-
*/
|
65 |
-
protected $_conditionFullNames = array();
|
66 |
-
|
67 |
-
|
68 |
-
/**
|
69 |
-
* Initialise the model.
|
70 |
-
*/
|
71 |
-
protected function _construct()
|
72 |
-
{
|
73 |
-
$this->_init("bpost_shm/bpost_tablerates_homedelivery", "pk");
|
74 |
-
}
|
75 |
-
|
76 |
-
|
77 |
-
/**
|
78 |
-
* Fetch rate from the table for selected shipping address.
|
79 |
-
*
|
80 |
-
* @param Mage_Shipping_Model_Rate_Request $request
|
81 |
-
* @return array
|
82 |
-
*/
|
83 |
-
public function getRate(Mage_Shipping_Model_Rate_Request $request)
|
84 |
-
{
|
85 |
-
$adapter = $this->_getReadAdapter();
|
86 |
-
$bind = array(
|
87 |
-
':website_id' => (int) $request->getWebsiteId(),
|
88 |
-
':country_id' => $request->getDestCountryId(),
|
89 |
-
':region_id' => (int) $request->getDestRegionId(),
|
90 |
-
':postcode' => $request->getDestPostcode()
|
91 |
-
);
|
92 |
-
$select = $adapter->select()
|
93 |
-
->from($this->getMainTable())
|
94 |
-
->where('website_id = :website_id')
|
95 |
-
->order(array('dest_country_id DESC', 'dest_region_id DESC', 'dest_zip DESC', 'condition_value DESC'))
|
96 |
-
->limit(1);
|
97 |
-
|
98 |
-
// Render destination condition
|
99 |
-
$orWhere = '(' . implode(') OR (', array(
|
100 |
-
"dest_country_id = :country_id AND dest_region_id = :region_id AND dest_zip = :postcode",
|
101 |
-
"dest_country_id = :country_id AND dest_region_id = :region_id AND dest_zip = ''",
|
102 |
-
|
103 |
-
// Handle asterix in dest_zip field
|
104 |
-
"dest_country_id = :country_id AND dest_region_id = :region_id AND dest_zip = '*'",
|
105 |
-
"dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = '*'",
|
106 |
-
"dest_country_id = '0' AND dest_region_id = :region_id AND dest_zip = '*'",
|
107 |
-
"dest_country_id = '0' AND dest_region_id = 0 AND dest_zip = '*'",
|
108 |
-
|
109 |
-
"dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = ''",
|
110 |
-
"dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = :postcode",
|
111 |
-
"dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = '*'",
|
112 |
-
)) . ')';
|
113 |
-
$select->where($orWhere);
|
114 |
-
|
115 |
-
// Render condition by condition name
|
116 |
-
if (is_array($request->getConditionName())) {
|
117 |
-
$orWhere = array();
|
118 |
-
$i = 0;
|
119 |
-
foreach ($request->getConditionName() as $conditionName) {
|
120 |
-
$bindNameKey = sprintf(':condition_name_%d', $i);
|
121 |
-
$bindValueKey = sprintf(':condition_value_%d', $i);
|
122 |
-
$orWhere[] = "(condition_name = {$bindNameKey} AND condition_value <= {$bindValueKey})";
|
123 |
-
$bind[$bindNameKey] = $conditionName;
|
124 |
-
$bind[$bindValueKey] = $request->getData($conditionName);
|
125 |
-
$i++;
|
126 |
-
}
|
127 |
-
|
128 |
-
if ($orWhere) {
|
129 |
-
$select->where(implode(' OR ', $orWhere));
|
130 |
-
}
|
131 |
-
} else {
|
132 |
-
$bind[':condition_name'] = $request->getConditionName();
|
133 |
-
$bind[':condition_value'] = $request->getData($request->getConditionName());
|
134 |
-
|
135 |
-
$select->where('condition_name = :condition_name');
|
136 |
-
$select->where('condition_value <= :condition_value');
|
137 |
-
}
|
138 |
-
|
139 |
-
$result = $adapter->fetchRow($select, $bind);
|
140 |
-
// Normalize destination zip code
|
141 |
-
if ($result && $result['dest_zip'] == '*') {
|
142 |
-
$result['dest_zip'] = '';
|
143 |
-
}
|
144 |
-
return $result;
|
145 |
-
}
|
146 |
-
|
147 |
-
|
148 |
-
/**
|
149 |
-
* Upload and import table rates csv.
|
150 |
-
*
|
151 |
-
* @param Varien_Object $object
|
152 |
-
* @return $this
|
153 |
-
*/
|
154 |
-
public function uploadAndImport(Varien_Object $object)
|
155 |
-
{
|
156 |
-
if (empty($_FILES['groups']['tmp_name']['bpost_homedelivery']['fields']['import_homedelivery']['value'])) {
|
157 |
-
return $this;
|
158 |
-
}
|
159 |
-
|
160 |
-
$csvFile = $_FILES['groups']['tmp_name']['bpost_homedelivery']['fields']['import_homedelivery']['value'];
|
161 |
-
$website = Mage::app()->getWebsite($object->getScopeId());
|
162 |
-
|
163 |
-
$this->_importWebsiteId = (int)$website->getId();
|
164 |
-
$this->_importUniqueHash = array();
|
165 |
-
$this->_importErrors = array();
|
166 |
-
$this->_importedRows = 0;
|
167 |
-
|
168 |
-
$io = new Varien_Io_File();
|
169 |
-
$info = pathinfo($csvFile);
|
170 |
-
$io->open(array('path' => $info['dirname']));
|
171 |
-
$io->streamOpen($info['basename'], 'r');
|
172 |
-
|
173 |
-
// check and skip headers
|
174 |
-
$headers = $io->streamReadCsv();
|
175 |
-
if ($headers === false || count($headers) < 5) {
|
176 |
-
$io->streamClose();
|
177 |
-
Mage::throwException(Mage::helper('bpost_shm')->__('Invalid Table Rates File Format'));
|
178 |
-
}
|
179 |
-
if ($object->getData('groups/bpost_homedelivery/fields/condition_name/inherit') == '1') {
|
180 |
-
$conditionName = (string)Mage::getConfig()->getNode('default/carriers/bpost_homedelivery/condition_name');
|
181 |
-
} else {
|
182 |
-
$conditionName = $object->getData('groups/bpost_homedelivery/fields/condition_name/value');
|
183 |
-
}
|
184 |
-
$this->_importConditionName = $conditionName;
|
185 |
-
$adapter = $this->_getWriteAdapter();
|
186 |
-
$adapter->beginTransaction();
|
187 |
-
|
188 |
-
try {
|
189 |
-
$rowNumber = 1;
|
190 |
-
$importData = array();
|
191 |
-
|
192 |
-
$this->_loadDirectoryCountries();
|
193 |
-
$this->_loadDirectoryRegions();
|
194 |
-
|
195 |
-
// delete old data by website and condition name
|
196 |
-
$condition = array(
|
197 |
-
'website_id = ?' => $this->_importWebsiteId,
|
198 |
-
'condition_name = ?' => $this->_importConditionName
|
199 |
-
);
|
200 |
-
$adapter->delete($this->getMainTable(), $condition);
|
201 |
-
|
202 |
-
while (false !== ($csvLine = $io->streamReadCsv())) {
|
203 |
-
$rowNumber ++;
|
204 |
-
|
205 |
-
if (empty($csvLine)) {
|
206 |
-
continue;
|
207 |
-
}
|
208 |
-
|
209 |
-
$row = $this->_getImportRow($csvLine, $rowNumber);
|
210 |
-
if ($row !== false) {
|
211 |
-
$importData[] = $row;
|
212 |
-
}
|
213 |
-
|
214 |
-
if (count($importData) == 5000) {
|
215 |
-
$this->_saveImportData($importData);
|
216 |
-
$importData = array();
|
217 |
-
}
|
218 |
-
}
|
219 |
-
$this->_saveImportData($importData);
|
220 |
-
$io->streamClose();
|
221 |
-
} catch (Mage_Core_Exception $e) {
|
222 |
-
$adapter->rollback();
|
223 |
-
$io->streamClose();
|
224 |
-
Mage::throwException($e->getMessage());
|
225 |
-
} catch (Exception $e) {
|
226 |
-
$adapter->rollback();
|
227 |
-
$io->streamClose();
|
228 |
-
Mage::helper('bpost_shm')->log($e,Zend_Log::ERR);
|
229 |
-
Mage::throwException(Mage::helper('bpost_shm')->__('An error occurred while importing table rates.'));
|
230 |
-
}
|
231 |
-
|
232 |
-
$adapter->commit();
|
233 |
-
|
234 |
-
if ($this->_importErrors) {
|
235 |
-
$error = Mage::helper('bpost_shm')->__('File has not been imported. See the following list of errors: %s', implode(" \n", $this->_importErrors));
|
236 |
-
Mage::throwException($error);
|
237 |
-
}
|
238 |
-
|
239 |
-
return $this;
|
240 |
-
}
|
241 |
-
|
242 |
-
/**
|
243 |
-
* Load directory countries.
|
244 |
-
*
|
245 |
-
* @return Mage_Shipping_Model_Resource_Carrier_Tablerate
|
246 |
-
*/
|
247 |
-
protected function _loadDirectoryCountries()
|
248 |
-
{
|
249 |
-
if (!is_null($this->_importIso2Countries) && !is_null($this->_importIso3Countries)) {
|
250 |
-
return $this;
|
251 |
-
}
|
252 |
-
|
253 |
-
$this->_importIso2Countries = array();
|
254 |
-
$this->_importIso3Countries = array();
|
255 |
-
|
256 |
-
/** @var $collection Mage_Directory_Model_Resource_Country_Collection */
|
257 |
-
$collection = Mage::getResourceModel('directory/country_collection');
|
258 |
-
foreach ($collection->getData() as $row) {
|
259 |
-
$this->_importIso2Countries[$row['iso2_code']] = $row['country_id'];
|
260 |
-
$this->_importIso3Countries[$row['iso3_code']] = $row['country_id'];
|
261 |
-
}
|
262 |
-
|
263 |
-
return $this;
|
264 |
-
}
|
265 |
-
|
266 |
-
/**
|
267 |
-
* Load directory regions.
|
268 |
-
*
|
269 |
-
* @return Mage_Shipping_Model_Resource_Carrier_Tablerate
|
270 |
-
*/
|
271 |
-
protected function _loadDirectoryRegions()
|
272 |
-
{
|
273 |
-
if (!is_null($this->_importRegions)) {
|
274 |
-
return $this;
|
275 |
-
}
|
276 |
-
|
277 |
-
$this->_importRegions = array();
|
278 |
-
|
279 |
-
/** @var $collection Mage_Directory_Model_Resource_Region_Collection */
|
280 |
-
$collection = Mage::getResourceModel('directory/region_collection');
|
281 |
-
foreach ($collection->getData() as $row) {
|
282 |
-
$this->_importRegions[$row['country_id']][$row['code']] = (int)$row['region_id'];
|
283 |
-
}
|
284 |
-
|
285 |
-
return $this;
|
286 |
-
}
|
287 |
-
|
288 |
-
/**
|
289 |
-
* Return import condition full name by condition name code.
|
290 |
-
*
|
291 |
-
* @param string $conditionName
|
292 |
-
* @return string
|
293 |
-
*/
|
294 |
-
protected function _getConditionFullName($conditionName)
|
295 |
-
{
|
296 |
-
if (!isset($this->_conditionFullNames[$conditionName])) {
|
297 |
-
$name = Mage::getSingleton('shipping/carrier_tablerate')->getCode('condition_name_short', $conditionName);
|
298 |
-
$this->_conditionFullNames[$conditionName] = $name;
|
299 |
-
}
|
300 |
-
return $this->_conditionFullNames[$conditionName];
|
301 |
-
}
|
302 |
-
|
303 |
-
/**
|
304 |
-
* Validate row for import and return table rate array or false.
|
305 |
-
* Error will be add to _importErrors array.
|
306 |
-
*
|
307 |
-
* @param array $row
|
308 |
-
* @param int $rowNumber
|
309 |
-
* @return array|false
|
310 |
-
*/
|
311 |
-
protected function _getImportRow($row, $rowNumber = 0)
|
312 |
-
{
|
313 |
-
// validate row
|
314 |
-
if (count($row) < 5) {
|
315 |
-
$this->_importErrors[] = Mage::helper('bpost_shm')->__('Invalid Table Rates format in the Row #%s', $rowNumber);
|
316 |
-
return false;
|
317 |
-
}
|
318 |
-
|
319 |
-
// strip whitespace from the beginning and end of each row
|
320 |
-
foreach ($row as $k => $v) {
|
321 |
-
$row[$k] = trim($v);
|
322 |
-
}
|
323 |
-
|
324 |
-
// validate country
|
325 |
-
if (isset($this->_importIso2Countries[$row[0]])){
|
326 |
-
$countryId = $this->_importIso2Countries[$row[0]];
|
327 |
-
} elseif (isset($this->_importIso3Countries[$row[0]])) {
|
328 |
-
$countryId = $this->_importIso3Countries[$row[0]];
|
329 |
-
} elseif ($row[0] == '*' || $row[0] == '') {
|
330 |
-
$countryId = '0';
|
331 |
-
} else {
|
332 |
-
$this->_importErrors[] = Mage::helper('bpost_shm')->__('Invalid Country "%s" in the Row #%s.', $row[0], $rowNumber);
|
333 |
-
return false;
|
334 |
-
}
|
335 |
-
|
336 |
-
// validate region
|
337 |
-
if ($countryId != '0' && isset($this->_importRegions[$countryId][$row[1]])) {
|
338 |
-
$regionId = $this->_importRegions[$countryId][$row[1]];
|
339 |
-
} elseif ($row[1] == '*' || $row[1] == '') {
|
340 |
-
$regionId = 0;
|
341 |
-
} else {
|
342 |
-
$this->_importErrors[] = Mage::helper('bpost_shm')->__('Invalid Region/State "%s" in the Row #%s.', $row[1], $rowNumber);
|
343 |
-
return false;
|
344 |
-
}
|
345 |
-
|
346 |
-
// detect zip code
|
347 |
-
if ($row[2] == '*' || $row[2] == '') {
|
348 |
-
$zipCode = '*';
|
349 |
-
} else {
|
350 |
-
$zipCode = $row[2];
|
351 |
-
}
|
352 |
-
|
353 |
-
// validate condition value
|
354 |
-
$value = $this->_parseDecimalValue($row[3]);
|
355 |
-
if ($value === false) {
|
356 |
-
$this->_importErrors[] = Mage::helper('bpost_shm')->__('Invalid %s "%s" in the Row #%s.', $this->_getConditionFullName($this->_importConditionName), $row[3], $rowNumber);
|
357 |
-
return false;
|
358 |
-
}
|
359 |
-
|
360 |
-
// validate price
|
361 |
-
$price = $this->_parseDecimalValue($row[4]);
|
362 |
-
if ($price === false) {
|
363 |
-
$this->_importErrors[] = Mage::helper('bpost_shm')->__('Invalid Shipping Price "%s" in the Row #%s.', $row[4], $rowNumber);
|
364 |
-
return false;
|
365 |
-
}
|
366 |
-
|
367 |
-
// protect from duplicate
|
368 |
-
$hash = sprintf("%s-%d-%s-%F", $countryId, $regionId, $zipCode, $value);
|
369 |
-
if (isset($this->_importUniqueHash[$hash])) {
|
370 |
-
$this->_importErrors[] = Mage::helper('bpost_shm')->__('Duplicate Row #%s (Country "%s", Region/State "%s", Zip "%s" and Value "%s").', $rowNumber, $row[0], $row[1], $zipCode, $value);
|
371 |
-
return false;
|
372 |
-
}
|
373 |
-
$this->_importUniqueHash[$hash] = true;
|
374 |
-
|
375 |
-
return array(
|
376 |
-
$this->_importWebsiteId, // website_id
|
377 |
-
$countryId, // dest_country_id
|
378 |
-
$regionId, // dest_region_id,
|
379 |
-
$zipCode, // dest_zip
|
380 |
-
$this->_importConditionName,// condition_name,
|
381 |
-
$value, // condition_value
|
382 |
-
$price // price
|
383 |
-
);
|
384 |
-
}
|
385 |
-
|
386 |
-
/**
|
387 |
-
* Save all import data.
|
388 |
-
*
|
389 |
-
* @param array $data
|
390 |
-
* @return $this
|
391 |
-
*/
|
392 |
-
protected function _saveImportData(array $data)
|
393 |
-
{
|
394 |
-
if (!empty($data)) {
|
395 |
-
$columns = array('website_id', 'dest_country_id', 'dest_region_id', 'dest_zip',
|
396 |
-
'condition_name', 'condition_value', 'price');
|
397 |
-
$this->_getWriteAdapter()->insertArray($this->getMainTable(), $columns, $data);
|
398 |
-
$this->_importedRows += count($data);
|
399 |
-
}
|
400 |
-
|
401 |
-
return $this;
|
402 |
-
}
|
403 |
-
|
404 |
-
/**
|
405 |
-
* Conversion.
|
406 |
-
*
|
407 |
-
* @param $value
|
408 |
-
* @return bool|float
|
409 |
-
*/
|
410 |
-
protected function _parseDecimalValue($value)
|
411 |
-
{
|
412 |
-
if (!is_numeric($value)) {
|
413 |
-
return false;
|
414 |
-
}
|
415 |
-
$value = (float)sprintf('%.4F', $value);
|
416 |
-
if ($value < 0.0000) {
|
417 |
-
return false;
|
418 |
-
}
|
419 |
-
return $value;
|
420 |
-
}
|
421 |
}
|
1 |
+
<?php
|
2 |
+
class Bpost_ShM_Model_Resource_Tablerates_Homedelivery extends Mage_Core_Model_Resource_Db_Abstract{
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Website Id selected in scope.
|
6 |
+
*
|
7 |
+
* @var int
|
8 |
+
*/
|
9 |
+
protected $_importWebsiteId = 0;
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Array to fill with possible errors.
|
13 |
+
*
|
14 |
+
* @var array
|
15 |
+
*/
|
16 |
+
protected $_importErrors = array();
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Number of rows imported.
|
20 |
+
*
|
21 |
+
* @var int
|
22 |
+
*/
|
23 |
+
protected $_importedRows = 0;
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Conversion.
|
27 |
+
*
|
28 |
+
* @var array
|
29 |
+
*/
|
30 |
+
protected $_importUniqueHash = array();
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Conversion.
|
34 |
+
*
|
35 |
+
* @var
|
36 |
+
*/
|
37 |
+
protected $_importIso2Countries;
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Conversion.
|
41 |
+
*
|
42 |
+
* @var
|
43 |
+
*/
|
44 |
+
protected $_importIso3Countries;
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Regions to import.
|
48 |
+
*
|
49 |
+
* @var
|
50 |
+
*/
|
51 |
+
protected $_importRegions;
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Condition name selected in sysconfig.
|
55 |
+
*
|
56 |
+
* @var
|
57 |
+
*/
|
58 |
+
protected $_importConditionName;
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Full name of condition selected in sysconfig.
|
62 |
+
*
|
63 |
+
* @var array
|
64 |
+
*/
|
65 |
+
protected $_conditionFullNames = array();
|
66 |
+
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Initialise the model.
|
70 |
+
*/
|
71 |
+
protected function _construct()
|
72 |
+
{
|
73 |
+
$this->_init("bpost_shm/bpost_tablerates_homedelivery", "pk");
|
74 |
+
}
|
75 |
+
|
76 |
+
|
77 |
+
/**
|
78 |
+
* Fetch rate from the table for selected shipping address.
|
79 |
+
*
|
80 |
+
* @param Mage_Shipping_Model_Rate_Request $request
|
81 |
+
* @return array
|
82 |
+
*/
|
83 |
+
public function getRate(Mage_Shipping_Model_Rate_Request $request)
|
84 |
+
{
|
85 |
+
$adapter = $this->_getReadAdapter();
|
86 |
+
$bind = array(
|
87 |
+
':website_id' => (int) $request->getWebsiteId(),
|
88 |
+
':country_id' => $request->getDestCountryId(),
|
89 |
+
':region_id' => (int) $request->getDestRegionId(),
|
90 |
+
':postcode' => $request->getDestPostcode()
|
91 |
+
);
|
92 |
+
$select = $adapter->select()
|
93 |
+
->from($this->getMainTable())
|
94 |
+
->where('website_id = :website_id')
|
95 |
+
->order(array('dest_country_id DESC', 'dest_region_id DESC', 'dest_zip DESC', 'condition_value DESC'))
|
96 |
+
->limit(1);
|
97 |
+
|
98 |
+
// Render destination condition
|
99 |
+
$orWhere = '(' . implode(') OR (', array(
|
100 |
+
"dest_country_id = :country_id AND dest_region_id = :region_id AND dest_zip = :postcode",
|
101 |
+
"dest_country_id = :country_id AND dest_region_id = :region_id AND dest_zip = ''",
|
102 |
+
|
103 |
+
// Handle asterix in dest_zip field
|
104 |
+
"dest_country_id = :country_id AND dest_region_id = :region_id AND dest_zip = '*'",
|
105 |
+
"dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = '*'",
|
106 |
+
"dest_country_id = '0' AND dest_region_id = :region_id AND dest_zip = '*'",
|
107 |
+
"dest_country_id = '0' AND dest_region_id = 0 AND dest_zip = '*'",
|
108 |
+
|
109 |
+
"dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = ''",
|
110 |
+
"dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = :postcode",
|
111 |
+
"dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = '*'",
|
112 |
+
)) . ')';
|
113 |
+
$select->where($orWhere);
|
114 |
+
|
115 |
+
// Render condition by condition name
|
116 |
+
if (is_array($request->getConditionName())) {
|
117 |
+
$orWhere = array();
|
118 |
+
$i = 0;
|
119 |
+
foreach ($request->getConditionName() as $conditionName) {
|
120 |
+
$bindNameKey = sprintf(':condition_name_%d', $i);
|
121 |
+
$bindValueKey = sprintf(':condition_value_%d', $i);
|
122 |
+
$orWhere[] = "(condition_name = {$bindNameKey} AND condition_value <= {$bindValueKey})";
|
123 |
+
$bind[$bindNameKey] = $conditionName;
|
124 |
+
$bind[$bindValueKey] = $request->getData($conditionName);
|
125 |
+
$i++;
|
126 |
+
}
|
127 |
+
|
128 |
+
if ($orWhere) {
|
129 |
+
$select->where(implode(' OR ', $orWhere));
|
130 |
+
}
|
131 |
+
} else {
|
132 |
+
$bind[':condition_name'] = $request->getConditionName();
|
133 |
+
$bind[':condition_value'] = $request->getData($request->getConditionName());
|
134 |
+
|
135 |
+
$select->where('condition_name = :condition_name');
|
136 |
+
$select->where('condition_value <= :condition_value');
|
137 |
+
}
|
138 |
+
|
139 |
+
$result = $adapter->fetchRow($select, $bind);
|
140 |
+
// Normalize destination zip code
|
141 |
+
if ($result && $result['dest_zip'] == '*') {
|
142 |
+
$result['dest_zip'] = '';
|
143 |
+
}
|
144 |
+
return $result;
|
145 |
+
}
|
146 |
+
|
147 |
+
|
148 |
+
/**
|
149 |
+
* Upload and import table rates csv.
|
150 |
+
*
|
151 |
+
* @param Varien_Object $object
|
152 |
+
* @return $this
|
153 |
+
*/
|
154 |
+
public function uploadAndImport(Varien_Object $object)
|
155 |
+
{
|
156 |
+
if (empty($_FILES['groups']['tmp_name']['bpost_homedelivery']['fields']['import_homedelivery']['value'])) {
|
157 |
+
return $this;
|
158 |
+
}
|
159 |
+
|
160 |
+
$csvFile = $_FILES['groups']['tmp_name']['bpost_homedelivery']['fields']['import_homedelivery']['value'];
|
161 |
+
$website = Mage::app()->getWebsite($object->getScopeId());
|
162 |
+
|
163 |
+
$this->_importWebsiteId = (int)$website->getId();
|
164 |
+
$this->_importUniqueHash = array();
|
165 |
+
$this->_importErrors = array();
|
166 |
+
$this->_importedRows = 0;
|
167 |
+
|
168 |
+
$io = new Varien_Io_File();
|
169 |
+
$info = pathinfo($csvFile);
|
170 |
+
$io->open(array('path' => $info['dirname']));
|
171 |
+
$io->streamOpen($info['basename'], 'r');
|
172 |
+
|
173 |
+
// check and skip headers
|
174 |
+
$headers = $io->streamReadCsv();
|
175 |
+
if ($headers === false || count($headers) < 5) {
|
176 |
+
$io->streamClose();
|
177 |
+
Mage::throwException(Mage::helper('bpost_shm')->__('Invalid Table Rates File Format'));
|
178 |
+
}
|
179 |
+
if ($object->getData('groups/bpost_homedelivery/fields/condition_name/inherit') == '1') {
|
180 |
+
$conditionName = (string)Mage::getConfig()->getNode('default/carriers/bpost_homedelivery/condition_name');
|
181 |
+
} else {
|
182 |
+
$conditionName = $object->getData('groups/bpost_homedelivery/fields/condition_name/value');
|
183 |
+
}
|
184 |
+
$this->_importConditionName = $conditionName;
|
185 |
+
$adapter = $this->_getWriteAdapter();
|
186 |
+
$adapter->beginTransaction();
|
187 |
+
|
188 |
+
try {
|
189 |
+
$rowNumber = 1;
|
190 |
+
$importData = array();
|
191 |
+
|
192 |
+
$this->_loadDirectoryCountries();
|
193 |
+
$this->_loadDirectoryRegions();
|
194 |
+
|
195 |
+
// delete old data by website and condition name
|
196 |
+
$condition = array(
|
197 |
+
'website_id = ?' => $this->_importWebsiteId,
|
198 |
+
'condition_name = ?' => $this->_importConditionName
|
199 |
+
);
|
200 |
+
$adapter->delete($this->getMainTable(), $condition);
|
201 |
+
|
202 |
+
while (false !== ($csvLine = $io->streamReadCsv())) {
|
203 |
+
$rowNumber ++;
|
204 |
+
|
205 |
+
if (empty($csvLine)) {
|
206 |
+
continue;
|
207 |
+
}
|
208 |
+
|
209 |
+
$row = $this->_getImportRow($csvLine, $rowNumber);
|
210 |
+
if ($row !== false) {
|
211 |
+
$importData[] = $row;
|
212 |
+
}
|
213 |
+
|
214 |
+
if (count($importData) == 5000) {
|
215 |
+
$this->_saveImportData($importData);
|
216 |
+
$importData = array();
|
217 |
+
}
|
218 |
+
}
|
219 |
+
$this->_saveImportData($importData);
|
220 |
+
$io->streamClose();
|
221 |
+
} catch (Mage_Core_Exception $e) {
|
222 |
+
$adapter->rollback();
|
223 |
+
$io->streamClose();
|
224 |
+
Mage::throwException($e->getMessage());
|
225 |
+
} catch (Exception $e) {
|
226 |
+
$adapter->rollback();
|
227 |
+
$io->streamClose();
|
228 |
+
Mage::helper('bpost_shm')->log($e,Zend_Log::ERR);
|
229 |
+
Mage::throwException(Mage::helper('bpost_shm')->__('An error occurred while importing table rates.'));
|
230 |
+
}
|
231 |
+
|
232 |
+
$adapter->commit();
|
233 |
+
|
234 |
+
if ($this->_importErrors) {
|
235 |
+
$error = Mage::helper('bpost_shm')->__('File has not been imported. See the following list of errors: %s', implode(" \n", $this->_importErrors));
|
236 |
+
Mage::throwException($error);
|
237 |
+
}
|
238 |
+
|
239 |
+
return $this;
|
240 |
+
}
|
241 |
+
|
242 |
+
/**
|
243 |
+
* Load directory countries.
|
244 |
+
*
|
245 |
+
* @return Mage_Shipping_Model_Resource_Carrier_Tablerate
|
246 |
+
*/
|
247 |
+
protected function _loadDirectoryCountries()
|
248 |
+
{
|
249 |
+
if (!is_null($this->_importIso2Countries) && !is_null($this->_importIso3Countries)) {
|
250 |
+
return $this;
|
251 |
+
}
|
252 |
+
|
253 |
+
$this->_importIso2Countries = array();
|
254 |
+
$this->_importIso3Countries = array();
|
255 |
+
|
256 |
+
/** @var $collection Mage_Directory_Model_Resource_Country_Collection */
|
257 |
+
$collection = Mage::getResourceModel('directory/country_collection');
|
258 |
+
foreach ($collection->getData() as $row) {
|
259 |
+
$this->_importIso2Countries[$row['iso2_code']] = $row['country_id'];
|
260 |
+
$this->_importIso3Countries[$row['iso3_code']] = $row['country_id'];
|
261 |
+
}
|
262 |
+
|
263 |
+
return $this;
|
264 |
+
}
|
265 |
+
|
266 |
+
/**
|
267 |
+
* Load directory regions.
|
268 |
+
*
|
269 |
+
* @return Mage_Shipping_Model_Resource_Carrier_Tablerate
|
270 |
+
*/
|
271 |
+
protected function _loadDirectoryRegions()
|
272 |
+
{
|
273 |
+
if (!is_null($this->_importRegions)) {
|
274 |
+
return $this;
|
275 |
+
}
|
276 |
+
|
277 |
+
$this->_importRegions = array();
|
278 |
+
|
279 |
+
/** @var $collection Mage_Directory_Model_Resource_Region_Collection */
|
280 |
+
$collection = Mage::getResourceModel('directory/region_collection');
|
281 |
+
foreach ($collection->getData() as $row) {
|
282 |
+
$this->_importRegions[$row['country_id']][$row['code']] = (int)$row['region_id'];
|
283 |
+
}
|
284 |
+
|
285 |
+
return $this;
|
286 |
+
}
|
287 |
+
|
288 |
+
/**
|
289 |
+
* Return import condition full name by condition name code.
|
290 |
+
*
|
291 |
+
* @param string $conditionName
|
292 |
+
* @return string
|
293 |
+
*/
|
294 |
+
protected function _getConditionFullName($conditionName)
|
295 |
+
{
|
296 |
+
if (!isset($this->_conditionFullNames[$conditionName])) {
|
297 |
+
$name = Mage::getSingleton('shipping/carrier_tablerate')->getCode('condition_name_short', $conditionName);
|
298 |
+
$this->_conditionFullNames[$conditionName] = $name;
|
299 |
+
}
|
300 |
+
return $this->_conditionFullNames[$conditionName];
|
301 |
+
}
|
302 |
+
|
303 |
+
/**
|
304 |
+
* Validate row for import and return table rate array or false.
|
305 |
+
* Error will be add to _importErrors array.
|
306 |
+
*
|
307 |
+
* @param array $row
|
308 |
+
* @param int $rowNumber
|
309 |
+
* @return array|false
|
310 |
+
*/
|
311 |
+
protected function _getImportRow($row, $rowNumber = 0)
|
312 |
+
{
|
313 |
+
// validate row
|
314 |
+
if (count($row) < 5) {
|
315 |
+
$this->_importErrors[] = Mage::helper('bpost_shm')->__('Invalid Table Rates format in the Row #%s', $rowNumber);
|
316 |
+
return false;
|
317 |
+
}
|
318 |
+
|
319 |
+
// strip whitespace from the beginning and end of each row
|
320 |
+
foreach ($row as $k => $v) {
|
321 |
+
$row[$k] = trim($v);
|
322 |
+
}
|
323 |
+
|
324 |
+
// validate country
|
325 |
+
if (isset($this->_importIso2Countries[$row[0]])){
|
326 |
+
$countryId = $this->_importIso2Countries[$row[0]];
|
327 |
+
} elseif (isset($this->_importIso3Countries[$row[0]])) {
|
328 |
+
$countryId = $this->_importIso3Countries[$row[0]];
|
329 |
+
} elseif ($row[0] == '*' || $row[0] == '') {
|
330 |
+
$countryId = '0';
|
331 |
+
} else {
|
332 |
+
$this->_importErrors[] = Mage::helper('bpost_shm')->__('Invalid Country "%s" in the Row #%s.', $row[0], $rowNumber);
|
333 |
+
return false;
|
334 |
+
}
|
335 |
+
|
336 |
+
// validate region
|
337 |
+
if ($countryId != '0' && isset($this->_importRegions[$countryId][$row[1]])) {
|
338 |
+
$regionId = $this->_importRegions[$countryId][$row[1]];
|
339 |
+
} elseif ($row[1] == '*' || $row[1] == '') {
|
340 |
+
$regionId = 0;
|
341 |
+
} else {
|
342 |
+
$this->_importErrors[] = Mage::helper('bpost_shm')->__('Invalid Region/State "%s" in the Row #%s.', $row[1], $rowNumber);
|
343 |
+
return false;
|
344 |
+
}
|
345 |
+
|
346 |
+
// detect zip code
|
347 |
+
if ($row[2] == '*' || $row[2] == '') {
|
348 |
+
$zipCode = '*';
|
349 |
+
} else {
|
350 |
+
$zipCode = $row[2];
|
351 |
+
}
|
352 |
+
|
353 |
+
// validate condition value
|
354 |
+
$value = $this->_parseDecimalValue($row[3]);
|
355 |
+
if ($value === false) {
|
356 |
+
$this->_importErrors[] = Mage::helper('bpost_shm')->__('Invalid %s "%s" in the Row #%s.', $this->_getConditionFullName($this->_importConditionName), $row[3], $rowNumber);
|
357 |
+
return false;
|
358 |
+
}
|
359 |
+
|
360 |
+
// validate price
|
361 |
+
$price = $this->_parseDecimalValue($row[4]);
|
362 |
+
if ($price === false) {
|
363 |
+
$this->_importErrors[] = Mage::helper('bpost_shm')->__('Invalid Shipping Price "%s" in the Row #%s.', $row[4], $rowNumber);
|
364 |
+
return false;
|
365 |
+
}
|
366 |
+
|
367 |
+
// protect from duplicate
|
368 |
+
$hash = sprintf("%s-%d-%s-%F", $countryId, $regionId, $zipCode, $value);
|
369 |
+
if (isset($this->_importUniqueHash[$hash])) {
|
370 |
+
$this->_importErrors[] = Mage::helper('bpost_shm')->__('Duplicate Row #%s (Country "%s", Region/State "%s", Zip "%s" and Value "%s").', $rowNumber, $row[0], $row[1], $zipCode, $value);
|
371 |
+
return false;
|
372 |
+
}
|
373 |
+
$this->_importUniqueHash[$hash] = true;
|
374 |
+
|
375 |
+
return array(
|
376 |
+
$this->_importWebsiteId, // website_id
|
377 |
+
$countryId, // dest_country_id
|
378 |
+
$regionId, // dest_region_id,
|
379 |
+
$zipCode, // dest_zip
|
380 |
+
$this->_importConditionName,// condition_name,
|
381 |
+
$value, // condition_value
|
382 |
+
$price // price
|
383 |
+
);
|
384 |
+
}
|
385 |
+
|
386 |
+
/**
|
387 |
+
* Save all import data.
|
388 |
+
*
|
389 |
+
* @param array $data
|
390 |
+
* @return $this
|
391 |
+
*/
|
392 |
+
protected function _saveImportData(array $data)
|
393 |
+
{
|
394 |
+
if (!empty($data)) {
|
395 |
+
$columns = array('website_id', 'dest_country_id', 'dest_region_id', 'dest_zip',
|
396 |
+
'condition_name', 'condition_value', 'price');
|
397 |
+
$this->_getWriteAdapter()->insertArray($this->getMainTable(), $columns, $data);
|
398 |
+
$this->_importedRows += count($data);
|
399 |
+
}
|
400 |
+
|
401 |
+
return $this;
|
402 |
+
}
|
403 |
+
|
404 |
+
/**
|
405 |
+
* Conversion.
|
406 |
+
*
|
407 |
+
* @param $value
|
408 |
+
* @return bool|float
|
409 |
+
*/
|
410 |
+
protected function _parseDecimalValue($value)
|
411 |
+
{
|
412 |
+
if (!is_numeric($value)) {
|
413 |
+
return false;
|
414 |
+
}
|
415 |
+
$value = (float)sprintf('%.4F', $value);
|
416 |
+
if ($value < 0.0000) {
|
417 |
+
return false;
|
418 |
+
}
|
419 |
+
return $value;
|
420 |
+
}
|
421 |
}
|
app/code/community/Bpost/ShM/Model/Resource/Tablerates/Homedelivery/Collection.php
CHANGED
@@ -1,95 +1,95 @@
|
|
1 |
-
<?php
|
2 |
-
class Bpost_ShM_Model_Resource_Tablerates_Homedelivery_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
|
3 |
-
{
|
4 |
-
/**
|
5 |
-
* main table name
|
6 |
-
*
|
7 |
-
* @deprecated since 1.4.1.0
|
8 |
-
* @var string
|
9 |
-
*/
|
10 |
-
protected $_shipTable;
|
11 |
-
|
12 |
-
/**
|
13 |
-
* directory/country table name
|
14 |
-
*
|
15 |
-
* @var string
|
16 |
-
*/
|
17 |
-
protected $_countryTable;
|
18 |
-
|
19 |
-
/**
|
20 |
-
* directory/country_region table name
|
21 |
-
*
|
22 |
-
* @var string
|
23 |
-
*/
|
24 |
-
protected $_regionTable;
|
25 |
-
|
26 |
-
/**
|
27 |
-
* Define resource model and item
|
28 |
-
*
|
29 |
-
*/
|
30 |
-
protected function _construct()
|
31 |
-
{
|
32 |
-
$this->_init('bpost_shm/tablerates_homedelivery');
|
33 |
-
$this->_shipTable = $this->getMainTable();
|
34 |
-
$this->_countryTable = $this->getTable('directory/country');
|
35 |
-
$this->_regionTable = $this->getTable('directory/country_region');
|
36 |
-
}
|
37 |
-
|
38 |
-
/**
|
39 |
-
* Initialize select, add country iso3 code and region name
|
40 |
-
*
|
41 |
-
* @return void
|
42 |
-
*/
|
43 |
-
public function _initSelect()
|
44 |
-
{
|
45 |
-
parent::_initSelect();
|
46 |
-
|
47 |
-
$this->_select
|
48 |
-
->joinLeft(
|
49 |
-
array('country_table' => $this->_countryTable),
|
50 |
-
'country_table.country_id = main_table.dest_country_id',
|
51 |
-
array('dest_country' => 'iso3_code'))
|
52 |
-
->joinLeft(
|
53 |
-
array('region_table' => $this->_regionTable),
|
54 |
-
'region_table.region_id = main_table.dest_region_id',
|
55 |
-
array('dest_region' => 'code'));
|
56 |
-
|
57 |
-
$this->addOrder('dest_country', self::SORT_ORDER_ASC);
|
58 |
-
$this->addOrder('dest_region', self::SORT_ORDER_ASC);
|
59 |
-
$this->addOrder('dest_zip', self::SORT_ORDER_ASC);
|
60 |
-
$this->addOrder('condition_value', self::SORT_ORDER_ASC);
|
61 |
-
}
|
62 |
-
|
63 |
-
/**
|
64 |
-
* Add website filter to collection
|
65 |
-
*
|
66 |
-
* @param int $websiteId
|
67 |
-
* @return Mage_Shipping_Model_Resource_Carrier_Tablerate_Collection
|
68 |
-
*/
|
69 |
-
public function setWebsiteFilter($websiteId)
|
70 |
-
{
|
71 |
-
return $this->addFieldToFilter('website_id', $websiteId);
|
72 |
-
}
|
73 |
-
|
74 |
-
/**
|
75 |
-
* Add condition name (code) filter to collection
|
76 |
-
*
|
77 |
-
* @param string $conditionName
|
78 |
-
* @return Mage_Shipping_Model_Resource_Carrier_Tablerate_Collection
|
79 |
-
*/
|
80 |
-
public function setConditionFilter($conditionName)
|
81 |
-
{
|
82 |
-
return $this->addFieldToFilter('condition_name', $conditionName);
|
83 |
-
}
|
84 |
-
|
85 |
-
/**
|
86 |
-
* Add country filter to collection
|
87 |
-
*
|
88 |
-
* @param string $countryId
|
89 |
-
* @return Mage_Shipping_Model_Resource_Carrier_Tablerate_Collection
|
90 |
-
*/
|
91 |
-
public function setCountryFilter($countryId)
|
92 |
-
{
|
93 |
-
return $this->addFieldToFilter('dest_country_id', $countryId);
|
94 |
-
}
|
95 |
}
|
1 |
+
<?php
|
2 |
+
class Bpost_ShM_Model_Resource_Tablerates_Homedelivery_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
|
3 |
+
{
|
4 |
+
/**
|
5 |
+
* main table name
|
6 |
+
*
|
7 |
+
* @deprecated since 1.4.1.0
|
8 |
+
* @var string
|
9 |
+
*/
|
10 |
+
protected $_shipTable;
|
11 |
+
|
12 |
+
/**
|
13 |
+
* directory/country table name
|
14 |
+
*
|
15 |
+
* @var string
|
16 |
+
*/
|
17 |
+
protected $_countryTable;
|
18 |
+
|
19 |
+
/**
|
20 |
+
* directory/country_region table name
|
21 |
+
*
|
22 |
+
* @var string
|
23 |
+
*/
|
24 |
+
protected $_regionTable;
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Define resource model and item
|
28 |
+
*
|
29 |
+
*/
|
30 |
+
protected function _construct()
|
31 |
+
{
|
32 |
+
$this->_init('bpost_shm/tablerates_homedelivery');
|
33 |
+
$this->_shipTable = $this->getMainTable();
|
34 |
+
$this->_countryTable = $this->getTable('directory/country');
|
35 |
+
$this->_regionTable = $this->getTable('directory/country_region');
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Initialize select, add country iso3 code and region name
|
40 |
+
*
|
41 |
+
* @return void
|
42 |
+
*/
|
43 |
+
public function _initSelect()
|
44 |
+
{
|
45 |
+
parent::_initSelect();
|
46 |
+
|
47 |
+
$this->_select
|
48 |
+
->joinLeft(
|
49 |
+
array('country_table' => $this->_countryTable),
|
50 |
+
'country_table.country_id = main_table.dest_country_id',
|
51 |
+
array('dest_country' => 'iso3_code'))
|
52 |
+
->joinLeft(
|
53 |
+
array('region_table' => $this->_regionTable),
|
54 |
+
'region_table.region_id = main_table.dest_region_id',
|
55 |
+
array('dest_region' => 'code'));
|
56 |
+
|
57 |
+
$this->addOrder('dest_country', self::SORT_ORDER_ASC);
|
58 |
+
$this->addOrder('dest_region', self::SORT_ORDER_ASC);
|
59 |
+
$this->addOrder('dest_zip', self::SORT_ORDER_ASC);
|
60 |
+
$this->addOrder('condition_value', self::SORT_ORDER_ASC);
|
61 |
+
}
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Add website filter to collection
|
65 |
+
*
|
66 |
+
* @param int $websiteId
|
67 |
+
* @return Mage_Shipping_Model_Resource_Carrier_Tablerate_Collection
|
68 |
+
*/
|
69 |
+
public function setWebsiteFilter($websiteId)
|
70 |
+
{
|
71 |
+
return $this->addFieldToFilter('website_id', $websiteId);
|
72 |
+
}
|
73 |
+
|
74 |
+
/**
|
75 |
+
* Add condition name (code) filter to collection
|
76 |
+
*
|
77 |
+
* @param string $conditionName
|
78 |
+
* @return Mage_Shipping_Model_Resource_Carrier_Tablerate_Collection
|
79 |
+
*/
|
80 |
+
public function setConditionFilter($conditionName)
|
81 |
+
{
|
82 |
+
return $this->addFieldToFilter('condition_name', $conditionName);
|
83 |
+
}
|
84 |
+
|
85 |
+
/**
|
86 |
+
* Add country filter to collection
|
87 |
+
*
|
88 |
+
* @param string $countryId
|
89 |
+
* @return Mage_Shipping_Model_Resource_Carrier_Tablerate_Collection
|
90 |
+
*/
|
91 |
+
public function setCountryFilter($countryId)
|
92 |
+
{
|
93 |
+
return $this->addFieldToFilter('dest_country_id', $countryId);
|
94 |
+
}
|
95 |
}
|
app/code/community/Bpost/ShM/Model/Resource/Tablerates/International.php
CHANGED
@@ -1,423 +1,423 @@
|
|
1 |
-
<?php
|
2 |
-
class Bpost_ShM_Model_Resource_Tablerates_International extends Mage_Core_Model_Resource_Db_Abstract{
|
3 |
-
|
4 |
-
/**
|
5 |
-
* Website Id selected in scope.
|
6 |
-
*
|
7 |
-
* @var int
|
8 |
-
*/
|
9 |
-
protected $_importWebsiteId = 0;
|
10 |
-
|
11 |
-
/**
|
12 |
-
* Array to fill with possible errors.
|
13 |
-
*
|
14 |
-
* @var array
|
15 |
-
*/
|
16 |
-
protected $_importErrors = array();
|
17 |
-
|
18 |
-
/**
|
19 |
-
* Number of rows imported.
|
20 |
-
*
|
21 |
-
* @var int
|
22 |
-
*/
|
23 |
-
protected $_importedRows = 0;
|
24 |
-
|
25 |
-
/**
|
26 |
-
* Conversion.
|
27 |
-
*
|
28 |
-
* @var array
|
29 |
-
*/
|
30 |
-
protected $_importUniqueHash = array();
|
31 |
-
|
32 |
-
/**
|
33 |
-
* Conversion.
|
34 |
-
*
|
35 |
-
* @var
|
36 |
-
*/
|
37 |
-
protected $_importIso2Countries;
|
38 |
-
|
39 |
-
/**
|
40 |
-
* Conversion.
|
41 |
-
*
|
42 |
-
* @var
|
43 |
-
*/
|
44 |
-
protected $_importIso3Countries;
|
45 |
-
|
46 |
-
/**
|
47 |
-
* Regions to import.
|
48 |
-
*
|
49 |
-
* @var
|
50 |
-
*/
|
51 |
-
protected $_importRegions;
|
52 |
-
|
53 |
-
/**
|
54 |
-
* Condition name selected in sysconfig.
|
55 |
-
*
|
56 |
-
* @var
|
57 |
-
*/
|
58 |
-
protected $_importConditionName;
|
59 |
-
|
60 |
-
/**
|
61 |
-
* Full name of condition selected in sysconfig.
|
62 |
-
*
|
63 |
-
* @var array
|
64 |
-
*/
|
65 |
-
protected $_conditionFullNames = array();
|
66 |
-
|
67 |
-
|
68 |
-
/**
|
69 |
-
* Initialise the model.
|
70 |
-
*/
|
71 |
-
protected function _construct()
|
72 |
-
{
|
73 |
-
$this->_init("bpost_shm/bpost_tablerates_international", "pk");
|
74 |
-
}
|
75 |
-
|
76 |
-
|
77 |
-
/**
|
78 |
-
* Fetch rate from the table for selected shipping address.
|
79 |
-
*
|
80 |
-
* @param Mage_Shipping_Model_Rate_Request $request
|
81 |
-
* @return array
|
82 |
-
*/
|
83 |
-
public function getRate(Mage_Shipping_Model_Rate_Request $request)
|
84 |
-
{
|
85 |
-
$adapter = $this->_getReadAdapter();
|
86 |
-
$bind = array(
|
87 |
-
':website_id' => (int) $request->getWebsiteId(),
|
88 |
-
':country_id' => $request->getDestCountryId(),
|
89 |
-
':region_id' => (int) $request->getDestRegionId(),
|
90 |
-
':postcode' => $request->getDestPostcode()
|
91 |
-
);
|
92 |
-
$select = $adapter->select()
|
93 |
-
->from($this->getMainTable())
|
94 |
-
->where('website_id = :website_id')
|
95 |
-
->order(array('dest_country_id DESC', 'dest_region_id DESC', 'dest_zip DESC', 'condition_value DESC'))
|
96 |
-
->limit(1);
|
97 |
-
|
98 |
-
// Render destination condition
|
99 |
-
$orWhere = '(' . implode(') OR (', array(
|
100 |
-
"dest_country_id = :country_id AND dest_region_id = :region_id AND dest_zip = :postcode",
|
101 |
-
"dest_country_id = :country_id AND dest_region_id = :region_id AND dest_zip = ''",
|
102 |
-
|
103 |
-
// Handle asterix in dest_zip field
|
104 |
-
"dest_country_id = :country_id AND dest_region_id = :region_id AND dest_zip = '*'",
|
105 |
-
"dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = '*'",
|
106 |
-
"dest_country_id = '0' AND dest_region_id = :region_id AND dest_zip = '*'",
|
107 |
-
"dest_country_id = '0' AND dest_region_id = 0 AND dest_zip = '*'",
|
108 |
-
|
109 |
-
"dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = ''",
|
110 |
-
"dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = :postcode",
|
111 |
-
"dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = '*'",
|
112 |
-
)) . ')';
|
113 |
-
$select->where($orWhere);
|
114 |
-
|
115 |
-
// Render condition by condition name
|
116 |
-
if (is_array($request->getConditionName())) {
|
117 |
-
$orWhere = array();
|
118 |
-
$i = 0;
|
119 |
-
foreach ($request->getConditionName() as $conditionName) {
|
120 |
-
$bindNameKey = sprintf(':condition_name_%d', $i);
|
121 |
-
$bindValueKey = sprintf(':condition_value_%d', $i);
|
122 |
-
$orWhere[] = "(condition_name = {$bindNameKey} AND condition_value <= {$bindValueKey})";
|
123 |
-
$bind[$bindNameKey] = $conditionName;
|
124 |
-
$bind[$bindValueKey] = $request->getData($conditionName);
|
125 |
-
$i++;
|
126 |
-
}
|
127 |
-
|
128 |
-
if ($orWhere) {
|
129 |
-
$select->where(implode(' OR ', $orWhere));
|
130 |
-
}
|
131 |
-
} else {
|
132 |
-
$bind[':condition_name'] = $request->getConditionName();
|
133 |
-
$bind[':condition_value'] = $request->getData($request->getConditionName());
|
134 |
-
|
135 |
-
$select->where('condition_name = :condition_name');
|
136 |
-
$select->where('condition_value <= :condition_value');
|
137 |
-
}
|
138 |
-
|
139 |
-
$result = $adapter->fetchRow($select, $bind);
|
140 |
-
|
141 |
-
// Normalize destination zip code
|
142 |
-
if ($result && $result['dest_zip'] == '*') {
|
143 |
-
$result['dest_zip'] = '';
|
144 |
-
}
|
145 |
-
|
146 |
-
return $result;
|
147 |
-
}
|
148 |
-
|
149 |
-
|
150 |
-
/**
|
151 |
-
* Upload and import table rates csv.
|
152 |
-
*
|
153 |
-
* @param Varien_Object $object
|
154 |
-
* @return $this
|
155 |
-
*/
|
156 |
-
public function uploadAndImport(Varien_Object $object)
|
157 |
-
{
|
158 |
-
if (empty($_FILES['groups']['tmp_name']['bpost_international']['fields']['import_international']['value'])) {
|
159 |
-
return $this;
|
160 |
-
}
|
161 |
-
|
162 |
-
$csvFile = $_FILES['groups']['tmp_name']['bpost_international']['fields']['import_international']['value'];
|
163 |
-
$website = Mage::app()->getWebsite($object->getScopeId());
|
164 |
-
|
165 |
-
$this->_importWebsiteId = (int)$website->getId();
|
166 |
-
$this->_importUniqueHash = array();
|
167 |
-
$this->_importErrors = array();
|
168 |
-
$this->_importedRows = 0;
|
169 |
-
|
170 |
-
$io = new Varien_Io_File();
|
171 |
-
$info = pathinfo($csvFile);
|
172 |
-
$io->open(array('path' => $info['dirname']));
|
173 |
-
$io->streamOpen($info['basename'], 'r');
|
174 |
-
|
175 |
-
// check and skip headers
|
176 |
-
$headers = $io->streamReadCsv();
|
177 |
-
if ($headers === false || count($headers) < 5) {
|
178 |
-
$io->streamClose();
|
179 |
-
Mage::throwException(Mage::helper('bpost_shm')->__('Invalid Table Rates File Format'));
|
180 |
-
}
|
181 |
-
if ($object->getData('groups/bpost_international/fields/condition_name/inherit') == '1') {
|
182 |
-
$conditionName = (string)Mage::getConfig()->getNode('default/carriers/bpost_international/condition_name');
|
183 |
-
} else {
|
184 |
-
$conditionName = $object->getData('groups/bpost_international/fields/condition_name/value');
|
185 |
-
}
|
186 |
-
$this->_importConditionName = $conditionName;
|
187 |
-
$adapter = $this->_getWriteAdapter();
|
188 |
-
$adapter->beginTransaction();
|
189 |
-
|
190 |
-
try {
|
191 |
-
$rowNumber = 1;
|
192 |
-
$importData = array();
|
193 |
-
|
194 |
-
$this->_loadDirectoryCountries();
|
195 |
-
$this->_loadDirectoryRegions();
|
196 |
-
|
197 |
-
// delete old data by website and condition name
|
198 |
-
$condition = array(
|
199 |
-
'website_id = ?' => $this->_importWebsiteId,
|
200 |
-
'condition_name = ?' => $this->_importConditionName
|
201 |
-
);
|
202 |
-
$adapter->delete($this->getMainTable(), $condition);
|
203 |
-
|
204 |
-
while (false !== ($csvLine = $io->streamReadCsv())) {
|
205 |
-
$rowNumber ++;
|
206 |
-
|
207 |
-
if (empty($csvLine)) {
|
208 |
-
continue;
|
209 |
-
}
|
210 |
-
|
211 |
-
$row = $this->_getImportRow($csvLine, $rowNumber);
|
212 |
-
if ($row !== false) {
|
213 |
-
$importData[] = $row;
|
214 |
-
}
|
215 |
-
|
216 |
-
if (count($importData) == 5000) {
|
217 |
-
$this->_saveImportData($importData);
|
218 |
-
$importData = array();
|
219 |
-
}
|
220 |
-
}
|
221 |
-
$this->_saveImportData($importData);
|
222 |
-
$io->streamClose();
|
223 |
-
} catch (Mage_Core_Exception $e) {
|
224 |
-
$adapter->rollback();
|
225 |
-
$io->streamClose();
|
226 |
-
Mage::throwException($e->getMessage());
|
227 |
-
} catch (Exception $e) {
|
228 |
-
$adapter->rollback();
|
229 |
-
$io->streamClose();
|
230 |
-
Mage::helper('bpost_shm')->log($e,Zend_Log::ERR);
|
231 |
-
Mage::throwException(Mage::helper('bpost_shm')->__('An error occurred while importing table rates.'));
|
232 |
-
}
|
233 |
-
|
234 |
-
$adapter->commit();
|
235 |
-
|
236 |
-
if ($this->_importErrors) {
|
237 |
-
$error = Mage::helper('bpost_shm')->__('File has not been imported. See the following list of errors: %s', implode(" \n", $this->_importErrors));
|
238 |
-
Mage::throwException($error);
|
239 |
-
}
|
240 |
-
|
241 |
-
return $this;
|
242 |
-
}
|
243 |
-
|
244 |
-
/**
|
245 |
-
* Load directory countries.
|
246 |
-
*
|
247 |
-
* @return Mage_Shipping_Model_Resource_Carrier_Tablerate
|
248 |
-
*/
|
249 |
-
protected function _loadDirectoryCountries()
|
250 |
-
{
|
251 |
-
if (!is_null($this->_importIso2Countries) && !is_null($this->_importIso3Countries)) {
|
252 |
-
return $this;
|
253 |
-
}
|
254 |
-
|
255 |
-
$this->_importIso2Countries = array();
|
256 |
-
$this->_importIso3Countries = array();
|
257 |
-
|
258 |
-
/** @var $collection Mage_Directory_Model_Resource_Country_Collection */
|
259 |
-
$collection = Mage::getResourceModel('directory/country_collection');
|
260 |
-
foreach ($collection->getData() as $row) {
|
261 |
-
$this->_importIso2Countries[$row['iso2_code']] = $row['country_id'];
|
262 |
-
$this->_importIso3Countries[$row['iso3_code']] = $row['country_id'];
|
263 |
-
}
|
264 |
-
|
265 |
-
return $this;
|
266 |
-
}
|
267 |
-
|
268 |
-
/**
|
269 |
-
* Load directory regions.
|
270 |
-
*
|
271 |
-
* @return Mage_Shipping_Model_Resource_Carrier_Tablerate
|
272 |
-
*/
|
273 |
-
protected function _loadDirectoryRegions()
|
274 |
-
{
|
275 |
-
if (!is_null($this->_importRegions)) {
|
276 |
-
return $this;
|
277 |
-
}
|
278 |
-
|
279 |
-
$this->_importRegions = array();
|
280 |
-
|
281 |
-
/** @var $collection Mage_Directory_Model_Resource_Region_Collection */
|
282 |
-
$collection = Mage::getResourceModel('directory/region_collection');
|
283 |
-
foreach ($collection->getData() as $row) {
|
284 |
-
$this->_importRegions[$row['country_id']][$row['code']] = (int)$row['region_id'];
|
285 |
-
}
|
286 |
-
|
287 |
-
return $this;
|
288 |
-
}
|
289 |
-
|
290 |
-
/**
|
291 |
-
* Return import condition full name by condition name code.
|
292 |
-
*
|
293 |
-
* @param string $conditionName
|
294 |
-
* @return string
|
295 |
-
*/
|
296 |
-
protected function _getConditionFullName($conditionName)
|
297 |
-
{
|
298 |
-
if (!isset($this->_conditionFullNames[$conditionName])) {
|
299 |
-
$name = Mage::getSingleton('shipping/carrier_tablerate')->getCode('condition_name_short', $conditionName);
|
300 |
-
$this->_conditionFullNames[$conditionName] = $name;
|
301 |
-
}
|
302 |
-
return $this->_conditionFullNames[$conditionName];
|
303 |
-
}
|
304 |
-
|
305 |
-
/**
|
306 |
-
* Validate row for import and return table rate array or false.
|
307 |
-
* Error will be add to _importErrors array.
|
308 |
-
*
|
309 |
-
* @param array $row
|
310 |
-
* @param int $rowNumber
|
311 |
-
* @return array|false
|
312 |
-
*/
|
313 |
-
protected function _getImportRow($row, $rowNumber = 0)
|
314 |
-
{
|
315 |
-
// validate row
|
316 |
-
if (count($row) < 5) {
|
317 |
-
$this->_importErrors[] = Mage::helper('bpost_shm')->__('Invalid Table Rates format in the Row #%s', $rowNumber);
|
318 |
-
return false;
|
319 |
-
}
|
320 |
-
|
321 |
-
// strip whitespace from the beginning and end of each row
|
322 |
-
foreach ($row as $k => $v) {
|
323 |
-
$row[$k] = trim($v);
|
324 |
-
}
|
325 |
-
|
326 |
-
// validate country
|
327 |
-
if (isset($this->_importIso2Countries[$row[0]])){
|
328 |
-
$countryId = $this->_importIso2Countries[$row[0]];
|
329 |
-
} elseif (isset($this->_importIso3Countries[$row[0]])) {
|
330 |
-
$countryId = $this->_importIso3Countries[$row[0]];
|
331 |
-
} elseif ($row[0] == '*' || $row[0] == '') {
|
332 |
-
$countryId = '0';
|
333 |
-
} else {
|
334 |
-
$this->_importErrors[] = Mage::helper('bpost_shm')->__('Invalid Country "%s" in the Row #%s.', $row[0], $rowNumber);
|
335 |
-
return false;
|
336 |
-
}
|
337 |
-
|
338 |
-
// validate region
|
339 |
-
if ($countryId != '0' && isset($this->_importRegions[$countryId][$row[1]])) {
|
340 |
-
$regionId = $this->_importRegions[$countryId][$row[1]];
|
341 |
-
} elseif ($row[1] == '*' || $row[1] == '') {
|
342 |
-
$regionId = 0;
|
343 |
-
} else {
|
344 |
-
$this->_importErrors[] = Mage::helper('bpost_shm')->__('Invalid Region/State "%s" in the Row #%s.', $row[1], $rowNumber);
|
345 |
-
return false;
|
346 |
-
}
|
347 |
-
|
348 |
-
// detect zip code
|
349 |
-
if ($row[2] == '*' || $row[2] == '') {
|
350 |
-
$zipCode = '*';
|
351 |
-
} else {
|
352 |
-
$zipCode = $row[2];
|
353 |
-
}
|
354 |
-
|
355 |
-
// validate condition value
|
356 |
-
$value = $this->_parseDecimalValue($row[3]);
|
357 |
-
if ($value === false) {
|
358 |
-
$this->_importErrors[] = Mage::helper('bpost_shm')->__('Invalid %s "%s" in the Row #%s.', $this->_getConditionFullName($this->_importConditionName), $row[3], $rowNumber);
|
359 |
-
return false;
|
360 |
-
}
|
361 |
-
|
362 |
-
// validate price
|
363 |
-
$price = $this->_parseDecimalValue($row[4]);
|
364 |
-
if ($price === false) {
|
365 |
-
$this->_importErrors[] = Mage::helper('bpost_shm')->__('Invalid Shipping Price "%s" in the Row #%s.', $row[4], $rowNumber);
|
366 |
-
return false;
|
367 |
-
}
|
368 |
-
|
369 |
-
// protect from duplicate
|
370 |
-
$hash = sprintf("%s-%d-%s-%F", $countryId, $regionId, $zipCode, $value);
|
371 |
-
if (isset($this->_importUniqueHash[$hash])) {
|
372 |
-
$this->_importErrors[] = Mage::helper('bpost_shm')->__('Duplicate Row #%s (Country "%s", Region/State "%s", Zip "%s" and Value "%s").', $rowNumber, $row[0], $row[1], $zipCode, $value);
|
373 |
-
return false;
|
374 |
-
}
|
375 |
-
$this->_importUniqueHash[$hash] = true;
|
376 |
-
|
377 |
-
return array(
|
378 |
-
$this->_importWebsiteId, // website_id
|
379 |
-
$countryId, // dest_country_id
|
380 |
-
$regionId, // dest_region_id,
|
381 |
-
$zipCode, // dest_zip
|
382 |
-
$this->_importConditionName,// condition_name,
|
383 |
-
$value, // condition_value
|
384 |
-
$price // price
|
385 |
-
);
|
386 |
-
}
|
387 |
-
|
388 |
-
/**
|
389 |
-
* Save all import data.
|
390 |
-
*
|
391 |
-
* @param array $data
|
392 |
-
* @return $this
|
393 |
-
*/
|
394 |
-
protected function _saveImportData(array $data)
|
395 |
-
{
|
396 |
-
if (!empty($data)) {
|
397 |
-
$columns = array('website_id', 'dest_country_id', 'dest_region_id', 'dest_zip',
|
398 |
-
'condition_name', 'condition_value', 'price');
|
399 |
-
$this->_getWriteAdapter()->insertArray($this->getMainTable(), $columns, $data);
|
400 |
-
$this->_importedRows += count($data);
|
401 |
-
}
|
402 |
-
|
403 |
-
return $this;
|
404 |
-
}
|
405 |
-
|
406 |
-
/**
|
407 |
-
* Conversion.
|
408 |
-
*
|
409 |
-
* @param $value
|
410 |
-
* @return bool|float
|
411 |
-
*/
|
412 |
-
protected function _parseDecimalValue($value)
|
413 |
-
{
|
414 |
-
if (!is_numeric($value)) {
|
415 |
-
return false;
|
416 |
-
}
|
417 |
-
$value = (float)sprintf('%.4F', $value);
|
418 |
-
if ($value < 0.0000) {
|
419 |
-
return false;
|
420 |
-
}
|
421 |
-
return $value;
|
422 |
-
}
|
423 |
}
|
1 |
+
<?php
|
2 |
+
class Bpost_ShM_Model_Resource_Tablerates_International extends Mage_Core_Model_Resource_Db_Abstract{
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Website Id selected in scope.
|
6 |
+
*
|
7 |
+
* @var int
|
8 |
+
*/
|
9 |
+
protected $_importWebsiteId = 0;
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Array to fill with possible errors.
|
13 |
+
*
|
14 |
+
* @var array
|
15 |
+
*/
|
16 |
+
protected $_importErrors = array();
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Number of rows imported.
|
20 |
+
*
|
21 |
+
* @var int
|
22 |
+
*/
|
23 |
+
protected $_importedRows = 0;
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Conversion.
|
27 |
+
*
|
28 |
+
* @var array
|
29 |
+
*/
|
30 |
+
protected $_importUniqueHash = array();
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Conversion.
|
34 |
+
*
|
35 |
+
* @var
|
36 |
+
*/
|
37 |
+
protected $_importIso2Countries;
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Conversion.
|
41 |
+
*
|
42 |
+
* @var
|
43 |
+
*/
|
44 |
+
protected $_importIso3Countries;
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Regions to import.
|
48 |
+
*
|
49 |
+
* @var
|
50 |
+
*/
|
51 |
+
protected $_importRegions;
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Condition name selected in sysconfig.
|
55 |
+
*
|
56 |
+
* @var
|
57 |
+
*/
|
58 |
+
protected $_importConditionName;
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Full name of condition selected in sysconfig.
|
62 |
+
*
|
63 |
+
* @var array
|
64 |
+
*/
|
65 |
+
protected $_conditionFullNames = array();
|
66 |
+
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Initialise the model.
|
70 |
+
*/
|
71 |
+
protected function _construct()
|
72 |
+
{
|
73 |
+
$this->_init("bpost_shm/bpost_tablerates_international", "pk");
|
74 |
+
}
|
75 |
+
|
76 |
+
|
77 |
+
/**
|
78 |
+
* Fetch rate from the table for selected shipping address.
|
79 |
+
*
|
80 |
+
* @param Mage_Shipping_Model_Rate_Request $request
|
81 |
+
* @return array
|
82 |
+
*/
|
83 |
+
public function getRate(Mage_Shipping_Model_Rate_Request $request)
|
84 |
+
{
|
85 |
+
$adapter = $this->_getReadAdapter();
|
86 |
+
$bind = array(
|
87 |
+
':website_id' => (int) $request->getWebsiteId(),
|
88 |
+
':country_id' => $request->getDestCountryId(),
|
89 |
+
':region_id' => (int) $request->getDestRegionId(),
|
90 |
+
':postcode' => $request->getDestPostcode()
|
91 |
+
);
|
92 |
+
$select = $adapter->select()
|
93 |
+
->from($this->getMainTable())
|
94 |
+
->where('website_id = :website_id')
|
95 |
+
->order(array('dest_country_id DESC', 'dest_region_id DESC', 'dest_zip DESC', 'condition_value DESC'))
|
96 |
+
->limit(1);
|
97 |
+
|
98 |
+
// Render destination condition
|
99 |
+
$orWhere = '(' . implode(') OR (', array(
|
100 |
+
"dest_country_id = :country_id AND dest_region_id = :region_id AND dest_zip = :postcode",
|
101 |
+
"dest_country_id = :country_id AND dest_region_id = :region_id AND dest_zip = ''",
|
102 |
+
|
103 |
+
// Handle asterix in dest_zip field
|
104 |
+
"dest_country_id = :country_id AND dest_region_id = :region_id AND dest_zip = '*'",
|
105 |
+
"dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = '*'",
|
106 |
+
"dest_country_id = '0' AND dest_region_id = :region_id AND dest_zip = '*'",
|
107 |
+
"dest_country_id = '0' AND dest_region_id = 0 AND dest_zip = '*'",
|
108 |
+
|
109 |
+
"dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = ''",
|
110 |
+
"dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = :postcode",
|
111 |
+
"dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = '*'",
|
112 |
+
)) . ')';
|
113 |
+
$select->where($orWhere);
|
114 |
+
|
115 |
+
// Render condition by condition name
|
116 |
+
if (is_array($request->getConditionName())) {
|
117 |
+
$orWhere = array();
|
118 |
+
$i = 0;
|
119 |
+
foreach ($request->getConditionName() as $conditionName) {
|
120 |
+
$bindNameKey = sprintf(':condition_name_%d', $i);
|
121 |
+
$bindValueKey = sprintf(':condition_value_%d', $i);
|
122 |
+
$orWhere[] = "(condition_name = {$bindNameKey} AND condition_value <= {$bindValueKey})";
|
123 |
+
$bind[$bindNameKey] = $conditionName;
|
124 |
+
$bind[$bindValueKey] = $request->getData($conditionName);
|
125 |
+
$i++;
|
126 |
+
}
|
127 |
+
|
128 |
+
if ($orWhere) {
|
129 |
+
$select->where(implode(' OR ', $orWhere));
|
130 |
+
}
|
131 |
+
} else {
|
132 |
+
$bind[':condition_name'] = $request->getConditionName();
|
133 |
+
$bind[':condition_value'] = $request->getData($request->getConditionName());
|
134 |
+
|
135 |
+
$select->where('condition_name = :condition_name');
|
136 |
+
$select->where('condition_value <= :condition_value');
|
137 |
+
}
|
138 |
+
|
139 |
+
$result = $adapter->fetchRow($select, $bind);
|
140 |
+
|
141 |
+
// Normalize destination zip code
|
142 |
+
if ($result && $result['dest_zip'] == '*') {
|
143 |
+
$result['dest_zip'] = '';
|
144 |
+
}
|
145 |
+
|
146 |
+
return $result;
|
147 |
+
}
|
148 |
+
|
149 |
+
|
150 |
+
/**
|
151 |
+
* Upload and import table rates csv.
|
152 |
+
*
|
153 |
+
* @param Varien_Object $object
|
154 |
+
* @return $this
|
155 |
+
*/
|
156 |
+
public function uploadAndImport(Varien_Object $object)
|
157 |
+
{
|
158 |
+
if (empty($_FILES['groups']['tmp_name']['bpost_international']['fields']['import_international']['value'])) {
|
159 |
+
return $this;
|
160 |
+
}
|
161 |
+
|
162 |
+
$csvFile = $_FILES['groups']['tmp_name']['bpost_international']['fields']['import_international']['value'];
|
163 |
+
$website = Mage::app()->getWebsite($object->getScopeId());
|
164 |
+
|
165 |
+
$this->_importWebsiteId = (int)$website->getId();
|
166 |
+
$this->_importUniqueHash = array();
|
167 |
+
$this->_importErrors = array();
|
168 |
+
$this->_importedRows = 0;
|
169 |
+
|
170 |
+
$io = new Varien_Io_File();
|
171 |
+
$info = pathinfo($csvFile);
|
172 |
+
$io->open(array('path' => $info['dirname']));
|
173 |
+
$io->streamOpen($info['basename'], 'r');
|
174 |
+
|
175 |
+
// check and skip headers
|
176 |
+
$headers = $io->streamReadCsv();
|
177 |
+
if ($headers === false || count($headers) < 5) {
|
178 |
+
$io->streamClose();
|
179 |
+
Mage::throwException(Mage::helper('bpost_shm')->__('Invalid Table Rates File Format'));
|
180 |
+
}
|
181 |
+
if ($object->getData('groups/bpost_international/fields/condition_name/inherit') == '1') {
|
182 |
+
$conditionName = (string)Mage::getConfig()->getNode('default/carriers/bpost_international/condition_name');
|
183 |
+
} else {
|
184 |
+
$conditionName = $object->getData('groups/bpost_international/fields/condition_name/value');
|
185 |
+
}
|
186 |
+
$this->_importConditionName = $conditionName;
|
187 |
+
$adapter = $this->_getWriteAdapter();
|
188 |
+
$adapter->beginTransaction();
|
189 |
+
|
190 |
+
try {
|
191 |
+
$rowNumber = 1;
|
192 |
+
$importData = array();
|
193 |
+
|
194 |
+
$this->_loadDirectoryCountries();
|
195 |
+
$this->_loadDirectoryRegions();
|
196 |
+
|
197 |
+
// delete old data by website and condition name
|
198 |
+
$condition = array(
|
199 |
+
'website_id = ?' => $this->_importWebsiteId,
|
200 |
+
'condition_name = ?' => $this->_importConditionName
|
201 |
+
);
|
202 |
+
$adapter->delete($this->getMainTable(), $condition);
|
203 |
+
|
204 |
+
while (false !== ($csvLine = $io->streamReadCsv())) {
|
205 |
+
$rowNumber ++;
|
206 |
+
|
207 |
+
if (empty($csvLine)) {
|
208 |
+
continue;
|
209 |
+
}
|
210 |
+
|
211 |
+
$row = $this->_getImportRow($csvLine, $rowNumber);
|
212 |
+
if ($row !== false) {
|
213 |
+
$importData[] = $row;
|
214 |
+
}
|
215 |
+
|
216 |
+
if (count($importData) == 5000) {
|
217 |
+
$this->_saveImportData($importData);
|
218 |
+
$importData = array();
|
219 |
+
}
|
220 |
+
}
|
221 |
+
$this->_saveImportData($importData);
|
222 |
+
$io->streamClose();
|
223 |
+
} catch (Mage_Core_Exception $e) {
|
224 |
+
$adapter->rollback();
|
225 |
+
$io->streamClose();
|
226 |
+
Mage::throwException($e->getMessage());
|
227 |
+
} catch (Exception $e) {
|
228 |
+
$adapter->rollback();
|
229 |
+
$io->streamClose();
|
230 |
+
Mage::helper('bpost_shm')->log($e,Zend_Log::ERR);
|
231 |
+
Mage::throwException(Mage::helper('bpost_shm')->__('An error occurred while importing table rates.'));
|
232 |
+
}
|
233 |
+
|
234 |
+
$adapter->commit();
|
235 |
+
|
236 |
+
if ($this->_importErrors) {
|
237 |
+
$error = Mage::helper('bpost_shm')->__('File has not been imported. See the following list of errors: %s', implode(" \n", $this->_importErrors));
|
238 |
+
Mage::throwException($error);
|
239 |
+
}
|
240 |
+
|
241 |
+
return $this;
|
242 |
+
}
|
243 |
+
|
244 |
+
/**
|
245 |
+
* Load directory countries.
|
246 |
+
*
|
247 |
+
* @return Mage_Shipping_Model_Resource_Carrier_Tablerate
|
248 |
+
*/
|
249 |
+
protected function _loadDirectoryCountries()
|
250 |
+
{
|
251 |
+
if (!is_null($this->_importIso2Countries) && !is_null($this->_importIso3Countries)) {
|
252 |
+
return $this;
|
253 |
+
}
|
254 |
+
|
255 |
+
$this->_importIso2Countries = array();
|
256 |
+
$this->_importIso3Countries = array();
|
257 |
+
|
258 |
+
/** @var $collection Mage_Directory_Model_Resource_Country_Collection */
|
259 |
+
$collection = Mage::getResourceModel('directory/country_collection');
|
260 |
+
foreach ($collection->getData() as $row) {
|
261 |
+
$this->_importIso2Countries[$row['iso2_code']] = $row['country_id'];
|
262 |
+
$this->_importIso3Countries[$row['iso3_code']] = $row['country_id'];
|
263 |
+
}
|
264 |
+
|
265 |
+
return $this;
|
266 |
+
}
|
267 |
+
|
268 |
+
/**
|
269 |
+
* Load directory regions.
|
270 |
+
*
|
271 |
+
* @return Mage_Shipping_Model_Resource_Carrier_Tablerate
|
272 |
+
*/
|
273 |
+
protected function _loadDirectoryRegions()
|
274 |
+
{
|
275 |
+
if (!is_null($this->_importRegions)) {
|
276 |
+
return $this;
|
277 |
+
}
|
278 |
+
|
279 |
+
$this->_importRegions = array();
|
280 |
+
|
281 |
+
/** @var $collection Mage_Directory_Model_Resource_Region_Collection */
|
282 |
+
$collection = Mage::getResourceModel('directory/region_collection');
|
283 |
+
foreach ($collection->getData() as $row) {
|
284 |
+
$this->_importRegions[$row['country_id']][$row['code']] = (int)$row['region_id'];
|
285 |
+
}
|
286 |
+
|
287 |
+
return $this;
|
288 |
+
}
|
289 |
+
|
290 |
+
/**
|
291 |
+
* Return import condition full name by condition name code.
|
292 |
+
*
|
293 |
+
* @param string $conditionName
|
294 |
+
* @return string
|
295 |
+
*/
|
296 |
+
protected function _getConditionFullName($conditionName)
|
297 |
+
{
|
298 |
+
if (!isset($this->_conditionFullNames[$conditionName])) {
|
299 |
+
$name = Mage::getSingleton('shipping/carrier_tablerate')->getCode('condition_name_short', $conditionName);
|
300 |
+
$this->_conditionFullNames[$conditionName] = $name;
|
301 |
+
}
|
302 |
+
return $this->_conditionFullNames[$conditionName];
|
303 |
+
}
|
304 |
+
|
305 |
+
/**
|
306 |
+
* Validate row for import and return table rate array or false.
|
307 |
+
* Error will be add to _importErrors array.
|
308 |
+
*
|
309 |
+
* @param array $row
|
310 |
+
* @param int $rowNumber
|
311 |
+
* @return array|false
|
312 |
+
*/
|
313 |
+
protected function _getImportRow($row, $rowNumber = 0)
|
314 |
+
{
|
315 |
+
// validate row
|
316 |
+
if (count($row) < 5) {
|
317 |
+
$this->_importErrors[] = Mage::helper('bpost_shm')->__('Invalid Table Rates format in the Row #%s', $rowNumber);
|
318 |
+
return false;
|
319 |
+
}
|
320 |
+
|
321 |
+
// strip whitespace from the beginning and end of each row
|
322 |
+
foreach ($row as $k => $v) {
|
323 |
+
$row[$k] = trim($v);
|
324 |
+
}
|
325 |
+
|
326 |
+
// validate country
|
327 |
+
if (isset($this->_importIso2Countries[$row[0]])){
|
328 |
+
$countryId = $this->_importIso2Countries[$row[0]];
|
329 |
+
} elseif (isset($this->_importIso3Countries[$row[0]])) {
|
330 |
+
$countryId = $this->_importIso3Countries[$row[0]];
|
331 |
+
} elseif ($row[0] == '*' || $row[0] == '') {
|
332 |
+
$countryId = '0';
|
333 |
+
} else {
|
334 |
+
$this->_importErrors[] = Mage::helper('bpost_shm')->__('Invalid Country "%s" in the Row #%s.', $row[0], $rowNumber);
|
335 |
+
return false;
|
336 |
+
}
|
337 |
+
|
338 |
+
// validate region
|
339 |
+
if ($countryId != '0' && isset($this->_importRegions[$countryId][$row[1]])) {
|
340 |
+
$regionId = $this->_importRegions[$countryId][$row[1]];
|
341 |
+
} elseif ($row[1] == '*' || $row[1] == '') {
|
342 |
+
$regionId = 0;
|
343 |
+
} else {
|
344 |
+
$this->_importErrors[] = Mage::helper('bpost_shm')->__('Invalid Region/State "%s" in the Row #%s.', $row[1], $rowNumber);
|
345 |
+
return false;
|
346 |
+
}
|
347 |
+
|
348 |
+
// detect zip code
|
349 |
+
if ($row[2] == '*' || $row[2] == '') {
|
350 |
+
$zipCode = '*';
|
351 |
+
} else {
|
352 |
+
$zipCode = $row[2];
|
353 |
+
}
|
354 |
+
|
355 |
+
// validate condition value
|
356 |
+
$value = $this->_parseDecimalValue($row[3]);
|
357 |
+
if ($value === false) {
|
358 |
+
$this->_importErrors[] = Mage::helper('bpost_shm')->__('Invalid %s "%s" in the Row #%s.', $this->_getConditionFullName($this->_importConditionName), $row[3], $rowNumber);
|
359 |
+
return false;
|
360 |
+
}
|
361 |
+
|
362 |
+
// validate price
|
363 |
+
$price = $this->_parseDecimalValue($row[4]);
|
364 |
+
if ($price === false) {
|
365 |
+
$this->_importErrors[] = Mage::helper('bpost_shm')->__('Invalid Shipping Price "%s" in the Row #%s.', $row[4], $rowNumber);
|
366 |
+
return false;
|
367 |
+
}
|
368 |
+
|
369 |
+
// protect from duplicate
|
370 |
+
$hash = sprintf("%s-%d-%s-%F", $countryId, $regionId, $zipCode, $value);
|
371 |
+
if (isset($this->_importUniqueHash[$hash])) {
|
372 |
+
$this->_importErrors[] = Mage::helper('bpost_shm')->__('Duplicate Row #%s (Country "%s", Region/State "%s", Zip "%s" and Value "%s").', $rowNumber, $row[0], $row[1], $zipCode, $value);
|
373 |
+
return false;
|
374 |
+
}
|
375 |
+
$this->_importUniqueHash[$hash] = true;
|
376 |
+
|
377 |
+
return array(
|
378 |
+
$this->_importWebsiteId, // website_id
|
379 |
+
$countryId, // dest_country_id
|
380 |
+
$regionId, // dest_region_id,
|
381 |
+
$zipCode, // dest_zip
|
382 |
+
$this->_importConditionName,// condition_name,
|
383 |
+
$value, // condition_value
|
384 |
+
$price // price
|
385 |
+
);
|
386 |
+
}
|
387 |
+
|
388 |
+
/**
|
389 |
+
* Save all import data.
|
390 |
+
*
|
391 |
+
* @param array $data
|
392 |
+
* @return $this
|
393 |
+
*/
|
394 |
+
protected function _saveImportData(array $data)
|
395 |
+
{
|
396 |
+
if (!empty($data)) {
|
397 |
+
$columns = array('website_id', 'dest_country_id', 'dest_region_id', 'dest_zip',
|
398 |
+
'condition_name', 'condition_value', 'price');
|
399 |
+
$this->_getWriteAdapter()->insertArray($this->getMainTable(), $columns, $data);
|
400 |
+
$this->_importedRows += count($data);
|
401 |
+
}
|
402 |
+
|
403 |
+
return $this;
|
404 |
+
}
|
405 |
+
|
406 |
+
/**
|
407 |
+
* Conversion.
|
408 |
+
*
|
409 |
+
* @param $value
|
410 |
+
* @return bool|float
|
411 |
+
*/
|
412 |
+
protected function _parseDecimalValue($value)
|
413 |
+
{
|
414 |
+
if (!is_numeric($value)) {
|
415 |
+
return false;
|
416 |
+
}
|
417 |
+
$value = (float)sprintf('%.4F', $value);
|
418 |
+
if ($value < 0.0000) {
|
419 |
+
return false;
|
420 |
+
}
|
421 |
+
return $value;
|
422 |
+
}
|
423 |
}
|
app/code/community/Bpost/ShM/Model/Resource/Tablerates/International/Collection.php
CHANGED
@@ -1,95 +1,95 @@
|
|
1 |
-
<?php
|
2 |
-
class Bpost_ShM_Model_Resource_Tablerates_International_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
|
3 |
-
{
|
4 |
-
/**
|
5 |
-
* main table name
|
6 |
-
*
|
7 |
-
* @deprecated since 1.4.1.0
|
8 |
-
* @var string
|
9 |
-
*/
|
10 |
-
protected $_shipTable;
|
11 |
-
|
12 |
-
/**
|
13 |
-
* directory/country table name
|
14 |
-
*
|
15 |
-
* @var string
|
16 |
-
*/
|
17 |
-
protected $_countryTable;
|
18 |
-
|
19 |
-
/**
|
20 |
-
* directory/country_region table name
|
21 |
-
*
|
22 |
-
* @var string
|
23 |
-
*/
|
24 |
-
protected $_regionTable;
|
25 |
-
|
26 |
-
/**
|
27 |
-
* Define resource model and item
|
28 |
-
*
|
29 |
-
*/
|
30 |
-
protected function _construct()
|
31 |
-
{
|
32 |
-
$this->_init('bpost_shm/tablerates_international');
|
33 |
-
$this->_shipTable = $this->getMainTable();
|
34 |
-
$this->_countryTable = $this->getTable('directory/country');
|
35 |
-
$this->_regionTable = $this->getTable('directory/country_region');
|
36 |
-
}
|
37 |
-
|
38 |
-
/**
|
39 |
-
* Initialize select, add country iso3 code and region name
|
40 |
-
*
|
41 |
-
* @return void
|
42 |
-
*/
|
43 |
-
public function _initSelect()
|
44 |
-
{
|
45 |
-
parent::_initSelect();
|
46 |
-
|
47 |
-
$this->_select
|
48 |
-
->joinLeft(
|
49 |
-
array('country_table' => $this->_countryTable),
|
50 |
-
'country_table.country_id = main_table.dest_country_id',
|
51 |
-
array('dest_country' => 'iso3_code'))
|
52 |
-
->joinLeft(
|
53 |
-
array('region_table' => $this->_regionTable),
|
54 |
-
'region_table.region_id = main_table.dest_region_id',
|
55 |
-
array('dest_region' => 'code'));
|
56 |
-
|
57 |
-
$this->addOrder('dest_country', self::SORT_ORDER_ASC);
|
58 |
-
$this->addOrder('dest_region', self::SORT_ORDER_ASC);
|
59 |
-
$this->addOrder('dest_zip', self::SORT_ORDER_ASC);
|
60 |
-
$this->addOrder('condition_value', self::SORT_ORDER_ASC);
|
61 |
-
}
|
62 |
-
|
63 |
-
/**
|
64 |
-
* Add website filter to collection
|
65 |
-
*
|
66 |
-
* @param int $websiteId
|
67 |
-
* @return Mage_Shipping_Model_Resource_Carrier_Tablerate_Collection
|
68 |
-
*/
|
69 |
-
public function setWebsiteFilter($websiteId)
|
70 |
-
{
|
71 |
-
return $this->addFieldToFilter('website_id', $websiteId);
|
72 |
-
}
|
73 |
-
|
74 |
-
/**
|
75 |
-
* Add condition name (code) filter to collection
|
76 |
-
*
|
77 |
-
* @param string $conditionName
|
78 |
-
* @return Mage_Shipping_Model_Resource_Carrier_Tablerate_Collection
|
79 |
-
*/
|
80 |
-
public function setConditionFilter($conditionName)
|
81 |
-
{
|
82 |
-
return $this->addFieldToFilter('condition_name', $conditionName);
|
83 |
-
}
|
84 |
-
|
85 |
-
/**
|
86 |
-
* Add country filter to collection
|
87 |
-
*
|
88 |
-
* @param string $countryId
|
89 |
-
* @return Mage_Shipping_Model_Resource_Carrier_Tablerate_Collection
|
90 |
-
*/
|
91 |
-
public function setCountryFilter($countryId)
|
92 |
-
{
|
93 |
-
return $this->addFieldToFilter('dest_country_id', $countryId);
|
94 |
-
}
|
95 |
}
|
1 |
+
<?php
|
2 |
+
class Bpost_ShM_Model_Resource_Tablerates_International_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
|
3 |
+
{
|
4 |
+
/**
|
5 |
+
* main table name
|
6 |
+
*
|
7 |
+
* @deprecated since 1.4.1.0
|
8 |
+
* @var string
|
9 |
+
*/
|
10 |
+
protected $_shipTable;
|
11 |
+
|
12 |
+
/**
|
13 |
+
* directory/country table name
|
14 |
+
*
|
15 |
+
* @var string
|
16 |
+
*/
|
17 |
+
protected $_countryTable;
|
18 |
+
|
19 |
+
/**
|
20 |
+
* directory/country_region table name
|
21 |
+
*
|
22 |
+
* @var string
|
23 |
+
*/
|
24 |
+
protected $_regionTable;
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Define resource model and item
|
28 |
+
*
|
29 |
+
*/
|
30 |
+
protected function _construct()
|
31 |
+
{
|
32 |
+
$this->_init('bpost_shm/tablerates_international');
|
33 |
+
$this->_shipTable = $this->getMainTable();
|
34 |
+
$this->_countryTable = $this->getTable('directory/country');
|
35 |
+
$this->_regionTable = $this->getTable('directory/country_region');
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Initialize select, add country iso3 code and region name
|
40 |
+
*
|
41 |
+
* @return void
|
42 |
+
*/
|
43 |
+
public function _initSelect()
|
44 |
+
{
|
45 |
+
parent::_initSelect();
|
46 |
+
|
47 |
+
$this->_select
|
48 |
+
->joinLeft(
|
49 |
+
array('country_table' => $this->_countryTable),
|
50 |
+
'country_table.country_id = main_table.dest_country_id',
|
51 |
+
array('dest_country' => 'iso3_code'))
|
52 |
+
->joinLeft(
|
53 |
+
array('region_table' => $this->_regionTable),
|
54 |
+
'region_table.region_id = main_table.dest_region_id',
|
55 |
+
array('dest_region' => 'code'));
|
56 |
+
|
57 |
+
$this->addOrder('dest_country', self::SORT_ORDER_ASC);
|
58 |
+
$this->addOrder('dest_region', self::SORT_ORDER_ASC);
|
59 |
+
$this->addOrder('dest_zip', self::SORT_ORDER_ASC);
|
60 |
+
$this->addOrder('condition_value', self::SORT_ORDER_ASC);
|
61 |
+
}
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Add website filter to collection
|
65 |
+
*
|
66 |
+
* @param int $websiteId
|
67 |
+
* @return Mage_Shipping_Model_Resource_Carrier_Tablerate_Collection
|
68 |
+
*/
|
69 |
+
public function setWebsiteFilter($websiteId)
|
70 |
+
{
|
71 |
+
return $this->addFieldToFilter('website_id', $websiteId);
|
72 |
+
}
|
73 |
+
|
74 |
+
/**
|
75 |
+
* Add condition name (code) filter to collection
|
76 |
+
*
|
77 |
+
* @param string $conditionName
|
78 |
+
* @return Mage_Shipping_Model_Resource_Carrier_Tablerate_Collection
|
79 |
+
*/
|
80 |
+
public function setConditionFilter($conditionName)
|
81 |
+
{
|
82 |
+
return $this->addFieldToFilter('condition_name', $conditionName);
|
83 |
+
}
|
84 |
+
|
85 |
+
/**
|
86 |
+
* Add country filter to collection
|
87 |
+
*
|
88 |
+
* @param string $countryId
|
89 |
+
* @return Mage_Shipping_Model_Resource_Carrier_Tablerate_Collection
|
90 |
+
*/
|
91 |
+
public function setCountryFilter($countryId)
|
92 |
+
{
|
93 |
+
return $this->addFieldToFilter('dest_country_id', $countryId);
|
94 |
+
}
|
95 |
}
|
app/code/community/Bpost/ShM/Model/Resource/Tablerates/Parcellocker.php
CHANGED
@@ -1,421 +1,421 @@
|
|
1 |
-
<?php
|
2 |
-
class Bpost_ShM_Model_Resource_Tablerates_Parcellocker extends Mage_Core_Model_Resource_Db_Abstract{
|
3 |
-
|
4 |
-
/**
|
5 |
-
* Website Id selected in scope.
|
6 |
-
*
|
7 |
-
* @var int
|
8 |
-
*/
|
9 |
-
protected $_importWebsiteId = 0;
|
10 |
-
|
11 |
-
/**
|
12 |
-
* Array to fill with possible errors.
|
13 |
-
*
|
14 |
-
* @var array
|
15 |
-
*/
|
16 |
-
protected $_importErrors = array();
|
17 |
-
|
18 |
-
/**
|
19 |
-
* Number of rows imported.
|
20 |
-
*
|
21 |
-
* @var int
|
22 |
-
*/
|
23 |
-
protected $_importedRows = 0;
|
24 |
-
|
25 |
-
/**
|
26 |
-
* Conversion.
|
27 |
-
*
|
28 |
-
* @var array
|
29 |
-
*/
|
30 |
-
protected $_importUniqueHash = array();
|
31 |
-
|
32 |
-
/**
|
33 |
-
* Conversion.
|
34 |
-
*
|
35 |
-
* @var
|
36 |
-
*/
|
37 |
-
protected $_importIso2Countries;
|
38 |
-
|
39 |
-
/**
|
40 |
-
* Conversion.
|
41 |
-
*
|
42 |
-
* @var
|
43 |
-
*/
|
44 |
-
protected $_importIso3Countries;
|
45 |
-
|
46 |
-
/**
|
47 |
-
* Regions to import.
|
48 |
-
*
|
49 |
-
* @var
|
50 |
-
*/
|
51 |
-
protected $_importRegions;
|
52 |
-
|
53 |
-
/**
|
54 |
-
* Condition name selected in sysconfig.
|
55 |
-
*
|
56 |
-
* @var
|
57 |
-
*/
|
58 |
-
protected $_importConditionName;
|
59 |
-
|
60 |
-
/**
|
61 |
-
* Full name of condition selected in sysconfig.
|
62 |
-
*
|
63 |
-
* @var array
|
64 |
-
*/
|
65 |
-
protected $_conditionFullNames = array();
|
66 |
-
|
67 |
-
|
68 |
-
/**
|
69 |
-
* Initialise the model.
|
70 |
-
*/
|
71 |
-
protected function _construct()
|
72 |
-
{
|
73 |
-
$this->_init("bpost_shm/bpost_tablerates_parcellocker", "pk");
|
74 |
-
}
|
75 |
-
|
76 |
-
|
77 |
-
/**
|
78 |
-
* Fetch rate from the table for selected shipping address.
|
79 |
-
*
|
80 |
-
* @param Mage_Shipping_Model_Rate_Request $request
|
81 |
-
* @return array
|
82 |
-
*/
|
83 |
-
public function getRate(Mage_Shipping_Model_Rate_Request $request)
|
84 |
-
{
|
85 |
-
$adapter = $this->_getReadAdapter();
|
86 |
-
$bind = array(
|
87 |
-
':website_id' => (int) $request->getWebsiteId(),
|
88 |
-
':country_id' => $request->getDestCountryId(),
|
89 |
-
':region_id' => (int) $request->getDestRegionId(),
|
90 |
-
':postcode' => $request->getDestPostcode()
|
91 |
-
);
|
92 |
-
$select = $adapter->select()
|
93 |
-
->from($this->getMainTable())
|
94 |
-
->where('website_id = :website_id')
|
95 |
-
->order(array('dest_country_id DESC', 'dest_region_id DESC', 'dest_zip DESC', 'condition_value DESC'))
|
96 |
-
->limit(1);
|
97 |
-
|
98 |
-
// Render destination condition
|
99 |
-
$orWhere = '(' . implode(') OR (', array(
|
100 |
-
"dest_country_id = :country_id AND dest_region_id = :region_id AND dest_zip = :postcode",
|
101 |
-
"dest_country_id = :country_id AND dest_region_id = :region_id AND dest_zip = ''",
|
102 |
-
|
103 |
-
// Handle asterix in dest_zip field
|
104 |
-
"dest_country_id = :country_id AND dest_region_id = :region_id AND dest_zip = '*'",
|
105 |
-
"dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = '*'",
|
106 |
-
"dest_country_id = '0' AND dest_region_id = :region_id AND dest_zip = '*'",
|
107 |
-
"dest_country_id = '0' AND dest_region_id = 0 AND dest_zip = '*'",
|
108 |
-
|
109 |
-
"dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = ''",
|
110 |
-
"dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = :postcode",
|
111 |
-
"dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = '*'",
|
112 |
-
)) . ')';
|
113 |
-
$select->where($orWhere);
|
114 |
-
|
115 |
-
// Render condition by condition name
|
116 |
-
if (is_array($request->getConditionName())) {
|
117 |
-
$orWhere = array();
|
118 |
-
$i = 0;
|
119 |
-
foreach ($request->getConditionName() as $conditionName) {
|
120 |
-
$bindNameKey = sprintf(':condition_name_%d', $i);
|
121 |
-
$bindValueKey = sprintf(':condition_value_%d', $i);
|
122 |
-
$orWhere[] = "(condition_name = {$bindNameKey} AND condition_value <= {$bindValueKey})";
|
123 |
-
$bind[$bindNameKey] = $conditionName;
|
124 |
-
$bind[$bindValueKey] = $request->getData($conditionName);
|
125 |
-
$i++;
|
126 |
-
}
|
127 |
-
|
128 |
-
if ($orWhere) {
|
129 |
-
$select->where(implode(' OR ', $orWhere));
|
130 |
-
}
|
131 |
-
} else {
|
132 |
-
$bind[':condition_name'] = $request->getConditionName();
|
133 |
-
$bind[':condition_value'] = $request->getData($request->getConditionName());
|
134 |
-
|
135 |
-
$select->where('condition_name = :condition_name');
|
136 |
-
$select->where('condition_value <= :condition_value');
|
137 |
-
}
|
138 |
-
|
139 |
-
$result = $adapter->fetchRow($select, $bind);
|
140 |
-
// Normalize destination zip code
|
141 |
-
if ($result && $result['dest_zip'] == '*') {
|
142 |
-
$result['dest_zip'] = '';
|
143 |
-
}
|
144 |
-
return $result;
|
145 |
-
}
|
146 |
-
|
147 |
-
|
148 |
-
/**
|
149 |
-
* Upload and import table rates csv.
|
150 |
-
*
|
151 |
-
* @param Varien_Object $object
|
152 |
-
* @return $this
|
153 |
-
*/
|
154 |
-
public function uploadAndImport(Varien_Object $object)
|
155 |
-
{
|
156 |
-
if (empty($_FILES['groups']['tmp_name']['bpost_parcellocker']['fields']['import_parcellocker']['value'])) {
|
157 |
-
return $this;
|
158 |
-
}
|
159 |
-
|
160 |
-
$csvFile = $_FILES['groups']['tmp_name']['bpost_parcellocker']['fields']['import_parcellocker']['value'];
|
161 |
-
$website = Mage::app()->getWebsite($object->getScopeId());
|
162 |
-
|
163 |
-
$this->_importWebsiteId = (int)$website->getId();
|
164 |
-
$this->_importUniqueHash = array();
|
165 |
-
$this->_importErrors = array();
|
166 |
-
$this->_importedRows = 0;
|
167 |
-
|
168 |
-
$io = new Varien_Io_File();
|
169 |
-
$info = pathinfo($csvFile);
|
170 |
-
$io->open(array('path' => $info['dirname']));
|
171 |
-
$io->streamOpen($info['basename'], 'r');
|
172 |
-
|
173 |
-
// check and skip headers
|
174 |
-
$headers = $io->streamReadCsv();
|
175 |
-
if ($headers === false || count($headers) < 5) {
|
176 |
-
$io->streamClose();
|
177 |
-
Mage::throwException(Mage::helper('bpost_shm')->__('Invalid Table Rates File Format'));
|
178 |
-
}
|
179 |
-
if ($object->getData('groups/bpost_parcellocker/fields/condition_name/inherit') == '1') {
|
180 |
-
$conditionName = (string)Mage::getConfig()->getNode('default/carriers/bpost_parcellocker/condition_name');
|
181 |
-
} else {
|
182 |
-
$conditionName = $object->getData('groups/bpost_parcellocker/fields/condition_name/value');
|
183 |
-
}
|
184 |
-
$this->_importConditionName = $conditionName;
|
185 |
-
$adapter = $this->_getWriteAdapter();
|
186 |
-
$adapter->beginTransaction();
|
187 |
-
|
188 |
-
try {
|
189 |
-
$rowNumber = 1;
|
190 |
-
$importData = array();
|
191 |
-
|
192 |
-
$this->_loadDirectoryCountries();
|
193 |
-
$this->_loadDirectoryRegions();
|
194 |
-
|
195 |
-
// delete old data by website and condition name
|
196 |
-
$condition = array(
|
197 |
-
'website_id = ?' => $this->_importWebsiteId,
|
198 |
-
'condition_name = ?' => $this->_importConditionName
|
199 |
-
);
|
200 |
-
$adapter->delete($this->getMainTable(), $condition);
|
201 |
-
|
202 |
-
while (false !== ($csvLine = $io->streamReadCsv())) {
|
203 |
-
$rowNumber ++;
|
204 |
-
|
205 |
-
if (empty($csvLine)) {
|
206 |
-
continue;
|
207 |
-
}
|
208 |
-
|
209 |
-
$row = $this->_getImportRow($csvLine, $rowNumber);
|
210 |
-
if ($row !== false) {
|
211 |
-
$importData[] = $row;
|
212 |
-
}
|
213 |
-
|
214 |
-
if (count($importData) == 5000) {
|
215 |
-
$this->_saveImportData($importData);
|
216 |
-
$importData = array();
|
217 |
-
}
|
218 |
-
}
|
219 |
-
$this->_saveImportData($importData);
|
220 |
-
$io->streamClose();
|
221 |
-
} catch (Mage_Core_Exception $e) {
|
222 |
-
$adapter->rollback();
|
223 |
-
$io->streamClose();
|
224 |
-
Mage::throwException($e->getMessage());
|
225 |
-
} catch (Exception $e) {
|
226 |
-
$adapter->rollback();
|
227 |
-
$io->streamClose();
|
228 |
-
Mage::helper('bpost_shm')->log($e,Zend_Log::ERR);
|
229 |
-
Mage::throwException(Mage::helper('bpost_shm')->__('An error occurred while importing table rates.'));
|
230 |
-
}
|
231 |
-
|
232 |
-
$adapter->commit();
|
233 |
-
|
234 |
-
if ($this->_importErrors) {
|
235 |
-
$error = Mage::helper('bpost_shm')->__('File has not been imported. See the following list of errors: %s', implode(" \n", $this->_importErrors));
|
236 |
-
Mage::throwException($error);
|
237 |
-
}
|
238 |
-
|
239 |
-
return $this;
|
240 |
-
}
|
241 |
-
|
242 |
-
/**
|
243 |
-
* Load directory countries.
|
244 |
-
*
|
245 |
-
* @return Mage_Shipping_Model_Resource_Carrier_Tablerate
|
246 |
-
*/
|
247 |
-
protected function _loadDirectoryCountries()
|
248 |
-
{
|
249 |
-
if (!is_null($this->_importIso2Countries) && !is_null($this->_importIso3Countries)) {
|
250 |
-
return $this;
|
251 |
-
}
|
252 |
-
|
253 |
-
$this->_importIso2Countries = array();
|
254 |
-
$this->_importIso3Countries = array();
|
255 |
-
|
256 |
-
/** @var $collection Mage_Directory_Model_Resource_Country_Collection */
|
257 |
-
$collection = Mage::getResourceModel('directory/country_collection');
|
258 |
-
foreach ($collection->getData() as $row) {
|
259 |
-
$this->_importIso2Countries[$row['iso2_code']] = $row['country_id'];
|
260 |
-
$this->_importIso3Countries[$row['iso3_code']] = $row['country_id'];
|
261 |
-
}
|
262 |
-
|
263 |
-
return $this;
|
264 |
-
}
|
265 |
-
|
266 |
-
/**
|
267 |
-
* Load directory regions.
|
268 |
-
*
|
269 |
-
* @return Mage_Shipping_Model_Resource_Carrier_Tablerate
|
270 |
-
*/
|
271 |
-
protected function _loadDirectoryRegions()
|
272 |
-
{
|
273 |
-
if (!is_null($this->_importRegions)) {
|
274 |
-
return $this;
|
275 |
-
}
|
276 |
-
|
277 |
-
$this->_importRegions = array();
|
278 |
-
|
279 |
-
/** @var $collection Mage_Directory_Model_Resource_Region_Collection */
|
280 |
-
$collection = Mage::getResourceModel('directory/region_collection');
|
281 |
-
foreach ($collection->getData() as $row) {
|
282 |
-
$this->_importRegions[$row['country_id']][$row['code']] = (int)$row['region_id'];
|
283 |
-
}
|
284 |
-
|
285 |
-
return $this;
|
286 |
-
}
|
287 |
-
|
288 |
-
/**
|
289 |
-
* Return import condition full name by condition name code.
|
290 |
-
*
|
291 |
-
* @param string $conditionName
|
292 |
-
* @return string
|
293 |
-
*/
|
294 |
-
protected function _getConditionFullName($conditionName)
|
295 |
-
{
|
296 |
-
if (!isset($this->_conditionFullNames[$conditionName])) {
|
297 |
-
$name = Mage::getSingleton('shipping/carrier_tablerate')->getCode('condition_name_short', $conditionName);
|
298 |
-
$this->_conditionFullNames[$conditionName] = $name;
|
299 |
-
}
|
300 |
-
return $this->_conditionFullNames[$conditionName];
|
301 |
-
}
|
302 |
-
|
303 |
-
/**
|
304 |
-
* Validate row for import and return table rate array or false.
|
305 |
-
* Error will be add to _importErrors array.
|
306 |
-
*
|
307 |
-
* @param array $row
|
308 |
-
* @param int $rowNumber
|
309 |
-
* @return array|false
|
310 |
-
*/
|
311 |
-
protected function _getImportRow($row, $rowNumber = 0)
|
312 |
-
{
|
313 |
-
// validate row
|
314 |
-
if (count($row) < 5) {
|
315 |
-
$this->_importErrors[] = Mage::helper('bpost_shm')->__('Invalid Table Rates format in the Row #%s', $rowNumber);
|
316 |
-
return false;
|
317 |
-
}
|
318 |
-
|
319 |
-
// strip whitespace from the beginning and end of each row
|
320 |
-
foreach ($row as $k => $v) {
|
321 |
-
$row[$k] = trim($v);
|
322 |
-
}
|
323 |
-
|
324 |
-
// validate country
|
325 |
-
if (isset($this->_importIso2Countries[$row[0]])){
|
326 |
-
$countryId = $this->_importIso2Countries[$row[0]];
|
327 |
-
} elseif (isset($this->_importIso3Countries[$row[0]])) {
|
328 |
-
$countryId = $this->_importIso3Countries[$row[0]];
|
329 |
-
} elseif ($row[0] == '*' || $row[0] == '') {
|
330 |
-
$countryId = '0';
|
331 |
-
} else {
|
332 |
-
$this->_importErrors[] = Mage::helper('bpost_shm')->__('Invalid Country "%s" in the Row #%s.', $row[0], $rowNumber);
|
333 |
-
return false;
|
334 |
-
}
|
335 |
-
|
336 |
-
// validate region
|
337 |
-
if ($countryId != '0' && isset($this->_importRegions[$countryId][$row[1]])) {
|
338 |
-
$regionId = $this->_importRegions[$countryId][$row[1]];
|
339 |
-
} elseif ($row[1] == '*' || $row[1] == '') {
|
340 |
-
$regionId = 0;
|
341 |
-
} else {
|
342 |
-
$this->_importErrors[] = Mage::helper('bpost_shm')->__('Invalid Region/State "%s" in the Row #%s.', $row[1], $rowNumber);
|
343 |
-
return false;
|
344 |
-
}
|
345 |
-
|
346 |
-
// detect zip code
|
347 |
-
if ($row[2] == '*' || $row[2] == '') {
|
348 |
-
$zipCode = '*';
|
349 |
-
} else {
|
350 |
-
$zipCode = $row[2];
|
351 |
-
}
|
352 |
-
|
353 |
-
// validate condition value
|
354 |
-
$value = $this->_parseDecimalValue($row[3]);
|
355 |
-
if ($value === false) {
|
356 |
-
$this->_importErrors[] = Mage::helper('bpost_shm')->__('Invalid %s "%s" in the Row #%s.', $this->_getConditionFullName($this->_importConditionName), $row[3], $rowNumber);
|
357 |
-
return false;
|
358 |
-
}
|
359 |
-
|
360 |
-
// validate price
|
361 |
-
$price = $this->_parseDecimalValue($row[4]);
|
362 |
-
if ($price === false) {
|
363 |
-
$this->_importErrors[] = Mage::helper('bpost_shm')->__('Invalid Shipping Price "%s" in the Row #%s.', $row[4], $rowNumber);
|
364 |
-
return false;
|
365 |
-
}
|
366 |
-
|
367 |
-
// protect from duplicate
|
368 |
-
$hash = sprintf("%s-%d-%s-%F", $countryId, $regionId, $zipCode, $value);
|
369 |
-
if (isset($this->_importUniqueHash[$hash])) {
|
370 |
-
$this->_importErrors[] = Mage::helper('bpost_shm')->__('Duplicate Row #%s (Country "%s", Region/State "%s", Zip "%s" and Value "%s").', $rowNumber, $row[0], $row[1], $zipCode, $value);
|
371 |
-
return false;
|
372 |
-
}
|
373 |
-
$this->_importUniqueHash[$hash] = true;
|
374 |
-
|
375 |
-
return array(
|
376 |
-
$this->_importWebsiteId, // website_id
|
377 |
-
$countryId, // dest_country_id
|
378 |
-
$regionId, // dest_region_id,
|
379 |
-
$zipCode, // dest_zip
|
380 |
-
$this->_importConditionName,// condition_name,
|
381 |
-
$value, // condition_value
|
382 |
-
$price // price
|
383 |
-
);
|
384 |
-
}
|
385 |
-
|
386 |
-
/**
|
387 |
-
* Save all import data.
|
388 |
-
*
|
389 |
-
* @param array $data
|
390 |
-
* @return $this
|
391 |
-
*/
|
392 |
-
protected function _saveImportData(array $data)
|
393 |
-
{
|
394 |
-
if (!empty($data)) {
|
395 |
-
$columns = array('website_id', 'dest_country_id', 'dest_region_id', 'dest_zip',
|
396 |
-
'condition_name', 'condition_value', 'price');
|
397 |
-
$this->_getWriteAdapter()->insertArray($this->getMainTable(), $columns, $data);
|
398 |
-
$this->_importedRows += count($data);
|
399 |
-
}
|
400 |
-
|
401 |
-
return $this;
|
402 |
-
}
|
403 |
-
|
404 |
-
/**
|
405 |
-
* Conversion.
|
406 |
-
*
|
407 |
-
* @param $value
|
408 |
-
* @return bool|float
|
409 |
-
*/
|
410 |
-
protected function _parseDecimalValue($value)
|
411 |
-
{
|
412 |
-
if (!is_numeric($value)) {
|
413 |
-
return false;
|
414 |
-
}
|
415 |
-
$value = (float)sprintf('%.4F', $value);
|
416 |
-
if ($value < 0.0000) {
|
417 |
-
return false;
|
418 |
-
}
|
419 |
-
return $value;
|
420 |
-
}
|
421 |
}
|
1 |
+
<?php
|
2 |
+
class Bpost_ShM_Model_Resource_Tablerates_Parcellocker extends Mage_Core_Model_Resource_Db_Abstract{
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Website Id selected in scope.
|
6 |
+
*
|
7 |
+
* @var int
|
8 |
+
*/
|
9 |
+
protected $_importWebsiteId = 0;
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Array to fill with possible errors.
|
13 |
+
*
|
14 |
+
* @var array
|
15 |
+
*/
|
16 |
+
protected $_importErrors = array();
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Number of rows imported.
|
20 |
+
*
|
21 |
+
* @var int
|
22 |
+
*/
|
23 |
+
protected $_importedRows = 0;
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Conversion.
|
27 |
+
*
|
28 |
+
* @var array
|
29 |
+
*/
|
30 |
+
protected $_importUniqueHash = array();
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Conversion.
|
34 |
+
*
|
35 |
+
* @var
|
36 |
+
*/
|
37 |
+
protected $_importIso2Countries;
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Conversion.
|
41 |
+
*
|
42 |
+
* @var
|
43 |
+
*/
|
44 |
+
protected $_importIso3Countries;
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Regions to import.
|
48 |
+
*
|
49 |
+
* @var
|
50 |
+
*/
|
51 |
+
protected $_importRegions;
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Condition name selected in sysconfig.
|
55 |
+
*
|
56 |
+
* @var
|
57 |
+
*/
|
58 |
+
protected $_importConditionName;
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Full name of condition selected in sysconfig.
|
62 |
+
*
|
63 |
+
* @var array
|
64 |
+
*/
|
65 |
+
protected $_conditionFullNames = array();
|
66 |
+
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Initialise the model.
|
70 |
+
*/
|
71 |
+
protected function _construct()
|
72 |
+
{
|
73 |
+
$this->_init("bpost_shm/bpost_tablerates_parcellocker", "pk");
|
74 |
+
}
|
75 |
+
|
76 |
+
|
77 |
+
/**
|
78 |
+
* Fetch rate from the table for selected shipping address.
|
79 |
+
*
|
80 |
+
* @param Mage_Shipping_Model_Rate_Request $request
|
81 |
+
* @return array
|
82 |
+
*/
|
83 |
+
public function getRate(Mage_Shipping_Model_Rate_Request $request)
|
84 |
+
{
|
85 |
+
$adapter = $this->_getReadAdapter();
|
86 |
+
$bind = array(
|
87 |
+
':website_id' => (int) $request->getWebsiteId(),
|
88 |
+
':country_id' => $request->getDestCountryId(),
|
89 |
+
':region_id' => (int) $request->getDestRegionId(),
|
90 |
+
':postcode' => $request->getDestPostcode()
|
91 |
+
);
|
92 |
+
$select = $adapter->select()
|
93 |
+
->from($this->getMainTable())
|
94 |
+
->where('website_id = :website_id')
|
95 |
+
->order(array('dest_country_id DESC', 'dest_region_id DESC', 'dest_zip DESC', 'condition_value DESC'))
|
96 |
+
->limit(1);
|
97 |
+
|
98 |
+
// Render destination condition
|
99 |
+
$orWhere = '(' . implode(') OR (', array(
|
100 |
+
"dest_country_id = :country_id AND dest_region_id = :region_id AND dest_zip = :postcode",
|
101 |
+
"dest_country_id = :country_id AND dest_region_id = :region_id AND dest_zip = ''",
|
102 |
+
|
103 |
+
// Handle asterix in dest_zip field
|
104 |
+
"dest_country_id = :country_id AND dest_region_id = :region_id AND dest_zip = '*'",
|
105 |
+
"dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = '*'",
|
106 |
+
"dest_country_id = '0' AND dest_region_id = :region_id AND dest_zip = '*'",
|
107 |
+
"dest_country_id = '0' AND dest_region_id = 0 AND dest_zip = '*'",
|
108 |
+
|
109 |
+
"dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = ''",
|
110 |
+
"dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = :postcode",
|
111 |
+
"dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = '*'",
|
112 |
+
)) . ')';
|
113 |
+
$select->where($orWhere);
|
114 |
+
|
115 |
+
// Render condition by condition name
|
116 |
+
if (is_array($request->getConditionName())) {
|
117 |
+
$orWhere = array();
|
118 |
+
$i = 0;
|
119 |
+
foreach ($request->getConditionName() as $conditionName) {
|
120 |
+
$bindNameKey = sprintf(':condition_name_%d', $i);
|
121 |
+
$bindValueKey = sprintf(':condition_value_%d', $i);
|
122 |
+
$orWhere[] = "(condition_name = {$bindNameKey} AND condition_value <= {$bindValueKey})";
|
123 |
+
$bind[$bindNameKey] = $conditionName;
|
124 |
+
$bind[$bindValueKey] = $request->getData($conditionName);
|
125 |
+
$i++;
|
126 |
+
}
|
127 |
+
|
128 |
+
if ($orWhere) {
|
129 |
+
$select->where(implode(' OR ', $orWhere));
|
130 |
+
}
|
131 |
+
} else {
|
132 |
+
$bind[':condition_name'] = $request->getConditionName();
|
133 |
+
$bind[':condition_value'] = $request->getData($request->getConditionName());
|
134 |
+
|
135 |
+
$select->where('condition_name = :condition_name');
|
136 |
+
$select->where('condition_value <= :condition_value');
|
137 |
+
}
|
138 |
+
|
139 |
+
$result = $adapter->fetchRow($select, $bind);
|
140 |
+
// Normalize destination zip code
|
141 |
+
if ($result && $result['dest_zip'] == '*') {
|
142 |
+
$result['dest_zip'] = '';
|
143 |
+
}
|
144 |
+
return $result;
|
145 |
+
}
|
146 |
+
|
147 |
+
|
148 |
+
/**
|
149 |
+
* Upload and import table rates csv.
|
150 |
+
*
|
151 |
+
* @param Varien_Object $object
|
152 |
+
* @return $this
|
153 |
+
*/
|
154 |
+
public function uploadAndImport(Varien_Object $object)
|
155 |
+
{
|
156 |
+
if (empty($_FILES['groups']['tmp_name']['bpost_parcellocker']['fields']['import_parcellocker']['value'])) {
|
157 |
+
return $this;
|
158 |
+
}
|
159 |
+
|
160 |
+
$csvFile = $_FILES['groups']['tmp_name']['bpost_parcellocker']['fields']['import_parcellocker']['value'];
|
161 |
+
$website = Mage::app()->getWebsite($object->getScopeId());
|
162 |
+
|
163 |
+
$this->_importWebsiteId = (int)$website->getId();
|
164 |
+
$this->_importUniqueHash = array();
|
165 |
+
$this->_importErrors = array();
|
166 |
+
$this->_importedRows = 0;
|
167 |
+
|
168 |
+
$io = new Varien_Io_File();
|
169 |
+
$info = pathinfo($csvFile);
|
170 |
+
$io->open(array('path' => $info['dirname']));
|
171 |
+
$io->streamOpen($info['basename'], 'r');
|
172 |
+
|
173 |
+
// check and skip headers
|
174 |
+
$headers = $io->streamReadCsv();
|
175 |
+
if ($headers === false || count($headers) < 5) {
|
176 |
+
$io->streamClose();
|
177 |
+
Mage::throwException(Mage::helper('bpost_shm')->__('Invalid Table Rates File Format'));
|
178 |
+
}
|
179 |
+
if ($object->getData('groups/bpost_parcellocker/fields/condition_name/inherit') == '1') {
|
180 |
+
$conditionName = (string)Mage::getConfig()->getNode('default/carriers/bpost_parcellocker/condition_name');
|
181 |
+
} else {
|
182 |
+
$conditionName = $object->getData('groups/bpost_parcellocker/fields/condition_name/value');
|
183 |
+
}
|
184 |
+
$this->_importConditionName = $conditionName;
|
185 |
+
$adapter = $this->_getWriteAdapter();
|
186 |
+
$adapter->beginTransaction();
|
187 |
+
|
188 |
+
try {
|
189 |
+
$rowNumber = 1;
|
190 |
+
$importData = array();
|
191 |
+
|
192 |
+
$this->_loadDirectoryCountries();
|
193 |
+
$this->_loadDirectoryRegions();
|
194 |
+
|
195 |
+
// delete old data by website and condition name
|
196 |
+
$condition = array(
|
197 |
+
'website_id = ?' => $this->_importWebsiteId,
|
198 |
+
'condition_name = ?' => $this->_importConditionName
|
199 |
+
);
|
200 |
+
$adapter->delete($this->getMainTable(), $condition);
|
201 |
+
|
202 |
+
while (false !== ($csvLine = $io->streamReadCsv())) {
|
203 |
+
$rowNumber ++;
|
204 |
+
|
205 |
+
if (empty($csvLine)) {
|
206 |
+
continue;
|
207 |
+
}
|
208 |
+
|
209 |
+
$row = $this->_getImportRow($csvLine, $rowNumber);
|
210 |
+
if ($row !== false) {
|
211 |
+
$importData[] = $row;
|
212 |
+
}
|
213 |
+
|
214 |
+
if (count($importData) == 5000) {
|
215 |
+
$this->_saveImportData($importData);
|
216 |
+
$importData = array();
|
217 |
+
}
|
218 |
+
}
|
219 |
+
$this->_saveImportData($importData);
|
220 |
+
$io->streamClose();
|
221 |
+
} catch (Mage_Core_Exception $e) {
|
222 |
+
$adapter->rollback();
|
223 |
+
$io->streamClose();
|
224 |
+
Mage::throwException($e->getMessage());
|
225 |
+
} catch (Exception $e) {
|
226 |
+
$adapter->rollback();
|
227 |
+
$io->streamClose();
|
228 |
+
Mage::helper('bpost_shm')->log($e,Zend_Log::ERR);
|
229 |
+
Mage::throwException(Mage::helper('bpost_shm')->__('An error occurred while importing table rates.'));
|
230 |
+
}
|
231 |
+
|
232 |
+
$adapter->commit();
|
233 |
+
|
234 |
+
if ($this->_importErrors) {
|
235 |
+
$error = Mage::helper('bpost_shm')->__('File has not been imported. See the following list of errors: %s', implode(" \n", $this->_importErrors));
|
236 |
+
Mage::throwException($error);
|
237 |
+
}
|
238 |
+
|
239 |
+
return $this;
|
240 |
+
}
|
241 |
+
|
242 |
+
/**
|
243 |
+
* Load directory countries.
|
244 |
+
*
|
245 |
+
* @return Mage_Shipping_Model_Resource_Carrier_Tablerate
|
246 |
+
*/
|
247 |
+
protected function _loadDirectoryCountries()
|
248 |
+
{
|
249 |
+
if (!is_null($this->_importIso2Countries) && !is_null($this->_importIso3Countries)) {
|
250 |
+
return $this;
|
251 |
+
}
|
252 |
+
|
253 |
+
$this->_importIso2Countries = array();
|
254 |
+
$this->_importIso3Countries = array();
|
255 |
+
|
256 |
+
/** @var $collection Mage_Directory_Model_Resource_Country_Collection */
|
257 |
+
$collection = Mage::getResourceModel('directory/country_collection');
|
258 |
+
foreach ($collection->getData() as $row) {
|
259 |
+
$this->_importIso2Countries[$row['iso2_code']] = $row['country_id'];
|
260 |
+
$this->_importIso3Countries[$row['iso3_code']] = $row['country_id'];
|
261 |
+
}
|
262 |
+
|
263 |
+
return $this;
|
264 |
+
}
|
265 |
+
|
266 |
+
/**
|
267 |
+
* Load directory regions.
|
268 |
+
*
|
269 |
+
* @return Mage_Shipping_Model_Resource_Carrier_Tablerate
|
270 |
+
*/
|
271 |
+
protected function _loadDirectoryRegions()
|
272 |
+
{
|
273 |
+
if (!is_null($this->_importRegions)) {
|
274 |
+
return $this;
|
275 |
+
}
|
276 |
+
|
277 |
+
$this->_importRegions = array();
|
278 |
+
|
279 |
+
/** @var $collection Mage_Directory_Model_Resource_Region_Collection */
|
280 |
+
$collection = Mage::getResourceModel('directory/region_collection');
|
281 |
+
foreach ($collection->getData() as $row) {
|
282 |
+
$this->_importRegions[$row['country_id']][$row['code']] = (int)$row['region_id'];
|
283 |
+
}
|
284 |
+
|
285 |
+
return $this;
|
286 |
+
}
|
287 |
+
|
288 |
+
/**
|
289 |
+
* Return import condition full name by condition name code.
|
290 |
+
*
|
291 |
+
* @param string $conditionName
|
292 |
+
* @return string
|
293 |
+
*/
|
294 |
+
protected function _getConditionFullName($conditionName)
|
295 |
+
{
|
296 |
+
if (!isset($this->_conditionFullNames[$conditionName])) {
|
297 |
+
$name = Mage::getSingleton('shipping/carrier_tablerate')->getCode('condition_name_short', $conditionName);
|
298 |
+
$this->_conditionFullNames[$conditionName] = $name;
|
299 |
+
}
|
300 |
+
return $this->_conditionFullNames[$conditionName];
|
301 |
+
}
|
302 |
+
|
303 |
+
/**
|
304 |
+
* Validate row for import and return table rate array or false.
|
305 |
+
* Error will be add to _importErrors array.
|
306 |
+
*
|
307 |
+
* @param array $row
|
308 |
+
* @param int $rowNumber
|
309 |
+
* @return array|false
|
310 |
+
*/
|
311 |
+
protected function _getImportRow($row, $rowNumber = 0)
|
312 |
+
{
|
313 |
+
// validate row
|
314 |
+
if (count($row) < 5) {
|
315 |
+
$this->_importErrors[] = Mage::helper('bpost_shm')->__('Invalid Table Rates format in the Row #%s', $rowNumber);
|
316 |
+
return false;
|
317 |
+
}
|
318 |
+
|
319 |
+
// strip whitespace from the beginning and end of each row
|
320 |
+
foreach ($row as $k => $v) {
|
321 |
+
$row[$k] = trim($v);
|
322 |
+
}
|
323 |
+
|
324 |
+
// validate country
|
325 |
+
if (isset($this->_importIso2Countries[$row[0]])){
|
326 |
+
$countryId = $this->_importIso2Countries[$row[0]];
|
327 |
+
} elseif (isset($this->_importIso3Countries[$row[0]])) {
|
328 |
+
$countryId = $this->_importIso3Countries[$row[0]];
|
329 |
+
} elseif ($row[0] == '*' || $row[0] == '') {
|
330 |
+
$countryId = '0';
|
331 |
+
} else {
|
332 |
+
$this->_importErrors[] = Mage::helper('bpost_shm')->__('Invalid Country "%s" in the Row #%s.', $row[0], $rowNumber);
|
333 |
+
return false;
|
334 |
+
}
|
335 |
+
|
336 |
+
// validate region
|
337 |
+
if ($countryId != '0' && isset($this->_importRegions[$countryId][$row[1]])) {
|
338 |
+
$regionId = $this->_importRegions[$countryId][$row[1]];
|
339 |
+
} elseif ($row[1] == '*' || $row[1] == '') {
|
340 |
+
$regionId = 0;
|
341 |
+
} else {
|
342 |
+
$this->_importErrors[] = Mage::helper('bpost_shm')->__('Invalid Region/State "%s" in the Row #%s.', $row[1], $rowNumber);
|
343 |
+
return false;
|
344 |
+
}
|
345 |
+
|
346 |
+
// detect zip code
|
347 |
+
if ($row[2] == '*' || $row[2] == '') {
|
348 |
+
$zipCode = '*';
|
349 |
+
} else {
|
350 |
+
$zipCode = $row[2];
|
351 |
+
}
|
352 |
+
|
353 |
+
// validate condition value
|
354 |
+
$value = $this->_parseDecimalValue($row[3]);
|
355 |
+
if ($value === false) {
|
356 |
+
$this->_importErrors[] = Mage::helper('bpost_shm')->__('Invalid %s "%s" in the Row #%s.', $this->_getConditionFullName($this->_importConditionName), $row[3], $rowNumber);
|
357 |
+
return false;
|
358 |
+
}
|
359 |
+
|
360 |
+
// validate price
|
361 |
+
$price = $this->_parseDecimalValue($row[4]);
|
362 |
+
if ($price === false) {
|
363 |
+
$this->_importErrors[] = Mage::helper('bpost_shm')->__('Invalid Shipping Price "%s" in the Row #%s.', $row[4], $rowNumber);
|
364 |
+
return false;
|
365 |
+
}
|
366 |
+
|
367 |
+
// protect from duplicate
|
368 |
+
$hash = sprintf("%s-%d-%s-%F", $countryId, $regionId, $zipCode, $value);
|
369 |
+
if (isset($this->_importUniqueHash[$hash])) {
|
370 |
+
$this->_importErrors[] = Mage::helper('bpost_shm')->__('Duplicate Row #%s (Country "%s", Region/State "%s", Zip "%s" and Value "%s").', $rowNumber, $row[0], $row[1], $zipCode, $value);
|
371 |
+
return false;
|
372 |
+
}
|
373 |
+
$this->_importUniqueHash[$hash] = true;
|
374 |
+
|
375 |
+
return array(
|
376 |
+
$this->_importWebsiteId, // website_id
|
377 |
+
$countryId, // dest_country_id
|
378 |
+
$regionId, // dest_region_id,
|
379 |
+
$zipCode, // dest_zip
|
380 |
+
$this->_importConditionName,// condition_name,
|
381 |
+
$value, // condition_value
|
382 |
+
$price // price
|
383 |
+
);
|
384 |
+
}
|
385 |
+
|
386 |
+
/**
|
387 |
+
* Save all import data.
|
388 |
+
*
|
389 |
+
* @param array $data
|
390 |
+
* @return $this
|
391 |
+
*/
|
392 |
+
protected function _saveImportData(array $data)
|
393 |
+
{
|
394 |
+
if (!empty($data)) {
|
395 |
+
$columns = array('website_id', 'dest_country_id', 'dest_region_id', 'dest_zip',
|
396 |
+
'condition_name', 'condition_value', 'price');
|
397 |
+
$this->_getWriteAdapter()->insertArray($this->getMainTable(), $columns, $data);
|
398 |
+
$this->_importedRows += count($data);
|
399 |
+
}
|
400 |
+
|
401 |
+
return $this;
|
402 |
+
}
|
403 |
+
|
404 |
+
/**
|
405 |
+
* Conversion.
|
406 |
+
*
|
407 |
+
* @param $value
|
408 |
+
* @return bool|float
|
409 |
+
*/
|
410 |
+
protected function _parseDecimalValue($value)
|
411 |
+
{
|
412 |
+
if (!is_numeric($value)) {
|
413 |
+
return false;
|
414 |
+
}
|
415 |
+
$value = (float)sprintf('%.4F', $value);
|
416 |
+
if ($value < 0.0000) {
|
417 |
+
return false;
|
418 |
+
}
|
419 |
+
return $value;
|
420 |
+
}
|
421 |
}
|
app/code/community/Bpost/ShM/Model/Resource/Tablerates/Parcellocker/Collection.php
CHANGED
@@ -1,95 +1,95 @@
|
|
1 |
-
<?php
|
2 |
-
class Bpost_ShM_Model_Resource_Tablerates_Parcellocker_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
|
3 |
-
{
|
4 |
-
/**
|
5 |
-
* main table name
|
6 |
-
*
|
7 |
-
* @deprecated since 1.4.1.0
|
8 |
-
* @var string
|
9 |
-
*/
|
10 |
-
protected $_shipTable;
|
11 |
-
|
12 |
-
/**
|
13 |
-
* directory/country table name
|
14 |
-
*
|
15 |
-
* @var string
|
16 |
-
*/
|
17 |
-
protected $_countryTable;
|
18 |
-
|
19 |
-
/**
|
20 |
-
* directory/country_region table name
|
21 |
-
*
|
22 |
-
* @var string
|
23 |
-
*/
|
24 |
-
protected $_regionTable;
|
25 |
-
|
26 |
-
/**
|
27 |
-
* Define resource model and item
|
28 |
-
*
|
29 |
-
*/
|
30 |
-
protected function _construct()
|
31 |
-
{
|
32 |
-
$this->_init('bpost_shm/tablerates_parcellocker');
|
33 |
-
$this->_shipTable = $this->getMainTable();
|
34 |
-
$this->_countryTable = $this->getTable('directory/country');
|
35 |
-
$this->_regionTable = $this->getTable('directory/country_region');
|
36 |
-
}
|
37 |
-
|
38 |
-
/**
|
39 |
-
* Initialize select, add country iso3 code and region name
|
40 |
-
*
|
41 |
-
* @return void
|
42 |
-
*/
|
43 |
-
public function _initSelect()
|
44 |
-
{
|
45 |
-
parent::_initSelect();
|
46 |
-
|
47 |
-
$this->_select
|
48 |
-
->joinLeft(
|
49 |
-
array('country_table' => $this->_countryTable),
|
50 |
-
'country_table.country_id = main_table.dest_country_id',
|
51 |
-
array('dest_country' => 'iso3_code'))
|
52 |
-
->joinLeft(
|
53 |
-
array('region_table' => $this->_regionTable),
|
54 |
-
'region_table.region_id = main_table.dest_region_id',
|
55 |
-
array('dest_region' => 'code'));
|
56 |
-
|
57 |
-
$this->addOrder('dest_country', self::SORT_ORDER_ASC);
|
58 |
-
$this->addOrder('dest_region', self::SORT_ORDER_ASC);
|
59 |
-
$this->addOrder('dest_zip', self::SORT_ORDER_ASC);
|
60 |
-
$this->addOrder('condition_value', self::SORT_ORDER_ASC);
|
61 |
-
}
|
62 |
-
|
63 |
-
/**
|
64 |
-
* Add website filter to collection
|
65 |
-
*
|
66 |
-
* @param int $websiteId
|
67 |
-
* @return Mage_Shipping_Model_Resource_Carrier_Tablerate_Collection
|
68 |
-
*/
|
69 |
-
public function setWebsiteFilter($websiteId)
|
70 |
-
{
|
71 |
-
return $this->addFieldToFilter('website_id', $websiteId);
|
72 |
-
}
|
73 |
-
|
74 |
-
/**
|
75 |
-
* Add condition name (code) filter to collection
|
76 |
-
*
|
77 |
-
* @param string $conditionName
|
78 |
-
* @return Mage_Shipping_Model_Resource_Carrier_Tablerate_Collection
|
79 |
-
*/
|
80 |
-
public function setConditionFilter($conditionName)
|
81 |
-
{
|
82 |
-
return $this->addFieldToFilter('condition_name', $conditionName);
|
83 |
-
}
|
84 |
-
|
85 |
-
/**
|
86 |
-
* Add country filter to collection
|
87 |
-
*
|
88 |
-
* @param string $countryId
|
89 |
-
* @return Mage_Shipping_Model_Resource_Carrier_Tablerate_Collection
|
90 |
-
*/
|
91 |
-
public function setCountryFilter($countryId)
|
92 |
-
{
|
93 |
-
return $this->addFieldToFilter('dest_country_id', $countryId);
|
94 |
-
}
|
95 |
}
|
1 |
+
<?php
|
2 |
+
class Bpost_ShM_Model_Resource_Tablerates_Parcellocker_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
|
3 |
+
{
|
4 |
+
/**
|
5 |
+
* main table name
|
6 |
+
*
|
7 |
+
* @deprecated since 1.4.1.0
|
8 |
+
* @var string
|
9 |
+
*/
|
10 |
+
protected $_shipTable;
|
11 |
+
|
12 |
+
/**
|
13 |
+
* directory/country table name
|
14 |
+
*
|
15 |
+
* @var string
|
16 |
+
*/
|
17 |
+
protected $_countryTable;
|
18 |
+
|
19 |
+
/**
|
20 |
+
* directory/country_region table name
|
21 |
+
*
|
22 |
+
* @var string
|
23 |
+
*/
|
24 |
+
protected $_regionTable;
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Define resource model and item
|
28 |
+
*
|
29 |
+
*/
|
30 |
+
protected function _construct()
|
31 |
+
{
|
32 |
+
$this->_init('bpost_shm/tablerates_parcellocker');
|
33 |
+
$this->_shipTable = $this->getMainTable();
|
34 |
+
$this->_countryTable = $this->getTable('directory/country');
|
35 |
+
$this->_regionTable = $this->getTable('directory/country_region');
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Initialize select, add country iso3 code and region name
|
40 |
+
*
|
41 |
+
* @return void
|
42 |
+
*/
|
43 |
+
public function _initSelect()
|
44 |
+
{
|
45 |
+
parent::_initSelect();
|
46 |
+
|
47 |
+
$this->_select
|
48 |
+
->joinLeft(
|
49 |
+
array('country_table' => $this->_countryTable),
|
50 |
+
'country_table.country_id = main_table.dest_country_id',
|
51 |
+
array('dest_country' => 'iso3_code'))
|
52 |
+
->joinLeft(
|
53 |
+
array('region_table' => $this->_regionTable),
|
54 |
+
'region_table.region_id = main_table.dest_region_id',
|
55 |
+
array('dest_region' => 'code'));
|
56 |
+
|
57 |
+
$this->addOrder('dest_country', self::SORT_ORDER_ASC);
|
58 |
+
$this->addOrder('dest_region', self::SORT_ORDER_ASC);
|
59 |
+
$this->addOrder('dest_zip', self::SORT_ORDER_ASC);
|
60 |
+
$this->addOrder('condition_value', self::SORT_ORDER_ASC);
|
61 |
+
}
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Add website filter to collection
|
65 |
+
*
|
66 |
+
* @param int $websiteId
|
67 |
+
* @return Mage_Shipping_Model_Resource_Carrier_Tablerate_Collection
|
68 |
+
*/
|
69 |
+
public function setWebsiteFilter($websiteId)
|
70 |
+
{
|
71 |
+
return $this->addFieldToFilter('website_id', $websiteId);
|
72 |
+
}
|
73 |
+
|
74 |
+
/**
|
75 |
+
* Add condition name (code) filter to collection
|
76 |
+
*
|
77 |
+
* @param string $conditionName
|
78 |
+
* @return Mage_Shipping_Model_Resource_Carrier_Tablerate_Collection
|
79 |
+
*/
|
80 |
+
public function setConditionFilter($conditionName)
|
81 |
+
{
|
82 |
+
return $this->addFieldToFilter('condition_name', $conditionName);
|
83 |
+
}
|
84 |
+
|
85 |
+
/**
|
86 |
+
* Add country filter to collection
|
87 |
+
*
|
88 |
+
* @param string $countryId
|
89 |
+
* @return Mage_Shipping_Model_Resource_Carrier_Tablerate_Collection
|
90 |
+
*/
|
91 |
+
public function setCountryFilter($countryId)
|
92 |
+
{
|
93 |
+
return $this->addFieldToFilter('dest_country_id', $countryId);
|
94 |
+
}
|
95 |
}
|
app/code/community/Bpost/ShM/Model/Resource/Tablerates/Pickuppoint.php
CHANGED
@@ -1,421 +1,421 @@
|
|
1 |
-
<?php
|
2 |
-
class Bpost_ShM_Model_Resource_Tablerates_Pickuppoint extends Mage_Core_Model_Resource_Db_Abstract{
|
3 |
-
|
4 |
-
/**
|
5 |
-
* Website Id selected in scope.
|
6 |
-
*
|
7 |
-
* @var int
|
8 |
-
*/
|
9 |
-
protected $_importWebsiteId = 0;
|
10 |
-
|
11 |
-
/**
|
12 |
-
* Array to fill with possible errors.
|
13 |
-
*
|
14 |
-
* @var array
|
15 |
-
*/
|
16 |
-
protected $_importErrors = array();
|
17 |
-
|
18 |
-
/**
|
19 |
-
* Number of rows imported.
|
20 |
-
*
|
21 |
-
* @var int
|
22 |
-
*/
|
23 |
-
protected $_importedRows = 0;
|
24 |
-
|
25 |
-
/**
|
26 |
-
* Conversion.
|
27 |
-
*
|
28 |
-
* @var array
|
29 |
-
*/
|
30 |
-
protected $_importUniqueHash = array();
|
31 |
-
|
32 |
-
/**
|
33 |
-
* Conversion.
|
34 |
-
*
|
35 |
-
* @var
|
36 |
-
*/
|
37 |
-
protected $_importIso2Countries;
|
38 |
-
|
39 |
-
/**
|
40 |
-
* Conversion.
|
41 |
-
*
|
42 |
-
* @var
|
43 |
-
*/
|
44 |
-
protected $_importIso3Countries;
|
45 |
-
|
46 |
-
/**
|
47 |
-
* Regions to import.
|
48 |
-
*
|
49 |
-
* @var
|
50 |
-
*/
|
51 |
-
protected $_importRegions;
|
52 |
-
|
53 |
-
/**
|
54 |
-
* Condition name selected in sysconfig.
|
55 |
-
*
|
56 |
-
* @var
|
57 |
-
*/
|
58 |
-
protected $_importConditionName;
|
59 |
-
|
60 |
-
/**
|
61 |
-
* Full name of condition selected in sysconfig.
|
62 |
-
*
|
63 |
-
* @var array
|
64 |
-
*/
|
65 |
-
protected $_conditionFullNames = array();
|
66 |
-
|
67 |
-
|
68 |
-
/**
|
69 |
-
* Initialise the model.
|
70 |
-
*/
|
71 |
-
protected function _construct()
|
72 |
-
{
|
73 |
-
$this->_init("bpost_shm/bpost_tablerates_pickuppoint", "pk");
|
74 |
-
}
|
75 |
-
|
76 |
-
|
77 |
-
/**
|
78 |
-
* Fetch rate from the table for selected shipping address.
|
79 |
-
*
|
80 |
-
* @param Mage_Shipping_Model_Rate_Request $request
|
81 |
-
* @return array
|
82 |
-
*/
|
83 |
-
public function getRate(Mage_Shipping_Model_Rate_Request $request)
|
84 |
-
{
|
85 |
-
$adapter = $this->_getReadAdapter();
|
86 |
-
$bind = array(
|
87 |
-
':website_id' => (int) $request->getWebsiteId(),
|
88 |
-
':country_id' => $request->getDestCountryId(),
|
89 |
-
':region_id' => (int) $request->getDestRegionId(),
|
90 |
-
':postcode' => $request->getDestPostcode()
|
91 |
-
);
|
92 |
-
$select = $adapter->select()
|
93 |
-
->from($this->getMainTable())
|
94 |
-
->where('website_id = :website_id')
|
95 |
-
->order(array('dest_country_id DESC', 'dest_region_id DESC', 'dest_zip DESC', 'condition_value DESC'))
|
96 |
-
->limit(1);
|
97 |
-
|
98 |
-
// Render destination condition
|
99 |
-
$orWhere = '(' . implode(') OR (', array(
|
100 |
-
"dest_country_id = :country_id AND dest_region_id = :region_id AND dest_zip = :postcode",
|
101 |
-
"dest_country_id = :country_id AND dest_region_id = :region_id AND dest_zip = ''",
|
102 |
-
|
103 |
-
// Handle asterix in dest_zip field
|
104 |
-
"dest_country_id = :country_id AND dest_region_id = :region_id AND dest_zip = '*'",
|
105 |
-
"dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = '*'",
|
106 |
-
"dest_country_id = '0' AND dest_region_id = :region_id AND dest_zip = '*'",
|
107 |
-
"dest_country_id = '0' AND dest_region_id = 0 AND dest_zip = '*'",
|
108 |
-
|
109 |
-
"dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = ''",
|
110 |
-
"dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = :postcode",
|
111 |
-
"dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = '*'",
|
112 |
-
)) . ')';
|
113 |
-
$select->where($orWhere);
|
114 |
-
|
115 |
-
// Render condition by condition name
|
116 |
-
if (is_array($request->getConditionName())) {
|
117 |
-
$orWhere = array();
|
118 |
-
$i = 0;
|
119 |
-
foreach ($request->getConditionName() as $conditionName) {
|
120 |
-
$bindNameKey = sprintf(':condition_name_%d', $i);
|
121 |
-
$bindValueKey = sprintf(':condition_value_%d', $i);
|
122 |
-
$orWhere[] = "(condition_name = {$bindNameKey} AND condition_value <= {$bindValueKey})";
|
123 |
-
$bind[$bindNameKey] = $conditionName;
|
124 |
-
$bind[$bindValueKey] = $request->getData($conditionName);
|
125 |
-
$i++;
|
126 |
-
}
|
127 |
-
|
128 |
-
if ($orWhere) {
|
129 |
-
$select->where(implode(' OR ', $orWhere));
|
130 |
-
}
|
131 |
-
} else {
|
132 |
-
$bind[':condition_name'] = $request->getConditionName();
|
133 |
-
$bind[':condition_value'] = $request->getData($request->getConditionName());
|
134 |
-
|
135 |
-
$select->where('condition_name = :condition_name');
|
136 |
-
$select->where('condition_value <= :condition_value');
|
137 |
-
}
|
138 |
-
|
139 |
-
$result = $adapter->fetchRow($select, $bind);
|
140 |
-
// Normalize destination zip code
|
141 |
-
if ($result && $result['dest_zip'] == '*') {
|
142 |
-
$result['dest_zip'] = '';
|
143 |
-
}
|
144 |
-
return $result;
|
145 |
-
}
|
146 |
-
|
147 |
-
|
148 |
-
/**
|
149 |
-
* Upload and import table rates csv.
|
150 |
-
*
|
151 |
-
* @param Varien_Object $object
|
152 |
-
* @return $this
|
153 |
-
*/
|
154 |
-
public function uploadAndImport(Varien_Object $object)
|
155 |
-
{
|
156 |
-
if (empty($_FILES['groups']['tmp_name']['bpost_pickuppoint']['fields']['import_pickuppoint']['value'])) {
|
157 |
-
return $this;
|
158 |
-
}
|
159 |
-
|
160 |
-
$csvFile = $_FILES['groups']['tmp_name']['bpost_pickuppoint']['fields']['import_pickuppoint']['value'];
|
161 |
-
$website = Mage::app()->getWebsite($object->getScopeId());
|
162 |
-
|
163 |
-
$this->_importWebsiteId = (int)$website->getId();
|
164 |
-
$this->_importUniqueHash = array();
|
165 |
-
$this->_importErrors = array();
|
166 |
-
$this->_importedRows = 0;
|
167 |
-
|
168 |
-
$io = new Varien_Io_File();
|
169 |
-
$info = pathinfo($csvFile);
|
170 |
-
$io->open(array('path' => $info['dirname']));
|
171 |
-
$io->streamOpen($info['basename'], 'r');
|
172 |
-
|
173 |
-
// check and skip headers
|
174 |
-
$headers = $io->streamReadCsv();
|
175 |
-
if ($headers === false || count($headers) < 5) {
|
176 |
-
$io->streamClose();
|
177 |
-
Mage::throwException(Mage::helper('bpost_shm')->__('Invalid Table Rates File Format'));
|
178 |
-
}
|
179 |
-
if ($object->getData('groups/bpost_pickuppoint/fields/condition_name/inherit') == '1') {
|
180 |
-
$conditionName = (string)Mage::getConfig()->getNode('default/carriers/bpost_pickuppoint/condition_name');
|
181 |
-
} else {
|
182 |
-
$conditionName = $object->getData('groups/bpost_pickuppoint/fields/condition_name/value');
|
183 |
-
}
|
184 |
-
$this->_importConditionName = $conditionName;
|
185 |
-
$adapter = $this->_getWriteAdapter();
|
186 |
-
$adapter->beginTransaction();
|
187 |
-
|
188 |
-
try {
|
189 |
-
$rowNumber = 1;
|
190 |
-
$importData = array();
|
191 |
-
|
192 |
-
$this->_loadDirectoryCountries();
|
193 |
-
$this->_loadDirectoryRegions();
|
194 |
-
|
195 |
-
// delete old data by website and condition name
|
196 |
-
$condition = array(
|
197 |
-
'website_id = ?' => $this->_importWebsiteId,
|
198 |
-
'condition_name = ?' => $this->_importConditionName
|
199 |
-
);
|
200 |
-
$adapter->delete($this->getMainTable(), $condition);
|
201 |
-
|
202 |
-
while (false !== ($csvLine = $io->streamReadCsv())) {
|
203 |
-
$rowNumber ++;
|
204 |
-
|
205 |
-
if (empty($csvLine)) {
|
206 |
-
continue;
|
207 |
-
}
|
208 |
-
|
209 |
-
$row = $this->_getImportRow($csvLine, $rowNumber);
|
210 |
-
if ($row !== false) {
|
211 |
-
$importData[] = $row;
|
212 |
-
}
|
213 |
-
|
214 |
-
if (count($importData) == 5000) {
|
215 |
-
$this->_saveImportData($importData);
|
216 |
-
$importData = array();
|
217 |
-
}
|
218 |
-
}
|
219 |
-
$this->_saveImportData($importData);
|
220 |
-
$io->streamClose();
|
221 |
-
} catch (Mage_Core_Exception $e) {
|
222 |
-
$adapter->rollback();
|
223 |
-
$io->streamClose();
|
224 |
-
Mage::throwException($e->getMessage());
|
225 |
-
} catch (Exception $e) {
|
226 |
-
$adapter->rollback();
|
227 |
-
$io->streamClose();
|
228 |
-
Mage::helper('bpost_shm')->log($e,Zend_Log::ERR);
|
229 |
-
Mage::throwException(Mage::helper('bpost_shm')->__('An error occurred while importing table rates.'));
|
230 |
-
}
|
231 |
-
|
232 |
-
$adapter->commit();
|
233 |
-
|
234 |
-
if ($this->_importErrors) {
|
235 |
-
$error = Mage::helper('bpost_shm')->__('File has not been imported. See the following list of errors: %s', implode(" \n", $this->_importErrors));
|
236 |
-
Mage::throwException($error);
|
237 |
-
}
|
238 |
-
|
239 |
-
return $this;
|
240 |
-
}
|
241 |
-
|
242 |
-
/**
|
243 |
-
* Load directory countries.
|
244 |
-
*
|
245 |
-
* @return Mage_Shipping_Model_Resource_Carrier_Tablerate
|
246 |
-
*/
|
247 |
-
protected function _loadDirectoryCountries()
|
248 |
-
{
|
249 |
-
if (!is_null($this->_importIso2Countries) && !is_null($this->_importIso3Countries)) {
|
250 |
-
return $this;
|
251 |
-
}
|
252 |
-
|
253 |
-
$this->_importIso2Countries = array();
|
254 |
-
$this->_importIso3Countries = array();
|
255 |
-
|
256 |
-
/** @var $collection Mage_Directory_Model_Resource_Country_Collection */
|
257 |
-
$collection = Mage::getResourceModel('directory/country_collection');
|
258 |
-
foreach ($collection->getData() as $row) {
|
259 |
-
$this->_importIso2Countries[$row['iso2_code']] = $row['country_id'];
|
260 |
-
$this->_importIso3Countries[$row['iso3_code']] = $row['country_id'];
|
261 |
-
}
|
262 |
-
|
263 |
-
return $this;
|
264 |
-
}
|
265 |
-
|
266 |
-
/**
|
267 |
-
* Load directory regions.
|
268 |
-
*
|
269 |
-
* @return Mage_Shipping_Model_Resource_Carrier_Tablerate
|
270 |
-
*/
|
271 |
-
protected function _loadDirectoryRegions()
|
272 |
-
{
|
273 |
-
if (!is_null($this->_importRegions)) {
|
274 |
-
return $this;
|
275 |
-
}
|
276 |
-
|
277 |
-
$this->_importRegions = array();
|
278 |
-
|
279 |
-
/** @var $collection Mage_Directory_Model_Resource_Region_Collection */
|
280 |
-
$collection = Mage::getResourceModel('directory/region_collection');
|
281 |
-
foreach ($collection->getData() as $row) {
|
282 |
-
$this->_importRegions[$row['country_id']][$row['code']] = (int)$row['region_id'];
|
283 |
-
}
|
284 |
-
|
285 |
-
return $this;
|
286 |
-
}
|
287 |
-
|
288 |
-
/**
|
289 |
-
* Return import condition full name by condition name code.
|
290 |
-
*
|
291 |
-
* @param string $conditionName
|
292 |
-
* @return string
|
293 |
-
*/
|
294 |
-
protected function _getConditionFullName($conditionName)
|
295 |
-
{
|
296 |
-
if (!isset($this->_conditionFullNames[$conditionName])) {
|
297 |
-
$name = Mage::getSingleton('shipping/carrier_tablerate')->getCode('condition_name_short', $conditionName);
|
298 |
-
$this->_conditionFullNames[$conditionName] = $name;
|
299 |
-
}
|
300 |
-
return $this->_conditionFullNames[$conditionName];
|
301 |
-
}
|
302 |
-
|
303 |
-
/**
|
304 |
-
* Validate row for import and return table rate array or false.
|
305 |
-
* Error will be add to _importErrors array.
|
306 |
-
*
|
307 |
-
* @param array $row
|
308 |
-
* @param int $rowNumber
|
309 |
-
* @return array|false
|
310 |
-
*/
|
311 |
-
protected function _getImportRow($row, $rowNumber = 0)
|
312 |
-
{
|
313 |
-
// validate row
|
314 |
-
if (count($row) < 5) {
|
315 |
-
$this->_importErrors[] = Mage::helper('bpost_shm')->__('Invalid Table Rates format in the Row #%s', $rowNumber);
|
316 |
-
return false;
|
317 |
-
}
|
318 |
-
|
319 |
-
// strip whitespace from the beginning and end of each row
|
320 |
-
foreach ($row as $k => $v) {
|
321 |
-
$row[$k] = trim($v);
|
322 |
-
}
|
323 |
-
|
324 |
-
// validate country
|
325 |
-
if (isset($this->_importIso2Countries[$row[0]])){
|
326 |
-
$countryId = $this->_importIso2Countries[$row[0]];
|
327 |
-
} elseif (isset($this->_importIso3Countries[$row[0]])) {
|
328 |
-
$countryId = $this->_importIso3Countries[$row[0]];
|
329 |
-
} elseif ($row[0] == '*' || $row[0] == '') {
|
330 |
-
$countryId = '0';
|
331 |
-
} else {
|
332 |
-
$this->_importErrors[] = Mage::helper('bpost_shm')->__('Invalid Country "%s" in the Row #%s.', $row[0], $rowNumber);
|
333 |
-
return false;
|
334 |
-
}
|
335 |
-
|
336 |
-
// validate region
|
337 |
-
if ($countryId != '0' && isset($this->_importRegions[$countryId][$row[1]])) {
|
338 |
-
$regionId = $this->_importRegions[$countryId][$row[1]];
|
339 |
-
} elseif ($row[1] == '*' || $row[1] == '') {
|
340 |
-
$regionId = 0;
|
341 |
-
} else {
|
342 |
-
$this->_importErrors[] = Mage::helper('bpost_shm')->__('Invalid Region/State "%s" in the Row #%s.', $row[1], $rowNumber);
|
343 |
-
return false;
|
344 |
-
}
|
345 |
-
|
346 |
-
// detect zip code
|
347 |
-
if ($row[2] == '*' || $row[2] == '') {
|
348 |
-
$zipCode = '*';
|
349 |
-
} else {
|
350 |
-
$zipCode = $row[2];
|
351 |
-
}
|
352 |
-
|
353 |
-
// validate condition value
|
354 |
-
$value = $this->_parseDecimalValue($row[3]);
|
355 |
-
if ($value === false) {
|
356 |
-
$this->_importErrors[] = Mage::helper('bpost_shm')->__('Invalid %s "%s" in the Row #%s.', $this->_getConditionFullName($this->_importConditionName), $row[3], $rowNumber);
|
357 |
-
return false;
|
358 |
-
}
|
359 |
-
|
360 |
-
// validate price
|
361 |
-
$price = $this->_parseDecimalValue($row[4]);
|
362 |
-
if ($price === false) {
|
363 |
-
$this->_importErrors[] = Mage::helper('bpost_shm')->__('Invalid Shipping Price "%s" in the Row #%s.', $row[4], $rowNumber);
|
364 |
-
return false;
|
365 |
-
}
|
366 |
-
|
367 |
-
// protect from duplicate
|
368 |
-
$hash = sprintf("%s-%d-%s-%F", $countryId, $regionId, $zipCode, $value);
|
369 |
-
if (isset($this->_importUniqueHash[$hash])) {
|
370 |
-
$this->_importErrors[] = Mage::helper('bpost_shm')->__('Duplicate Row #%s (Country "%s", Region/State "%s", Zip "%s" and Value "%s").', $rowNumber, $row[0], $row[1], $zipCode, $value);
|
371 |
-
return false;
|
372 |
-
}
|
373 |
-
$this->_importUniqueHash[$hash] = true;
|
374 |
-
|
375 |
-
return array(
|
376 |
-
$this->_importWebsiteId, // website_id
|
377 |
-
$countryId, // dest_country_id
|
378 |
-
$regionId, // dest_region_id,
|
379 |
-
$zipCode, // dest_zip
|
380 |
-
$this->_importConditionName,// condition_name,
|
381 |
-
$value, // condition_value
|
382 |
-
$price // price
|
383 |
-
);
|
384 |
-
}
|
385 |
-
|
386 |
-
/**
|
387 |
-
* Save all import data.
|
388 |
-
*
|
389 |
-
* @param array $data
|
390 |
-
* @return $this
|
391 |
-
*/
|
392 |
-
protected function _saveImportData(array $data)
|
393 |
-
{
|
394 |
-
if (!empty($data)) {
|
395 |
-
$columns = array('website_id', 'dest_country_id', 'dest_region_id', 'dest_zip',
|
396 |
-
'condition_name', 'condition_value', 'price');
|
397 |
-
$this->_getWriteAdapter()->insertArray($this->getMainTable(), $columns, $data);
|
398 |
-
$this->_importedRows += count($data);
|
399 |
-
}
|
400 |
-
|
401 |
-
return $this;
|
402 |
-
}
|
403 |
-
|
404 |
-
/**
|
405 |
-
* Conversion.
|
406 |
-
*
|
407 |
-
* @param $value
|
408 |
-
* @return bool|float
|
409 |
-
*/
|
410 |
-
protected function _parseDecimalValue($value)
|
411 |
-
{
|
412 |
-
if (!is_numeric($value)) {
|
413 |
-
return false;
|
414 |
-
}
|
415 |
-
$value = (float)sprintf('%.4F', $value);
|
416 |
-
if ($value < 0.0000) {
|
417 |
-
return false;
|
418 |
-
}
|
419 |
-
return $value;
|
420 |
-
}
|
421 |
}
|
1 |
+
<?php
|
2 |
+
class Bpost_ShM_Model_Resource_Tablerates_Pickuppoint extends Mage_Core_Model_Resource_Db_Abstract{
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Website Id selected in scope.
|
6 |
+
*
|
7 |
+
* @var int
|
8 |
+
*/
|
9 |
+
protected $_importWebsiteId = 0;
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Array to fill with possible errors.
|
13 |
+
*
|
14 |
+
* @var array
|
15 |
+
*/
|
16 |
+
protected $_importErrors = array();
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Number of rows imported.
|
20 |
+
*
|
21 |
+
* @var int
|
22 |
+
*/
|
23 |
+
protected $_importedRows = 0;
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Conversion.
|
27 |
+
*
|
28 |
+
* @var array
|
29 |
+
*/
|
30 |
+
protected $_importUniqueHash = array();
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Conversion.
|
34 |
+
*
|
35 |
+
* @var
|
36 |
+
*/
|
37 |
+
protected $_importIso2Countries;
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Conversion.
|
41 |
+
*
|
42 |
+
* @var
|
43 |
+
*/
|
44 |
+
protected $_importIso3Countries;
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Regions to import.
|
48 |
+
*
|
49 |
+
* @var
|
50 |
+
*/
|
51 |
+
protected $_importRegions;
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Condition name selected in sysconfig.
|
55 |
+
*
|
56 |
+
* @var
|
57 |
+
*/
|
58 |
+
protected $_importConditionName;
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Full name of condition selected in sysconfig.
|
62 |
+
*
|
63 |
+
* @var array
|
64 |
+
*/
|
65 |
+
protected $_conditionFullNames = array();
|
66 |
+
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Initialise the model.
|
70 |
+
*/
|
71 |
+
protected function _construct()
|
72 |
+
{
|
73 |
+
$this->_init("bpost_shm/bpost_tablerates_pickuppoint", "pk");
|
74 |
+
}
|
75 |
+
|
76 |
+
|
77 |
+
/**
|
78 |
+
* Fetch rate from the table for selected shipping address.
|
79 |
+
*
|
80 |
+
* @param Mage_Shipping_Model_Rate_Request $request
|
81 |
+
* @return array
|
82 |
+
*/
|
83 |
+
public function getRate(Mage_Shipping_Model_Rate_Request $request)
|
84 |
+
{
|
85 |
+
$adapter = $this->_getReadAdapter();
|
86 |
+
$bind = array(
|
87 |
+
':website_id' => (int) $request->getWebsiteId(),
|
88 |
+
':country_id' => $request->getDestCountryId(),
|
89 |
+
':region_id' => (int) $request->getDestRegionId(),
|
90 |
+
':postcode' => $request->getDestPostcode()
|
91 |
+
);
|
92 |
+
$select = $adapter->select()
|
93 |
+
->from($this->getMainTable())
|
94 |
+
->where('website_id = :website_id')
|
95 |
+
->order(array('dest_country_id DESC', 'dest_region_id DESC', 'dest_zip DESC', 'condition_value DESC'))
|
96 |
+
->limit(1);
|
97 |
+
|
98 |
+
// Render destination condition
|
99 |
+
$orWhere = '(' . implode(') OR (', array(
|
100 |
+
"dest_country_id = :country_id AND dest_region_id = :region_id AND dest_zip = :postcode",
|
101 |
+
"dest_country_id = :country_id AND dest_region_id = :region_id AND dest_zip = ''",
|
102 |
+
|
103 |
+
// Handle asterix in dest_zip field
|
104 |
+
"dest_country_id = :country_id AND dest_region_id = :region_id AND dest_zip = '*'",
|
105 |
+
"dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = '*'",
|
106 |
+
"dest_country_id = '0' AND dest_region_id = :region_id AND dest_zip = '*'",
|
107 |
+
"dest_country_id = '0' AND dest_region_id = 0 AND dest_zip = '*'",
|
108 |
+
|
109 |
+
"dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = ''",
|
110 |
+
"dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = :postcode",
|
111 |
+
"dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = '*'",
|
112 |
+
)) . ')';
|
113 |
+
$select->where($orWhere);
|
114 |
+
|
115 |
+
// Render condition by condition name
|
116 |
+
if (is_array($request->getConditionName())) {
|
117 |
+
$orWhere = array();
|
118 |
+
$i = 0;
|
119 |
+
foreach ($request->getConditionName() as $conditionName) {
|
120 |
+
$bindNameKey = sprintf(':condition_name_%d', $i);
|
121 |
+
$bindValueKey = sprintf(':condition_value_%d', $i);
|
122 |
+
$orWhere[] = "(condition_name = {$bindNameKey} AND condition_value <= {$bindValueKey})";
|
123 |
+
$bind[$bindNameKey] = $conditionName;
|
124 |
+
$bind[$bindValueKey] = $request->getData($conditionName);
|
125 |
+
$i++;
|
126 |
+
}
|
127 |
+
|
128 |
+
if ($orWhere) {
|
129 |
+
$select->where(implode(' OR ', $orWhere));
|
130 |
+
}
|
131 |
+
} else {
|
132 |
+
$bind[':condition_name'] = $request->getConditionName();
|
133 |
+
$bind[':condition_value'] = $request->getData($request->getConditionName());
|
134 |
+
|
135 |
+
$select->where('condition_name = :condition_name');
|
136 |
+
$select->where('condition_value <= :condition_value');
|
137 |
+
}
|
138 |
+
|
139 |
+
$result = $adapter->fetchRow($select, $bind);
|
140 |
+
// Normalize destination zip code
|
141 |
+
if ($result && $result['dest_zip'] == '*') {
|
142 |
+
$result['dest_zip'] = '';
|
143 |
+
}
|
144 |
+
return $result;
|
145 |
+
}
|
146 |
+
|
147 |
+
|
148 |
+
/**
|
149 |
+
* Upload and import table rates csv.
|
150 |
+
*
|
151 |
+
* @param Varien_Object $object
|
152 |
+
* @return $this
|
153 |
+
*/
|
154 |
+
public function uploadAndImport(Varien_Object $object)
|
155 |
+
{
|
156 |
+
if (empty($_FILES['groups']['tmp_name']['bpost_pickuppoint']['fields']['import_pickuppoint']['value'])) {
|
157 |
+
return $this;
|
158 |
+
}
|
159 |
+
|
160 |
+
$csvFile = $_FILES['groups']['tmp_name']['bpost_pickuppoint']['fields']['import_pickuppoint']['value'];
|
161 |
+
$website = Mage::app()->getWebsite($object->getScopeId());
|
162 |
+
|
163 |
+
$this->_importWebsiteId = (int)$website->getId();
|
164 |
+
$this->_importUniqueHash = array();
|
165 |
+
$this->_importErrors = array();
|
166 |
+
$this->_importedRows = 0;
|
167 |
+
|
168 |
+
$io = new Varien_Io_File();
|
169 |
+
$info = pathinfo($csvFile);
|
170 |
+
$io->open(array('path' => $info['dirname']));
|
171 |
+
$io->streamOpen($info['basename'], 'r');
|
172 |
+
|
173 |
+
// check and skip headers
|
174 |
+
$headers = $io->streamReadCsv();
|
175 |
+
if ($headers === false || count($headers) < 5) {
|
176 |
+
$io->streamClose();
|
177 |
+
Mage::throwException(Mage::helper('bpost_shm')->__('Invalid Table Rates File Format'));
|
178 |
+
}
|
179 |
+
if ($object->getData('groups/bpost_pickuppoint/fields/condition_name/inherit') == '1') {
|
180 |
+
$conditionName = (string)Mage::getConfig()->getNode('default/carriers/bpost_pickuppoint/condition_name');
|
181 |
+
} else {
|
182 |
+
$conditionName = $object->getData('groups/bpost_pickuppoint/fields/condition_name/value');
|
183 |
+
}
|
184 |
+
$this->_importConditionName = $conditionName;
|
185 |
+
$adapter = $this->_getWriteAdapter();
|
186 |
+
$adapter->beginTransaction();
|
187 |
+
|
188 |
+
try {
|
189 |
+
$rowNumber = 1;
|
190 |
+
$importData = array();
|
191 |
+
|
192 |
+
$this->_loadDirectoryCountries();
|
193 |
+
$this->_loadDirectoryRegions();
|
194 |
+
|
195 |
+
// delete old data by website and condition name
|
196 |
+
$condition = array(
|
197 |
+
'website_id = ?' => $this->_importWebsiteId,
|
198 |
+
'condition_name = ?' => $this->_importConditionName
|
199 |
+
);
|
200 |
+
$adapter->delete($this->getMainTable(), $condition);
|
201 |
+
|
202 |
+
while (false !== ($csvLine = $io->streamReadCsv())) {
|
203 |
+
$rowNumber ++;
|
204 |
+
|
205 |
+
if (empty($csvLine)) {
|
206 |
+
continue;
|
207 |
+
}
|
208 |
+
|
209 |
+
$row = $this->_getImportRow($csvLine, $rowNumber);
|
210 |
+
if ($row !== false) {
|
211 |
+
$importData[] = $row;
|
212 |
+
}
|
213 |
+
|
214 |
+
if (count($importData) == 5000) {
|
215 |
+
$this->_saveImportData($importData);
|
216 |
+
$importData = array();
|
217 |
+
}
|
218 |
+
}
|
219 |
+
$this->_saveImportData($importData);
|
220 |
+
$io->streamClose();
|
221 |
+
} catch (Mage_Core_Exception $e) {
|
222 |
+
$adapter->rollback();
|
223 |
+
$io->streamClose();
|
224 |
+
Mage::throwException($e->getMessage());
|
225 |
+
} catch (Exception $e) {
|
226 |
+
$adapter->rollback();
|
227 |
+
$io->streamClose();
|
228 |
+
Mage::helper('bpost_shm')->log($e,Zend_Log::ERR);
|
229 |
+
Mage::throwException(Mage::helper('bpost_shm')->__('An error occurred while importing table rates.'));
|
230 |
+
}
|
231 |
+
|
232 |
+
$adapter->commit();
|
233 |
+
|
234 |
+
if ($this->_importErrors) {
|
235 |
+
$error = Mage::helper('bpost_shm')->__('File has not been imported. See the following list of errors: %s', implode(" \n", $this->_importErrors));
|
236 |
+
Mage::throwException($error);
|
237 |
+
}
|
238 |
+
|
239 |
+
return $this;
|
240 |
+
}
|
241 |
+
|
242 |
+
/**
|
243 |
+
* Load directory countries.
|
244 |
+
*
|
245 |
+
* @return Mage_Shipping_Model_Resource_Carrier_Tablerate
|
246 |
+
*/
|
247 |
+
protected function _loadDirectoryCountries()
|
248 |
+
{
|
249 |
+
if (!is_null($this->_importIso2Countries) && !is_null($this->_importIso3Countries)) {
|
250 |
+
return $this;
|
251 |
+
}
|
252 |
+
|
253 |
+
$this->_importIso2Countries = array();
|
254 |
+
$this->_importIso3Countries = array();
|
255 |
+
|
256 |
+
/** @var $collection Mage_Directory_Model_Resource_Country_Collection */
|
257 |
+
$collection = Mage::getResourceModel('directory/country_collection');
|
258 |
+
foreach ($collection->getData() as $row) {
|
259 |
+
$this->_importIso2Countries[$row['iso2_code']] = $row['country_id'];
|
260 |
+
$this->_importIso3Countries[$row['iso3_code']] = $row['country_id'];
|
261 |
+
}
|
262 |
+
|
263 |
+
return $this;
|
264 |
+
}
|
265 |
+
|
266 |
+
/**
|
267 |
+
* Load directory regions.
|
268 |
+
*
|
269 |
+
* @return Mage_Shipping_Model_Resource_Carrier_Tablerate
|
270 |
+
*/
|
271 |
+
protected function _loadDirectoryRegions()
|
272 |
+
{
|
273 |
+
if (!is_null($this->_importRegions)) {
|
274 |
+
return $this;
|
275 |
+
}
|
276 |
+
|
277 |
+
$this->_importRegions = array();
|
278 |
+
|
279 |
+
/** @var $collection Mage_Directory_Model_Resource_Region_Collection */
|
280 |
+
$collection = Mage::getResourceModel('directory/region_collection');
|
281 |
+
foreach ($collection->getData() as $row) {
|
282 |
+
$this->_importRegions[$row['country_id']][$row['code']] = (int)$row['region_id'];
|
283 |
+
}
|
284 |
+
|
285 |
+
return $this;
|
286 |
+
}
|
287 |
+
|
288 |
+
/**
|
289 |
+
* Return import condition full name by condition name code.
|
290 |
+
*
|
291 |
+
* @param string $conditionName
|
292 |
+
* @return string
|
293 |
+
*/
|
294 |
+
protected function _getConditionFullName($conditionName)
|
295 |
+
{
|
296 |
+
if (!isset($this->_conditionFullNames[$conditionName])) {
|
297 |
+
$name = Mage::getSingleton('shipping/carrier_tablerate')->getCode('condition_name_short', $conditionName);
|
298 |
+
$this->_conditionFullNames[$conditionName] = $name;
|
299 |
+
}
|
300 |
+
return $this->_conditionFullNames[$conditionName];
|
301 |
+
}
|
302 |
+
|
303 |
+
/**
|
304 |
+
* Validate row for import and return table rate array or false.
|
305 |
+
* Error will be add to _importErrors array.
|
306 |
+
*
|
307 |
+
* @param array $row
|
308 |
+
* @param int $rowNumber
|
309 |
+
* @return array|false
|
310 |
+
*/
|
311 |
+
protected function _getImportRow($row, $rowNumber = 0)
|
312 |
+
{
|
313 |
+
// validate row
|
314 |
+
if (count($row) < 5) {
|
315 |
+
$this->_importErrors[] = Mage::helper('bpost_shm')->__('Invalid Table Rates format in the Row #%s', $rowNumber);
|
316 |
+
return false;
|
317 |
+
}
|
318 |
+
|
319 |
+
// strip whitespace from the beginning and end of each row
|
320 |
+
foreach ($row as $k => $v) {
|
321 |
+
$row[$k] = trim($v);
|
322 |
+
}
|
323 |
+
|
324 |
+
// validate country
|
325 |
+
if (isset($this->_importIso2Countries[$row[0]])){
|
326 |
+
$countryId = $this->_importIso2Countries[$row[0]];
|
327 |
+
} elseif (isset($this->_importIso3Countries[$row[0]])) {
|
328 |
+
$countryId = $this->_importIso3Countries[$row[0]];
|
329 |
+
} elseif ($row[0] == '*' || $row[0] == '') {
|
330 |
+
$countryId = '0';
|
331 |
+
} else {
|
332 |
+
$this->_importErrors[] = Mage::helper('bpost_shm')->__('Invalid Country "%s" in the Row #%s.', $row[0], $rowNumber);
|
333 |
+
return false;
|
334 |
+
}
|
335 |
+
|
336 |
+
// validate region
|
337 |
+
if ($countryId != '0' && isset($this->_importRegions[$countryId][$row[1]])) {
|
338 |
+
$regionId = $this->_importRegions[$countryId][$row[1]];
|
339 |
+
} elseif ($row[1] == '*' || $row[1] == '') {
|
340 |
+
$regionId = 0;
|
341 |
+
} else {
|
342 |
+
$this->_importErrors[] = Mage::helper('bpost_shm')->__('Invalid Region/State "%s" in the Row #%s.', $row[1], $rowNumber);
|
343 |
+
return false;
|
344 |
+
}
|
345 |
+
|
346 |
+
// detect zip code
|
347 |
+
if ($row[2] == '*' || $row[2] == '') {
|
348 |
+
$zipCode = '*';
|
349 |
+
} else {
|
350 |
+
$zipCode = $row[2];
|
351 |
+
}
|
352 |
+
|
353 |
+
// validate condition value
|
354 |
+
$value = $this->_parseDecimalValue($row[3]);
|
355 |
+
if ($value === false) {
|
356 |
+
$this->_importErrors[] = Mage::helper('bpost_shm')->__('Invalid %s "%s" in the Row #%s.', $this->_getConditionFullName($this->_importConditionName), $row[3], $rowNumber);
|
357 |
+
return false;
|
358 |
+
}
|
359 |
+
|
360 |
+
// validate price
|
361 |
+
$price = $this->_parseDecimalValue($row[4]);
|
362 |
+
if ($price === false) {
|
363 |
+
$this->_importErrors[] = Mage::helper('bpost_shm')->__('Invalid Shipping Price "%s" in the Row #%s.', $row[4], $rowNumber);
|
364 |
+
return false;
|
365 |
+
}
|
366 |
+
|
367 |
+
// protect from duplicate
|
368 |
+
$hash = sprintf("%s-%d-%s-%F", $countryId, $regionId, $zipCode, $value);
|
369 |
+
if (isset($this->_importUniqueHash[$hash])) {
|
370 |
+
$this->_importErrors[] = Mage::helper('bpost_shm')->__('Duplicate Row #%s (Country "%s", Region/State "%s", Zip "%s" and Value "%s").', $rowNumber, $row[0], $row[1], $zipCode, $value);
|
371 |
+
return false;
|
372 |
+
}
|
373 |
+
$this->_importUniqueHash[$hash] = true;
|
374 |
+
|
375 |
+
return array(
|
376 |
+
$this->_importWebsiteId, // website_id
|
377 |
+
$countryId, // dest_country_id
|
378 |
+
$regionId, // dest_region_id,
|
379 |
+
$zipCode, // dest_zip
|
380 |
+
$this->_importConditionName,// condition_name,
|
381 |
+
$value, // condition_value
|
382 |
+
$price // price
|
383 |
+
);
|
384 |
+
}
|
385 |
+
|
386 |
+
/**
|
387 |
+
* Save all import data.
|
388 |
+
*
|
389 |
+
* @param array $data
|
390 |
+
* @return $this
|
391 |
+
*/
|
392 |
+
protected function _saveImportData(array $data)
|
393 |
+
{
|
394 |
+
if (!empty($data)) {
|
395 |
+
$columns = array('website_id', 'dest_country_id', 'dest_region_id', 'dest_zip',
|
396 |
+
'condition_name', 'condition_value', 'price');
|
397 |
+
$this->_getWriteAdapter()->insertArray($this->getMainTable(), $columns, $data);
|
398 |
+
$this->_importedRows += count($data);
|
399 |
+
}
|
400 |
+
|
401 |
+
return $this;
|
402 |
+
}
|
403 |
+
|
404 |
+
/**
|
405 |
+
* Conversion.
|
406 |
+
*
|
407 |
+
* @param $value
|
408 |
+
* @return bool|float
|
409 |
+
*/
|
410 |
+
protected function _parseDecimalValue($value)
|
411 |
+
{
|
412 |
+
if (!is_numeric($value)) {
|
413 |
+
return false;
|
414 |
+
}
|
415 |
+
$value = (float)sprintf('%.4F', $value);
|
416 |
+
if ($value < 0.0000) {
|
417 |
+
return false;
|
418 |
+
}
|
419 |
+
return $value;
|
420 |
+
}
|
421 |
}
|
app/code/community/Bpost/ShM/Model/Resource/Tablerates/Pickuppoint/Collection.php
CHANGED
@@ -1,95 +1,95 @@
|
|
1 |
-
<?php
|
2 |
-
class Bpost_ShM_Model_Resource_Tablerates_Pickuppoint_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
|
3 |
-
{
|
4 |
-
/**
|
5 |
-
* main table name
|
6 |
-
*
|
7 |
-
* @deprecated since 1.4.1.0
|
8 |
-
* @var string
|
9 |
-
*/
|
10 |
-
protected $_shipTable;
|
11 |
-
|
12 |
-
/**
|
13 |
-
* directory/country table name
|
14 |
-
*
|
15 |
-
* @var string
|
16 |
-
*/
|
17 |
-
protected $_countryTable;
|
18 |
-
|
19 |
-
/**
|
20 |
-
* directory/country_region table name
|
21 |
-
*
|
22 |
-
* @var string
|
23 |
-
*/
|
24 |
-
protected $_regionTable;
|
25 |
-
|
26 |
-
/**
|
27 |
-
* Define resource model and item
|
28 |
-
*
|
29 |
-
*/
|
30 |
-
protected function _construct()
|
31 |
-
{
|
32 |
-
$this->_init('bpost_shm/tablerates_pickuppoint');
|
33 |
-
$this->_shipTable = $this->getMainTable();
|
34 |
-
$this->_countryTable = $this->getTable('directory/country');
|
35 |
-
$this->_regionTable = $this->getTable('directory/country_region');
|
36 |
-
}
|
37 |
-
|
38 |
-
/**
|
39 |
-
* Initialize select, add country iso3 code and region name
|
40 |
-
*
|
41 |
-
* @return void
|
42 |
-
*/
|
43 |
-
public function _initSelect()
|
44 |
-
{
|
45 |
-
parent::_initSelect();
|
46 |
-
|
47 |
-
$this->_select
|
48 |
-
->joinLeft(
|
49 |
-
array('country_table' => $this->_countryTable),
|
50 |
-
'country_table.country_id = main_table.dest_country_id',
|
51 |
-
array('dest_country' => 'iso3_code'))
|
52 |
-
->joinLeft(
|
53 |
-
array('region_table' => $this->_regionTable),
|
54 |
-
'region_table.region_id = main_table.dest_region_id',
|
55 |
-
array('dest_region' => 'code'));
|
56 |
-
|
57 |
-
$this->addOrder('dest_country', self::SORT_ORDER_ASC);
|
58 |
-
$this->addOrder('dest_region', self::SORT_ORDER_ASC);
|
59 |
-
$this->addOrder('dest_zip', self::SORT_ORDER_ASC);
|
60 |
-
$this->addOrder('condition_value', self::SORT_ORDER_ASC);
|
61 |
-
}
|
62 |
-
|
63 |
-
/**
|
64 |
-
* Add website filter to collection
|
65 |
-
*
|
66 |
-
* @param int $websiteId
|
67 |
-
* @return Mage_Shipping_Model_Resource_Carrier_Tablerate_Collection
|
68 |
-
*/
|
69 |
-
public function setWebsiteFilter($websiteId)
|
70 |
-
{
|
71 |
-
return $this->addFieldToFilter('website_id', $websiteId);
|
72 |
-
}
|
73 |
-
|
74 |
-
/**
|
75 |
-
* Add condition name (code) filter to collection
|
76 |
-
*
|
77 |
-
* @param string $conditionName
|
78 |
-
* @return Mage_Shipping_Model_Resource_Carrier_Tablerate_Collection
|
79 |
-
*/
|
80 |
-
public function setConditionFilter($conditionName)
|
81 |
-
{
|
82 |
-
return $this->addFieldToFilter('condition_name', $conditionName);
|
83 |
-
}
|
84 |
-
|
85 |
-
/**
|
86 |
-
* Add country filter to collection
|
87 |
-
*
|
88 |
-
* @param string $countryId
|
89 |
-
* @return Mage_Shipping_Model_Resource_Carrier_Tablerate_Collection
|
90 |
-
*/
|
91 |
-
public function setCountryFilter($countryId)
|
92 |
-
{
|
93 |
-
return $this->addFieldToFilter('dest_country_id', $countryId);
|
94 |
-
}
|
95 |
}
|
1 |
+
<?php
|
2 |
+
class Bpost_ShM_Model_Resource_Tablerates_Pickuppoint_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
|
3 |
+
{
|
4 |
+
/**
|
5 |
+
* main table name
|
6 |
+
*
|
7 |
+
* @deprecated since 1.4.1.0
|
8 |
+
* @var string
|
9 |
+
*/
|
10 |
+
protected $_shipTable;
|
11 |
+
|
12 |
+
/**
|
13 |
+
* directory/country table name
|
14 |
+
*
|
15 |
+
* @var string
|
16 |
+
*/
|
17 |
+
protected $_countryTable;
|
18 |
+
|
19 |
+
/**
|
20 |
+
* directory/country_region table name
|
21 |
+
*
|
22 |
+
* @var string
|
23 |
+
*/
|
24 |
+
protected $_regionTable;
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Define resource model and item
|
28 |
+
*
|
29 |
+
*/
|
30 |
+
protected function _construct()
|
31 |
+
{
|
32 |
+
$this->_init('bpost_shm/tablerates_pickuppoint');
|
33 |
+
$this->_shipTable = $this->getMainTable();
|
34 |
+
$this->_countryTable = $this->getTable('directory/country');
|
35 |
+
$this->_regionTable = $this->getTable('directory/country_region');
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Initialize select, add country iso3 code and region name
|
40 |
+
*
|
41 |
+
* @return void
|
42 |
+
*/
|
43 |
+
public function _initSelect()
|
44 |
+
{
|
45 |
+
parent::_initSelect();
|
46 |
+
|
47 |
+
$this->_select
|
48 |
+
->joinLeft(
|
49 |
+
array('country_table' => $this->_countryTable),
|
50 |
+
'country_table.country_id = main_table.dest_country_id',
|
51 |
+
array('dest_country' => 'iso3_code'))
|
52 |
+
->joinLeft(
|
53 |
+
array('region_table' => $this->_regionTable),
|
54 |
+
'region_table.region_id = main_table.dest_region_id',
|
55 |
+
array('dest_region' => 'code'));
|
56 |
+
|
57 |
+
$this->addOrder('dest_country', self::SORT_ORDER_ASC);
|
58 |
+
$this->addOrder('dest_region', self::SORT_ORDER_ASC);
|
59 |
+
$this->addOrder('dest_zip', self::SORT_ORDER_ASC);
|
60 |
+
$this->addOrder('condition_value', self::SORT_ORDER_ASC);
|
61 |
+
}
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Add website filter to collection
|
65 |
+
*
|
66 |
+
* @param int $websiteId
|
67 |
+
* @return Mage_Shipping_Model_Resource_Carrier_Tablerate_Collection
|
68 |
+
*/
|
69 |
+
public function setWebsiteFilter($websiteId)
|
70 |
+
{
|
71 |
+
return $this->addFieldToFilter('website_id', $websiteId);
|
72 |
+
}
|
73 |
+
|
74 |
+
/**
|
75 |
+
* Add condition name (code) filter to collection
|
76 |
+
*
|
77 |
+
* @param string $conditionName
|
78 |
+
* @return Mage_Shipping_Model_Resource_Carrier_Tablerate_Collection
|
79 |
+
*/
|
80 |
+
public function setConditionFilter($conditionName)
|
81 |
+
{
|
82 |
+
return $this->addFieldToFilter('condition_name', $conditionName);
|
83 |
+
}
|
84 |
+
|
85 |
+
/**
|
86 |
+
* Add country filter to collection
|
87 |
+
*
|
88 |
+
* @param string $countryId
|
89 |
+
* @return Mage_Shipping_Model_Resource_Carrier_Tablerate_Collection
|
90 |
+
*/
|
91 |
+
public function setCountryFilter($countryId)
|
92 |
+
{
|
93 |
+
return $this->addFieldToFilter('dest_country_id', $countryId);
|
94 |
+
}
|
95 |
}
|
app/code/community/Bpost/ShM/Model/Returnlabel.php
CHANGED
@@ -1,124 +1,124 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Created by PHPro
|
5 |
-
*
|
6 |
-
* @package Bpost
|
7 |
-
* @subpackage ShM
|
8 |
-
* @author PHPro (info@phpro.be)
|
9 |
-
*/
|
10 |
-
|
11 |
-
/**
|
12 |
-
* Class Bpost_ShM_Model_Returnlabel
|
13 |
-
*/
|
14 |
-
class Bpost_ShM_Model_Returnlabel extends Mage_Core_Model_Abstract
|
15 |
-
{
|
16 |
-
const MEDIA_RETURNLABEL_PATH = "/bpost/";
|
17 |
-
|
18 |
-
/**
|
19 |
-
* Initialise the model.
|
20 |
-
*/
|
21 |
-
protected function _construct()
|
22 |
-
{
|
23 |
-
$this->_init("bpost_shm/returnlabel");
|
24 |
-
}
|
25 |
-
|
26 |
-
|
27 |
-
/**
|
28 |
-
* Gets label from webservice, saves it and returns the saved id.
|
29 |
-
*
|
30 |
-
* @param $orderId
|
31 |
-
* @return int
|
32 |
-
*/
|
33 |
-
public function generateLabelAndSave($orderId)
|
34 |
-
{
|
35 |
-
$order = Mage::getModel('sales/order')->load($orderId);
|
36 |
-
$bpostHelper = Mage::helper("bpost_shm");
|
37 |
-
$returnLabelHelper = Mage::helper("bpost_shm/returnlabel");
|
38 |
-
|
39 |
-
//check for return order
|
40 |
-
$api = Mage::getModel('bpost_shm/api');
|
41 |
-
$api->initialize($order->getStoreId());
|
42 |
-
$returnlabelResponse = $api->createReturnLabel($order);
|
43 |
-
|
44 |
-
if(!$returnlabelResponse){
|
45 |
-
Mage::throwException("Failed to create a return label. Please check your error logs.");
|
46 |
-
}
|
47 |
-
|
48 |
-
$parsedLabelResponse = $bpostHelper->parseLabelApiResponse($returnlabelResponse, $order);
|
49 |
-
|
50 |
-
//make sure we save with an unique name
|
51 |
-
//if no barcode is returned (probably never)
|
52 |
-
$barcode = $returnLabelHelper->getBarcodeByLabelResponse($order, $parsedLabelResponse);
|
53 |
-
|
54 |
-
foreach($parsedLabelResponse["pdfString"] as $pdfString){
|
55 |
-
//convertstring to pdf and save
|
56 |
-
$pdfname = $bpostHelper->generatePdfAndSave($pdfString, "returnlabel", $barcode);
|
57 |
-
}
|
58 |
-
|
59 |
-
$returnLabelObject = new Bpost_ShM_Model_Returnlabel;
|
60 |
-
$returnLabelObject
|
61 |
-
->setLabelBarcode($barcode)
|
62 |
-
->setLabelPdfPath("returnlabel/$pdfname.pdf")
|
63 |
-
->setOrderId($orderId)
|
64 |
-
->setDateCreated(time());
|
65 |
-
|
66 |
-
$order->setBpostReturnLabelExists(true);
|
67 |
-
|
68 |
-
//we start a transaction
|
69 |
-
//we save multiple objects
|
70 |
-
Mage::getModel('core/resource_transaction')
|
71 |
-
->addObject($returnLabelObject)
|
72 |
-
->addObject($order)
|
73 |
-
->save();
|
74 |
-
|
75 |
-
return $returnLabelObject->getId();
|
76 |
-
}
|
77 |
-
|
78 |
-
/**
|
79 |
-
* Sends email with custom bpost email and attached the pdf
|
80 |
-
*
|
81 |
-
* @param $order
|
82 |
-
* @param $returnId
|
83 |
-
* @return $this
|
84 |
-
*/
|
85 |
-
public function sendEmail($returnId)
|
86 |
-
{
|
87 |
-
$file = new Varien_Io_File();
|
88 |
-
$bpostHelper = Mage::helper("bpost_shm");
|
89 |
-
$translate = Mage::getSingleton('core/translate');
|
90 |
-
$translate->setTranslateInline(false);
|
91 |
-
$returnLabel = Mage::getModel('bpost_shm/returnlabel')->load($returnId);
|
92 |
-
$order = Mage::getModel('sales/order')->load($returnLabel->getOrderId());
|
93 |
-
$billingAddress = $order->getBillingAddress();
|
94 |
-
$pdfAttachment = $returnLabel->getLabelPdfPath();
|
95 |
-
|
96 |
-
$templateVars = array('returnlabel' => $returnLabel, 'order' => $order, 'store' => Mage::app()->getStore($order->getStoreId()));
|
97 |
-
$transactionalEmail = Mage::getModel('core/email_template')->setDesignConfig(array('area' => 'frontend', 'store' => $order->getStoreId()));
|
98 |
-
|
99 |
-
$filePath = Mage::getBaseDir('media') . self::MEDIA_RETURNLABEL_PATH . $pdfAttachment;
|
100 |
-
$pdfFileParser = Zend_Pdf::load($filePath);
|
101 |
-
|
102 |
-
if (!empty($pdfAttachment) && $file->fileExists($filePath)) {
|
103 |
-
$fileName = $bpostHelper->getFileNameByPath($pdfAttachment);
|
104 |
-
$transactionalEmail->getMail()
|
105 |
-
->createAttachment(
|
106 |
-
$pdfFileParser->render(),
|
107 |
-
Zend_Mime::TYPE_OCTETSTREAM,
|
108 |
-
Zend_Mime::DISPOSITION_ATTACHMENT,
|
109 |
-
Zend_Mime::ENCODING_BASE64,
|
110 |
-
$fileName
|
111 |
-
);
|
112 |
-
}
|
113 |
-
|
114 |
-
$transactionalEmail->sendTransactional('bpost_returnlabel_email_template',
|
115 |
-
array('name' => Mage::getStoreConfig('trans_email/ident_support/name'),
|
116 |
-
'email' => Mage::getStoreConfig('trans_email/ident_support/email')),
|
117 |
-
$billingAddress->getEmail(),
|
118 |
-
$billingAddress->getFirstname() . " " . $billingAddress->getLastname(),
|
119 |
-
$templateVars);
|
120 |
-
|
121 |
-
$translate->setTranslateInline(true);
|
122 |
-
return $billingAddress->getEmail();
|
123 |
-
}
|
124 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Created by PHPro
|
5 |
+
*
|
6 |
+
* @package Bpost
|
7 |
+
* @subpackage ShM
|
8 |
+
* @author PHPro (info@phpro.be)
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Class Bpost_ShM_Model_Returnlabel
|
13 |
+
*/
|
14 |
+
class Bpost_ShM_Model_Returnlabel extends Mage_Core_Model_Abstract
|
15 |
+
{
|
16 |
+
const MEDIA_RETURNLABEL_PATH = "/bpost/";
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Initialise the model.
|
20 |
+
*/
|
21 |
+
protected function _construct()
|
22 |
+
{
|
23 |
+
$this->_init("bpost_shm/returnlabel");
|
24 |
+
}
|
25 |
+
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Gets label from webservice, saves it and returns the saved id.
|
29 |
+
*
|
30 |
+
* @param $orderId
|
31 |
+
* @return int
|
32 |
+
*/
|
33 |
+
public function generateLabelAndSave($orderId)
|
34 |
+
{
|
35 |
+
$order = Mage::getModel('sales/order')->load($orderId);
|
36 |
+
$bpostHelper = Mage::helper("bpost_shm");
|
37 |
+
$returnLabelHelper = Mage::helper("bpost_shm/returnlabel");
|
38 |
+
|
39 |
+
//check for return order
|
40 |
+
$api = Mage::getModel('bpost_shm/api');
|
41 |
+
$api->initialize($order->getStoreId());
|
42 |
+
$returnlabelResponse = $api->createReturnLabel($order);
|
43 |
+
|
44 |
+
if(!$returnlabelResponse){
|
45 |
+
Mage::throwException("Failed to create a return label. Please check your error logs.");
|
46 |
+
}
|
47 |
+
|
48 |
+
$parsedLabelResponse = $bpostHelper->parseLabelApiResponse($returnlabelResponse, $order);
|
49 |
+
|
50 |
+
//make sure we save with an unique name
|
51 |
+
//if no barcode is returned (probably never)
|
52 |
+
$barcode = $returnLabelHelper->getBarcodeByLabelResponse($order, $parsedLabelResponse);
|
53 |
+
|
54 |
+
foreach($parsedLabelResponse["pdfString"] as $pdfString){
|
55 |
+
//convertstring to pdf and save
|
56 |
+
$pdfname = $bpostHelper->generatePdfAndSave($pdfString, "returnlabel", $barcode);
|
57 |
+
}
|
58 |
+
|
59 |
+
$returnLabelObject = new Bpost_ShM_Model_Returnlabel;
|
60 |
+
$returnLabelObject
|
61 |
+
->setLabelBarcode($barcode)
|
62 |
+
->setLabelPdfPath("returnlabel/$pdfname.pdf")
|
63 |
+
->setOrderId($orderId)
|
64 |
+
->setDateCreated(time());
|
65 |
+
|
66 |
+
$order->setBpostReturnLabelExists(true);
|
67 |
+
|
68 |
+
//we start a transaction
|
69 |
+
//we save multiple objects
|
70 |
+
Mage::getModel('core/resource_transaction')
|
71 |
+
->addObject($returnLabelObject)
|
72 |
+
->addObject($order)
|
73 |
+
->save();
|
74 |
+
|
75 |
+
return $returnLabelObject->getId();
|
76 |
+
}
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Sends email with custom bpost email and attached the pdf
|
80 |
+
*
|
81 |
+
* @param $order
|
82 |
+
* @param $returnId
|
83 |
+
* @return $this
|
84 |
+
*/
|
85 |
+
public function sendEmail($returnId)
|
86 |
+
{
|
87 |
+
$file = new Varien_Io_File();
|
88 |
+
$bpostHelper = Mage::helper("bpost_shm");
|
89 |
+
$translate = Mage::getSingleton('core/translate');
|
90 |
+
$translate->setTranslateInline(false);
|
91 |
+
$returnLabel = Mage::getModel('bpost_shm/returnlabel')->load($returnId);
|
92 |
+
$order = Mage::getModel('sales/order')->load($returnLabel->getOrderId());
|
93 |
+
$billingAddress = $order->getBillingAddress();
|
94 |
+
$pdfAttachment = $returnLabel->getLabelPdfPath();
|
95 |
+
|
96 |
+
$templateVars = array('returnlabel' => $returnLabel, 'order' => $order, 'store' => Mage::app()->getStore($order->getStoreId()));
|
97 |
+
$transactionalEmail = Mage::getModel('core/email_template')->setDesignConfig(array('area' => 'frontend', 'store' => $order->getStoreId()));
|
98 |
+
|
99 |
+
$filePath = Mage::getBaseDir('media') . self::MEDIA_RETURNLABEL_PATH . $pdfAttachment;
|
100 |
+
$pdfFileParser = Zend_Pdf::load($filePath);
|
101 |
+
|
102 |
+
if (!empty($pdfAttachment) && $file->fileExists($filePath)) {
|
103 |
+
$fileName = $bpostHelper->getFileNameByPath($pdfAttachment);
|
104 |
+
$transactionalEmail->getMail()
|
105 |
+
->createAttachment(
|
106 |
+
$pdfFileParser->render(),
|
107 |
+
Zend_Mime::TYPE_OCTETSTREAM,
|
108 |
+
Zend_Mime::DISPOSITION_ATTACHMENT,
|
109 |
+
Zend_Mime::ENCODING_BASE64,
|
110 |
+
$fileName
|
111 |
+
);
|
112 |
+
}
|
113 |
+
|
114 |
+
$transactionalEmail->sendTransactional('bpost_returnlabel_email_template',
|
115 |
+
array('name' => Mage::getStoreConfig('trans_email/ident_support/name'),
|
116 |
+
'email' => Mage::getStoreConfig('trans_email/ident_support/email')),
|
117 |
+
$billingAddress->getEmail(),
|
118 |
+
$billingAddress->getFirstname() . " " . $billingAddress->getLastname(),
|
119 |
+
$templateVars);
|
120 |
+
|
121 |
+
$translate->setTranslateInline(true);
|
122 |
+
return $billingAddress->getEmail();
|
123 |
+
}
|
124 |
+
}
|
app/code/community/Bpost/ShM/Model/Shipping/Carrier/BpostShM.php
CHANGED
@@ -1,339 +1,345 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Created by PHPro
|
5 |
-
*
|
6 |
-
* @package Bpost
|
7 |
-
* @subpackage ShM
|
8 |
-
* @author PHPro (info@phpro.be)
|
9 |
-
*/
|
10 |
-
|
11 |
-
/**
|
12 |
-
* Class Bpost_ShM_Model_Shipping_Carrier_BpostShM
|
13 |
-
*/
|
14 |
-
class Bpost_ShM_Model_Shipping_Carrier_BpostShM extends Mage_Shipping_Model_Carrier_Abstract
|
15 |
-
implements Mage_Shipping_Model_Carrier_Interface
|
16 |
-
{
|
17 |
-
const SHIPMENT_TRACK_DOMAIN = "http://track.bpost.be/";
|
18 |
-
|
19 |
-
protected $_code = 'bpostshm';
|
20 |
-
protected $_isFixed = true;
|
21 |
-
|
22 |
-
/**
|
23 |
-
* Edited collectRates function for bpost carriers
|
24 |
-
*
|
25 |
-
* @param Mage_Shipping_Model_Rate_Request $request
|
26 |
-
* @return bool|Mage_Shipping_Model_Rate_Result|null
|
27 |
-
*/
|
28 |
-
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
|
29 |
-
{
|
30 |
-
$disabledShippingMethods = 0;
|
31 |
-
$result = Mage::getModel('bpost_shm/shipping_rate_result');
|
32 |
-
|
33 |
-
$helper = Mage::helper("bpost_shm");
|
34 |
-
$configHelper = Mage::helper("bpost_shm/system_config");
|
35 |
-
$checkoutSession = Mage::getSingleton('checkout/session');
|
36 |
-
|
37 |
-
$ratePriceByMethod = array();
|
38 |
-
$totalAallowedShippingMethods = count($this->getAllowedMethods());
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
if (!$this->getBpostConfigData('
|
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 |
-
$request->
|
93 |
-
|
94 |
-
$
|
95 |
-
|
96 |
-
|
97 |
-
$request->
|
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 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
)
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
$
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
$
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
$
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
$
|
259 |
-
|
260 |
-
$
|
261 |
-
$
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
$
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Created by PHPro
|
5 |
+
*
|
6 |
+
* @package Bpost
|
7 |
+
* @subpackage ShM
|
8 |
+
* @author PHPro (info@phpro.be)
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Class Bpost_ShM_Model_Shipping_Carrier_BpostShM
|
13 |
+
*/
|
14 |
+
class Bpost_ShM_Model_Shipping_Carrier_BpostShM extends Mage_Shipping_Model_Carrier_Abstract
|
15 |
+
implements Mage_Shipping_Model_Carrier_Interface
|
16 |
+
{
|
17 |
+
const SHIPMENT_TRACK_DOMAIN = "http://track.bpost.be/";
|
18 |
+
|
19 |
+
protected $_code = 'bpostshm';
|
20 |
+
protected $_isFixed = true;
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Edited collectRates function for bpost carriers
|
24 |
+
*
|
25 |
+
* @param Mage_Shipping_Model_Rate_Request $request
|
26 |
+
* @return bool|Mage_Shipping_Model_Rate_Result|null
|
27 |
+
*/
|
28 |
+
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
|
29 |
+
{
|
30 |
+
$disabledShippingMethods = 0;
|
31 |
+
$result = Mage::getModel('bpost_shm/shipping_rate_result');
|
32 |
+
|
33 |
+
$helper = Mage::helper("bpost_shm");
|
34 |
+
$configHelper = Mage::helper("bpost_shm/system_config");
|
35 |
+
$checkoutSession = Mage::getSingleton('checkout/session');
|
36 |
+
|
37 |
+
$ratePriceByMethod = array();
|
38 |
+
$totalAallowedShippingMethods = count($this->getAllowedMethods());
|
39 |
+
|
40 |
+
$quote2 = Mage::getSingleton('checkout/session')->getQuote();
|
41 |
+
$discountTotal = 0;
|
42 |
+
foreach ($quote2->getAllItems() as $item){
|
43 |
+
$discountTotal += $item->getDiscountAmount();
|
44 |
+
}
|
45 |
+
|
46 |
+
foreach ($this->getAllowedMethods() as $shippingMethodCode => $shippingMethodName) {
|
47 |
+
if (!$this->getBpostConfigData('active', $shippingMethodCode) || !$this->checkAvailableBpostShipCountries($request, $shippingMethodCode)) {
|
48 |
+
$disabledShippingMethods++;
|
49 |
+
continue;
|
50 |
+
}
|
51 |
+
|
52 |
+
$method = Mage::getModel('shipping/rate_result_method');
|
53 |
+
if (!$this->getBpostConfigData('rate_type', $shippingMethodCode)) {
|
54 |
+
$price = $this->getBpostConfigData('flat_rate_price', $shippingMethodCode);
|
55 |
+
if ($request->getFreeShipping() === true ||
|
56 |
+
($this->getBpostConfigData('free_shipping', $shippingMethodCode) &&
|
57 |
+
$request->getBaseSubtotalInclTax() - $discountTotal >= $this->getBpostConfigData('free_shipping_from', $shippingMethodCode))
|
58 |
+
) {
|
59 |
+
$price = 0;
|
60 |
+
}
|
61 |
+
} else {
|
62 |
+
$freeQty = 0;
|
63 |
+
if ($request->getAllItems()) {
|
64 |
+
$freePackageValue = 0;
|
65 |
+
foreach ($request->getAllItems() as $item) {
|
66 |
+
if ($item->getProduct()->isVirtual() || $item->getParentItem()) {
|
67 |
+
continue;
|
68 |
+
}
|
69 |
+
|
70 |
+
if ($item->getHasChildren() && $item->isShipSeparately()) {
|
71 |
+
foreach ($item->getChildren() as $child) {
|
72 |
+
if ($child->getFreeShipping() && !$child->getProduct()->isVirtual()) {
|
73 |
+
$freeShipping = is_numeric($child->getFreeShipping()) ? $child->getFreeShipping() : 0;
|
74 |
+
$freeQty += $item->getQty() * ($child->getQty() - $freeShipping);
|
75 |
+
}
|
76 |
+
}
|
77 |
+
} elseif ($item->getFreeShipping()) {
|
78 |
+
$freeShipping = is_numeric($item->getFreeShipping()) ? $item->getFreeShipping() : 0;
|
79 |
+
$freeQty += $item->getQty() - $freeShipping;
|
80 |
+
$freePackageValue += $item->getBaseRowTotal();
|
81 |
+
}
|
82 |
+
}
|
83 |
+
$oldValue = $request->getPackageValue();
|
84 |
+
$request->setPackageValue($oldValue - $freePackageValue);
|
85 |
+
}
|
86 |
+
|
87 |
+
if ($freePackageValue) {
|
88 |
+
$request->setPackageValue($request->getPackageValue() - $freePackageValue);
|
89 |
+
}
|
90 |
+
|
91 |
+
$conditionName = $this->getBpostConfigData('condition_name', $shippingMethodCode);
|
92 |
+
$request->setConditionName($conditionName ? $conditionName : $this->_default_condition_name);
|
93 |
+
|
94 |
+
$oldWeight = $request->getPackageWeight();
|
95 |
+
$oldQty = $request->getPackageQty();
|
96 |
+
|
97 |
+
$request->setPackageWeight($request->getFreeMethodWeight());
|
98 |
+
$request->setPackageQty($oldQty - $freeQty);
|
99 |
+
|
100 |
+
$rate = $this->getRate($request, $shippingMethodCode);
|
101 |
+
|
102 |
+
$request->setPackageWeight($oldWeight);
|
103 |
+
$request->setPackageQty($oldQty);
|
104 |
+
|
105 |
+
if (!empty($rate) && $rate['price'] >= 0) {
|
106 |
+
if ($request->getFreeShipping() === true ||
|
107 |
+
($request->getPackageQty() == $freeQty) ||
|
108 |
+
($this->getBpostConfigData('free_shipping', $shippingMethodCode) &&
|
109 |
+
$request->getPackageValue() >= $this->getBpostConfigData('free_shipping_from', $shippingMethodCode))
|
110 |
+
) {
|
111 |
+
$price = 0;
|
112 |
+
} else {
|
113 |
+
$price = $rate['price'];
|
114 |
+
}
|
115 |
+
} elseif (empty($rate) && $request->getFreeShipping() === true) {
|
116 |
+
$request->setPackageValue($freePackageValue);
|
117 |
+
$request->setPackageQty($freeQty);
|
118 |
+
$rate = $this->getRate($request, $shippingMethodCode);
|
119 |
+
|
120 |
+
if (!empty($rate) && $rate['price'] >= 0) {
|
121 |
+
$price = 0;
|
122 |
+
}
|
123 |
+
} else {
|
124 |
+
$result->append($this->_getCarriersErrorMessage($shippingMethodCode));
|
125 |
+
continue;
|
126 |
+
}
|
127 |
+
}
|
128 |
+
|
129 |
+
$pcValidationResult = Mage::helper('bpost_shm')->validatePostcode($request->getDestCountryId(), $request->getDestPostcode());
|
130 |
+
if (($shippingMethodCode == 'bpost_homedelivery' || $shippingMethodCode == 'bpost_international') && $pcValidationResult != 'passed') {
|
131 |
+
$error = Mage::getModel('shipping/rate_result_error');
|
132 |
+
$error->setCarrier($this->_code);
|
133 |
+
$error->setCarrierTitle('Bpost ShippingManager');
|
134 |
+
$error->setData('error_message', Mage::helper('bpost_shm')->__('The Bpost shipping method "%s" is not available because your postal code is not correct. For your country the format should be like "%s". Please correct the postal code in your shipping address.', $shippingMethodName, $pcValidationResult));
|
135 |
+
$result->append($error);
|
136 |
+
continue;
|
137 |
+
}
|
138 |
+
|
139 |
+
$saturdayDeliveryCost = $helper->formatSaturdayDeliveryCost($configHelper->getBpostShippingConfig("saturday_delivery_cost", Mage::app()->getStore()->getId()));
|
140 |
+
$saturdayDelivery = $configHelper->getBpostCarriersConfig("saturday_delivery", $shippingMethodCode, Mage::app()->getStore()->getId());
|
141 |
+
$ratePriceByMethod[$this->_code . "_" . $shippingMethodCode] = $price;
|
142 |
+
|
143 |
+
if ((bool)$saturdayDelivery &&
|
144 |
+
(bool)Mage::helper("bpost_shm/system_config")->getBpostShippingConfig("display_delivery_date", Mage::app()->getStore()->getId()) &&
|
145 |
+
!(bool)$checkoutSession->getQuote()->getData("bpost_disable_saturday_delivery")
|
146 |
+
) {
|
147 |
+
$price = $price + $saturdayDeliveryCost;
|
148 |
+
}
|
149 |
+
|
150 |
+
$method->setCarrier($this->_code);
|
151 |
+
$method->setMethod($shippingMethodCode);
|
152 |
+
$method->setMethodTitle($helper->__($this->getBpostConfigData('name', $shippingMethodCode)));
|
153 |
+
$method->setCarrierTitle('Bpost');
|
154 |
+
$method->setPrice($price);
|
155 |
+
$method->setCost($price);
|
156 |
+
$result->append($method);
|
157 |
+
}
|
158 |
+
|
159 |
+
if ($disabledShippingMethods == $totalAallowedShippingMethods) {
|
160 |
+
return false;
|
161 |
+
}
|
162 |
+
|
163 |
+
$checkoutSession->setOriginalRatePrices($ratePriceByMethod);
|
164 |
+
|
165 |
+
return $result;
|
166 |
+
}
|
167 |
+
|
168 |
+
/**
|
169 |
+
* Function returns the current shipping method's error object
|
170 |
+
*
|
171 |
+
* @param $shippingMethodCode
|
172 |
+
* @return Mage_Shipping_Model_Rate_Result_Error
|
173 |
+
*/
|
174 |
+
protected function _getCarriersErrorMessage($shippingMethodCode)
|
175 |
+
{
|
176 |
+
$error = Mage::getModel('shipping/rate_result_error');
|
177 |
+
$msg = $this->getBpostConfigData('specificerrmsg', $shippingMethodCode);
|
178 |
+
|
179 |
+
if ($msg && $msg != '') {
|
180 |
+
$error->setData("error_message", $msg);
|
181 |
+
}
|
182 |
+
|
183 |
+
$error->setCarrier($this->_code);
|
184 |
+
$error->setCarrierTitle($this->getBpostConfigData('title', $shippingMethodCode));
|
185 |
+
|
186 |
+
return $error;
|
187 |
+
}
|
188 |
+
|
189 |
+
/**
|
190 |
+
* Get allowed bpost methods
|
191 |
+
*
|
192 |
+
* @return array
|
193 |
+
*/
|
194 |
+
public function getAllowedMethods()
|
195 |
+
{
|
196 |
+
$allowedMethods = array(
|
197 |
+
'bpost_homedelivery' => $this->getBpostConfigData('name', 'bpost_homedelivery'),
|
198 |
+
'bpost_international' => $this->getBpostConfigData('name', 'bpost_international'),
|
199 |
+
'bpost_parcellocker' => $this->getBpostConfigData('name', 'bpost_parcellocker'),
|
200 |
+
'bpost_pickuppoint' => $this->getBpostConfigData('name', 'bpost_pickuppoint'),
|
201 |
+
'bpost_clickcollect' => $this->getBpostConfigData('name', 'bpost_clickcollect')
|
202 |
+
);
|
203 |
+
|
204 |
+
return $allowedMethods;
|
205 |
+
}
|
206 |
+
|
207 |
+
/**
|
208 |
+
* Get system config carrier information
|
209 |
+
*
|
210 |
+
* @param $field
|
211 |
+
* @param $code
|
212 |
+
* @return string
|
213 |
+
*/
|
214 |
+
public function getBpostConfigData($field, $code)
|
215 |
+
{
|
216 |
+
if (empty($code)) {
|
217 |
+
return false;
|
218 |
+
}
|
219 |
+
|
220 |
+
return Mage::helper('bpost_shm/system_config')->getBpostCarriersConfig(
|
221 |
+
$field,
|
222 |
+
$code,
|
223 |
+
$this->getStore()
|
224 |
+
);
|
225 |
+
}
|
226 |
+
|
227 |
+
/**
|
228 |
+
* Get tracking result object.
|
229 |
+
*
|
230 |
+
* @param string $trackingNumber
|
231 |
+
* @return Mage_Shipping_Model_Tracking_Result $trackingResult
|
232 |
+
*/
|
233 |
+
public function getTrackingInfo($trackingNumber)
|
234 |
+
{
|
235 |
+
$trackingResult = $this->getTracking($trackingNumber);
|
236 |
+
|
237 |
+
if ($trackingResult instanceof $trackingResult) {
|
238 |
+
$trackings = $trackingResult->getAllTrackings();
|
239 |
+
if (is_array($trackings) && count($trackings) > 0) {
|
240 |
+
return $trackings[0];
|
241 |
+
}
|
242 |
+
}
|
243 |
+
return false;
|
244 |
+
}
|
245 |
+
|
246 |
+
/**
|
247 |
+
* Get tracking Url
|
248 |
+
*
|
249 |
+
* @param string $trackingNumber
|
250 |
+
* @return Mage_Shipping_Model_Tracking_Result
|
251 |
+
*/
|
252 |
+
public function getTracking($trackingNumber)
|
253 |
+
{
|
254 |
+
$collection = Mage::getResourceModel('sales/order_shipment_track_collection')
|
255 |
+
->addFieldToFilter('track_number', $trackingNumber)
|
256 |
+
->addAttributeToSelect("order_id")
|
257 |
+
->join('sales/order', 'order_id=`sales/order`.entity_id', array('increment_id' => 'increment_id', 'shipping_description' => 'shipping_description'), null, 'left');
|
258 |
+
$carrierTitle = $collection->getFirstItem()->getShippingDescription();
|
259 |
+
$trackingResult = Mage::getModel('shipping/tracking_result');
|
260 |
+
$trackingStatus = Mage::getModel('shipping/tracking_result_status');
|
261 |
+
$localeExploded = explode('_', Mage::app()->getLocale()->getLocaleCode());
|
262 |
+
$trackingStatus->setCarrier($this->_code);
|
263 |
+
$trackingStatus->setCarrierTitle($carrierTitle);
|
264 |
+
$trackingStatus->setTracking($trackingNumber);
|
265 |
+
|
266 |
+
$trackDomainUrl = self::SHIPMENT_TRACK_DOMAIN;
|
267 |
+
$trackingStatus->addData(
|
268 |
+
array(
|
269 |
+
'status' => '<a target="_blank" href="' . $trackDomainUrl . 'etr/light/performSearch.do?searchByItemCode=true&oss_language=' . $localeExploded[0] . '&itemCodes=' . $trackingNumber . '"><img src="' . Mage::getDesign()->getSkinUrl('images/bpost/bpost_logo_RGB72_M.png') . '" /> <br />' . Mage::helper('bpost_shm')->__('Click here to track your bpost shipments.') . '</a>'
|
270 |
+
)
|
271 |
+
);
|
272 |
+
$trackingResult->append($trackingStatus);
|
273 |
+
|
274 |
+
return $trackingResult;
|
275 |
+
}
|
276 |
+
|
277 |
+
/**
|
278 |
+
* Make tracking available for Bpost shippingmethods.
|
279 |
+
*
|
280 |
+
* @return bool
|
281 |
+
*/
|
282 |
+
public function isTrackingAvailable()
|
283 |
+
{
|
284 |
+
return true;
|
285 |
+
}
|
286 |
+
|
287 |
+
/**
|
288 |
+
* Make shipping labels not available as we provided our own method.
|
289 |
+
*
|
290 |
+
* @return bool
|
291 |
+
*/
|
292 |
+
public function isShippingLabelsAvailable()
|
293 |
+
{
|
294 |
+
return false;
|
295 |
+
}
|
296 |
+
|
297 |
+
/**
|
298 |
+
* Check for available bpost shipping countries
|
299 |
+
*
|
300 |
+
* @param $request
|
301 |
+
* @param $shippingMethodCode
|
302 |
+
* @return bool
|
303 |
+
*/
|
304 |
+
public function checkAvailableBpostShipCountries(Mage_Shipping_Model_Rate_Request $request, $shippingMethodCode)
|
305 |
+
{
|
306 |
+
$speCountriesAllow = (int)$this->getBpostConfigData('sallowspecific', $shippingMethodCode);
|
307 |
+
$bpostHelper = Mage::helper("bpost_shm/system_config");
|
308 |
+
$countryId = $request->getDestCountryId();
|
309 |
+
|
310 |
+
if ($speCountriesAllow == 1) {
|
311 |
+
$allowedCountries = $bpostHelper->getBpostCarriersConfig("specificcountry", "bpost_international");
|
312 |
+
$availableCountries = explode(',', $allowedCountries);
|
313 |
+
|
314 |
+
if (!empty($availableCountries) && in_array($countryId, $availableCountries)) {
|
315 |
+
return true;
|
316 |
+
} else {
|
317 |
+
return false;
|
318 |
+
}
|
319 |
+
}
|
320 |
+
|
321 |
+
//we check on national shipping country Belgium
|
322 |
+
if (($shippingMethodCode === "bpost_homedelivery" ||
|
323 |
+
$shippingMethodCode === "bpost_parcellocker" ||
|
324 |
+
$shippingMethodCode === "bpost_pickuppoint" ||
|
325 |
+
$shippingMethodCode === "bpost_clickcollect") &&
|
326 |
+
$countryId != "BE"
|
327 |
+
) {
|
328 |
+
return false;
|
329 |
+
}
|
330 |
+
|
331 |
+
return true;
|
332 |
+
}
|
333 |
+
|
334 |
+
/**
|
335 |
+
* Get rate object for specific shipping method
|
336 |
+
*
|
337 |
+
* @param $request
|
338 |
+
* @param $shippingMethodCode
|
339 |
+
* @return array
|
340 |
+
*/
|
341 |
+
public function getRate($request, $shippingMethodCode)
|
342 |
+
{
|
343 |
+
return Mage::getResourceModel('bpost_shm/tablerates_' . str_replace('bpost_', '', $shippingMethodCode))->getRate($request);
|
344 |
+
}
|
345 |
+
}
|
app/code/community/Bpost/ShM/Model/Shipping/Geocode.php
CHANGED
@@ -1,143 +1,143 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Created by PHPro
|
5 |
-
*
|
6 |
-
* @package Bpost
|
7 |
-
* @subpackage ShM
|
8 |
-
* @author PHPro (info@phpro.be)
|
9 |
-
*/
|
10 |
-
|
11 |
-
/**
|
12 |
-
* Class Bpost_ShM_Model_Shipping_Geocode
|
13 |
-
*/
|
14 |
-
class Bpost_ShM_Model_Shipping_Geocode
|
15 |
-
{
|
16 |
-
protected $_addressLine;
|
17 |
-
/**
|
18 |
-
* @var Bpost_ShM_Helper_Data
|
19 |
-
*/
|
20 |
-
protected $_success = false;
|
21 |
-
protected $_xml;
|
22 |
-
|
23 |
-
/**
|
24 |
-
* Make the call to google geocode
|
25 |
-
* @param $gMapsAddress
|
26 |
-
* @param $latitude
|
27 |
-
* @param $longitude
|
28 |
-
* @return $this|boolean
|
29 |
-
*/
|
30 |
-
public function callGoogleMaps($gMapsAddress, $latitude = false, $longitude = false)
|
31 |
-
{
|
32 |
-
$configHelper = Mage::helper("bpost_shm/system_config");
|
33 |
-
$key = $configHelper->getBpostShippingConfig("server_api_key", Mage::app()->getStore()->getId());
|
34 |
-
|
35 |
-
if($gMapsAddress) {
|
36 |
-
$this->_addressLine = $gMapsAddress;
|
37 |
-
$url = 'https://maps.googleapis.com/maps/api/geocode/xml?address=' . urlencode($gMapsAddress);
|
38 |
-
} else {
|
39 |
-
$coords = $latitude.','.$longitude;
|
40 |
-
$this->_addressLine = $coords;
|
41 |
-
$url = 'https://maps.googleapis.com/maps/api/geocode/xml?latlng=' . urlencode($coords);
|
42 |
-
}
|
43 |
-
$url .= '&language=nl';
|
44 |
-
if($key) {
|
45 |
-
$url .= '&key='.$key;
|
46 |
-
}
|
47 |
-
Mage::helper('bpost_shm')->log("Geo URL: " . $url, Zend_Log::DEBUG);
|
48 |
-
try{
|
49 |
-
$xml = simplexml_load_file($url);
|
50 |
-
switch($xml->status){
|
51 |
-
case "OK":
|
52 |
-
$this->_success = true;
|
53 |
-
$this->_xml = $xml;
|
54 |
-
Mage::helper('bpost_shm')->log("Geocode: OK ".$this->_addressLine." to xml" ,Zend_Log::DEBUG);
|
55 |
-
return $this;
|
56 |
-
break;
|
57 |
-
case "ZERO_RESULTS":
|
58 |
-
$errormsg = "Geocode: no results found for ".$this->_addressLine;
|
59 |
-
Mage::helper('bpost_shm')->log($errormsg, Zend_Log::ERR);
|
60 |
-
return $errormsg;
|
61 |
-
break;
|
62 |
-
case "OVER_QUERY_LIMIT":
|
63 |
-
$errormsg = "Geocode: Over Query Limit. check your api console";
|
64 |
-
Mage::helper('bpost_shm')->log($errormsg, Zend_Log::ERR);
|
65 |
-
return $errormsg;
|
66 |
-
break;
|
67 |
-
case "REQUEST_DENIED":
|
68 |
-
$errormsg = "Geocode: Request denied";
|
69 |
-
Mage::helper('bpost_shm')->log($errormsg, Zend_Log::ERR);
|
70 |
-
return $errormsg;
|
71 |
-
break;
|
72 |
-
case "INVALID_REQUEST":
|
73 |
-
$errormsg = "Geocode: invalid request , address missing?";
|
74 |
-
Mage::helper('bpost_shm')->log($errormsg, Zend_Log::ERR);
|
75 |
-
return $errormsg;
|
76 |
-
break;
|
77 |
-
case "UNKNOWN_ERROR":
|
78 |
-
$errormsg = "Geocode: unknown Error";
|
79 |
-
Mage::helper('bpost_shm')->log($errormsg, Zend_Log::ERR);
|
80 |
-
return $errormsg;
|
81 |
-
break;
|
82 |
-
default:
|
83 |
-
$errormsg = "Geocode: unknown Status " . $xml->status;
|
84 |
-
Mage::helper('bpost_shm')->log($errormsg, Zend_Log::ERR);
|
85 |
-
return $errormsg;
|
86 |
-
break;
|
87 |
-
}
|
88 |
-
}catch (Exception $e){
|
89 |
-
Mage::helper('bpost_shm')->log("Geocode: ". $e->getMessage() ,Zend_Log::ERR);
|
90 |
-
return $e-getMessage();
|
91 |
-
}
|
92 |
-
}
|
93 |
-
|
94 |
-
/**
|
95 |
-
* Extract useful address information from the geocode xml
|
96 |
-
* @return string|boolean
|
97 |
-
*/
|
98 |
-
protected function _extractFromAdress($components, $type)
|
99 |
-
{
|
100 |
-
foreach ($components->address_component as $component) {
|
101 |
-
if($component->type == $type) {
|
102 |
-
return $component->long_name;
|
103 |
-
}
|
104 |
-
}
|
105 |
-
return false;
|
106 |
-
}
|
107 |
-
|
108 |
-
/**
|
109 |
-
* Get the coordinates from the xml
|
110 |
-
* @return array|boolean
|
111 |
-
*/
|
112 |
-
public function getLatLng()
|
113 |
-
{
|
114 |
-
if($this->_success){
|
115 |
-
$lat = (string)$this->_xml->result[0]->geometry->location->lat;
|
116 |
-
$lng = (string)$this->_xml->result[0]->geometry->location->lng;
|
117 |
-
|
118 |
-
if(isset($lat) && isset($lng)) {
|
119 |
-
return array('lat' => $lat, 'lng' => $lng);
|
120 |
-
}
|
121 |
-
}
|
122 |
-
return false;
|
123 |
-
}
|
124 |
-
|
125 |
-
/**
|
126 |
-
* Get the postal code/city from the xml
|
127 |
-
* @return string|boolean
|
128 |
-
*/
|
129 |
-
public function getPostalCode()
|
130 |
-
{
|
131 |
-
if($this->_success){
|
132 |
-
$postalCode = $this->_extractFromAdress($this->_xml->result[0], 'postal_code');
|
133 |
-
$locality = $this->_extractFromAdress($this->_xml->result[0], 'locality');
|
134 |
-
|
135 |
-
if($postalCode) {
|
136 |
-
return (string)$postalCode;
|
137 |
-
} elseif($locality) {
|
138 |
-
return (string)$locality;
|
139 |
-
}
|
140 |
-
}
|
141 |
-
return false;
|
142 |
-
}
|
143 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Created by PHPro
|
5 |
+
*
|
6 |
+
* @package Bpost
|
7 |
+
* @subpackage ShM
|
8 |
+
* @author PHPro (info@phpro.be)
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Class Bpost_ShM_Model_Shipping_Geocode
|
13 |
+
*/
|
14 |
+
class Bpost_ShM_Model_Shipping_Geocode
|
15 |
+
{
|
16 |
+
protected $_addressLine;
|
17 |
+
/**
|
18 |
+
* @var Bpost_ShM_Helper_Data
|
19 |
+
*/
|
20 |
+
protected $_success = false;
|
21 |
+
protected $_xml;
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Make the call to google geocode
|
25 |
+
* @param $gMapsAddress
|
26 |
+
* @param $latitude
|
27 |
+
* @param $longitude
|
28 |
+
* @return $this|boolean
|
29 |
+
*/
|
30 |
+
public function callGoogleMaps($gMapsAddress, $latitude = false, $longitude = false)
|
31 |
+
{
|
32 |
+
$configHelper = Mage::helper("bpost_shm/system_config");
|
33 |
+
$key = $configHelper->getBpostShippingConfig("server_api_key", Mage::app()->getStore()->getId());
|
34 |
+
|
35 |
+
if($gMapsAddress) {
|
36 |
+
$this->_addressLine = $gMapsAddress;
|
37 |
+
$url = 'https://maps.googleapis.com/maps/api/geocode/xml?address=' . urlencode($gMapsAddress);
|
38 |
+
} else {
|
39 |
+
$coords = $latitude.','.$longitude;
|
40 |
+
$this->_addressLine = $coords;
|
41 |
+
$url = 'https://maps.googleapis.com/maps/api/geocode/xml?latlng=' . urlencode($coords);
|
42 |
+
}
|
43 |
+
$url .= '&language=nl';
|
44 |
+
if($key) {
|
45 |
+
$url .= '&key='.$key;
|
46 |
+
}
|
47 |
+
Mage::helper('bpost_shm')->log("Geo URL: " . $url, Zend_Log::DEBUG);
|
48 |
+
try{
|
49 |
+
$xml = simplexml_load_file($url);
|
50 |
+
switch($xml->status){
|
51 |
+
case "OK":
|
52 |
+
$this->_success = true;
|
53 |
+
$this->_xml = $xml;
|
54 |
+
Mage::helper('bpost_shm')->log("Geocode: OK ".$this->_addressLine." to xml" ,Zend_Log::DEBUG);
|
55 |
+
return $this;
|
56 |
+
break;
|
57 |
+
case "ZERO_RESULTS":
|
58 |
+
$errormsg = "Geocode: no results found for ".$this->_addressLine;
|
59 |
+
Mage::helper('bpost_shm')->log($errormsg, Zend_Log::ERR);
|
60 |
+
return $errormsg;
|
61 |
+
break;
|
62 |
+
case "OVER_QUERY_LIMIT":
|
63 |
+
$errormsg = "Geocode: Over Query Limit. check your api console";
|
64 |
+
Mage::helper('bpost_shm')->log($errormsg, Zend_Log::ERR);
|
65 |
+
return $errormsg;
|
66 |
+
break;
|
67 |
+
case "REQUEST_DENIED":
|
68 |
+
$errormsg = "Geocode: Request denied";
|
69 |
+
Mage::helper('bpost_shm')->log($errormsg, Zend_Log::ERR);
|
70 |
+
return $errormsg;
|
71 |
+
break;
|
72 |
+
case "INVALID_REQUEST":
|
73 |
+
$errormsg = "Geocode: invalid request , address missing?";
|
74 |
+
Mage::helper('bpost_shm')->log($errormsg, Zend_Log::ERR);
|
75 |
+
return $errormsg;
|
76 |
+
break;
|
77 |
+
case "UNKNOWN_ERROR":
|
78 |
+
$errormsg = "Geocode: unknown Error";
|
79 |
+
Mage::helper('bpost_shm')->log($errormsg, Zend_Log::ERR);
|
80 |
+
return $errormsg;
|
81 |
+
break;
|
82 |
+
default:
|
83 |
+
$errormsg = "Geocode: unknown Status " . $xml->status;
|
84 |
+
Mage::helper('bpost_shm')->log($errormsg, Zend_Log::ERR);
|
85 |
+
return $errormsg;
|
86 |
+
break;
|
87 |
+
}
|
88 |
+
}catch (Exception $e){
|
89 |
+
Mage::helper('bpost_shm')->log("Geocode: ". $e->getMessage() ,Zend_Log::ERR);
|
90 |
+
return $e-getMessage();
|
91 |
+
}
|
92 |
+
}
|
93 |
+
|
94 |
+
/**
|
95 |
+
* Extract useful address information from the geocode xml
|
96 |
+
* @return string|boolean
|
97 |
+
*/
|
98 |
+
protected function _extractFromAdress($components, $type)
|
99 |
+
{
|
100 |
+
foreach ($components->address_component as $component) {
|
101 |
+
if($component->type == $type) {
|
102 |
+
return $component->long_name;
|
103 |
+
}
|
104 |
+
}
|
105 |
+
return false;
|
106 |
+
}
|
107 |
+
|
108 |
+
/**
|
109 |
+
* Get the coordinates from the xml
|
110 |
+
* @return array|boolean
|
111 |
+
*/
|
112 |
+
public function getLatLng()
|
113 |
+
{
|
114 |
+
if($this->_success){
|
115 |
+
$lat = (string)$this->_xml->result[0]->geometry->location->lat;
|
116 |
+
$lng = (string)$this->_xml->result[0]->geometry->location->lng;
|
117 |
+
|
118 |
+
if(isset($lat) && isset($lng)) {
|
119 |
+
return array('lat' => $lat, 'lng' => $lng);
|
120 |
+
}
|
121 |
+
}
|
122 |
+
return false;
|
123 |
+
}
|
124 |
+
|
125 |
+
/**
|
126 |
+
* Get the postal code/city from the xml
|
127 |
+
* @return string|boolean
|
128 |
+
*/
|
129 |
+
public function getPostalCode()
|
130 |
+
{
|
131 |
+
if($this->_success){
|
132 |
+
$postalCode = $this->_extractFromAdress($this->_xml->result[0], 'postal_code');
|
133 |
+
$locality = $this->_extractFromAdress($this->_xml->result[0], 'locality');
|
134 |
+
|
135 |
+
if($postalCode) {
|
136 |
+
return (string)$postalCode;
|
137 |
+
} elseif($locality) {
|
138 |
+
return (string)$locality;
|
139 |
+
}
|
140 |
+
}
|
141 |
+
return false;
|
142 |
+
}
|
143 |
+
}
|
app/code/community/Bpost/ShM/Model/Shipping/Rate/Result.php
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
-
<?php
|
2 |
-
class Bpost_ShM_Model_Shipping_Rate_Result extends Mage_Shipping_Model_Rate_Result
|
3 |
-
{
|
4 |
-
/**
|
5 |
-
* we create an empty sort function
|
6 |
-
* this way our shipping rates will keep their sort order
|
7 |
-
*/
|
8 |
-
public function sortRatesByPrice(){
|
9 |
-
return;
|
10 |
-
}
|
11 |
-
}
|
1 |
+
<?php
|
2 |
+
class Bpost_ShM_Model_Shipping_Rate_Result extends Mage_Shipping_Model_Rate_Result
|
3 |
+
{
|
4 |
+
/**
|
5 |
+
* we create an empty sort function
|
6 |
+
* this way our shipping rates will keep their sort order
|
7 |
+
*/
|
8 |
+
public function sortRatesByPrice(){
|
9 |
+
return;
|
10 |
+
}
|
11 |
+
}
|
app/code/community/Bpost/ShM/Model/System/Config/Source/Country.php
CHANGED
@@ -1,27 +1,27 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Created by PHPro
|
4 |
-
*
|
5 |
-
* @package Bpost
|
6 |
-
* @subpackage ShM
|
7 |
-
* @author PHPro (info@phpro.be)
|
8 |
-
*/
|
9 |
-
/**
|
10 |
-
* Class Bpost_ShM_Model_System_Config_Source_Country
|
11 |
-
*/
|
12 |
-
class Bpost_ShM_Model_System_Config_Source_Country
|
13 |
-
{
|
14 |
-
protected $_options;
|
15 |
-
|
16 |
-
public function toOptionArray()
|
17 |
-
{
|
18 |
-
if (!$this->_options) {
|
19 |
-
$this->_options = Mage::getResourceModel('bpost_shm/country_collection')->loadData()->toOptionArray(false);
|
20 |
-
}
|
21 |
-
|
22 |
-
$options = $this->_options;
|
23 |
-
|
24 |
-
return $options;
|
25 |
-
}
|
26 |
-
|
27 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Created by PHPro
|
4 |
+
*
|
5 |
+
* @package Bpost
|
6 |
+
* @subpackage ShM
|
7 |
+
* @author PHPro (info@phpro.be)
|
8 |
+
*/
|
9 |
+
/**
|
10 |
+
* Class Bpost_ShM_Model_System_Config_Source_Country
|
11 |
+
*/
|
12 |
+
class Bpost_ShM_Model_System_Config_Source_Country
|
13 |
+
{
|
14 |
+
protected $_options;
|
15 |
+
|
16 |
+
public function toOptionArray()
|
17 |
+
{
|
18 |
+
if (!$this->_options) {
|
19 |
+
$this->_options = Mage::getResourceModel('bpost_shm/country_collection')->loadData()->toOptionArray(false);
|
20 |
+
}
|
21 |
+
|
22 |
+
$options = $this->_options;
|
23 |
+
|
24 |
+
return $options;
|
25 |
+
}
|
26 |
+
|
27 |
+
}
|
app/code/community/Bpost/ShM/Model/System/Config/Source/Product.php
CHANGED
@@ -1,44 +1,44 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Created by PHPro
|
4 |
-
*
|
5 |
-
* @package Bpost
|
6 |
-
* @subpackage ShM
|
7 |
-
* @author PHPro (info@phpro.be)
|
8 |
-
*/
|
9 |
-
/**
|
10 |
-
* Class Bpost_ShM_Model_System_Config_Source_Ratetypes
|
11 |
-
*/
|
12 |
-
class Bpost_ShM_Model_System_Config_Source_Product
|
13 |
-
{
|
14 |
-
/**
|
15 |
-
* Options getter.
|
16 |
-
* Returns an option array for Shipping cost handler.
|
17 |
-
*
|
18 |
-
* @return array
|
19 |
-
*
|
20 |
-
*/
|
21 |
-
public function toOptionArray()
|
22 |
-
{
|
23 |
-
return array(
|
24 |
-
array('value' => 1, 'label' => Mage::helper('bpost_shm')->__('World Express Pro')),
|
25 |
-
array('value' => 0, 'label' => Mage::helper('bpost_shm')->__('World Business')),
|
26 |
-
);
|
27 |
-
}
|
28 |
-
|
29 |
-
/**
|
30 |
-
* Get options in "key-value" format.
|
31 |
-
* Returns an array for Shipping cost handler. (Magento basically expects both functions)
|
32 |
-
*
|
33 |
-
* @return array
|
34 |
-
*
|
35 |
-
*/
|
36 |
-
public function toArray()
|
37 |
-
{
|
38 |
-
return array(
|
39 |
-
0 => Mage::helper('bpost_shm')->__('World Business'),
|
40 |
-
1 => Mage::helper('bpost_shm')->__('World Express Pro'),
|
41 |
-
);
|
42 |
-
}
|
43 |
-
|
44 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Created by PHPro
|
4 |
+
*
|
5 |
+
* @package Bpost
|
6 |
+
* @subpackage ShM
|
7 |
+
* @author PHPro (info@phpro.be)
|
8 |
+
*/
|
9 |
+
/**
|
10 |
+
* Class Bpost_ShM_Model_System_Config_Source_Ratetypes
|
11 |
+
*/
|
12 |
+
class Bpost_ShM_Model_System_Config_Source_Product
|
13 |
+
{
|
14 |
+
/**
|
15 |
+
* Options getter.
|
16 |
+
* Returns an option array for Shipping cost handler.
|
17 |
+
*
|
18 |
+
* @return array
|
19 |
+
*
|
20 |
+
*/
|
21 |
+
public function toOptionArray()
|
22 |
+
{
|
23 |
+
return array(
|
24 |
+
array('value' => 1, 'label' => Mage::helper('bpost_shm')->__('World Express Pro')),
|
25 |
+
array('value' => 0, 'label' => Mage::helper('bpost_shm')->__('World Business')),
|
26 |
+
);
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Get options in "key-value" format.
|
31 |
+
* Returns an array for Shipping cost handler. (Magento basically expects both functions)
|
32 |
+
*
|
33 |
+
* @return array
|
34 |
+
*
|
35 |
+
*/
|
36 |
+
public function toArray()
|
37 |
+
{
|
38 |
+
return array(
|
39 |
+
0 => Mage::helper('bpost_shm')->__('World Business'),
|
40 |
+
1 => Mage::helper('bpost_shm')->__('World Express Pro'),
|
41 |
+
);
|
42 |
+
}
|
43 |
+
|
44 |
}
|
app/code/community/Bpost/ShM/Model/System/Config/Source/Ratetypes.php
CHANGED
@@ -1,44 +1,44 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Created by PHPro
|
4 |
-
*
|
5 |
-
* @package Bpost
|
6 |
-
* @subpackage ShM
|
7 |
-
* @author PHPro (info@phpro.be)
|
8 |
-
*/
|
9 |
-
/**
|
10 |
-
* Class Bpost_ShM_Model_System_Config_Source_Ratetypes
|
11 |
-
*/
|
12 |
-
class Bpost_ShM_Model_System_Config_Source_Ratetypes
|
13 |
-
{
|
14 |
-
/**
|
15 |
-
* Options getter.
|
16 |
-
* Returns an option array for Shipping cost handler.
|
17 |
-
*
|
18 |
-
* @return array
|
19 |
-
*
|
20 |
-
*/
|
21 |
-
public function toOptionArray()
|
22 |
-
{
|
23 |
-
return array(
|
24 |
-
array('value' => 1, 'label' => Mage::helper('bpost_shm')->__('Table Rates')),
|
25 |
-
array('value' => 0, 'label' => Mage::helper('bpost_shm')->__('Flat Rate')),
|
26 |
-
);
|
27 |
-
}
|
28 |
-
|
29 |
-
/**
|
30 |
-
* Get options in "key-value" format.
|
31 |
-
* Returns an array for Shipping cost handler. (Magento basically expects both functions)
|
32 |
-
*
|
33 |
-
* @return array
|
34 |
-
*
|
35 |
-
*/
|
36 |
-
public function toArray()
|
37 |
-
{
|
38 |
-
return array(
|
39 |
-
0 => Mage::helper('bpost_shm')->__('Flat Rate'),
|
40 |
-
1 => Mage::helper('bpost_shm')->__('Table Rates'),
|
41 |
-
);
|
42 |
-
}
|
43 |
-
|
44 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Created by PHPro
|
4 |
+
*
|
5 |
+
* @package Bpost
|
6 |
+
* @subpackage ShM
|
7 |
+
* @author PHPro (info@phpro.be)
|
8 |
+
*/
|
9 |
+
/**
|
10 |
+
* Class Bpost_ShM_Model_System_Config_Source_Ratetypes
|
11 |
+
*/
|
12 |
+
class Bpost_ShM_Model_System_Config_Source_Ratetypes
|
13 |
+
{
|
14 |
+
/**
|
15 |
+
* Options getter.
|
16 |
+
* Returns an option array for Shipping cost handler.
|
17 |
+
*
|
18 |
+
* @return array
|
19 |
+
*
|
20 |
+
*/
|
21 |
+
public function toOptionArray()
|
22 |
+
{
|
23 |
+
return array(
|
24 |
+
array('value' => 1, 'label' => Mage::helper('bpost_shm')->__('Table Rates')),
|
25 |
+
array('value' => 0, 'label' => Mage::helper('bpost_shm')->__('Flat Rate')),
|
26 |
+
);
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Get options in "key-value" format.
|
31 |
+
* Returns an array for Shipping cost handler. (Magento basically expects both functions)
|
32 |
+
*
|
33 |
+
* @return array
|
34 |
+
*
|
35 |
+
*/
|
36 |
+
public function toArray()
|
37 |
+
{
|
38 |
+
return array(
|
39 |
+
0 => Mage::helper('bpost_shm')->__('Flat Rate'),
|
40 |
+
1 => Mage::helper('bpost_shm')->__('Table Rates'),
|
41 |
+
);
|
42 |
+
}
|
43 |
+
|
44 |
}
|
app/code/community/Bpost/ShM/Model/System/Config/Source/Weightunit.php
CHANGED
@@ -1,47 +1,47 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Created by PHPro
|
4 |
-
*
|
5 |
-
* @subpackage Shipping
|
6 |
-
* @category Checkout
|
7 |
-
* @author PHPro (info@phpro.be)
|
8 |
-
*/
|
9 |
-
|
10 |
-
/**
|
11 |
-
* Class Bpost_ShM_Model_System_Config_Source_Weightunit
|
12 |
-
*/
|
13 |
-
class Bpost_ShM_Model_System_Config_Source_Weightunit
|
14 |
-
{
|
15 |
-
/**
|
16 |
-
* Options getter.
|
17 |
-
* Returns an option array for unit weight to pass to the webservice.
|
18 |
-
*
|
19 |
-
* @return array
|
20 |
-
*
|
21 |
-
*/
|
22 |
-
public function toOptionArray()
|
23 |
-
{
|
24 |
-
return array(
|
25 |
-
array('value' => 1000, 'label' => Mage::helper('bpost_shm')->__('kg')),
|
26 |
-
array('value' => 1, 'label' => Mage::helper('bpost_shm')->__('g')),
|
27 |
-
array('value' => 453.592, 'label' => Mage::helper('bpost_shm')->__('lb')),
|
28 |
-
);
|
29 |
-
}
|
30 |
-
|
31 |
-
/**
|
32 |
-
* Get options in "key-value" format.
|
33 |
-
* Returns an array for unit weight to pass to the webservice. (Magento basically expects both functions)
|
34 |
-
*
|
35 |
-
* @return array
|
36 |
-
*
|
37 |
-
*/
|
38 |
-
public function toArray()
|
39 |
-
{
|
40 |
-
return array(
|
41 |
-
'1000' => Mage::helper('bpost_shm')->__('kg'),
|
42 |
-
'1' => Mage::helper('bpost_shm')->__('g'),
|
43 |
-
'453.592' => Mage::helper('bpost_shm')->__('lb')
|
44 |
-
);
|
45 |
-
}
|
46 |
-
|
47 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Created by PHPro
|
4 |
+
*
|
5 |
+
* @subpackage Shipping
|
6 |
+
* @category Checkout
|
7 |
+
* @author PHPro (info@phpro.be)
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Class Bpost_ShM_Model_System_Config_Source_Weightunit
|
12 |
+
*/
|
13 |
+
class Bpost_ShM_Model_System_Config_Source_Weightunit
|
14 |
+
{
|
15 |
+
/**
|
16 |
+
* Options getter.
|
17 |
+
* Returns an option array for unit weight to pass to the webservice.
|
18 |
+
*
|
19 |
+
* @return array
|
20 |
+
*
|
21 |
+
*/
|
22 |
+
public function toOptionArray()
|
23 |
+
{
|
24 |
+
return array(
|
25 |
+
array('value' => 1000, 'label' => Mage::helper('bpost_shm')->__('kg')),
|
26 |
+
array('value' => 1, 'label' => Mage::helper('bpost_shm')->__('g')),
|
27 |
+
array('value' => 453.592, 'label' => Mage::helper('bpost_shm')->__('lb')),
|
28 |
+
);
|
29 |
+
}
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Get options in "key-value" format.
|
33 |
+
* Returns an array for unit weight to pass to the webservice. (Magento basically expects both functions)
|
34 |
+
*
|
35 |
+
* @return array
|
36 |
+
*
|
37 |
+
*/
|
38 |
+
public function toArray()
|
39 |
+
{
|
40 |
+
return array(
|
41 |
+
'1000' => Mage::helper('bpost_shm')->__('kg'),
|
42 |
+
'1' => Mage::helper('bpost_shm')->__('g'),
|
43 |
+
'453.592' => Mage::helper('bpost_shm')->__('lb')
|
44 |
+
);
|
45 |
+
}
|
46 |
+
|
47 |
}
|
app/code/community/Bpost/ShM/Model/Tablerates/Clickcollect.php
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
-
<?php
|
2 |
-
class Bpost_ShM_Model_Tablerates_Clickcollect extends Mage_Core_Model_Abstract{
|
3 |
-
|
4 |
-
protected function _construct()
|
5 |
-
{
|
6 |
-
$this->_init('bpost_shm/tablerates_clickcollect');
|
7 |
-
}
|
8 |
-
|
9 |
}
|
1 |
+
<?php
|
2 |
+
class Bpost_ShM_Model_Tablerates_Clickcollect extends Mage_Core_Model_Abstract{
|
3 |
+
|
4 |
+
protected function _construct()
|
5 |
+
{
|
6 |
+
$this->_init('bpost_shm/tablerates_clickcollect');
|
7 |
+
}
|
8 |
+
|
9 |
}
|
app/code/community/Bpost/ShM/Model/Tablerates/Homedelivery.php
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
-
<?php
|
2 |
-
class Bpost_ShM_Model_Tablerates_Homedelivery extends Mage_Core_Model_Abstract{
|
3 |
-
|
4 |
-
protected function _construct()
|
5 |
-
{
|
6 |
-
$this->_init('bpost_shm/tablerates_homedelivery');
|
7 |
-
}
|
8 |
-
|
9 |
}
|
1 |
+
<?php
|
2 |
+
class Bpost_ShM_Model_Tablerates_Homedelivery extends Mage_Core_Model_Abstract{
|
3 |
+
|
4 |
+
protected function _construct()
|
5 |
+
{
|
6 |
+
$this->_init('bpost_shm/tablerates_homedelivery');
|
7 |
+
}
|
8 |
+
|
9 |
}
|
app/code/community/Bpost/ShM/Model/Tablerates/International.php
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
-
<?php
|
2 |
-
class Bpost_ShM_Model_Tablerates_International extends Mage_Core_Model_Abstract{
|
3 |
-
|
4 |
-
protected function _construct()
|
5 |
-
{
|
6 |
-
$this->_init('bpost_shm/tablerates_international');
|
7 |
-
}
|
8 |
-
|
9 |
}
|
1 |
+
<?php
|
2 |
+
class Bpost_ShM_Model_Tablerates_International extends Mage_Core_Model_Abstract{
|
3 |
+
|
4 |
+
protected function _construct()
|
5 |
+
{
|
6 |
+
$this->_init('bpost_shm/tablerates_international');
|
7 |
+
}
|
8 |
+
|
9 |
}
|
app/code/community/Bpost/ShM/Model/Tablerates/Parcellocker.php
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
-
<?php
|
2 |
-
class Bpost_ShM_Model_Tablerates_Parcellocker extends Mage_Core_Model_Abstract{
|
3 |
-
|
4 |
-
protected function _construct()
|
5 |
-
{
|
6 |
-
$this->_init('bpost_shm/tablerates_parcellocker');
|
7 |
-
}
|
8 |
-
|
9 |
}
|
1 |
+
<?php
|
2 |
+
class Bpost_ShM_Model_Tablerates_Parcellocker extends Mage_Core_Model_Abstract{
|
3 |
+
|
4 |
+
protected function _construct()
|
5 |
+
{
|
6 |
+
$this->_init('bpost_shm/tablerates_parcellocker');
|
7 |
+
}
|
8 |
+
|
9 |
}
|
app/code/community/Bpost/ShM/Model/Tablerates/Pickuppoint.php
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
-
<?php
|
2 |
-
class Bpost_ShM_Model_Tablerates_Pickuppoint extends Mage_Core_Model_Abstract{
|
3 |
-
|
4 |
-
protected function _construct()
|
5 |
-
{
|
6 |
-
$this->_init('bpost_shm/tablerates_pickuppoint');
|
7 |
-
}
|
8 |
-
|
9 |
}
|
1 |
+
<?php
|
2 |
+
class Bpost_ShM_Model_Tablerates_Pickuppoint extends Mage_Core_Model_Abstract{
|
3 |
+
|
4 |
+
protected function _construct()
|
5 |
+
{
|
6 |
+
$this->_init('bpost_shm/tablerates_pickuppoint');
|
7 |
+
}
|
8 |
+
|
9 |
}
|
app/code/community/Bpost/ShM/controllers/Adminhtml/Bpost/ShM/AllOrdersController.php
CHANGED
@@ -1,64 +1,64 @@
|
|
1 |
-
<?php
|
2 |
-
class Bpost_ShM_Adminhtml_Bpost_ShM_AllOrdersController extends Bpost_ShM_Controller_ShM_Order
|
3 |
-
{
|
4 |
-
/**
|
5 |
-
* Load indexpage of this controller.
|
6 |
-
*/
|
7 |
-
public function indexAction()
|
8 |
-
{
|
9 |
-
Mage::getSingleton('core/session')->setBpostReturn(0);
|
10 |
-
$this->_title($this->__('bpost'))->_title($this->__('Bpost Orders'));
|
11 |
-
$this->loadLayout();
|
12 |
-
$this->_setActiveMenu('sales/bpost_all_orders');
|
13 |
-
$this->_addContent($this->getLayout()->createBlock('bpost_shm/adminhtml_sales_allOrders'));
|
14 |
-
$this->renderLayout();
|
15 |
-
}
|
16 |
-
|
17 |
-
/**
|
18 |
-
* Load the grid.
|
19 |
-
*/
|
20 |
-
public function gridAction()
|
21 |
-
{
|
22 |
-
$this->loadLayout();
|
23 |
-
$this->getResponse()->setBody(
|
24 |
-
$this->getLayout()->createBlock('bpost_shm/adminhtml_sales_allOrders_grid')->toHtml()
|
25 |
-
);
|
26 |
-
}
|
27 |
-
|
28 |
-
protected function _isAllowed()
|
29 |
-
{
|
30 |
-
$configHelper = Mage::helper("bpost_shm/system_config");
|
31 |
-
$manageLabels = $configHelper->getBpostShippingConfig("manage_labels_with_magento");
|
32 |
-
|
33 |
-
if(!$manageLabels){
|
34 |
-
$this->_getSession()->addNotice('Please enable the "Use Magento to manage labels" setting first under "system -> configuration -> shipping settings -> Bpost Shipping Manager" if you want to use this functionality.');
|
35 |
-
return false;
|
36 |
-
}
|
37 |
-
|
38 |
-
return Mage::getSingleton('admin/session')->isAllowed('sales/bpost_orders/bpost_all_orders');
|
39 |
-
}
|
40 |
-
|
41 |
-
|
42 |
-
/**
|
43 |
-
* Call this to send an email with the bpost template.
|
44 |
-
* This calls the model to handle emails the magento way.
|
45 |
-
* Logs all errors in try catch.
|
46 |
-
*/
|
47 |
-
public function sendEmailAction()
|
48 |
-
{
|
49 |
-
$returnId = $this->getRequest()->getParam('return_id');
|
50 |
-
try {
|
51 |
-
$email = Mage::getModel('bpost_shm/returnlabel')->sendEmail($returnId);
|
52 |
-
} catch (Exception $e) {
|
53 |
-
Mage::getSingleton('core/session')->addError($e->getMessage());
|
54 |
-
$this->_redirectReferer();
|
55 |
-
return $this;
|
56 |
-
}
|
57 |
-
$message = Mage::helper('bpost_shm')->__("The email with return label has been sent to %s.", $email);
|
58 |
-
Mage::getSingleton('core/session')->addSuccess($message);
|
59 |
-
$this->_redirectReferer();
|
60 |
-
return $this;
|
61 |
-
}
|
62 |
-
|
63 |
-
}
|
64 |
-
|
1 |
+
<?php
|
2 |
+
class Bpost_ShM_Adminhtml_Bpost_ShM_AllOrdersController extends Bpost_ShM_Controller_ShM_Order
|
3 |
+
{
|
4 |
+
/**
|
5 |
+
* Load indexpage of this controller.
|
6 |
+
*/
|
7 |
+
public function indexAction()
|
8 |
+
{
|
9 |
+
Mage::getSingleton('core/session')->setBpostReturn(0);
|
10 |
+
$this->_title($this->__('bpost'))->_title($this->__('Bpost Orders'));
|
11 |
+
$this->loadLayout();
|
12 |
+
$this->_setActiveMenu('sales/bpost_all_orders');
|
13 |
+
$this->_addContent($this->getLayout()->createBlock('bpost_shm/adminhtml_sales_allOrders'));
|
14 |
+
$this->renderLayout();
|
15 |
+
}
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Load the grid.
|
19 |
+
*/
|
20 |
+
public function gridAction()
|
21 |
+
{
|
22 |
+
$this->loadLayout();
|
23 |
+
$this->getResponse()->setBody(
|
24 |
+
$this->getLayout()->createBlock('bpost_shm/adminhtml_sales_allOrders_grid')->toHtml()
|
25 |
+
);
|
26 |
+
}
|
27 |
+
|
28 |
+
protected function _isAllowed()
|
29 |
+
{
|
30 |
+
$configHelper = Mage::helper("bpost_shm/system_config");
|
31 |
+
$manageLabels = $configHelper->getBpostShippingConfig("manage_labels_with_magento");
|
32 |
+
|
33 |
+
if(!$manageLabels){
|
34 |
+
$this->_getSession()->addNotice('Please enable the "Use Magento to manage labels" setting first under "system -> configuration -> shipping settings -> Bpost Shipping Manager" if you want to use this functionality.');
|
35 |
+
return false;
|
36 |
+
}
|
37 |
+
|
38 |
+
return Mage::getSingleton('admin/session')->isAllowed('sales/bpost_orders/bpost_all_orders');
|
39 |
+
}
|
40 |
+
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Call this to send an email with the bpost template.
|
44 |
+
* This calls the model to handle emails the magento way.
|
45 |
+
* Logs all errors in try catch.
|
46 |
+
*/
|
47 |
+
public function sendEmailAction()
|
48 |
+
{
|
49 |
+
$returnId = $this->getRequest()->getParam('return_id');
|
50 |
+
try {
|
51 |
+
$email = Mage::getModel('bpost_shm/returnlabel')->sendEmail($returnId);
|
52 |
+
} catch (Exception $e) {
|
53 |
+
Mage::getSingleton('core/session')->addError($e->getMessage());
|
54 |
+
$this->_redirectReferer();
|
55 |
+
return $this;
|
56 |
+
}
|
57 |
+
$message = Mage::helper('bpost_shm')->__("The email with return label has been sent to %s.", $email);
|
58 |
+
Mage::getSingleton('core/session')->addSuccess($message);
|
59 |
+
$this->_redirectReferer();
|
60 |
+
return $this;
|
61 |
+
}
|
62 |
+
|
63 |
+
}
|
64 |
+
|
app/code/community/Bpost/ShM/controllers/Adminhtml/Bpost/ShM/ConfigController.php
CHANGED
@@ -1,153 +1,153 @@
|
|
1 |
-
<?php
|
2 |
-
class Bpost_ShM_Adminhtml_Bpost_ShM_ConfigController extends Mage_Adminhtml_Controller_Action
|
3 |
-
{
|
4 |
-
/**
|
5 |
-
* renders the bpost information popup
|
6 |
-
*/
|
7 |
-
public function informationPopupAction(){
|
8 |
-
$this->loadLayout();
|
9 |
-
$this->renderLayout();
|
10 |
-
}
|
11 |
-
|
12 |
-
/**
|
13 |
-
* renders the bpost grid information popup when labels are generated
|
14 |
-
*/
|
15 |
-
public function gridInformationPopupAction(){
|
16 |
-
$this->loadLayout();
|
17 |
-
$this->renderLayout();
|
18 |
-
}
|
19 |
-
|
20 |
-
/**
|
21 |
-
* action is used in for showing an example screenshot of how the module will look like.
|
22 |
-
*/
|
23 |
-
public function screenshotPopupAction(){
|
24 |
-
$this->loadLayout();
|
25 |
-
|
26 |
-
//because Mage::getEdition will not work in all Magento versions,
|
27 |
-
//we simple check on the filepath enterprise
|
28 |
-
//if exists, enterprise is running
|
29 |
-
|
30 |
-
$appPath = Mage::getBaseDir('app');
|
31 |
-
$enterprisePath = $appPath.DS."code".DS."core".DS."Enterprise";
|
32 |
-
|
33 |
-
$ioFile = new Varien_Io_File();
|
34 |
-
try{
|
35 |
-
$ioFile->cd($enterprisePath);
|
36 |
-
|
37 |
-
//get enterprise screenshot
|
38 |
-
$imagePath = Mage::getDesign()->getSkinUrl("images/bpost/ee-screenshot.png");
|
39 |
-
}catch(Exception $e){
|
40 |
-
//get community screenshot
|
41 |
-
$imagePath = Mage::getDesign()->getSkinUrl("images/bpost/ce-screenshot.png");
|
42 |
-
}
|
43 |
-
|
44 |
-
$data = array("image_path" => $imagePath, "width" => "600px");
|
45 |
-
|
46 |
-
$this->getLayout()->getBlock("screenshot.popup")->setData($data);
|
47 |
-
$this->renderLayout();
|
48 |
-
}
|
49 |
-
|
50 |
-
/**
|
51 |
-
* @throws Mage_Core_Exception
|
52 |
-
*/
|
53 |
-
public function exportTableratesAction(){
|
54 |
-
$request = $this->getRequest();
|
55 |
-
$fileName = $request->getParam('filename');
|
56 |
-
|
57 |
-
/** @var $gridBlock Mage_Adminhtml_Block_Shipping_Carrier_Tablerate_Grid */
|
58 |
-
$gridBlock = $this->getLayout()->createBlock('bpost_shm/adminhtml_shipping_carrier_bpost_tablerate_' . $request->getParam('method') . '_grid');
|
59 |
-
$website = Mage::app()->getWebsite($this->getRequest()->getParam('website'));
|
60 |
-
if ($this->getRequest()->getParam('conditionName')) {
|
61 |
-
$conditionName = $this->getRequest()->getParam('conditionName');
|
62 |
-
} else {
|
63 |
-
$conditionName = $website->getConfig('carriers/bpost_parcellocker/table_rate_condition');
|
64 |
-
}
|
65 |
-
$gridBlock->setWebsiteId($website->getId())->setConditionName($conditionName);
|
66 |
-
$content = $gridBlock->getCsvFile();
|
67 |
-
$this->_prepareDownloadResponse($fileName, $content);
|
68 |
-
}
|
69 |
-
|
70 |
-
|
71 |
-
/**
|
72 |
-
* checks if authentication is valid and updates the country codes for international shipping
|
73 |
-
*/
|
74 |
-
public function importCountriesByApiAction(){
|
75 |
-
|
76 |
-
$session = Mage::getSingleton("adminhtml/session");
|
77 |
-
$configHelper = Mage::helper("bpost_shm/system_config");
|
78 |
-
|
79 |
-
try{
|
80 |
-
/** @var Bpost_ShM_Model_Api $api */
|
81 |
-
$api = Mage::getModel( 'bpost_shm/api', true );
|
82 |
-
$apiResponse = $api->getProductConfig();
|
83 |
-
|
84 |
-
if(!$apiResponse) {
|
85 |
-
Mage::throwException("Failed to authenticate with bpost, please check your credentials.");
|
86 |
-
}
|
87 |
-
|
88 |
-
$xml = simplexml_load_string($apiResponse->getBody());
|
89 |
-
$product = $configHelper->getBpostCarriersConfig("product", "bpost_international", 0);
|
90 |
-
|
91 |
-
if(!$product){
|
92 |
-
$product = "bpack World Business";
|
93 |
-
}else{
|
94 |
-
$product = "bpack World Express Pro";
|
95 |
-
}
|
96 |
-
|
97 |
-
$countryCodes = array();
|
98 |
-
foreach ($xml->deliveryMethod as $deliveryMethodData) {
|
99 |
-
foreach($deliveryMethodData->product as $productData){
|
100 |
-
$attributes = $productData->attributes();
|
101 |
-
$productName = $attributes["name"];
|
102 |
-
|
103 |
-
if($productName == $product) {
|
104 |
-
$productData = $deliveryMethodData->product;
|
105 |
-
foreach ($productData->price as $priceData) {
|
106 |
-
$countryCode = (string)$priceData["countryIso2Code"];
|
107 |
-
$countryCodes[] = $countryCode;
|
108 |
-
}
|
109 |
-
|
110 |
-
break 2;
|
111 |
-
}
|
112 |
-
}
|
113 |
-
}
|
114 |
-
|
115 |
-
|
116 |
-
if(!empty($countryCodes)){
|
117 |
-
$countryModel = Mage::getModel("bpost_shm/country");
|
118 |
-
$countryResourceModel = Mage::getResourceModel('bpost_shm/country');
|
119 |
-
$countryCollection = $countryModel->getCollection();
|
120 |
-
|
121 |
-
//we truncate our table first by calling our own truncate function
|
122 |
-
$countryResourceModel->truncateTable();
|
123 |
-
|
124 |
-
//then we populate bpost_country with our last data
|
125 |
-
foreach($countryCodes as $countryCode){
|
126 |
-
$itemModel = Mage::getModel("bpost_shm/country");
|
127 |
-
$itemModel->setData(array("country_code" => $countryCode));
|
128 |
-
$countryCollection->addItem($itemModel);
|
129 |
-
}
|
130 |
-
|
131 |
-
$countryCollection->save();
|
132 |
-
|
133 |
-
}else{
|
134 |
-
$session->addNotice($configHelper->__("No bpost product configuration found for %s. Please check your bpost shipping manager for international delivery.", $product));
|
135 |
-
}
|
136 |
-
|
137 |
-
$session->addSuccess($configHelper->__("Successfully authenticated with bpost."));
|
138 |
-
}catch(Exception $e){
|
139 |
-
$session->addError($configHelper->__($e->getMessage()));
|
140 |
-
}
|
141 |
-
|
142 |
-
$this->_redirect("adminhtml/system_config/edit", array("section" => "carriers"));
|
143 |
-
}
|
144 |
-
|
145 |
-
|
146 |
-
/**
|
147 |
-
* @return bool
|
148 |
-
*/
|
149 |
-
protected function _isAllowed()
|
150 |
-
{
|
151 |
-
return Mage::getSingleton('admin/session')->isAllowed('system/config/bpost_shm');
|
152 |
-
}
|
153 |
}
|
1 |
+
<?php
|
2 |
+
class Bpost_ShM_Adminhtml_Bpost_ShM_ConfigController extends Mage_Adminhtml_Controller_Action
|
3 |
+
{
|
4 |
+
/**
|
5 |
+
* renders the bpost information popup
|
6 |
+
*/
|
7 |
+
public function informationPopupAction(){
|
8 |
+
$this->loadLayout();
|
9 |
+
$this->renderLayout();
|
10 |
+
}
|
11 |
+
|
12 |
+
/**
|
13 |
+
* renders the bpost grid information popup when labels are generated
|
14 |
+
*/
|
15 |
+
public function gridInformationPopupAction(){
|
16 |
+
$this->loadLayout();
|
17 |
+
$this->renderLayout();
|
18 |
+
}
|
19 |
+
|
20 |
+
/**
|
21 |
+
* action is used in for showing an example screenshot of how the module will look like.
|
22 |
+
*/
|
23 |
+
public function screenshotPopupAction(){
|
24 |
+
$this->loadLayout();
|
25 |
+
|
26 |
+
//because Mage::getEdition will not work in all Magento versions,
|
27 |
+
//we simple check on the filepath enterprise
|
28 |
+
//if exists, enterprise is running
|
29 |
+
|
30 |
+
$appPath = Mage::getBaseDir('app');
|
31 |
+
$enterprisePath = $appPath.DS."code".DS."core".DS."Enterprise";
|
32 |
+
|
33 |
+
$ioFile = new Varien_Io_File();
|
34 |
+
try{
|
35 |
+
$ioFile->cd($enterprisePath);
|
36 |
+
|
37 |
+
//get enterprise screenshot
|
38 |
+
$imagePath = Mage::getDesign()->getSkinUrl("images/bpost/ee-screenshot.png");
|
39 |
+
}catch(Exception $e){
|
40 |
+
//get community screenshot
|
41 |
+
$imagePath = Mage::getDesign()->getSkinUrl("images/bpost/ce-screenshot.png");
|
42 |
+
}
|
43 |
+
|
44 |
+
$data = array("image_path" => $imagePath, "width" => "600px");
|
45 |
+
|
46 |
+
$this->getLayout()->getBlock("screenshot.popup")->setData($data);
|
47 |
+
$this->renderLayout();
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* @throws Mage_Core_Exception
|
52 |
+
*/
|
53 |
+
public function exportTableratesAction(){
|
54 |
+
$request = $this->getRequest();
|
55 |
+
$fileName = $request->getParam('filename');
|
56 |
+
|
57 |
+
/** @var $gridBlock Mage_Adminhtml_Block_Shipping_Carrier_Tablerate_Grid */
|
58 |
+
$gridBlock = $this->getLayout()->createBlock('bpost_shm/adminhtml_shipping_carrier_bpost_tablerate_' . $request->getParam('method') . '_grid');
|
59 |
+
$website = Mage::app()->getWebsite($this->getRequest()->getParam('website'));
|
60 |
+
if ($this->getRequest()->getParam('conditionName')) {
|
61 |
+
$conditionName = $this->getRequest()->getParam('conditionName');
|
62 |
+
} else {
|
63 |
+
$conditionName = $website->getConfig('carriers/bpost_parcellocker/table_rate_condition');
|
64 |
+
}
|
65 |
+
$gridBlock->setWebsiteId($website->getId())->setConditionName($conditionName);
|
66 |
+
$content = $gridBlock->getCsvFile();
|
67 |
+
$this->_prepareDownloadResponse($fileName, $content);
|
68 |
+
}
|
69 |
+
|
70 |
+
|
71 |
+
/**
|
72 |
+
* checks if authentication is valid and updates the country codes for international shipping
|
73 |
+
*/
|
74 |
+
public function importCountriesByApiAction(){
|
75 |
+
|
76 |
+
$session = Mage::getSingleton("adminhtml/session");
|
77 |
+
$configHelper = Mage::helper("bpost_shm/system_config");
|
78 |
+
|
79 |
+
try{
|
80 |
+
/** @var Bpost_ShM_Model_Api $api */
|
81 |
+
$api = Mage::getModel( 'bpost_shm/api', true );
|
82 |
+
$apiResponse = $api->getProductConfig();
|
83 |
+
|
84 |
+
if(!$apiResponse) {
|
85 |
+
Mage::throwException("Failed to authenticate with bpost, please check your credentials.");
|
86 |
+
}
|
87 |
+
|
88 |
+
$xml = simplexml_load_string($apiResponse->getBody());
|
89 |
+
$product = $configHelper->getBpostCarriersConfig("product", "bpost_international", 0);
|
90 |
+
|
91 |
+
if(!$product){
|
92 |
+
$product = "bpack World Business";
|
93 |
+
}else{
|
94 |
+
$product = "bpack World Express Pro";
|
95 |
+
}
|
96 |
+
|
97 |
+
$countryCodes = array();
|
98 |
+
foreach ($xml->deliveryMethod as $deliveryMethodData) {
|
99 |
+
foreach($deliveryMethodData->product as $productData){
|
100 |
+
$attributes = $productData->attributes();
|
101 |
+
$productName = $attributes["name"];
|
102 |
+
|
103 |
+
if($productName == $product) {
|
104 |
+
$productData = $deliveryMethodData->product;
|
105 |
+
foreach ($productData->price as $priceData) {
|
106 |
+
$countryCode = (string)$priceData["countryIso2Code"];
|
107 |
+
$countryCodes[] = $countryCode;
|
108 |
+
}
|
109 |
+
|
110 |
+
break 2;
|
111 |
+
}
|
112 |
+
}
|
113 |
+
}
|
114 |
+
|
115 |
+
|
116 |
+
if(!empty($countryCodes)){
|
117 |
+
$countryModel = Mage::getModel("bpost_shm/country");
|
118 |
+
$countryResourceModel = Mage::getResourceModel('bpost_shm/country');
|
119 |
+
$countryCollection = $countryModel->getCollection();
|
120 |
+
|
121 |
+
//we truncate our table first by calling our own truncate function
|
122 |
+
$countryResourceModel->truncateTable();
|
123 |
+
|
124 |
+
//then we populate bpost_country with our last data
|
125 |
+
foreach($countryCodes as $countryCode){
|
126 |
+
$itemModel = Mage::getModel("bpost_shm/country");
|
127 |
+
$itemModel->setData(array("country_code" => $countryCode));
|
128 |
+
$countryCollection->addItem($itemModel);
|
129 |
+
}
|
130 |
+
|
131 |
+
$countryCollection->save();
|
132 |
+
|
133 |
+
}else{
|
134 |
+
$session->addNotice($configHelper->__("No bpost product configuration found for %s. Please check your bpost shipping manager for international delivery.", $product));
|
135 |
+
}
|
136 |
+
|
137 |
+
$session->addSuccess($configHelper->__("Successfully authenticated with bpost."));
|
138 |
+
}catch(Exception $e){
|
139 |
+
$session->addError($configHelper->__($e->getMessage()));
|
140 |
+
}
|
141 |
+
|
142 |
+
$this->_redirect("adminhtml/system_config/edit", array("section" => "carriers"));
|
143 |
+
}
|
144 |
+
|
145 |
+
|
146 |
+
/**
|
147 |
+
* @return bool
|
148 |
+
*/
|
149 |
+
protected function _isAllowed()
|
150 |
+
{
|
151 |
+
return Mage::getSingleton('admin/session')->isAllowed('system/config/bpost_shm');
|
152 |
+
}
|
153 |
}
|
app/code/community/Bpost/ShM/controllers/Adminhtml/Bpost/ShM/DownloadController.php
CHANGED
@@ -1,115 +1,115 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Class Bpost_ShM_Adminhtml_Bpost_ShM_DownloadController
|
5 |
-
*/
|
6 |
-
class Bpost_ShM_Adminhtml_Bpost_ShM_DownloadController extends Mage_Adminhtml_Controller_Action
|
7 |
-
{
|
8 |
-
|
9 |
-
/**
|
10 |
-
* Fetches the label and puts it in a download response.
|
11 |
-
*/
|
12 |
-
public function labelAction()
|
13 |
-
{
|
14 |
-
$request = $this->getRequest();
|
15 |
-
$orderId = $request->getParam('order_id');
|
16 |
-
$ioFile = new Varien_Io_File();
|
17 |
-
$bpostMediaFilePath = Mage::getBaseDir('media') . Bpost_ShM_Model_Adminhtml_Bpostgrid::MEDIA_LABEL_PATH;
|
18 |
-
$shipmentCollection = Mage::getResourceModel('sales/order_shipment_collection');
|
19 |
-
|
20 |
-
if($orderId){
|
21 |
-
$shipmentCollection->addFieldToFilter('order_id', $orderId);
|
22 |
-
$shipmentCollection->addFieldToFilter('bpost_label_path', array("neq" => ""));
|
23 |
-
$shipment = $shipmentCollection->getFirstItem();
|
24 |
-
|
25 |
-
//get shipments by order
|
26 |
-
$order = Mage::getModel("sales/order")->load($orderId);
|
27 |
-
$pdfDownloadName = $order->getIncrementId().".pdf";
|
28 |
-
}else{
|
29 |
-
$shipmentId = $request->getParam('shipment_id');
|
30 |
-
$shipmentCollection->addFieldToFilter('entity_id', $shipmentId);
|
31 |
-
$shipment = $shipmentCollection->getFirstItem();
|
32 |
-
|
33 |
-
if (!$shipment->hasData() || $shipment->getBpostLabelPath() == "") {
|
34 |
-
$message = Mage::helper('bpost_shm')->__("No label generated yet - please perform the ‘Generate Label and Complete’ action from the overview.");
|
35 |
-
Mage::getSingleton('core/session')->addError($message);
|
36 |
-
$this->_redirect('*/sales_order_shipment/view/' , array('shipment_id' => $shipmentId));
|
37 |
-
return;
|
38 |
-
}
|
39 |
-
|
40 |
-
$order = $shipment->getOrder();
|
41 |
-
$pdfDownloadName = $shipment->getIncrementId().".pdf";
|
42 |
-
}
|
43 |
-
|
44 |
-
$pdfMerged = new Zend_Pdf();
|
45 |
-
$merged = false;
|
46 |
-
|
47 |
-
if ($shipment->getBpostLabelPath() != "") {
|
48 |
-
$pdfNames = explode(":", $shipment->getBpostLabelPath());
|
49 |
-
|
50 |
-
foreach($pdfNames as $pdfName){
|
51 |
-
$pdfPath = $bpostMediaFilePath . $pdfName;
|
52 |
-
|
53 |
-
if($ioFile->fileExists($pdfPath)){
|
54 |
-
$tmpPdf = Zend_Pdf::load($pdfPath);
|
55 |
-
|
56 |
-
foreach ($tmpPdf->pages as $page) {
|
57 |
-
$clonedPage = clone $page;
|
58 |
-
$pdfMerged->pages[] = $clonedPage;
|
59 |
-
}
|
60 |
-
|
61 |
-
$merged = true;
|
62 |
-
}
|
63 |
-
}
|
64 |
-
}
|
65 |
-
|
66 |
-
if($merged){
|
67 |
-
$shipmentCollection->setDataToAll("bpost_label_exported", true);
|
68 |
-
$shipmentCollection->save();
|
69 |
-
}
|
70 |
-
|
71 |
-
if(!count($pdfMerged->pages)) {
|
72 |
-
$this->_getSession()->addError("Pdf(s) could not be found.");
|
73 |
-
$this->_redirectUrl($this->_getRefererUrl());
|
74 |
-
return;
|
75 |
-
}else{
|
76 |
-
$order->setBpostLabelExported(1)->save();
|
77 |
-
}
|
78 |
-
|
79 |
-
$this->_prepareDownloadResponse($pdfDownloadName, $pdfMerged->render(), 'application/pdf');
|
80 |
-
}
|
81 |
-
|
82 |
-
|
83 |
-
/**
|
84 |
-
* return label action creates a return label
|
85 |
-
*/
|
86 |
-
public function returnLabelAction(){
|
87 |
-
|
88 |
-
try{
|
89 |
-
$orderId = $this->getRequest()->getParam('order_id');
|
90 |
-
$bpostHelper = Mage::helper('bpost_shm');
|
91 |
-
|
92 |
-
if(!$orderId){
|
93 |
-
Mage::throwException('No order id found to process.');
|
94 |
-
}
|
95 |
-
|
96 |
-
$returnLabelModel = Mage::getModel('bpost_shm/returnlabel');
|
97 |
-
$returnLabelModel->generateLabelAndSave($orderId);
|
98 |
-
|
99 |
-
$this->_getSession()->addSuccess($bpostHelper->__("Your return has been generated and is available under -bpost Return labels- in this order."));
|
100 |
-
}catch(Exception $e){
|
101 |
-
$this->_getSession()->addError($bpostHelper->__($e->getMessage()));
|
102 |
-
}
|
103 |
-
|
104 |
-
$this->_redirect('*/sales_order/view', array('order_id' => $orderId));
|
105 |
-
}
|
106 |
-
|
107 |
-
|
108 |
-
/**
|
109 |
-
* @return mixed
|
110 |
-
*/
|
111 |
-
protected function _isAllowed()
|
112 |
-
{
|
113 |
-
return Mage::getSingleton('admin/session')->isAllowed('sales/bpost_orders/bpost_download_labels');
|
114 |
-
}
|
115 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class Bpost_ShM_Adminhtml_Bpost_ShM_DownloadController
|
5 |
+
*/
|
6 |
+
class Bpost_ShM_Adminhtml_Bpost_ShM_DownloadController extends Mage_Adminhtml_Controller_Action
|
7 |
+
{
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Fetches the label and puts it in a download response.
|
11 |
+
*/
|
12 |
+
public function labelAction()
|
13 |
+
{
|
14 |
+
$request = $this->getRequest();
|
15 |
+
$orderId = $request->getParam('order_id');
|
16 |
+
$ioFile = new Varien_Io_File();
|
17 |
+
$bpostMediaFilePath = Mage::getBaseDir('media') . Bpost_ShM_Model_Adminhtml_Bpostgrid::MEDIA_LABEL_PATH;
|
18 |
+
$shipmentCollection = Mage::getResourceModel('sales/order_shipment_collection');
|
19 |
+
|
20 |
+
if($orderId){
|
21 |
+
$shipmentCollection->addFieldToFilter('order_id', $orderId);
|
22 |
+
$shipmentCollection->addFieldToFilter('bpost_label_path', array("neq" => ""));
|
23 |
+
$shipment = $shipmentCollection->getFirstItem();
|
24 |
+
|
25 |
+
//get shipments by order
|
26 |
+
$order = Mage::getModel("sales/order")->load($orderId);
|
27 |
+
$pdfDownloadName = $order->getIncrementId().".pdf";
|
28 |
+
}else{
|
29 |
+
$shipmentId = $request->getParam('shipment_id');
|
30 |
+
$shipmentCollection->addFieldToFilter('entity_id', $shipmentId);
|
31 |
+
$shipment = $shipmentCollection->getFirstItem();
|
32 |
+
|
33 |
+
if (!$shipment->hasData() || $shipment->getBpostLabelPath() == "") {
|
34 |
+
$message = Mage::helper('bpost_shm')->__("No label generated yet - please perform the ‘Generate Label and Complete’ action from the overview.");
|
35 |
+
Mage::getSingleton('core/session')->addError($message);
|
36 |
+
$this->_redirect('*/sales_order_shipment/view/' , array('shipment_id' => $shipmentId));
|
37 |
+
return;
|
38 |
+
}
|
39 |
+
|
40 |
+
$order = $shipment->getOrder();
|
41 |
+
$pdfDownloadName = $shipment->getIncrementId().".pdf";
|
42 |
+
}
|
43 |
+
|
44 |
+
$pdfMerged = new Zend_Pdf();
|
45 |
+
$merged = false;
|
46 |
+
|
47 |
+
if ($shipment->getBpostLabelPath() != "") {
|
48 |
+
$pdfNames = explode(":", $shipment->getBpostLabelPath());
|
49 |
+
|
50 |
+
foreach($pdfNames as $pdfName){
|
51 |
+
$pdfPath = $bpostMediaFilePath . $pdfName;
|
52 |
+
|
53 |
+
if($ioFile->fileExists($pdfPath)){
|
54 |
+
$tmpPdf = Zend_Pdf::load($pdfPath);
|
55 |
+
|
56 |
+
foreach ($tmpPdf->pages as $page) {
|
57 |
+
$clonedPage = clone $page;
|
58 |
+
$pdfMerged->pages[] = $clonedPage;
|
59 |
+
}
|
60 |
+
|
61 |
+
$merged = true;
|
62 |
+
}
|
63 |
+
}
|
64 |
+
}
|
65 |
+
|
66 |
+
if($merged){
|
67 |
+
$shipmentCollection->setDataToAll("bpost_label_exported", true);
|
68 |
+
$shipmentCollection->save();
|
69 |
+
}
|
70 |
+
|
71 |
+
if(!count($pdfMerged->pages)) {
|
72 |
+
$this->_getSession()->addError("Pdf(s) could not be found.");
|
73 |
+
$this->_redirectUrl($this->_getRefererUrl());
|
74 |
+
return;
|
75 |
+
}else{
|
76 |
+
$order->setBpostLabelExported(1)->save();
|
77 |
+
}
|
78 |
+
|
79 |
+
$this->_prepareDownloadResponse($pdfDownloadName, $pdfMerged->render(), 'application/pdf');
|
80 |
+
}
|
81 |
+
|
82 |
+
|
83 |
+
/**
|
84 |
+
* return label action creates a return label
|
85 |
+
*/
|
86 |
+
public function returnLabelAction(){
|
87 |
+
|
88 |
+
try{
|
89 |
+
$orderId = $this->getRequest()->getParam('order_id');
|
90 |
+
$bpostHelper = Mage::helper('bpost_shm');
|
91 |
+
|
92 |
+
if(!$orderId){
|
93 |
+
Mage::throwException('No order id found to process.');
|
94 |
+
}
|
95 |
+
|
96 |
+
$returnLabelModel = Mage::getModel('bpost_shm/returnlabel');
|
97 |
+
$returnLabelModel->generateLabelAndSave($orderId);
|
98 |
+
|
99 |
+
$this->_getSession()->addSuccess($bpostHelper->__("Your return has been generated and is available under -bpost Return labels- in this order."));
|
100 |
+
}catch(Exception $e){
|
101 |
+
$this->_getSession()->addError($bpostHelper->__($e->getMessage()));
|
102 |
+
}
|
103 |
+
|
104 |
+
$this->_redirect('*/sales_order/view', array('order_id' => $orderId));
|
105 |
+
}
|
106 |
+
|
107 |
+
|
108 |
+
/**
|
109 |
+
* @return mixed
|
110 |
+
*/
|
111 |
+
protected function _isAllowed()
|
112 |
+
{
|
113 |
+
return Mage::getSingleton('admin/session')->isAllowed('sales/bpost_orders/bpost_download_labels');
|
114 |
+
}
|
115 |
+
}
|
app/code/community/Bpost/ShM/controllers/Adminhtml/Bpost/ShM/PendingOrdersController.php
CHANGED
@@ -1,41 +1,41 @@
|
|
1 |
-
<?php
|
2 |
-
class Bpost_ShM_Adminhtml_Bpost_ShM_PendingOrdersController extends Bpost_ShM_Controller_ShM_Order
|
3 |
-
{
|
4 |
-
/**
|
5 |
-
* Load indexpage of this controller.
|
6 |
-
*/
|
7 |
-
public function indexAction()
|
8 |
-
{
|
9 |
-
Mage::getSingleton('core/session')->setBpostReturn(0);
|
10 |
-
$this->_title($this->__('bpost'))->_title($this->__('Bpost Orders'));
|
11 |
-
$this->loadLayout();
|
12 |
-
$this->_setActiveMenu('sales/bpost_pending_orders');
|
13 |
-
$this->_addContent($this->getLayout()->createBlock('bpost_shm/adminhtml_sales_pendingOrders'));
|
14 |
-
$this->renderLayout();
|
15 |
-
}
|
16 |
-
|
17 |
-
/**
|
18 |
-
* Load the grid.
|
19 |
-
*/
|
20 |
-
public function gridAction()
|
21 |
-
{
|
22 |
-
$this->loadLayout();
|
23 |
-
$this->getResponse()->setBody(
|
24 |
-
$this->getLayout()->createBlock('bpost_shm/adminhtml_sales_pendingOrders_grid')->toHtml()
|
25 |
-
);
|
26 |
-
}
|
27 |
-
|
28 |
-
protected function _isAllowed()
|
29 |
-
{
|
30 |
-
$configHelper = Mage::helper("bpost_shm/system_config");
|
31 |
-
$manageLabels = $configHelper->getBpostShippingConfig("manage_labels_with_magento");
|
32 |
-
|
33 |
-
if(!$manageLabels){
|
34 |
-
$this->_getSession()->addNotice('Please enable the "Use Magento to manage labels" setting first under "system -> configuration -> shipping settings -> Bpost Shipping Manager" if you want to use this functionality.');
|
35 |
-
return false;
|
36 |
-
}
|
37 |
-
|
38 |
-
return Mage::getSingleton('admin/session')->isAllowed('sales/bpost_orders/bpost_pending_orders');
|
39 |
-
}
|
40 |
-
}
|
41 |
-
|
1 |
+
<?php
|
2 |
+
class Bpost_ShM_Adminhtml_Bpost_ShM_PendingOrdersController extends Bpost_ShM_Controller_ShM_Order
|
3 |
+
{
|
4 |
+
/**
|
5 |
+
* Load indexpage of this controller.
|
6 |
+
*/
|
7 |
+
public function indexAction()
|
8 |
+
{
|
9 |
+
Mage::getSingleton('core/session')->setBpostReturn(0);
|
10 |
+
$this->_title($this->__('bpost'))->_title($this->__('Bpost Orders'));
|
11 |
+
$this->loadLayout();
|
12 |
+
$this->_setActiveMenu('sales/bpost_pending_orders');
|
13 |
+
$this->_addContent($this->getLayout()->createBlock('bpost_shm/adminhtml_sales_pendingOrders'));
|
14 |
+
$this->renderLayout();
|
15 |
+
}
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Load the grid.
|
19 |
+
*/
|
20 |
+
public function gridAction()
|
21 |
+
{
|
22 |
+
$this->loadLayout();
|
23 |
+
$this->getResponse()->setBody(
|
24 |
+
$this->getLayout()->createBlock('bpost_shm/adminhtml_sales_pendingOrders_grid')->toHtml()
|
25 |
+
);
|
26 |
+
}
|
27 |
+
|
28 |
+
protected function _isAllowed()
|
29 |
+
{
|
30 |
+
$configHelper = Mage::helper("bpost_shm/system_config");
|
31 |
+
$manageLabels = $configHelper->getBpostShippingConfig("manage_labels_with_magento");
|
32 |
+
|
33 |
+
if(!$manageLabels){
|
34 |
+
$this->_getSession()->addNotice('Please enable the "Use Magento to manage labels" setting first under "system -> configuration -> shipping settings -> Bpost Shipping Manager" if you want to use this functionality.');
|
35 |
+
return false;
|
36 |
+
}
|
37 |
+
|
38 |
+
return Mage::getSingleton('admin/session')->isAllowed('sales/bpost_orders/bpost_pending_orders');
|
39 |
+
}
|
40 |
+
}
|
41 |
+
|
app/code/community/Bpost/ShM/controllers/AjaxController.php
CHANGED
@@ -1,150 +1,150 @@
|
|
1 |
-
<?php
|
2 |
-
class Bpost_ShM_AjaxController extends Mage_Core_Controller_Front_Action {
|
3 |
-
|
4 |
-
public function indexAction() {
|
5 |
-
$this->loadLayout();
|
6 |
-
$this->renderLayout();
|
7 |
-
}
|
8 |
-
|
9 |
-
/**
|
10 |
-
* Return a list of all bpost spots
|
11 |
-
*/
|
12 |
-
public function getwindowAction() {
|
13 |
-
$request = $this->getRequest();
|
14 |
-
$isAjax = $request->isAjax();
|
15 |
-
|
16 |
-
if ($isAjax) {
|
17 |
-
$params = $request->getParams();
|
18 |
-
|
19 |
-
if(isset($params["pointType"])){
|
20 |
-
$apiCall = Mage::helper("bpost_shm")->getBpostSpots($params);
|
21 |
-
}else{
|
22 |
-
//make call and check if it returns an error.
|
23 |
-
$apiCall = Mage::helper("bpost_shm")->getBpostSpots();
|
24 |
-
}
|
25 |
-
if(!is_array($apiCall)){
|
26 |
-
$payloadFull = array("error" => Mage::helper("bpost_shm")->__('Your address could not be determined, please return to the shipping address step to correct it.'), "poilist" => $apiCall, "coordinates" => "");
|
27 |
-
$this->getResponse()->setHeader('Content-type', 'application/json');
|
28 |
-
$this->getResponse()->setBody(json_encode($payloadFull));
|
29 |
-
return;
|
30 |
-
}
|
31 |
-
|
32 |
-
$error = array();
|
33 |
-
$xml = simplexml_load_string($apiCall['poiList']);
|
34 |
-
$coordinates = $apiCall['coordinates'];
|
35 |
-
|
36 |
-
try{
|
37 |
-
$poiList = $xml->PoiList;
|
38 |
-
}catch (Exception $e){
|
39 |
-
Mage::helper("bpost_shm")->log("Webservice: not expected result returned:" . $e->getMessage(), Zend_Log::WARN);
|
40 |
-
$poiList = "";
|
41 |
-
$error[] = Mage::helper('bpost_shm')->__("Sorry, there was a problem contacting bpost, please contact the store owner for support.");
|
42 |
-
}
|
43 |
-
$payloadFull = array("error" => $error, "poilist" => $poiList, "coordinates" => $coordinates);
|
44 |
-
$this->getResponse()->setHeader('Content-type', 'application/json');
|
45 |
-
$this->getResponse()->setBody(json_encode($payloadFull));
|
46 |
-
}
|
47 |
-
}
|
48 |
-
|
49 |
-
/**
|
50 |
-
* Return opening hours of a bpost spot
|
51 |
-
*/
|
52 |
-
public function gethoursAction() {
|
53 |
-
$request = $this->getRequest();
|
54 |
-
$isAjax = $request->isAjax();
|
55 |
-
|
56 |
-
if ($isAjax) {
|
57 |
-
$error = array();
|
58 |
-
$params = $request->getParams();
|
59 |
-
|
60 |
-
$id = isset($params["id"]) ? $params["id"] : false;
|
61 |
-
$type = isset($params["type"]) && is_numeric($params["type"]) ? $params["type"] : false;
|
62 |
-
$spots = isset($params["spots"]) ? json_decode($params["spots"]) : false;
|
63 |
-
|
64 |
-
if($id && $type) {
|
65 |
-
$apiCall = Mage::helper('bpost_shm')->getBpostOpeningHours($id, $type);
|
66 |
-
|
67 |
-
$xml = simplexml_load_string($apiCall);
|
68 |
-
|
69 |
-
try {
|
70 |
-
$openingHours = $xml->Poi->Record->Hours;
|
71 |
-
} catch (Exception $e) {
|
72 |
-
Mage::helper("bpost_shm")->log("Webservice: not expected result returned:" . $e->getMessage(), Zend_Log::WARN);
|
73 |
-
$openingHours = "";
|
74 |
-
$error[] = Mage::helper('bpost_shm')->__("Sorry, there was a problem contacting bpost, please contact the store owner for support.");
|
75 |
-
}
|
76 |
-
|
77 |
-
$payloadFull = array("error" => $error, "hours" => $openingHours);
|
78 |
-
|
79 |
-
} elseif(is_array($spots)) {
|
80 |
-
foreach ($spots as $spot) {
|
81 |
-
$id = $spot->id;
|
82 |
-
$type = $spot->type;
|
83 |
-
|
84 |
-
$apiCall = Mage::helper('bpost_shm')->getBpostOpeningHours($id, $type);
|
85 |
-
|
86 |
-
$xml = simplexml_load_string($apiCall);
|
87 |
-
|
88 |
-
try {
|
89 |
-
$openingHours = $xml->Poi->Record->Hours;
|
90 |
-
} catch (Exception $e) {
|
91 |
-
Mage::helper("bpost_shm")->log("Webservice: not expected result returned:" . $e->getMessage(), Zend_Log::WARN);
|
92 |
-
$openingHours = "";
|
93 |
-
$error[] = Mage::helper('bpost_shm')->__("Sorry, there was a problem contacting bpost, please contact the store owner for support.");
|
94 |
-
}
|
95 |
-
|
96 |
-
$payloadFull[$id] = array("error" => $error, "hours" => $openingHours);
|
97 |
-
}
|
98 |
-
}
|
99 |
-
|
100 |
-
$this->getResponse()->setHeader('Content-type', 'application/json');
|
101 |
-
$this->getResponse()->setBody(json_encode($payloadFull));
|
102 |
-
}
|
103 |
-
}
|
104 |
-
|
105 |
-
/**
|
106 |
-
* Return opening dates of a bpost spot
|
107 |
-
*/
|
108 |
-
public function getdatesAction() {
|
109 |
-
$request = $this->getRequest();
|
110 |
-
$isAjax = $request->isAjax();
|
111 |
-
|
112 |
-
$id = $request->getPost("id");
|
113 |
-
$type = $request->getPost("type");
|
114 |
-
|
115 |
-
if ($isAjax && $id && $type) {
|
116 |
-
$apiCall = Mage::helper('bpost_shm')->getBpostOpeningHours($id, $type);
|
117 |
-
$error = array();
|
118 |
-
$weekDays = array('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday');
|
119 |
-
$closedOn = array();
|
120 |
-
|
121 |
-
$xml = simplexml_load_string($apiCall);
|
122 |
-
|
123 |
-
try{
|
124 |
-
$openingHours = $xml->Poi->Record->Hours;
|
125 |
-
|
126 |
-
foreach($weekDays as $weekDay) {
|
127 |
-
$day = $openingHours->$weekDay;
|
128 |
-
|
129 |
-
if($day) {
|
130 |
-
if(empty($day->AMOpen[0]) && empty($day->AMClose[0]) && empty($day->PMOpen[0]) && empty($day->PMClose[0])) {
|
131 |
-
//assume the point is closed for the day
|
132 |
-
array_push($closedOn, $weekDay);
|
133 |
-
}
|
134 |
-
}
|
135 |
-
}
|
136 |
-
|
137 |
-
$shippingDates = Mage::helper('bpost_shm')->getBpostShippingDates($closedOn);
|
138 |
-
|
139 |
-
}catch (Exception $e){
|
140 |
-
Mage::helper("bpost_shm")->log("Webservice: not expected result returned:" . $e->getMessage(), Zend_Log::WARN);
|
141 |
-
$shippingDates = "";
|
142 |
-
$error[] = Mage::helper('bpost_shm')->__("Sorry, there was a problem contacting bpost, please contact the store owner for support.");
|
143 |
-
}
|
144 |
-
|
145 |
-
$payloadFull = array("error" => $error, "dates" => $shippingDates);
|
146 |
-
$this->getResponse()->setHeader('Content-type', 'application/json');
|
147 |
-
$this->getResponse()->setBody(json_encode($payloadFull));
|
148 |
-
}
|
149 |
-
}
|
150 |
-
}
|
1 |
+
<?php
|
2 |
+
class Bpost_ShM_AjaxController extends Mage_Core_Controller_Front_Action {
|
3 |
+
|
4 |
+
public function indexAction() {
|
5 |
+
$this->loadLayout();
|
6 |
+
$this->renderLayout();
|
7 |
+
}
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Return a list of all bpost spots
|
11 |
+
*/
|
12 |
+
public function getwindowAction() {
|
13 |
+
$request = $this->getRequest();
|
14 |
+
$isAjax = $request->isAjax();
|
15 |
+
|
16 |
+
if ($isAjax) {
|
17 |
+
$params = $request->getParams();
|
18 |
+
|
19 |
+
if(isset($params["pointType"])){
|
20 |
+
$apiCall = Mage::helper("bpost_shm")->getBpostSpots($params);
|
21 |
+
}else{
|
22 |
+
//make call and check if it returns an error.
|
23 |
+
$apiCall = Mage::helper("bpost_shm")->getBpostSpots();
|
24 |
+
}
|
25 |
+
if(!is_array($apiCall)){
|
26 |
+
$payloadFull = array("error" => Mage::helper("bpost_shm")->__('Your address could not be determined, please return to the shipping address step to correct it.'), "poilist" => $apiCall, "coordinates" => "");
|
27 |
+
$this->getResponse()->setHeader('Content-type', 'application/json');
|
28 |
+
$this->getResponse()->setBody(json_encode($payloadFull));
|
29 |
+
return;
|
30 |
+
}
|
31 |
+
|
32 |
+
$error = array();
|
33 |
+
$xml = simplexml_load_string($apiCall['poiList']);
|
34 |
+
$coordinates = $apiCall['coordinates'];
|
35 |
+
|
36 |
+
try{
|
37 |
+
$poiList = $xml->PoiList;
|
38 |
+
}catch (Exception $e){
|
39 |
+
Mage::helper("bpost_shm")->log("Webservice: not expected result returned:" . $e->getMessage(), Zend_Log::WARN);
|
40 |
+
$poiList = "";
|
41 |
+
$error[] = Mage::helper('bpost_shm')->__("Sorry, there was a problem contacting bpost, please contact the store owner for support.");
|
42 |
+
}
|
43 |
+
$payloadFull = array("error" => $error, "poilist" => $poiList, "coordinates" => $coordinates);
|
44 |
+
$this->getResponse()->setHeader('Content-type', 'application/json');
|
45 |
+
$this->getResponse()->setBody(json_encode($payloadFull));
|
46 |
+
}
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Return opening hours of a bpost spot
|
51 |
+
*/
|
52 |
+
public function gethoursAction() {
|
53 |
+
$request = $this->getRequest();
|
54 |
+
$isAjax = $request->isAjax();
|
55 |
+
|
56 |
+
if ($isAjax) {
|
57 |
+
$error = array();
|
58 |
+
$params = $request->getParams();
|
59 |
+
|
60 |
+
$id = isset($params["id"]) ? $params["id"] : false;
|
61 |
+
$type = isset($params["type"]) && is_numeric($params["type"]) ? $params["type"] : false;
|
62 |
+
$spots = isset($params["spots"]) ? json_decode($params["spots"]) : false;
|
63 |
+
|
64 |
+
if($id && $type) {
|
65 |
+
$apiCall = Mage::helper('bpost_shm')->getBpostOpeningHours($id, $type);
|
66 |
+
|
67 |
+
$xml = simplexml_load_string($apiCall);
|
68 |
+
|
69 |
+
try {
|
70 |
+
$openingHours = $xml->Poi->Record->Hours;
|
71 |
+
} catch (Exception $e) {
|
72 |
+
Mage::helper("bpost_shm")->log("Webservice: not expected result returned:" . $e->getMessage(), Zend_Log::WARN);
|
73 |
+
$openingHours = "";
|
74 |
+
$error[] = Mage::helper('bpost_shm')->__("Sorry, there was a problem contacting bpost, please contact the store owner for support.");
|
75 |
+
}
|
76 |
+
|
77 |
+
$payloadFull = array("error" => $error, "hours" => $openingHours);
|
78 |
+
|
79 |
+
} elseif(is_array($spots)) {
|
80 |
+
foreach ($spots as $spot) {
|
81 |
+
$id = $spot->id;
|
82 |
+
$type = $spot->type;
|
83 |
+
|
84 |
+
$apiCall = Mage::helper('bpost_shm')->getBpostOpeningHours($id, $type);
|
85 |
+
|
86 |
+
$xml = simplexml_load_string($apiCall);
|
87 |
+
|
88 |
+
try {
|
89 |
+
$openingHours = $xml->Poi->Record->Hours;
|
90 |
+
} catch (Exception $e) {
|
91 |
+
Mage::helper("bpost_shm")->log("Webservice: not expected result returned:" . $e->getMessage(), Zend_Log::WARN);
|
92 |
+
$openingHours = "";
|
93 |
+
$error[] = Mage::helper('bpost_shm')->__("Sorry, there was a problem contacting bpost, please contact the store owner for support.");
|
94 |
+
}
|
95 |
+
|
96 |
+
$payloadFull[$id] = array("error" => $error, "hours" => $openingHours);
|
97 |
+
}
|
98 |
+
}
|
99 |
+
|
100 |
+
$this->getResponse()->setHeader('Content-type', 'application/json');
|
101 |
+
$this->getResponse()->setBody(json_encode($payloadFull));
|
102 |
+
}
|
103 |
+
}
|
104 |
+
|
105 |
+
/**
|
106 |
+
* Return opening dates of a bpost spot
|
107 |
+
*/
|
108 |
+
public function getdatesAction() {
|
109 |
+
$request = $this->getRequest();
|
110 |
+
$isAjax = $request->isAjax();
|
111 |
+
|
112 |
+
$id = $request->getPost("id");
|
113 |
+
$type = $request->getPost("type");
|
114 |
+
|
115 |
+
if ($isAjax && $id && $type) {
|
116 |
+
$apiCall = Mage::helper('bpost_shm')->getBpostOpeningHours($id, $type);
|
117 |
+
$error = array();
|
118 |
+
$weekDays = array('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday');
|
119 |
+
$closedOn = array();
|
120 |
+
|
121 |
+
$xml = simplexml_load_string($apiCall);
|
122 |
+
|
123 |
+
try{
|
124 |
+
$openingHours = $xml->Poi->Record->Hours;
|
125 |
+
|
126 |
+
foreach($weekDays as $weekDay) {
|
127 |
+
$day = $openingHours->$weekDay;
|
128 |
+
|
129 |
+
if($day) {
|
130 |
+
if(empty($day->AMOpen[0]) && empty($day->AMClose[0]) && empty($day->PMOpen[0]) && empty($day->PMClose[0])) {
|
131 |
+
//assume the point is closed for the day
|
132 |
+
array_push($closedOn, $weekDay);
|
133 |
+
}
|
134 |
+
}
|
135 |
+
}
|
136 |
+
|
137 |
+
$shippingDates = Mage::helper('bpost_shm')->getBpostShippingDates($closedOn);
|
138 |
+
|
139 |
+
}catch (Exception $e){
|
140 |
+
Mage::helper("bpost_shm")->log("Webservice: not expected result returned:" . $e->getMessage(), Zend_Log::WARN);
|
141 |
+
$shippingDates = "";
|
142 |
+
$error[] = Mage::helper('bpost_shm')->__("Sorry, there was a problem contacting bpost, please contact the store owner for support.");
|
143 |
+
}
|
144 |
+
|
145 |
+
$payloadFull = array("error" => $error, "dates" => $shippingDates);
|
146 |
+
$this->getResponse()->setHeader('Content-type', 'application/json');
|
147 |
+
$this->getResponse()->setBody(json_encode($payloadFull));
|
148 |
+
}
|
149 |
+
}
|
150 |
+
}
|
app/code/community/Bpost/ShM/etc/adminhtml.xml
CHANGED
@@ -1,71 +1,71 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
<config>
|
3 |
-
<menu>
|
4 |
-
<sales>
|
5 |
-
<children>
|
6 |
-
<bpost_orders module="bpost_shm" translate="title">
|
7 |
-
<title>bpost Orders</title>
|
8 |
-
<sort_order>15</sort_order>
|
9 |
-
<children>
|
10 |
-
<bpost_all_orders>
|
11 |
-
<title>All bpost orders</title>
|
12 |
-
<sort_order>1</sort_order>
|
13 |
-
<action>adminhtml/bpost_shM_allOrders/index</action>
|
14 |
-
</bpost_all_orders>
|
15 |
-
<bpost_pending_orders>
|
16 |
-
<title>Pending bpost orders</title>
|
17 |
-
<sort_order>2</sort_order>
|
18 |
-
<action>adminhtml/bpost_shM_pendingOrders/index</action>
|
19 |
-
</bpost_pending_orders>
|
20 |
-
</children>
|
21 |
-
</bpost_orders>
|
22 |
-
</children>
|
23 |
-
</sales>
|
24 |
-
</menu>
|
25 |
-
<acl>
|
26 |
-
<resources>
|
27 |
-
<all>
|
28 |
-
<title>Allow Everything</title>
|
29 |
-
</all>
|
30 |
-
<admin>
|
31 |
-
<children>
|
32 |
-
<sales>
|
33 |
-
<children>
|
34 |
-
<bpost_orders translate="title">
|
35 |
-
<title>Bpost orders</title>
|
36 |
-
<sort_order>1</sort_order>
|
37 |
-
<children>
|
38 |
-
<bpost_all_orders>
|
39 |
-
<title>All bpost orders</title>
|
40 |
-
<sort_order>1</sort_order>
|
41 |
-
</bpost_all_orders>
|
42 |
-
<bpost_pending_orders>
|
43 |
-
<title>Pending bpost orders</title>
|
44 |
-
<sort_order>1</sort_order>
|
45 |
-
</bpost_pending_orders>
|
46 |
-
<bpost_download_labels>
|
47 |
-
<title>Download bpost labels</title>
|
48 |
-
<sort_order>1</sort_order>
|
49 |
-
</bpost_download_labels>
|
50 |
-
</children>
|
51 |
-
</bpost_orders>
|
52 |
-
</children>
|
53 |
-
</sales>
|
54 |
-
|
55 |
-
<system>
|
56 |
-
<children>
|
57 |
-
<config>
|
58 |
-
<children>
|
59 |
-
<bpost_shm translate="title" module="bpost_shm">
|
60 |
-
<title>Bpost - Shipping Manager</title>
|
61 |
-
<sort_order>1</sort_order>
|
62 |
-
</bpost_shm>
|
63 |
-
</children>
|
64 |
-
</config>
|
65 |
-
</children>
|
66 |
-
</system>
|
67 |
-
</children>
|
68 |
-
</admin>
|
69 |
-
</resources>
|
70 |
-
</acl>
|
71 |
</config>
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<menu>
|
4 |
+
<sales>
|
5 |
+
<children>
|
6 |
+
<bpost_orders module="bpost_shm" translate="title">
|
7 |
+
<title>bpost Orders</title>
|
8 |
+
<sort_order>15</sort_order>
|
9 |
+
<children>
|
10 |
+
<bpost_all_orders>
|
11 |
+
<title>All bpost orders</title>
|
12 |
+
<sort_order>1</sort_order>
|
13 |
+
<action>adminhtml/bpost_shM_allOrders/index</action>
|
14 |
+
</bpost_all_orders>
|
15 |
+
<bpost_pending_orders>
|
16 |
+
<title>Pending bpost orders</title>
|
17 |
+
<sort_order>2</sort_order>
|
18 |
+
<action>adminhtml/bpost_shM_pendingOrders/index</action>
|
19 |
+
</bpost_pending_orders>
|
20 |
+
</children>
|
21 |
+
</bpost_orders>
|
22 |
+
</children>
|
23 |
+
</sales>
|
24 |
+
</menu>
|
25 |
+
<acl>
|
26 |
+
<resources>
|
27 |
+
<all>
|
28 |
+
<title>Allow Everything</title>
|
29 |
+
</all>
|
30 |
+
<admin>
|
31 |
+
<children>
|
32 |
+
<sales>
|
33 |
+
<children>
|
34 |
+
<bpost_orders translate="title">
|
35 |
+
<title>Bpost orders</title>
|
36 |
+
<sort_order>1</sort_order>
|
37 |
+
<children>
|
38 |
+
<bpost_all_orders>
|
39 |
+
<title>All bpost orders</title>
|
40 |
+
<sort_order>1</sort_order>
|
41 |
+
</bpost_all_orders>
|
42 |
+
<bpost_pending_orders>
|
43 |
+
<title>Pending bpost orders</title>
|
44 |
+
<sort_order>1</sort_order>
|
45 |
+
</bpost_pending_orders>
|
46 |
+
<bpost_download_labels>
|
47 |
+
<title>Download bpost labels</title>
|
48 |
+
<sort_order>1</sort_order>
|
49 |
+
</bpost_download_labels>
|
50 |
+
</children>
|
51 |
+
</bpost_orders>
|
52 |
+
</children>
|
53 |
+
</sales>
|
54 |
+
|
55 |
+
<system>
|
56 |
+
<children>
|
57 |
+
<config>
|
58 |
+
<children>
|
59 |
+
<bpost_shm translate="title" module="bpost_shm">
|
60 |
+
<title>Bpost - Shipping Manager</title>
|
61 |
+
<sort_order>1</sort_order>
|
62 |
+
</bpost_shm>
|
63 |
+
</children>
|
64 |
+
</config>
|
65 |
+
</children>
|
66 |
+
</system>
|
67 |
+
</children>
|
68 |
+
</admin>
|
69 |
+
</resources>
|
70 |
+
</acl>
|
71 |
</config>
|
app/code/community/Bpost/ShM/etc/config.xml
CHANGED
@@ -1,404 +1,404 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
<config>
|
3 |
-
<modules>
|
4 |
-
<Bpost_ShM>
|
5 |
-
<version>1.3.2</version>
|
6 |
-
</Bpost_ShM>
|
7 |
-
</modules>
|
8 |
-
<global>
|
9 |
-
<blocks>
|
10 |
-
<bpost_shm>
|
11 |
-
<class>Bpost_ShM_Block</class>
|
12 |
-
</bpost_shm>
|
13 |
-
</blocks>
|
14 |
-
<models>
|
15 |
-
<bpost_shm>
|
16 |
-
<class>Bpost_ShM_Model</class>
|
17 |
-
<resourceModel>bpost_shm_resource</resourceModel>
|
18 |
-
</bpost_shm>
|
19 |
-
<bpost_shm_resource>
|
20 |
-
<class>Bpost_ShM_Model_Resource</class>
|
21 |
-
<entities>
|
22 |
-
<bpost_tablerates_homedelivery>
|
23 |
-
<table>bpost_tablerates_homedelivery</table>
|
24 |
-
</bpost_tablerates_homedelivery>
|
25 |
-
|
26 |
-
<bpost_tablerates_international>
|
27 |
-
<table>bpost_tablerates_international</table>
|
28 |
-
</bpost_tablerates_international>
|
29 |
-
|
30 |
-
<bpost_tablerates_pickuppoint>
|
31 |
-
<table>bpost_tablerates_pickuppoint</table>
|
32 |
-
</bpost_tablerates_pickuppoint>
|
33 |
-
|
34 |
-
<bpost_tablerates_parcellocker>
|
35 |
-
<table>bpost_tablerates_parcellocker</table>
|
36 |
-
</bpost_tablerates_parcellocker>
|
37 |
-
|
38 |
-
<bpost_tablerates_clickcollect>
|
39 |
-
<table>bpost_tablerates_clickcollect</table>
|
40 |
-
</bpost_tablerates_clickcollect>
|
41 |
-
|
42 |
-
<returnlabel>
|
43 |
-
<table>bpost_shipping_returnlabel</table>
|
44 |
-
</returnlabel>
|
45 |
-
|
46 |
-
<bpost_country>
|
47 |
-
<table>bpost_country</table>
|
48 |
-
</bpost_country>
|
49 |
-
|
50 |
-
<bpost_holidays>
|
51 |
-
<table>bpost_holidays</table>
|
52 |
-
</bpost_holidays>
|
53 |
-
</entities>
|
54 |
-
</bpost_shm_resource>
|
55 |
-
</models>
|
56 |
-
|
57 |
-
<resources>
|
58 |
-
<bpost_shm_setup>
|
59 |
-
<setup>
|
60 |
-
<module>Bpost_ShM</module>
|
61 |
-
</setup>
|
62 |
-
<connection>
|
63 |
-
<use>core_setup</use>
|
64 |
-
</connection>
|
65 |
-
</bpost_shm_setup>
|
66 |
-
<bpost_shm_write>
|
67 |
-
<connection>
|
68 |
-
<use>core_write</use>
|
69 |
-
</connection>
|
70 |
-
</bpost_shm_write>
|
71 |
-
<bpost_shm_read>
|
72 |
-
<connection>
|
73 |
-
<use>core_read</use>
|
74 |
-
</connection>
|
75 |
-
</bpost_shm_read>
|
76 |
-
</resources>
|
77 |
-
|
78 |
-
<helpers>
|
79 |
-
<bpost_shm>
|
80 |
-
<class>Bpost_ShM_Helper</class>
|
81 |
-
</bpost_shm>
|
82 |
-
</helpers>
|
83 |
-
|
84 |
-
<template>
|
85 |
-
<email>
|
86 |
-
<bpost_shm_errorhandling_create_order_email_template translate="label" module="bpost_shm">
|
87 |
-
<label>bpost - errorhandling create order</label>
|
88 |
-
<file>bpost/errorhandling_create_order.html</file>
|
89 |
-
<type>html</type>
|
90 |
-
</bpost_shm_errorhandling_create_order_email_template>
|
91 |
-
|
92 |
-
<bpost_returnlabel_email_template translate="label" module="bpost_shm">
|
93 |
-
<label>bpost - returnlabel Email</label>
|
94 |
-
<file>bpost/returnlabel.html</file>
|
95 |
-
<type>html</type>
|
96 |
-
</bpost_returnlabel_email_template>
|
97 |
-
</email>
|
98 |
-
</template>
|
99 |
-
|
100 |
-
<fieldsets>
|
101 |
-
<sales_convert_quote>
|
102 |
-
<bpost_notification_sms><to_order>*</to_order></bpost_notification_sms>
|
103 |
-
<bpost_notification_email><to_order>*</to_order></bpost_notification_email>
|
104 |
-
<bpost_reduced_mobility><to_order>*</to_order></bpost_reduced_mobility>
|
105 |
-
<bpost_delivery_date><to_order>*</to_order></bpost_delivery_date>
|
106 |
-
<bpost_drop_date><to_order>*</to_order></bpost_drop_date>
|
107 |
-
</sales_convert_quote>
|
108 |
-
|
109 |
-
<sales_convert_order>
|
110 |
-
<bpost_notification_sms><to_quote>*</to_quote></bpost_notification_sms>
|
111 |
-
<bpost_notification_email><to_quote>*</to_quote></bpost_notification_email>
|
112 |
-
<bpost_reduced_mobility><to_quote>*</to_quote></bpost_reduced_mobility>
|
113 |
-
<bpost_delivery_date><to_quote>*</to_quote></bpost_delivery_date>
|
114 |
-
<bpost_drop_date><to_quote>*</to_quote></bpost_drop_date>
|
115 |
-
</sales_convert_order>
|
116 |
-
</fieldsets>
|
117 |
-
</global>
|
118 |
-
|
119 |
-
<frontend>
|
120 |
-
<translate>
|
121 |
-
<modules>
|
122 |
-
<Bpost_ShM>
|
123 |
-
<files>
|
124 |
-
<default>Bpost_ShM.csv</default>
|
125 |
-
</files>
|
126 |
-
</Bpost_ShM>
|
127 |
-
</modules>
|
128 |
-
</translate>
|
129 |
-
<layout>
|
130 |
-
<updates>
|
131 |
-
<bpost_shm>
|
132 |
-
<file>bpost/shm.xml</file>
|
133 |
-
</bpost_shm>
|
134 |
-
</updates>
|
135 |
-
</layout>
|
136 |
-
<routers>
|
137 |
-
<bpost_shm>
|
138 |
-
<use>standard</use>
|
139 |
-
<args>
|
140 |
-
<module>Bpost_ShM</module>
|
141 |
-
<frontName>bpost</frontName>
|
142 |
-
</args>
|
143 |
-
</bpost_shm>
|
144 |
-
</routers>
|
145 |
-
<events>
|
146 |
-
<core_block_abstract_to_html_after>
|
147 |
-
<observers>
|
148 |
-
<bpost_shm_core_block_abstract_to_html_after>
|
149 |
-
<class>bpost_shm/observer</class>
|
150 |
-
<method>core_block_abstract_to_html_after</method>
|
151 |
-
</bpost_shm_core_block_abstract_to_html_after>
|
152 |
-
</observers>
|
153 |
-
</core_block_abstract_to_html_after>
|
154 |
-
|
155 |
-
<controller_action_predispatch_onestepcheckout_index_index>
|
156 |
-
<observers>
|
157 |
-
<bpost_shm_controller_action_predispatch_onestepcheckout_index_index>
|
158 |
-
<class>bpost_shm/observer</class>
|
159 |
-
<method>controller_action_predispatch_onestepcheckout_index_index</method>
|
160 |
-
</bpost_shm_controller_action_predispatch_onestepcheckout_index_index>
|
161 |
-
</observers>
|
162 |
-
</controller_action_predispatch_onestepcheckout_index_index>
|
163 |
-
|
164 |
-
<controller_action_predispatch_checkout_onepage_saveBilling>
|
165 |
-
<observers>
|
166 |
-
<bpost_shm_controller_action_predispatch_checkout_onepage_savebilling>
|
167 |
-
<class>bpost_shm/observer</class>
|
168 |
-
<method>controller_action_predispatch_checkout_onepage_saveAddress</method>
|
169 |
-
</bpost_shm_controller_action_predispatch_checkout_onepage_savebilling>
|
170 |
-
</observers>
|
171 |
-
</controller_action_predispatch_checkout_onepage_saveBilling>
|
172 |
-
|
173 |
-
<controller_action_predispatch_checkout_onepage_saveShipping>
|
174 |
-
<observers>
|
175 |
-
<bpost_shm_controller_action_predispatch_checkout_onepage_saveshipping>
|
176 |
-
<class>bpost_shm/observer</class>
|
177 |
-
<method>controller_action_predispatch_checkout_onepage_saveAddress</method>
|
178 |
-
</bpost_shm_controller_action_predispatch_checkout_onepage_saveshipping>
|
179 |
-
</observers>
|
180 |
-
</controller_action_predispatch_checkout_onepage_saveShipping>
|
181 |
-
|
182 |
-
<controller_action_postdispatch_checkout_onepage_saveBilling>
|
183 |
-
<observers>
|
184 |
-
<bpost_shm_controller_action_postdispatch_checkout_onepage_savebilling>
|
185 |
-
<class>bpost_shm/observer</class>
|
186 |
-
<method>controller_action_postdispatch_checkout_onepage_saveAddress</method>
|
187 |
-
</bpost_shm_controller_action_postdispatch_checkout_onepage_savebilling>
|
188 |
-
</observers>
|
189 |
-
</controller_action_postdispatch_checkout_onepage_saveBilling>
|
190 |
-
|
191 |
-
<controller_action_postdispatch_checkout_onepage_saveShipping>
|
192 |
-
<observers>
|
193 |
-
<bpost_shm_controller_action_postdispatch_checkout_onepage_saveshipping>
|
194 |
-
<class>bpost_shm/observer</class>
|
195 |
-
<method>controller_action_postdispatch_checkout_onepage_saveAddress</method>
|
196 |
-
</bpost_shm_controller_action_postdispatch_checkout_onepage_saveshipping>
|
197 |
-
</observers>
|
198 |
-
</controller_action_postdispatch_checkout_onepage_saveShipping>
|
199 |
-
|
200 |
-
<controller_action_postdispatch_onestepcheckout_ajax_save_billing>
|
201 |
-
<observers>
|
202 |
-
<bpost_shm_controller_action_postdispatch_onestepcheckout_ajax_save_billing>
|
203 |
-
<class>bpost_shm/observer</class>
|
204 |
-
<method>controller_action_postdispatch_checkout_onepage_saveAddress</method>
|
205 |
-
</bpost_shm_controller_action_postdispatch_onestepcheckout_ajax_save_billing>
|
206 |
-
</observers>
|
207 |
-
</controller_action_postdispatch_onestepcheckout_ajax_save_billing>
|
208 |
-
|
209 |
-
<checkout_controller_onepage_save_shipping_method>
|
210 |
-
<observers>
|
211 |
-
<bpost_shm_checkout_controller_onepage_save_shipping_method>
|
212 |
-
<class>bpost_shm/observer</class>
|
213 |
-
<method>checkout_controller_onepage_save_shipping_method</method>
|
214 |
-
</bpost_shm_checkout_controller_onepage_save_shipping_method>
|
215 |
-
</observers>
|
216 |
-
</checkout_controller_onepage_save_shipping_method>
|
217 |
-
|
218 |
-
<checkout_submit_all_after>
|
219 |
-
<observers>
|
220 |
-
<bpost_shm_checkout_submit_all_after>
|
221 |
-
<class>bpost_shm/observer</class>
|
222 |
-
<method>checkout_submit_all_after</method>
|
223 |
-
</bpost_shm_checkout_submit_all_after>
|
224 |
-
</observers>
|
225 |
-
</checkout_submit_all_after>
|
226 |
-
|
227 |
-
<sales_quote_collect_totals_before>
|
228 |
-
<observers>
|
229 |
-
<bpost_shm_set_address_defaults>
|
230 |
-
<type>model</type>
|
231 |
-
<class>bpost_shm/observer</class>
|
232 |
-
<method>sales_quote_collect_totals_before</method>
|
233 |
-
</bpost_shm_set_address_defaults>
|
234 |
-
</observers>
|
235 |
-
</sales_quote_collect_totals_before>
|
236 |
-
</events>
|
237 |
-
</frontend>
|
238 |
-
<adminhtml>
|
239 |
-
<translate>
|
240 |
-
<modules>
|
241 |
-
<Bpost_ShM>
|
242 |
-
<files>
|
243 |
-
<default>Bpost_ShM.csv</default>
|
244 |
-
</files>
|
245 |
-
</Bpost_ShM>
|
246 |
-
</modules>
|
247 |
-
</translate>
|
248 |
-
<layout>
|
249 |
-
<updates>
|
250 |
-
<bpost_shm>
|
251 |
-
<file>bpost/shm.xml</file>
|
252 |
-
</bpost_shm>
|
253 |
-
</updates>
|
254 |
-
</layout>
|
255 |
-
<events>
|
256 |
-
<core_block_abstract_to_html_before>
|
257 |
-
<observers>
|
258 |
-
<bpost_shm_core_block_abstract_to_html_before>
|
259 |
-
<class>bpost_shm/adminhtml_observer</class>
|
260 |
-
<method>core_block_abstract_to_html_before</method>
|
261 |
-
</bpost_shm_core_block_abstract_to_html_before>
|
262 |
-
</observers>
|
263 |
-
</core_block_abstract_to_html_before>
|
264 |
-
|
265 |
-
<admin_system_config_changed_section_shipping>
|
266 |
-
<observers>
|
267 |
-
<bpost_shm_admin_system_config_changed_section_shipping>
|
268 |
-
<class>bpost_shm/adminhtml_observer</class>
|
269 |
-
<method>admin_system_config_changed_section_shipping</method>
|
270 |
-
</bpost_shm_admin_system_config_changed_section_shipping>
|
271 |
-
</observers>
|
272 |
-
</admin_system_config_changed_section_shipping>
|
273 |
-
|
274 |
-
<bpost_shm_prepare_grid_collection_after>
|
275 |
-
<observers>
|
276 |
-
<bpost_shm_prepare_grid_collection_after>
|
277 |
-
<class>bpost_shm/adminhtml_observer</class>
|
278 |
-
<method>bpost_shm_prepare_grid_collection_after</method>
|
279 |
-
</bpost_shm_prepare_grid_collection_after>
|
280 |
-
</observers>
|
281 |
-
</bpost_shm_prepare_grid_collection_after>
|
282 |
-
|
283 |
-
<sales_order_shipment_save_before>
|
284 |
-
<observers>
|
285 |
-
<bpost_shm_sales_order_shipment_save_before>
|
286 |
-
<class>bpost_shm/adminhtml_observer</class>
|
287 |
-
<method>sales_order_shipment_save_before</method>
|
288 |
-
<type>model</type>
|
289 |
-
</bpost_shm_sales_order_shipment_save_before>
|
290 |
-
</observers>
|
291 |
-
</sales_order_shipment_save_before>
|
292 |
-
</events>
|
293 |
-
</adminhtml>
|
294 |
-
<admin>
|
295 |
-
<routers>
|
296 |
-
<adminhtml>
|
297 |
-
<args>
|
298 |
-
<modules>
|
299 |
-
<bpost_shm before="Mage_Adminhtml">Bpost_ShM_Adminhtml</bpost_shm>
|
300 |
-
</modules>
|
301 |
-
</args>
|
302 |
-
</adminhtml>
|
303 |
-
</routers>
|
304 |
-
</admin>
|
305 |
-
<default>
|
306 |
-
<carriers>
|
307 |
-
<bpostshm>
|
308 |
-
<active>1</active>
|
309 |
-
<model>bpost_shm/shipping_carrier_bpostShM</model>
|
310 |
-
<title>bpost</title>
|
311 |
-
<name>bpost</name>
|
312 |
-
<showmethod>1</showmethod>
|
313 |
-
</bpostshm>
|
314 |
-
<bpost_homedelivery>
|
315 |
-
<active>1</active>
|
316 |
-
<title>bpost</title>
|
317 |
-
<name>Home delivery</name>
|
318 |
-
<free_shipping>0</free_shipping>
|
319 |
-
<rate_type>0</rate_type>
|
320 |
-
<flat_rate_price>0</flat_rate_price>
|
321 |
-
<sort_order>0</sort_order>
|
322 |
-
<showmethod>1</showmethod>
|
323 |
-
<second_presentation>0</second_presentation>
|
324 |
-
<insurance>0</insurance>
|
325 |
-
<signature>0</signature>
|
326 |
-
<saturday_delivery>0</saturday_delivery>
|
327 |
-
<sort_order>1</sort_order>
|
328 |
-
<showmethod>1</showmethod>
|
329 |
-
<specificerrmsg>Bpost homedelivery is currently unavailable. If you would like to ship using this shipping method, please contact us.</specificerrmsg>
|
330 |
-
</bpost_homedelivery>
|
331 |
-
<bpost_international>
|
332 |
-
<active>1</active>
|
333 |
-
<title>bpost</title>
|
334 |
-
<name>International</name>
|
335 |
-
<sort_order>10</sort_order>
|
336 |
-
<rate_type>0</rate_type>
|
337 |
-
<flat_rate_price>0</flat_rate_price>
|
338 |
-
<showmethod>1</showmethod>
|
339 |
-
<sallowspecific>1</sallowspecific>
|
340 |
-
<product>0</product>
|
341 |
-
<insurance>0</insurance>
|
342 |
-
<specificerrmsg>Bpost international is currently unavailable. If you would like to ship using this shipping method, please contact us.</specificerrmsg>
|
343 |
-
</bpost_international>
|
344 |
-
<bpost_pickuppoint>
|
345 |
-
<active>1</active>
|
346 |
-
<title>bpost</title>
|
347 |
-
<name>Pick-up point</name>
|
348 |
-
<rate_type>0</rate_type>
|
349 |
-
<flat_rate_price>0</flat_rate_price>
|
350 |
-
<showmethod>1</showmethod>
|
351 |
-
<insurance>0</insurance>
|
352 |
-
<sort_order>20</sort_order>
|
353 |
-
<saturday_delivery>0</saturday_delivery>
|
354 |
-
<specificerrmsg>Bpost pick-up-point is currently unavailable. If you would like to ship using this shipping method, please contact us.</specificerrmsg>
|
355 |
-
</bpost_pickuppoint>
|
356 |
-
<bpost_parcellocker>
|
357 |
-
<active>1</active>
|
358 |
-
<title>bpost</title>
|
359 |
-
<name>Parcel locker</name>
|
360 |
-
<rate_type>0</rate_type>
|
361 |
-
<flat_rate_price>0</flat_rate_price>
|
362 |
-
<showmethod>1</showmethod>
|
363 |
-
<insurance>0</insurance>
|
364 |
-
<sort_order>30</sort_order>
|
365 |
-
<saturday_delivery>0</saturday_delivery>
|
366 |
-
<specificerrmsg>Bpost parcel locker is currently unavailable. If you would like to ship using this shipping method, please contact us.</specificerrmsg>
|
367 |
-
</bpost_parcellocker>
|
368 |
-
<bpost_clickcollect>
|
369 |
-
<activated>0</activated>
|
370 |
-
<active>0</active>
|
371 |
-
<title>bpost</title>
|
372 |
-
<name><![CDATA[Click & Collect]]></name>
|
373 |
-
<rate_type>0</rate_type>
|
374 |
-
<flat_rate_price>0</flat_rate_price>
|
375 |
-
<showmethod>1</showmethod>
|
376 |
-
<insurance>0</insurance>
|
377 |
-
<sort_order>20</sort_order>
|
378 |
-
<saturday_delivery>0</saturday_delivery>
|
379 |
-
<specificerrmsg><![CDATA[Bpost Click & Collect is currently unavailable. If you would like to ship using this shipping method, please contact the web merchant.]]></specificerrmsg>
|
380 |
-
</bpost_clickcollect>
|
381 |
-
</carriers>
|
382 |
-
<shipping>
|
383 |
-
<bpost_shm>
|
384 |
-
<api_log_level>3</api_log_level>
|
385 |
-
<log_level>3</log_level>
|
386 |
-
<enable_log_api>1</enable_log_api>
|
387 |
-
<enable_log>1</enable_log>
|
388 |
-
<api_url>https://api.bpost.be</api_url>
|
389 |
-
<frontend_api_url>https://shippingmanager.bpost.be/ShmFrontEnd/start</frontend_api_url>
|
390 |
-
<sender_country>BE</sender_country>
|
391 |
-
<manage_labels_with_magento>1</manage_labels_with_magento>
|
392 |
-
<label_format>A4</label_format>
|
393 |
-
<automatic_retour_labels>0</automatic_retour_labels>
|
394 |
-
<automatic_track_and_trace_information>1</automatic_track_and_trace_information>
|
395 |
-
<display_delivery_date>0</display_delivery_date>
|
396 |
-
<choose_delivery_date>0</choose_delivery_date>
|
397 |
-
<nr_of_delivery_days_shown>5</nr_of_delivery_days_shown>
|
398 |
-
<next_day_delivery_allowed_till>17,00</next_day_delivery_allowed_till>
|
399 |
-
<days_between_order_and_shipment>0</days_between_order_and_shipment>
|
400 |
-
<weight_unit>1</weight_unit>
|
401 |
-
</bpost_shm>
|
402 |
-
</shipping>
|
403 |
-
</default>
|
404 |
</config>
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Bpost_ShM>
|
5 |
+
<version>1.3.2</version>
|
6 |
+
</Bpost_ShM>
|
7 |
+
</modules>
|
8 |
+
<global>
|
9 |
+
<blocks>
|
10 |
+
<bpost_shm>
|
11 |
+
<class>Bpost_ShM_Block</class>
|
12 |
+
</bpost_shm>
|
13 |
+
</blocks>
|
14 |
+
<models>
|
15 |
+
<bpost_shm>
|
16 |
+
<class>Bpost_ShM_Model</class>
|
17 |
+
<resourceModel>bpost_shm_resource</resourceModel>
|
18 |
+
</bpost_shm>
|
19 |
+
<bpost_shm_resource>
|
20 |
+
<class>Bpost_ShM_Model_Resource</class>
|
21 |
+
<entities>
|
22 |
+
<bpost_tablerates_homedelivery>
|
23 |
+
<table>bpost_tablerates_homedelivery</table>
|
24 |
+
</bpost_tablerates_homedelivery>
|
25 |
+
|
26 |
+
<bpost_tablerates_international>
|
27 |
+
<table>bpost_tablerates_international</table>
|
28 |
+
</bpost_tablerates_international>
|
29 |
+
|
30 |
+
<bpost_tablerates_pickuppoint>
|
31 |
+
<table>bpost_tablerates_pickuppoint</table>
|
32 |
+
</bpost_tablerates_pickuppoint>
|
33 |
+
|
34 |
+
<bpost_tablerates_parcellocker>
|
35 |
+
<table>bpost_tablerates_parcellocker</table>
|
36 |
+
</bpost_tablerates_parcellocker>
|
37 |
+
|
38 |
+
<bpost_tablerates_clickcollect>
|
39 |
+
<table>bpost_tablerates_clickcollect</table>
|
40 |
+
</bpost_tablerates_clickcollect>
|
41 |
+
|
42 |
+
<returnlabel>
|
43 |
+
<table>bpost_shipping_returnlabel</table>
|
44 |
+
</returnlabel>
|
45 |
+
|
46 |
+
<bpost_country>
|
47 |
+
<table>bpost_country</table>
|
48 |
+
</bpost_country>
|
49 |
+
|
50 |
+
<bpost_holidays>
|
51 |
+
<table>bpost_holidays</table>
|
52 |
+
</bpost_holidays>
|
53 |
+
</entities>
|
54 |
+
</bpost_shm_resource>
|
55 |
+
</models>
|
56 |
+
|
57 |
+
<resources>
|
58 |
+
<bpost_shm_setup>
|
59 |
+
<setup>
|
60 |
+
<module>Bpost_ShM</module>
|
61 |
+
</setup>
|
62 |
+
<connection>
|
63 |
+
<use>core_setup</use>
|
64 |
+
</connection>
|
65 |
+
</bpost_shm_setup>
|
66 |
+
<bpost_shm_write>
|
67 |
+
<connection>
|
68 |
+
<use>core_write</use>
|
69 |
+
</connection>
|
70 |
+
</bpost_shm_write>
|
71 |
+
<bpost_shm_read>
|
72 |
+
<connection>
|
73 |
+
<use>core_read</use>
|
74 |
+
</connection>
|
75 |
+
</bpost_shm_read>
|
76 |
+
</resources>
|
77 |
+
|
78 |
+
<helpers>
|
79 |
+
<bpost_shm>
|
80 |
+
<class>Bpost_ShM_Helper</class>
|
81 |
+
</bpost_shm>
|
82 |
+
</helpers>
|
83 |
+
|
84 |
+
<template>
|
85 |
+
<email>
|
86 |
+
<bpost_shm_errorhandling_create_order_email_template translate="label" module="bpost_shm">
|
87 |
+
<label>bpost - errorhandling create order</label>
|
88 |
+
<file>bpost/errorhandling_create_order.html</file>
|
89 |
+
<type>html</type>
|
90 |
+
</bpost_shm_errorhandling_create_order_email_template>
|
91 |
+
|
92 |
+
<bpost_returnlabel_email_template translate="label" module="bpost_shm">
|
93 |
+
<label>bpost - returnlabel Email</label>
|
94 |
+
<file>bpost/returnlabel.html</file>
|
95 |
+
<type>html</type>
|
96 |
+
</bpost_returnlabel_email_template>
|
97 |
+
</email>
|
98 |
+
</template>
|
99 |
+
|
100 |
+
<fieldsets>
|
101 |
+
<sales_convert_quote>
|
102 |
+
<bpost_notification_sms><to_order>*</to_order></bpost_notification_sms>
|
103 |
+
<bpost_notification_email><to_order>*</to_order></bpost_notification_email>
|
104 |
+
<bpost_reduced_mobility><to_order>*</to_order></bpost_reduced_mobility>
|
105 |
+
<bpost_delivery_date><to_order>*</to_order></bpost_delivery_date>
|
106 |
+
<bpost_drop_date><to_order>*</to_order></bpost_drop_date>
|
107 |
+
</sales_convert_quote>
|
108 |
+
|
109 |
+
<sales_convert_order>
|
110 |
+
<bpost_notification_sms><to_quote>*</to_quote></bpost_notification_sms>
|
111 |
+
<bpost_notification_email><to_quote>*</to_quote></bpost_notification_email>
|
112 |
+
<bpost_reduced_mobility><to_quote>*</to_quote></bpost_reduced_mobility>
|
113 |
+
<bpost_delivery_date><to_quote>*</to_quote></bpost_delivery_date>
|
114 |
+
<bpost_drop_date><to_quote>*</to_quote></bpost_drop_date>
|
115 |
+
</sales_convert_order>
|
116 |
+
</fieldsets>
|
117 |
+
</global>
|
118 |
+
|
119 |
+
<frontend>
|
120 |
+
<translate>
|
121 |
+
<modules>
|
122 |
+
<Bpost_ShM>
|
123 |
+
<files>
|
124 |
+
<default>Bpost_ShM.csv</default>
|
125 |
+
</files>
|
126 |
+
</Bpost_ShM>
|
127 |
+
</modules>
|
128 |
+
</translate>
|
129 |
+
<layout>
|
130 |
+
<updates>
|
131 |
+
<bpost_shm>
|
132 |
+
<file>bpost/shm.xml</file>
|
133 |
+
</bpost_shm>
|
134 |
+
</updates>
|
135 |
+
</layout>
|
136 |
+
<routers>
|
137 |
+
<bpost_shm>
|
138 |
+
<use>standard</use>
|
139 |
+
<args>
|
140 |
+
<module>Bpost_ShM</module>
|
141 |
+
<frontName>bpost</frontName>
|
142 |
+
</args>
|
143 |
+
</bpost_shm>
|
144 |
+
</routers>
|
145 |
+
<events>
|
146 |
+
<core_block_abstract_to_html_after>
|
147 |
+
<observers>
|
148 |
+
<bpost_shm_core_block_abstract_to_html_after>
|
149 |
+
<class>bpost_shm/observer</class>
|
150 |
+
<method>core_block_abstract_to_html_after</method>
|
151 |
+
</bpost_shm_core_block_abstract_to_html_after>
|
152 |
+
</observers>
|
153 |
+
</core_block_abstract_to_html_after>
|
154 |
+
|
155 |
+
<controller_action_predispatch_onestepcheckout_index_index>
|
156 |
+
<observers>
|
157 |
+
<bpost_shm_controller_action_predispatch_onestepcheckout_index_index>
|
158 |
+
<class>bpost_shm/observer</class>
|
159 |
+
<method>controller_action_predispatch_onestepcheckout_index_index</method>
|
160 |
+
</bpost_shm_controller_action_predispatch_onestepcheckout_index_index>
|
161 |
+
</observers>
|
162 |
+
</controller_action_predispatch_onestepcheckout_index_index>
|
163 |
+
|
164 |
+
<controller_action_predispatch_checkout_onepage_saveBilling>
|
165 |
+
<observers>
|
166 |
+
<bpost_shm_controller_action_predispatch_checkout_onepage_savebilling>
|
167 |
+
<class>bpost_shm/observer</class>
|
168 |
+
<method>controller_action_predispatch_checkout_onepage_saveAddress</method>
|
169 |
+
</bpost_shm_controller_action_predispatch_checkout_onepage_savebilling>
|
170 |
+
</observers>
|
171 |
+
</controller_action_predispatch_checkout_onepage_saveBilling>
|
172 |
+
|
173 |
+
<controller_action_predispatch_checkout_onepage_saveShipping>
|
174 |
+
<observers>
|
175 |
+
<bpost_shm_controller_action_predispatch_checkout_onepage_saveshipping>
|
176 |
+
<class>bpost_shm/observer</class>
|
177 |
+
<method>controller_action_predispatch_checkout_onepage_saveAddress</method>
|
178 |
+
</bpost_shm_controller_action_predispatch_checkout_onepage_saveshipping>
|
179 |
+
</observers>
|
180 |
+
</controller_action_predispatch_checkout_onepage_saveShipping>
|
181 |
+
|
182 |
+
<controller_action_postdispatch_checkout_onepage_saveBilling>
|
183 |
+
<observers>
|
184 |
+
<bpost_shm_controller_action_postdispatch_checkout_onepage_savebilling>
|
185 |
+
<class>bpost_shm/observer</class>
|
186 |
+
<method>controller_action_postdispatch_checkout_onepage_saveAddress</method>
|
187 |
+
</bpost_shm_controller_action_postdispatch_checkout_onepage_savebilling>
|
188 |
+
</observers>
|
189 |
+
</controller_action_postdispatch_checkout_onepage_saveBilling>
|
190 |
+
|
191 |
+
<controller_action_postdispatch_checkout_onepage_saveShipping>
|
192 |
+
<observers>
|
193 |
+
<bpost_shm_controller_action_postdispatch_checkout_onepage_saveshipping>
|
194 |
+
<class>bpost_shm/observer</class>
|
195 |
+
<method>controller_action_postdispatch_checkout_onepage_saveAddress</method>
|
196 |
+
</bpost_shm_controller_action_postdispatch_checkout_onepage_saveshipping>
|
197 |
+
</observers>
|
198 |
+
</controller_action_postdispatch_checkout_onepage_saveShipping>
|
199 |
+
|
200 |
+
<controller_action_postdispatch_onestepcheckout_ajax_save_billing>
|
201 |
+
<observers>
|
202 |
+
<bpost_shm_controller_action_postdispatch_onestepcheckout_ajax_save_billing>
|
203 |
+
<class>bpost_shm/observer</class>
|
204 |
+
<method>controller_action_postdispatch_checkout_onepage_saveAddress</method>
|
205 |
+
</bpost_shm_controller_action_postdispatch_onestepcheckout_ajax_save_billing>
|
206 |
+
</observers>
|
207 |
+
</controller_action_postdispatch_onestepcheckout_ajax_save_billing>
|
208 |
+
|
209 |
+
<checkout_controller_onepage_save_shipping_method>
|
210 |
+
<observers>
|
211 |
+
<bpost_shm_checkout_controller_onepage_save_shipping_method>
|
212 |
+
<class>bpost_shm/observer</class>
|
213 |
+
<method>checkout_controller_onepage_save_shipping_method</method>
|
214 |
+
</bpost_shm_checkout_controller_onepage_save_shipping_method>
|
215 |
+
</observers>
|
216 |
+
</checkout_controller_onepage_save_shipping_method>
|
217 |
+
|
218 |
+
<checkout_submit_all_after>
|
219 |
+
<observers>
|
220 |
+
<bpost_shm_checkout_submit_all_after>
|
221 |
+
<class>bpost_shm/observer</class>
|
222 |
+
<method>checkout_submit_all_after</method>
|
223 |
+
</bpost_shm_checkout_submit_all_after>
|
224 |
+
</observers>
|
225 |
+
</checkout_submit_all_after>
|
226 |
+
|
227 |
+
<sales_quote_collect_totals_before>
|
228 |
+
<observers>
|
229 |
+
<bpost_shm_set_address_defaults>
|
230 |
+
<type>model</type>
|
231 |
+
<class>bpost_shm/observer</class>
|
232 |
+
<method>sales_quote_collect_totals_before</method>
|
233 |
+
</bpost_shm_set_address_defaults>
|
234 |
+
</observers>
|
235 |
+
</sales_quote_collect_totals_before>
|
236 |
+
</events>
|
237 |
+
</frontend>
|
238 |
+
<adminhtml>
|
239 |
+
<translate>
|
240 |
+
<modules>
|
241 |
+
<Bpost_ShM>
|
242 |
+
<files>
|
243 |
+
<default>Bpost_ShM.csv</default>
|
244 |
+
</files>
|
245 |
+
</Bpost_ShM>
|
246 |
+
</modules>
|
247 |
+
</translate>
|
248 |
+
<layout>
|
249 |
+
<updates>
|
250 |
+
<bpost_shm>
|
251 |
+
<file>bpost/shm.xml</file>
|
252 |
+
</bpost_shm>
|
253 |
+
</updates>
|
254 |
+
</layout>
|
255 |
+
<events>
|
256 |
+
<core_block_abstract_to_html_before>
|
257 |
+
<observers>
|
258 |
+
<bpost_shm_core_block_abstract_to_html_before>
|
259 |
+
<class>bpost_shm/adminhtml_observer</class>
|
260 |
+
<method>core_block_abstract_to_html_before</method>
|
261 |
+
</bpost_shm_core_block_abstract_to_html_before>
|
262 |
+
</observers>
|
263 |
+
</core_block_abstract_to_html_before>
|
264 |
+
|
265 |
+
<admin_system_config_changed_section_shipping>
|
266 |
+
<observers>
|
267 |
+
<bpost_shm_admin_system_config_changed_section_shipping>
|
268 |
+
<class>bpost_shm/adminhtml_observer</class>
|
269 |
+
<method>admin_system_config_changed_section_shipping</method>
|
270 |
+
</bpost_shm_admin_system_config_changed_section_shipping>
|
271 |
+
</observers>
|
272 |
+
</admin_system_config_changed_section_shipping>
|
273 |
+
|
274 |
+
<bpost_shm_prepare_grid_collection_after>
|
275 |
+
<observers>
|
276 |
+
<bpost_shm_prepare_grid_collection_after>
|
277 |
+
<class>bpost_shm/adminhtml_observer</class>
|
278 |
+
<method>bpost_shm_prepare_grid_collection_after</method>
|
279 |
+
</bpost_shm_prepare_grid_collection_after>
|
280 |
+
</observers>
|
281 |
+
</bpost_shm_prepare_grid_collection_after>
|
282 |
+
|
283 |
+
<sales_order_shipment_save_before>
|
284 |
+
<observers>
|
285 |
+
<bpost_shm_sales_order_shipment_save_before>
|
286 |
+
<class>bpost_shm/adminhtml_observer</class>
|
287 |
+
<method>sales_order_shipment_save_before</method>
|
288 |
+
<type>model</type>
|
289 |
+
</bpost_shm_sales_order_shipment_save_before>
|
290 |
+
</observers>
|
291 |
+
</sales_order_shipment_save_before>
|
292 |
+
</events>
|
293 |
+
</adminhtml>
|
294 |
+
<admin>
|
295 |
+
<routers>
|
296 |
+
<adminhtml>
|
297 |
+
<args>
|
298 |
+
<modules>
|
299 |
+
<bpost_shm before="Mage_Adminhtml">Bpost_ShM_Adminhtml</bpost_shm>
|
300 |
+
</modules>
|
301 |
+
</args>
|
302 |
+
</adminhtml>
|
303 |
+
</routers>
|
304 |
+
</admin>
|
305 |
+
<default>
|
306 |
+
<carriers>
|
307 |
+
<bpostshm>
|
308 |
+
<active>1</active>
|
309 |
+
<model>bpost_shm/shipping_carrier_bpostShM</model>
|
310 |
+
<title>bpost</title>
|
311 |
+
<name>bpost</name>
|
312 |
+
<showmethod>1</showmethod>
|
313 |
+
</bpostshm>
|
314 |
+
<bpost_homedelivery>
|
315 |
+
<active>1</active>
|
316 |
+
<title>bpost</title>
|
317 |
+
<name>Home delivery</name>
|
318 |
+
<free_shipping>0</free_shipping>
|
319 |
+
<rate_type>0</rate_type>
|
320 |
+
<flat_rate_price>0</flat_rate_price>
|
321 |
+
<sort_order>0</sort_order>
|
322 |
+
<showmethod>1</showmethod>
|
323 |
+
<second_presentation>0</second_presentation>
|
324 |
+
<insurance>0</insurance>
|
325 |
+
<signature>0</signature>
|
326 |
+
<saturday_delivery>0</saturday_delivery>
|
327 |
+
<sort_order>1</sort_order>
|
328 |
+
<showmethod>1</showmethod>
|
329 |
+
<specificerrmsg>Bpost homedelivery is currently unavailable. If you would like to ship using this shipping method, please contact us.</specificerrmsg>
|
330 |
+
</bpost_homedelivery>
|
331 |
+
<bpost_international>
|
332 |
+
<active>1</active>
|
333 |
+
<title>bpost</title>
|
334 |
+
<name>International</name>
|
335 |
+
<sort_order>10</sort_order>
|
336 |
+
<rate_type>0</rate_type>
|
337 |
+
<flat_rate_price>0</flat_rate_price>
|
338 |
+
<showmethod>1</showmethod>
|
339 |
+
<sallowspecific>1</sallowspecific>
|
340 |
+
<product>0</product>
|
341 |
+
<insurance>0</insurance>
|
342 |
+
<specificerrmsg>Bpost international is currently unavailable. If you would like to ship using this shipping method, please contact us.</specificerrmsg>
|
343 |
+
</bpost_international>
|
344 |
+
<bpost_pickuppoint>
|
345 |
+
<active>1</active>
|
346 |
+
<title>bpost</title>
|
347 |
+
<name>Pick-up point</name>
|
348 |
+
<rate_type>0</rate_type>
|
349 |
+
<flat_rate_price>0</flat_rate_price>
|
350 |
+
<showmethod>1</showmethod>
|
351 |
+
<insurance>0</insurance>
|
352 |
+
<sort_order>20</sort_order>
|
353 |
+
<saturday_delivery>0</saturday_delivery>
|
354 |
+
<specificerrmsg>Bpost pick-up-point is currently unavailable. If you would like to ship using this shipping method, please contact us.</specificerrmsg>
|
355 |
+
</bpost_pickuppoint>
|
356 |
+
<bpost_parcellocker>
|
357 |
+
<active>1</active>
|
358 |
+
<title>bpost</title>
|
359 |
+
<name>Parcel locker</name>
|
360 |
+
<rate_type>0</rate_type>
|
361 |
+
<flat_rate_price>0</flat_rate_price>
|
362 |
+
<showmethod>1</showmethod>
|
363 |
+
<insurance>0</insurance>
|
364 |
+
<sort_order>30</sort_order>
|
365 |
+
<saturday_delivery>0</saturday_delivery>
|
366 |
+
<specificerrmsg>Bpost parcel locker is currently unavailable. If you would like to ship using this shipping method, please contact us.</specificerrmsg>
|
367 |
+
</bpost_parcellocker>
|
368 |
+
<bpost_clickcollect>
|
369 |
+
<activated>0</activated>
|
370 |
+
<active>0</active>
|
371 |
+
<title>bpost</title>
|
372 |
+
<name><![CDATA[Click & Collect]]></name>
|
373 |
+
<rate_type>0</rate_type>
|
374 |
+
<flat_rate_price>0</flat_rate_price>
|
375 |
+
<showmethod>1</showmethod>
|
376 |
+
<insurance>0</insurance>
|
377 |
+
<sort_order>20</sort_order>
|
378 |
+
<saturday_delivery>0</saturday_delivery>
|
379 |
+
<specificerrmsg><![CDATA[Bpost Click & Collect is currently unavailable. If you would like to ship using this shipping method, please contact the web merchant.]]></specificerrmsg>
|
380 |
+
</bpost_clickcollect>
|
381 |
+
</carriers>
|
382 |
+
<shipping>
|
383 |
+
<bpost_shm>
|
384 |
+
<api_log_level>3</api_log_level>
|
385 |
+
<log_level>3</log_level>
|
386 |
+
<enable_log_api>1</enable_log_api>
|
387 |
+
<enable_log>1</enable_log>
|
388 |
+
<api_url>https://api.bpost.be</api_url>
|
389 |
+
<frontend_api_url>https://shippingmanager.bpost.be/ShmFrontEnd/start</frontend_api_url>
|
390 |
+
<sender_country>BE</sender_country>
|
391 |
+
<manage_labels_with_magento>1</manage_labels_with_magento>
|
392 |
+
<label_format>A4</label_format>
|
393 |
+
<automatic_retour_labels>0</automatic_retour_labels>
|
394 |
+
<automatic_track_and_trace_information>1</automatic_track_and_trace_information>
|
395 |
+
<display_delivery_date>0</display_delivery_date>
|
396 |
+
<choose_delivery_date>0</choose_delivery_date>
|
397 |
+
<nr_of_delivery_days_shown>5</nr_of_delivery_days_shown>
|
398 |
+
<next_day_delivery_allowed_till>17,00</next_day_delivery_allowed_till>
|
399 |
+
<days_between_order_and_shipment>0</days_between_order_and_shipment>
|
400 |
+
<weight_unit>1</weight_unit>
|
401 |
+
</bpost_shm>
|
402 |
+
</shipping>
|
403 |
+
</default>
|
404 |
</config>
|
app/code/community/Bpost/ShM/etc/system.xml
CHANGED
@@ -1,1448 +1,1448 @@
|
|
1 |
-
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
-
<config>
|
3 |
-
<sections>
|
4 |
-
<shipping>
|
5 |
-
<groups>
|
6 |
-
<bpost_shm translate="label" module="bpost_shm">
|
7 |
-
<label>bpost Shipping Manager</label>
|
8 |
-
<frontend_type>text</frontend_type>
|
9 |
-
<sort_order>10</sort_order>
|
10 |
-
<show_in_default>1</show_in_default>
|
11 |
-
<show_in_website>1</show_in_website>
|
12 |
-
<show_in_store>0</show_in_store>
|
13 |
-
<fields>
|
14 |
-
|
15 |
-
<info_text translate="label">
|
16 |
-
<label>Info text</label>
|
17 |
-
<frontend_type>text</frontend_type>
|
18 |
-
<frontend_model>bpost_shm/adminhtml_system_config_form_field_info</frontend_model>
|
19 |
-
<sort_order>0</sort_order>
|
20 |
-
<show_in_default>1</show_in_default>
|
21 |
-
<show_in_website>1</show_in_website>
|
22 |
-
<show_in_store>1</show_in_store>
|
23 |
-
</info_text>
|
24 |
-
|
25 |
-
<logo translate="label">
|
26 |
-
<label>Logo</label>
|
27 |
-
<frontend_type>text</frontend_type>
|
28 |
-
<frontend_model>bpost_shm/adminhtml_system_config_form_field_logo</frontend_model>
|
29 |
-
<sort_order>5</sort_order>
|
30 |
-
<show_in_default>1</show_in_default>
|
31 |
-
<show_in_website>1</show_in_website>
|
32 |
-
<show_in_store>1</show_in_store>
|
33 |
-
</logo>
|
34 |
-
|
35 |
-
<accountid translate="label,comment">
|
36 |
-
<label>Account id</label>
|
37 |
-
<frontend_type>text</frontend_type>
|
38 |
-
<sort_order>10</sort_order>
|
39 |
-
<show_in_default>1</show_in_default>
|
40 |
-
<show_in_website>1</show_in_website>
|
41 |
-
<show_in_store>0</show_in_store>
|
42 |
-
<comment><![CDATA[Your 6 digits bpost account ID used for the Shipping Manager.<br/><a target='_blank' href='http://bpost.freshdesk.com/solution/articles/4000061189'>http://bpost.freshdesk.com/solution/articles/4000061189</a>]]></comment>
|
43 |
-
</accountid>
|
44 |
-
|
45 |
-
<passphrase translate="label,comment">
|
46 |
-
<label>Passphrase</label>
|
47 |
-
<frontend_type>password</frontend_type>
|
48 |
-
<backend_model>adminhtml/system_config_backend_encrypted</backend_model>
|
49 |
-
<sort_order>20</sort_order>
|
50 |
-
<show_in_default>1</show_in_default>
|
51 |
-
<show_in_website>1</show_in_website>
|
52 |
-
<show_in_store>0</show_in_store>
|
53 |
-
<comment><![CDATA[The passphrase you entered in bpost Shipping Manager back-office application. This is not the password used to access bpost portal.]]></comment>
|
54 |
-
</passphrase>
|
55 |
-
|
56 |
-
<api_url translate="label,comment">
|
57 |
-
<label>API url</label>
|
58 |
-
<frontend_type>text</frontend_type>
|
59 |
-
<sort_order>30</sort_order>
|
60 |
-
<show_in_default>1</show_in_default>
|
61 |
-
<show_in_website>1</show_in_website>
|
62 |
-
<show_in_store>0</show_in_store>
|
63 |
-
<comment><![CDATA[Do not modify this setting if you are not 100% sure of what you are doing.]]></comment>
|
64 |
-
</api_url>
|
65 |
-
|
66 |
-
|
67 |
-
<sender_name translate="label,comment">
|
68 |
-
<label>Sender name</label>
|
69 |
-
<frontend_type>text</frontend_type>
|
70 |
-
<sort_order>60</sort_order>
|
71 |
-
<show_in_default>1</show_in_default>
|
72 |
-
<show_in_website>1</show_in_website>
|
73 |
-
<show_in_store>0</show_in_store>
|
74 |
-
<comment><![CDATA[Used in the webservice calls.]]></comment>
|
75 |
-
</sender_name>
|
76 |
-
|
77 |
-
<sender_company translate="label,comment">
|
78 |
-
<label>Sender company</label>
|
79 |
-
<frontend_type>text</frontend_type>
|
80 |
-
<sort_order>70</sort_order>
|
81 |
-
<show_in_default>1</show_in_default>
|
82 |
-
<show_in_website>1</show_in_website>
|
83 |
-
<show_in_store>0</show_in_store>
|
84 |
-
<comment><![CDATA[Used in the webservice calls.]]></comment>
|
85 |
-
</sender_company>
|
86 |
-
|
87 |
-
<sender_streetname translate="label,comment">
|
88 |
-
<label>Sender streetname</label>
|
89 |
-
<frontend_type>text</frontend_type>
|
90 |
-
<sort_order>80</sort_order>
|
91 |
-
<show_in_default>1</show_in_default>
|
92 |
-
<show_in_website>1</show_in_website>
|
93 |
-
<show_in_store>0</show_in_store>
|
94 |
-
<comment><![CDATA[Used in the webservice calls.]]></comment>
|
95 |
-
</sender_streetname>
|
96 |
-
|
97 |
-
<sender_streetnumber translate="label,comment">
|
98 |
-
<label>Sender streetnumber</label>
|
99 |
-
<frontend_type>text</frontend_type>
|
100 |
-
<sort_order>90</sort_order>
|
101 |
-
<show_in_default>1</show_in_default>
|
102 |
-
<show_in_website>1</show_in_website>
|
103 |
-
<show_in_store>0</show_in_store>
|
104 |
-
<comment><![CDATA[Used in the webservice calls.]]></comment>
|
105 |
-
</sender_streetnumber>
|
106 |
-
|
107 |
-
<sender_boxnumber translate="label,comment">
|
108 |
-
<label>Sender boxnumber</label>
|
109 |
-
<frontend_type>text</frontend_type>
|
110 |
-
<sort_order>100</sort_order>
|
111 |
-
<show_in_default>1</show_in_default>
|
112 |
-
<show_in_website>1</show_in_website>
|
113 |
-
<show_in_store>0</show_in_store>
|
114 |
-
<comment><![CDATA[Used in the webservice calls.]]></comment>
|
115 |
-
</sender_boxnumber>
|
116 |
-
|
117 |
-
<sender_postal_code translate="label,comment">
|
118 |
-
<label>Sender postal code</label>
|
119 |
-
<frontend_type>text</frontend_type>
|
120 |
-
<sort_order>110</sort_order>
|
121 |
-
<show_in_default>1</show_in_default>
|
122 |
-
<show_in_website>1</show_in_website>
|
123 |
-
<show_in_store>0</show_in_store>
|
124 |
-
<comment><![CDATA[Used in the webservice calls.]]></comment>
|
125 |
-
</sender_postal_code>
|
126 |
-
|
127 |
-
<sender_city translate="label,comment">
|
128 |
-
<label>Sender city</label>
|
129 |
-
<frontend_type>text</frontend_type>
|
130 |
-
<sort_order>120</sort_order>
|
131 |
-
<show_in_default>1</show_in_default>
|
132 |
-
<show_in_website>1</show_in_website>
|
133 |
-
<show_in_store>0</show_in_store>
|
134 |
-
<comment><![CDATA[Used in the webservice calls.]]></comment>
|
135 |
-
</sender_city>
|
136 |
-
|
137 |
-
<sender_country translate="label,comment">
|
138 |
-
<label>Sender country</label>
|
139 |
-
<frontend_type>select</frontend_type>
|
140 |
-
<source_model>bpost_shm/adminhtml_system_config_source_shipping::getCountries</source_model>
|
141 |
-
<sort_order>130</sort_order>
|
142 |
-
<show_in_default>1</show_in_default>
|
143 |
-
<show_in_website>1</show_in_website>
|
144 |
-
<show_in_store>0</show_in_store>
|
145 |
-
<comment><![CDATA[Used in the webservice calls.]]></comment>
|
146 |
-
</sender_country>
|
147 |
-
|
148 |
-
<sender_email translate="label,comment">
|
149 |
-
<label>Sender email</label>
|
150 |
-
<frontend_type>text</frontend_type>
|
151 |
-
<sort_order>140</sort_order>
|
152 |
-
<show_in_default>1</show_in_default>
|
153 |
-
<show_in_website>1</show_in_website>
|
154 |
-
<show_in_store>0</show_in_store>
|
155 |
-
<comment><![CDATA[Used in the webservice calls.]]></comment>
|
156 |
-
</sender_email>
|
157 |
-
|
158 |
-
<sender_phonenumber translate="label,comment">
|
159 |
-
<label>Sender phonenumber</label>
|
160 |
-
<frontend_type>text</frontend_type>
|
161 |
-
<sort_order>150</sort_order>
|
162 |
-
<show_in_default>1</show_in_default>
|
163 |
-
<show_in_website>1</show_in_website>
|
164 |
-
<show_in_store>0</show_in_store>
|
165 |
-
<comment><![CDATA[Used in the webservice calls.]]></comment>
|
166 |
-
</sender_phonenumber>
|
167 |
-
|
168 |
-
<manage_labels_with_magento translate="label,comment">
|
169 |
-
<label>Use Magento to manage labels</label>
|
170 |
-
<frontend_type>select</frontend_type>
|
171 |
-
<source_model>adminhtml/system_config_source_yesno</source_model>
|
172 |
-
<sort_order>160</sort_order>
|
173 |
-
<show_in_default>1</show_in_default>
|
174 |
-
<show_in_website>0</show_in_website>
|
175 |
-
<show_in_store>0</show_in_store>
|
176 |
-
<comment><![CDATA[If you enable this option, labels are generated directly within Magento. It is not needed to use the bpost Shipping Manager for these tasks. Pop-ups must be enabled in your browser, in order to view the printed labels. Click <a href='http://bpost.freshdesk.com/solution/articles/4000061188' target='_blank'>here</a> to learn more about this option.]]></comment>
|
177 |
-
</manage_labels_with_magento>
|
178 |
-
|
179 |
-
|
180 |
-
<label_format translate="label,comment">
|
181 |
-
<label>Label format</label>
|
182 |
-
<frontend_type>select</frontend_type>
|
183 |
-
<source_model>bpost_shm/adminhtml_system_config_source_shipping::getLabelSizesOptionsArray</source_model>
|
184 |
-
<sort_order>170</sort_order>
|
185 |
-
<show_in_default>1</show_in_default>
|
186 |
-
<show_in_website>1</show_in_website>
|
187 |
-
<show_in_store>0</show_in_store>
|
188 |
-
<depends>
|
189 |
-
<manage_labels_with_magento>1</manage_labels_with_magento>
|
190 |
-
</depends>
|
191 |
-
<comment><![CDATA[Choose between A6 or A4 format]]></comment>
|
192 |
-
</label_format>
|
193 |
-
|
194 |
-
<automatic_retour_labels translate="label">
|
195 |
-
<label>Automatic retour labels</label>
|
196 |
-
<frontend_type>select</frontend_type>
|
197 |
-
<source_model>adminhtml/system_config_source_yesno</source_model>
|
198 |
-
<sort_order>180</sort_order>
|
199 |
-
<show_in_default>1</show_in_default>
|
200 |
-
<show_in_website>1</show_in_website>
|
201 |
-
<show_in_store>0</show_in_store>
|
202 |
-
<depends>
|
203 |
-
<manage_labels_with_magento>1</manage_labels_with_magento>
|
204 |
-
</depends>
|
205 |
-
<comment><![CDATA[If you enable this option, a retour label is automatically added and printed when generating labels. If disabled, you are able to manually create retour labels.]]></comment>
|
206 |
-
</automatic_retour_labels>
|
207 |
-
|
208 |
-
<automatic_track_and_trace_information translate="label,comment">
|
209 |
-
<label>Automatic track and trace information</label>
|
210 |
-
<frontend_type>select</frontend_type>
|
211 |
-
<source_model>adminhtml/system_config_source_yesno</source_model>
|
212 |
-
<sort_order>190</sort_order>
|
213 |
-
<show_in_default>1</show_in_default>
|
214 |
-
<show_in_website>1</show_in_website>
|
215 |
-
<show_in_store>0</show_in_store>
|
216 |
-
<depends>
|
217 |
-
<manage_labels_with_magento>1</manage_labels_with_magento>
|
218 |
-
</depends>
|
219 |
-
<comment><![CDATA[If you enable this option, the bpost Track & Trace link will be added in the Magento mail templates. It is always possible to manually send these emails.<br/><a href='http://bpost.freshdesk.com/solution/articles/4000062605' target='_blank'>http://bpost.freshdesk.com/solution/articles/4000062605</a>]]></comment>
|
220 |
-
</automatic_track_and_trace_information>
|
221 |
-
|
222 |
-
<display_delivery_date translate="label,comment">
|
223 |
-
<label>Display delivery date</label>
|
224 |
-
<frontend_type>select</frontend_type>
|
225 |
-
<source_model>adminhtml/system_config_source_yesno</source_model>
|
226 |
-
<sort_order>200</sort_order>
|
227 |
-
<show_in_default>1</show_in_default>
|
228 |
-
<show_in_website>1</show_in_website>
|
229 |
-
<show_in_store>0</show_in_store>
|
230 |
-
<comment><![CDATA[Displays calculated delivery date]]></comment>
|
231 |
-
<comment>
|
232 |
-
<model>bpost_shm/adminhtml_system_config_source_datecomment</model>
|
233 |
-
</comment>
|
234 |
-
</display_delivery_date>
|
235 |
-
|
236 |
-
<days_between_order_and_shipment translate="label">
|
237 |
-
<label>Days between order and shipment</label>
|
238 |
-
<frontend_type>text</frontend_type>
|
239 |
-
<sort_order>210</sort_order>
|
240 |
-
<show_in_default>1</show_in_default>
|
241 |
-
<show_in_website>1</show_in_website>
|
242 |
-
<show_in_store>0</show_in_store>
|
243 |
-
<depends><display_delivery_date>1</display_delivery_date></depends>
|
244 |
-
</days_between_order_and_shipment>
|
245 |
-
|
246 |
-
<choose_delivery_date translate="label,comment">
|
247 |
-
<label>Choose delivery date</label>
|
248 |
-
<frontend_type>select</frontend_type>
|
249 |
-
<frontend_model>bpost_shm/adminhtml_system_config_form_field_choose</frontend_model>
|
250 |
-
<source_model>adminhtml/system_config_source_yesno</source_model>
|
251 |
-
<sort_order>220</sort_order>
|
252 |
-
<show_in_default>1</show_in_default>
|
253 |
-
<show_in_website>1</show_in_website>
|
254 |
-
<show_in_store>0</show_in_store>
|
255 |
-
<depends><display_delivery_date>1</display_delivery_date></depends>
|
256 |
-
<comment><![CDATA[Allow customer to choose their delivery date]]></comment>
|
257 |
-
</choose_delivery_date>
|
258 |
-
|
259 |
-
<nr_of_delivery_days_shown translate="label">
|
260 |
-
<label>Number of delivery days shown</label>
|
261 |
-
<frontend_type>select</frontend_type>
|
262 |
-
<source_model>bpost_shm/adminhtml_system_config_source_shipping::nrOfDeliveryDaysShownOptionsArray</source_model>
|
263 |
-
<sort_order>230</sort_order>
|
264 |
-
<show_in_default>1</show_in_default>
|
265 |
-
<show_in_website>1</show_in_website>
|
266 |
-
<show_in_store>0</show_in_store>
|
267 |
-
<depends>
|
268 |
-
<display_delivery_date>1</display_delivery_date>
|
269 |
-
<choose_delivery_date>1</choose_delivery_date>
|
270 |
-
</depends>
|
271 |
-
</nr_of_delivery_days_shown>
|
272 |
-
|
273 |
-
<next_day_delivery_allowed_till translate="label,comment">
|
274 |
-
<label>Next day delivery allowed till</label>
|
275 |
-
<frontend_type>time</frontend_type>
|
276 |
-
<frontend_model>bpost_shm/adminhtml_system_config_form_field_hour</frontend_model>
|
277 |
-
<sort_order>240</sort_order>
|
278 |
-
<show_in_default>1</show_in_default>
|
279 |
-
<show_in_website>1</show_in_website>
|
280 |
-
<show_in_store>0</show_in_store>
|
281 |
-
<comment><![CDATA[If the order is placed after this cut-off time, an extra day is added to the displayed date. Order placed = end of checkout.]]></comment>
|
282 |
-
<depends>
|
283 |
-
<display_delivery_date>1</display_delivery_date>
|
284 |
-
</depends>
|
285 |
-
</next_day_delivery_allowed_till>
|
286 |
-
|
287 |
-
<saturday_delivery_cost translate="label,comment">
|
288 |
-
<label>Saturday delivery cost</label>
|
289 |
-
<frontend_type>text</frontend_type>
|
290 |
-
<sort_order>250</sort_order>
|
291 |
-
<show_in_default>1</show_in_default>
|
292 |
-
<show_in_website>1</show_in_website>
|
293 |
-
<show_in_store>0</show_in_store>
|
294 |
-
<comment><![CDATA[Additional fee when using saturday delivery option, e.g.: 4.95.]]></comment>
|
295 |
-
</saturday_delivery_cost>
|
296 |
-
|
297 |
-
<weight_unit translate="label,comment">
|
298 |
-
<label>Weight unit</label>
|
299 |
-
<frontend_type>select</frontend_type>
|
300 |
-
<source_model>bpost_shm/system_config_source_weightunit</source_model>
|
301 |
-
<sort_order>255</sort_order>
|
302 |
-
<show_in_default>1</show_in_default>
|
303 |
-
<show_in_website>1</show_in_website>
|
304 |
-
<show_in_store>0</show_in_store>
|
305 |
-
<comment>Used to calculate the weight before sending it to bpost</comment>
|
306 |
-
</weight_unit>
|
307 |
-
|
308 |
-
<browser_api_key translate="label,comment">
|
309 |
-
<label>Google browser API key</label>
|
310 |
-
<frontend_type>text</frontend_type>
|
311 |
-
<sort_order>260</sort_order>
|
312 |
-
<show_in_default>1</show_in_default>
|
313 |
-
<show_in_website>1</show_in_website>
|
314 |
-
<show_in_store>0</show_in_store>
|
315 |
-
<comment><![CDATA[bpost uses Google Maps API to display the map in the frontend. <strong>
Note:</strong> This is optional if you will not meet the usage limits. Visit Google’s online documentation for more information.]]></comment>
|
316 |
-
</browser_api_key>
|
317 |
-
|
318 |
-
<server_api_key translate="label,comment">
|
319 |
-
<label>Google server API key</label>
|
320 |
-
<frontend_type>text</frontend_type>
|
321 |
-
<sort_order>270</sort_order>
|
322 |
-
<show_in_default>1</show_in_default>
|
323 |
-
<show_in_website>1</show_in_website>
|
324 |
-
<show_in_store>0</show_in_store>
|
325 |
-
<comment><![CDATA[bpost uses Google Geocoding API to calculate GEO location based on the shipping address. <strong>
Note:</strong> This is optional if you will not meet the usage limits. Visit Google’s online documentation for more information.]]></comment>
|
326 |
-
</server_api_key>
|
327 |
-
</fields>
|
328 |
-
</bpost_shm>
|
329 |
-
</groups>
|
330 |
-
</shipping>
|
331 |
-
|
332 |
-
<carriers>
|
333 |
-
<groups>
|
334 |
-
<bpost_homedelivery translate="label" module="bpost_shm">
|
335 |
-
<label>bpost Home delivery</label>
|
336 |
-
<frontend_type>text</frontend_type>
|
337 |
-
<sort_order>50</sort_order>
|
338 |
-
<show_in_default>1</show_in_default>
|
339 |
-
<show_in_website>1</show_in_website>
|
340 |
-
<show_in_store>1</show_in_store>
|
341 |
-
<fields>
|
342 |
-
<logo translate="label">
|
343 |
-
<label>Logoo</label>
|
344 |
-
<frontend_type>text</frontend_type>
|
345 |
-
<frontend_model>bpost_shm/adminhtml_system_config_form_field_logo</frontend_model>
|
346 |
-
<sort_order>0</sort_order>
|
347 |
-
<show_in_default>1</show_in_default>
|
348 |
-
<show_in_website>1</show_in_website>
|
349 |
-
<show_in_store>1</show_in_store>
|
350 |
-
</logo>
|
351 |
-
|
352 |
-
|
353 |
-
<subheader_general translate="label">
|
354 |
-
<label>General</label>
|
355 |
-
<frontend_type>text</frontend_type>
|
356 |
-
<frontend_model>bpost_shm/adminhtml_system_config_form_field_subheader</frontend_model>
|
357 |
-
<sort_order>0</sort_order>
|
358 |
-
<show_in_default>1</show_in_default>
|
359 |
-
<show_in_website>1</show_in_website>
|
360 |
-
<show_in_store>1</show_in_store>
|
361 |
-
</subheader_general>
|
362 |
-
|
363 |
-
<active translate="label,comment">
|
364 |
-
<label>Enabled</label>
|
365 |
-
<frontend_type>select</frontend_type>
|
366 |
-
<source_model>adminhtml/system_config_source_yesno</source_model>
|
367 |
-
<sort_order>1</sort_order>
|
368 |
-
<show_in_default>1</show_in_default>
|
369 |
-
<show_in_website>1</show_in_website>
|
370 |
-
<show_in_store>1</show_in_store>
|
371 |
-
<comment><![CDATA[Delivery at your doorstep or at your office? bpack@home is the most convenient option for you!]]></comment>
|
372 |
-
</active>
|
373 |
-
|
374 |
-
<subheader_rates translate="label">
|
375 |
-
<label>Rates</label>
|
376 |
-
<frontend_type>text</frontend_type>
|
377 |
-
<frontend_model>bpost_shm/adminhtml_system_config_form_field_subheader</frontend_model>
|
378 |
-
<sort_order>5</sort_order>
|
379 |
-
<show_in_default>1</show_in_default>
|
380 |
-
<show_in_website>1</show_in_website>
|
381 |
-
<show_in_store>1</show_in_store>
|
382 |
-
</subheader_rates>
|
383 |
-
|
384 |
-
<free_shipping translate="label,comment">
|
385 |
-
<label>Free shipping</label>
|
386 |
-
<frontend_type>select</frontend_type>
|
387 |
-
<source_model>adminhtml/system_config_source_yesno</source_model>
|
388 |
-
<sort_order>10</sort_order>
|
389 |
-
<show_in_default>1</show_in_default>
|
390 |
-
<show_in_website>1</show_in_website>
|
391 |
-
<show_in_store>1</show_in_store>
|
392 |
-
<comment><![CDATA[Allow free shipping]]></comment>
|
393 |
-
</free_shipping>
|
394 |
-
|
395 |
-
<free_shipping_from translate="label,comment">
|
396 |
-
<label>.. as of</label>
|
397 |
-
<frontend_type>text</frontend_type>
|
398 |
-
<sort_order>20</sort_order>
|
399 |
-
<depends>
|
400 |
-
<free_shipping>1</free_shipping>
|
401 |
-
</depends>
|
402 |
-
<show_in_default>1</show_in_default>
|
403 |
-
<show_in_website>1</show_in_website>
|
404 |
-
<show_in_store>1</show_in_store>
|
405 |
-
<comment><![CDATA[Free shipping will be applied as from a minimum amount]]></comment>
|
406 |
-
</free_shipping_from>
|
407 |
-
|
408 |
-
<rate_type translate="label,comment,tooltip">
|
409 |
-
<label>Rate type</label>
|
410 |
-
<frontend_type>select</frontend_type>
|
411 |
-
<source_model>bpost_shm/system_config_source_ratetypes</source_model>
|
412 |
-
<sort_order>30</sort_order>
|
413 |
-
<show_in_default>1</show_in_default>
|
414 |
-
<show_in_website>1</show_in_website>
|
415 |
-
<show_in_store>1</show_in_store>
|
416 |
-
<comment><![CDATA[Choose your rate type (Flat rate or Table rate)]]></comment>
|
417 |
-
<tooltip>Importing and exporting table rates only possible on website scope. View the documentation for more information.</tooltip>
|
418 |
-
</rate_type>
|
419 |
-
|
420 |
-
<flat_rate_price translate="label,comment">
|
421 |
-
<label>Flat rate price</label>
|
422 |
-
<frontend_type>text</frontend_type>
|
423 |
-
<sort_order>40</sort_order>
|
424 |
-
<depends>
|
425 |
-
<rate_type>0</rate_type>
|
426 |
-
</depends>
|
427 |
-
<show_in_default>1</show_in_default>
|
428 |
-
<show_in_website>1</show_in_website>
|
429 |
-
<show_in_store>1</show_in_store>
|
430 |
-
<comment><![CDATA[Fixed fee for bpost Home delivery shipments, e.g.: 4.95.]]></comment>
|
431 |
-
</flat_rate_price>
|
432 |
-
|
433 |
-
<condition_name translate="label">
|
434 |
-
<label>Table rates condition</label>
|
435 |
-
<frontend_type>select</frontend_type>
|
436 |
-
<source_model>adminhtml/system_config_source_shipping_tablerate</source_model>
|
437 |
-
<sort_order>50</sort_order>
|
438 |
-
<depends>
|
439 |
-
<rate_type>1</rate_type>
|
440 |
-
</depends>
|
441 |
-
<show_in_default>1</show_in_default>
|
442 |
-
<show_in_website>1</show_in_website>
|
443 |
-
<show_in_store>0</show_in_store>
|
444 |
-
</condition_name>
|
445 |
-
|
446 |
-
<export translate="label,comment">
|
447 |
-
<label>Export table rates file</label>
|
448 |
-
<frontend_type>button</frontend_type>
|
449 |
-
<frontend_model>bpost_shm/adminhtml_system_config_form_tablerates_export_homedelivery</frontend_model>
|
450 |
-
<sort_order>60</sort_order>
|
451 |
-
<depends>
|
452 |
-
<rate_type>1</rate_type>
|
453 |
-
</depends>
|
454 |
-
<show_in_default>0</show_in_default>
|
455 |
-
<show_in_website>1</show_in_website>
|
456 |
-
<show_in_store>0</show_in_store>
|
457 |
-
<comment><![CDATA[Export your table rates configuration here.]]></comment>
|
458 |
-
</export>
|
459 |
-
|
460 |
-
<import_homedelivery translate="label,comment">
|
461 |
-
<label>Import table rates file</label>
|
462 |
-
<frontend_type>import</frontend_type>
|
463 |
-
<sort_order>70</sort_order>
|
464 |
-
<backend_model>bpost_shm/adminhtml_system_config_backend_shipping_tablerates_homedelivery</backend_model>
|
465 |
-
<depends>
|
466 |
-
<rate_type>1</rate_type>
|
467 |
-
</depends>
|
468 |
-
<show_in_default>0</show_in_default>
|
469 |
-
<show_in_website>1</show_in_website>
|
470 |
-
<show_in_store>0</show_in_store>
|
471 |
-
<comment><![CDATA[Upload your table rates configuration here. Refer to the manual for more information.]]></comment>
|
472 |
-
</import_homedelivery>
|
473 |
-
|
474 |
-
<subheader_options translate="label">
|
475 |
-
<label>Options</label>
|
476 |
-
<frontend_type>text</frontend_type>
|
477 |
-
<frontend_model>bpost_shm/adminhtml_system_config_form_field_subheader</frontend_model>
|
478 |
-
<sort_order>75</sort_order>
|
479 |
-
<show_in_default>1</show_in_default>
|
480 |
-
<show_in_website>1</show_in_website>
|
481 |
-
<show_in_store>1</show_in_store>
|
482 |
-
</subheader_options>
|
483 |
-
|
484 |
-
<second_presentation translate="label,comment">
|
485 |
-
<label>2nd presentation</label>
|
486 |
-
<frontend_type>select</frontend_type>
|
487 |
-
<source_model>adminhtml/system_config_source_yesno</source_model>
|
488 |
-
<sort_order>80</sort_order>
|
489 |
-
<show_in_default>1</show_in_default>
|
490 |
-
<show_in_website>1</show_in_website>
|
491 |
-
<show_in_store>1</show_in_store>
|
492 |
-
<comment><![CDATA[This options provides automatically a second presentation at the receiver's address should he be absent upon first presentation.]]></comment>
|
493 |
-
</second_presentation>
|
494 |
-
|
495 |
-
<second_presentation_from translate="label">
|
496 |
-
<label>.. as from</label>
|
497 |
-
<frontend_type>text</frontend_type>
|
498 |
-
<sort_order>90</sort_order>
|
499 |
-
<depends>
|
500 |
-
<second_presentation>1</second_presentation>
|
501 |
-
</depends>
|
502 |
-
<show_in_default>1</show_in_default>
|
503 |
-
<show_in_website>1</show_in_website>
|
504 |
-
<show_in_store>1</show_in_store>
|
505 |
-
</second_presentation_from>
|
506 |
-
|
507 |
-
<insurance translate="label,comment">
|
508 |
-
<label>Insurance</label>
|
509 |
-
<frontend_type>select</frontend_type>
|
510 |
-
<source_model>adminhtml/system_config_source_yesno</source_model>
|
511 |
-
<sort_order>100</sort_order>
|
512 |
-
<show_in_default>1</show_in_default>
|
513 |
-
<show_in_website>1</show_in_website>
|
514 |
-
<show_in_store>1</show_in_store>
|
515 |
-
<comment><![CDATA[Insurance to insure your goods to a maximum of 500,00 euro.]]></comment>
|
516 |
-
</insurance>
|
517 |
-
|
518 |
-
<insurance_from translate="label">
|
519 |
-
<label>.. as from</label>
|
520 |
-
<frontend_type>text</frontend_type>
|
521 |
-
<sort_order>110</sort_order>
|
522 |
-
<depends>
|
523 |
-
<insurance>1</insurance>
|
524 |
-
</depends>
|
525 |
-
<show_in_default>1</show_in_default>
|
526 |
-
<show_in_website>1</show_in_website>
|
527 |
-
<show_in_store>1</show_in_store>
|
528 |
-
</insurance_from>
|
529 |
-
|
530 |
-
<signature translate="label,comment">
|
531 |
-
<label>Signature</label>
|
532 |
-
<frontend_type>select</frontend_type>
|
533 |
-
<source_model>adminhtml/system_config_source_yesno</source_model>
|
534 |
-
<sort_order>120</sort_order>
|
535 |
-
<show_in_default>1</show_in_default>
|
536 |
-
<show_in_website>1</show_in_website>
|
537 |
-
<show_in_store>1</show_in_store>
|
538 |
-
<comment><![CDATA[The delivery happens against signature by the receiver.]]></comment>
|
539 |
-
</signature>
|
540 |
-
|
541 |
-
<signature_from translate="label">
|
542 |
-
<label>.. as from</label>
|
543 |
-
<frontend_type>text</frontend_type>
|
544 |
-
<sort_order>130</sort_order>
|
545 |
-
<depends>
|
546 |
-
<signature>1</signature>
|
547 |
-
</depends>
|
548 |
-
<show_in_default>1</show_in_default>
|
549 |
-
<show_in_website>1</show_in_website>
|
550 |
-
<show_in_store>1</show_in_store>
|
551 |
-
</signature_from>
|
552 |
-
|
553 |
-
<saturday_delivery translate="label,comment">
|
554 |
-
<label>Saturday delivery</label>
|
555 |
-
<frontend_type>select</frontend_type>
|
556 |
-
<source_model>adminhtml/system_config_source_yesno</source_model>
|
557 |
-
<sort_order>140</sort_order>
|
558 |
-
<show_in_default>1</show_in_default>
|
559 |
-
<show_in_website>1</show_in_website>
|
560 |
-
<show_in_store>1</show_in_store>
|
561 |
-
<comment><![CDATA[The parcel is delivered on Saturday if it is timely dropped in the bpost network.]]></comment>
|
562 |
-
</saturday_delivery>
|
563 |
-
|
564 |
-
<saturday_delivery_from translate="label">
|
565 |
-
<label>.. as from</label>
|
566 |
-
<frontend_type>text</frontend_type>
|
567 |
-
<sort_order>150</sort_order>
|
568 |
-
<depends>
|
569 |
-
<saturday_delivery>1</saturday_delivery>
|
570 |
-
</depends>
|
571 |
-
<show_in_default>1</show_in_default>
|
572 |
-
<show_in_website>1</show_in_website>
|
573 |
-
<show_in_store>1</show_in_store>
|
574 |
-
</saturday_delivery_from>
|
575 |
-
</fields>
|
576 |
-
</bpost_homedelivery>
|
577 |
-
<bpost_international translate="label" module="bpost_shm">
|
578 |
-
<label>bpost Home delivery international</label>
|
579 |
-
<frontend_type>text</frontend_type>
|
580 |
-
<sort_order>60</sort_order>
|
581 |
-
<show_in_default>1</show_in_default>
|
582 |
-
<show_in_website>1</show_in_website>
|
583 |
-
<show_in_store>1</show_in_store>
|
584 |
-
<fields>
|
585 |
-
<logo translate="label">
|
586 |
-
<label>Logoo</label>
|
587 |
-
<frontend_type>text</frontend_type>
|
588 |
-
<frontend_model>bpost_shm/adminhtml_system_config_form_field_logo</frontend_model>
|
589 |
-
<sort_order>0</sort_order>
|
590 |
-
<show_in_default>1</show_in_default>
|
591 |
-
<show_in_website>1</show_in_website>
|
592 |
-
<show_in_store>1</show_in_store>
|
593 |
-
</logo>
|
594 |
-
|
595 |
-
<subheader_general translate="label">
|
596 |
-
<label>General</label>
|
597 |
-
<frontend_type>text</frontend_type>
|
598 |
-
<frontend_model>bpost_shm/adminhtml_system_config_form_field_subheader</frontend_model>
|
599 |
-
<sort_order>10</sort_order>
|
600 |
-
<show_in_default>1</show_in_default>
|
601 |
-
<show_in_website>1</show_in_website>
|
602 |
-
<show_in_store>1</show_in_store>
|
603 |
-
</subheader_general>
|
604 |
-
|
605 |
-
<active translate="label,comment">
|
606 |
-
<label>Enabled</label>
|
607 |
-
<frontend_type>select</frontend_type>
|
608 |
-
<source_model>adminhtml/system_config_source_yesno</source_model>
|
609 |
-
<sort_order>20</sort_order>
|
610 |
-
<show_in_default>1</show_in_default>
|
611 |
-
<show_in_website>1</show_in_website>
|
612 |
-
<show_in_store>1</show_in_store>
|
613 |
-
<comment><![CDATA[Delivery at your doorstep or at your office outside Belgium? bpack@international is the most convenient option for you!]]></comment>
|
614 |
-
</active>
|
615 |
-
|
616 |
-
<product translate="label,comment">
|
617 |
-
<label>Product</label>
|
618 |
-
<frontend_type>select</frontend_type>
|
619 |
-
<source_model>bpost_shm/system_config_source_product</source_model>
|
620 |
-
<sort_order>30</sort_order>
|
621 |
-
<show_in_default>1</show_in_default>
|
622 |
-
<show_in_website>1</show_in_website>
|
623 |
-
<show_in_store>1</show_in_store>
|
624 |
-
<comment><![CDATA[Select which product to use for international shipments]]></comment>
|
625 |
-
</product>
|
626 |
-
|
627 |
-
<subheader_rates translate="label">
|
628 |
-
<label>Rates</label>
|
629 |
-
<frontend_type>text</frontend_type>
|
630 |
-
<frontend_model>bpost_shm/adminhtml_system_config_form_field_subheader</frontend_model>
|
631 |
-
<sort_order>40</sort_order>
|
632 |
-
<show_in_default>1</show_in_default>
|
633 |
-
<show_in_website>1</show_in_website>
|
634 |
-
<show_in_store>1</show_in_store>
|
635 |
-
</subheader_rates>
|
636 |
-
|
637 |
-
<free_shipping translate="label,comment">
|
638 |
-
<label>Free shipping</label>
|
639 |
-
<frontend_type>select</frontend_type>
|
640 |
-
<source_model>adminhtml/system_config_source_yesno</source_model>
|
641 |
-
<sort_order>50</sort_order>
|
642 |
-
<show_in_default>1</show_in_default>
|
643 |
-
<show_in_website>1</show_in_website>
|
644 |
-
<show_in_store>1</show_in_store>
|
645 |
-
<comment><![CDATA[Allow free shipping]]></comment>
|
646 |
-
</free_shipping>
|
647 |
-
|
648 |
-
<free_shipping_from translate="label,comment">
|
649 |
-
<label>.. as of</label>
|
650 |
-
<frontend_type>text</frontend_type>
|
651 |
-
<sort_order>60</sort_order>
|
652 |
-
<depends>
|
653 |
-
<free_shipping>1</free_shipping>
|
654 |
-
</depends>
|
655 |
-
<show_in_default>1</show_in_default>
|
656 |
-
<show_in_website>1</show_in_website>
|
657 |
-
<show_in_store>1</show_in_store>
|
658 |
-
<comment><![CDATA[Free shipping will be applied as from a minimum amount]]></comment>
|
659 |
-
</free_shipping_from>
|
660 |
-
|
661 |
-
<rate_type translate="label,comment,tooltip">
|
662 |
-
<label>Rate type</label>
|
663 |
-
<frontend_type>select</frontend_type>
|
664 |
-
<source_model>bpost_shm/system_config_source_ratetypes</source_model>
|
665 |
-
<sort_order>70</sort_order>
|
666 |
-
<show_in_default>1</show_in_default>
|
667 |
-
<show_in_website>1</show_in_website>
|
668 |
-
<show_in_store>1</show_in_store>
|
669 |
-
<comment><![CDATA[Choose your rate type (Flat rate or Table rate)]]></comment>
|
670 |
-
<tooltip>Importing and exporting table rates only possible on website scope. View the documentation for more information.</tooltip>
|
671 |
-
</rate_type>
|
672 |
-
|
673 |
-
<flat_rate_price translate="label,comment">
|
674 |
-
<label>Flat rate price</label>
|
675 |
-
<frontend_type>text</frontend_type>
|
676 |
-
<sort_order>80</sort_order>
|
677 |
-
<depends>
|
678 |
-
<rate_type>0</rate_type>
|
679 |
-
</depends>
|
680 |
-
<show_in_default>1</show_in_default>
|
681 |
-
<show_in_website>1</show_in_website>
|
682 |
-
<show_in_store>1</show_in_store>
|
683 |
-
<comment><![CDATA[Fixed fee for bpost Home delivery international shipments, e.g.: 4.95.]]></comment>
|
684 |
-
</flat_rate_price>
|
685 |
-
|
686 |
-
<condition_name translate="label">
|
687 |
-
<label>Table rates condition</label>
|
688 |
-
<frontend_type>select</frontend_type>
|
689 |
-
<source_model>adminhtml/system_config_source_shipping_tablerate</source_model>
|
690 |
-
<sort_order>90</sort_order>
|
691 |
-
<depends>
|
692 |
-
<rate_type>1</rate_type>
|
693 |
-
</depends>
|
694 |
-
<show_in_default>1</show_in_default>
|
695 |
-
<show_in_website>1</show_in_website>
|
696 |
-
<show_in_store>0</show_in_store>
|
697 |
-
</condition_name>
|
698 |
-
|
699 |
-
<export translate="label,comment">
|
700 |
-
<label>Export table rates file</label>
|
701 |
-
<frontend_type>button</frontend_type>
|
702 |
-
<frontend_model>bpost_shm/adminhtml_system_config_form_tablerates_export_international</frontend_model>
|
703 |
-
<sort_order>100</sort_order>
|
704 |
-
<depends>
|
705 |
-
<rate_type>1</rate_type>
|
706 |
-
</depends>
|
707 |
-
<show_in_default>0</show_in_default>
|
708 |
-
<show_in_website>1</show_in_website>
|
709 |
-
<show_in_store>0</show_in_store>
|
710 |
-
<comment><![CDATA[Export your table rates configuration here.]]></comment>
|
711 |
-
</export>
|
712 |
-
|
713 |
-
<import_international translate="label,comment">
|
714 |
-
<label>Import table rates file</label>
|
715 |
-
<frontend_type>import</frontend_type>
|
716 |
-
<sort_order>110</sort_order>
|
717 |
-
<backend_model>bpost_shm/adminhtml_system_config_backend_shipping_tablerates_international</backend_model>
|
718 |
-
<depends>
|
719 |
-
<rate_type>1</rate_type>
|
720 |
-
</depends>
|
721 |
-
<show_in_default>0</show_in_default>
|
722 |
-
<show_in_website>1</show_in_website>
|
723 |
-
<show_in_store>0</show_in_store>
|
724 |
-
<comment><![CDATA[Upload your table rates configuration here. Refer to the manual for more information.]]></comment>
|
725 |
-
</import_international>
|
726 |
-
|
727 |
-
<subheader_options translate="label">
|
728 |
-
<label>Options</label>
|
729 |
-
<frontend_type>text</frontend_type>
|
730 |
-
<frontend_model>bpost_shm/adminhtml_system_config_form_field_subheader</frontend_model>
|
731 |
-
<sort_order>120</sort_order>
|
732 |
-
<show_in_default>1</show_in_default>
|
733 |
-
<show_in_website>1</show_in_website>
|
734 |
-
<show_in_store>1</show_in_store>
|
735 |
-
</subheader_options>
|
736 |
-
|
737 |
-
<import_countries translate="label,comment">
|
738 |
-
<label>Import countries</label>
|
739 |
-
<frontend_type>button</frontend_type>
|
740 |
-
<frontend_model>bpost_shm/adminhtml_system_config_form_api_import_countries</frontend_model>
|
741 |
-
<sort_order>125</sort_order>
|
742 |
-
<show_in_default>1</show_in_default>
|
743 |
-
<show_in_website>1</show_in_website>
|
744 |
-
<show_in_store>1</show_in_store>
|
745 |
-
<comment><![CDATA[Import your bpost configured countries here.]]></comment>
|
746 |
-
</import_countries>
|
747 |
-
|
748 |
-
<specificcountry translate="label,comment">
|
749 |
-
<label>Allowed countries</label>
|
750 |
-
<frontend_type>multiselect</frontend_type>
|
751 |
-
<sort_order>125</sort_order>
|
752 |
-
<source_model>bpost_shm/system_config_source_country</source_model>
|
753 |
-
<show_in_default>1</show_in_default>
|
754 |
-
<show_in_website>1</show_in_website>
|
755 |
-
<show_in_store>0</show_in_store>
|
756 |
-
<can_be_empty>0</can_be_empty>
|
757 |
-
<comment><![CDATA[Select one or more countries where bpost Home delivery international should be available for. Make sure your bpost shipping manager is configured properly. Otherwise no countries will be shown in this list after saving the 'Shipping Settings' configuration.]]></comment>
|
758 |
-
</specificcountry>
|
759 |
-
|
760 |
-
<insurance translate="label,comment">
|
761 |
-
<label>International insurance</label>
|
762 |
-
<frontend_type>select</frontend_type>
|
763 |
-
<source_model>adminhtml/system_config_source_yesno</source_model>
|
764 |
-
<sort_order>130</sort_order>
|
765 |
-
<show_in_default>1</show_in_default>
|
766 |
-
<show_in_website>1</show_in_website>
|
767 |
-
<show_in_store>1</show_in_store>
|
768 |
-
<comment><![CDATA[Insurance to insure your goods to a maximum of 500,00 euro.]]></comment>
|
769 |
-
</insurance>
|
770 |
-
|
771 |
-
<insurance_from translate="label">
|
772 |
-
<label>.. as from</label>
|
773 |
-
<frontend_type>text</frontend_type>
|
774 |
-
<sort_order>140</sort_order>
|
775 |
-
<depends>
|
776 |
-
<insurance>1</insurance>
|
777 |
-
</depends>
|
778 |
-
<show_in_default>1</show_in_default>
|
779 |
-
<show_in_website>1</show_in_website>
|
780 |
-
<show_in_store>1</show_in_store>
|
781 |
-
</insurance_from>
|
782 |
-
</fields>
|
783 |
-
</bpost_international>
|
784 |
-
<bpost_pickuppoint translate="label" module="bpost_shm">
|
785 |
-
<label>bpost Pick-up point</label>
|
786 |
-
<frontend_type>text</frontend_type>
|
787 |
-
<sort_order>70</sort_order>
|
788 |
-
<show_in_default>1</show_in_default>
|
789 |
-
<show_in_website>1</show_in_website>
|
790 |
-
<show_in_store>1</show_in_store>
|
791 |
-
<fields>
|
792 |
-
<logo translate="label">
|
793 |
-
<label>Logo</label>
|
794 |
-
<frontend_type>text</frontend_type>
|
795 |
-
<frontend_model>bpost_shm/adminhtml_system_config_form_field_logo</frontend_model>
|
796 |
-
<sort_order>0</sort_order>
|
797 |
-
<show_in_default>1</show_in_default>
|
798 |
-
<show_in_website>1</show_in_website>
|
799 |
-
<show_in_store>1</show_in_store>
|
800 |
-
</logo>
|
801 |
-
|
802 |
-
<subheader_general translate="label">
|
803 |
-
<label>General</label>
|
804 |
-
<frontend_type>text</frontend_type>
|
805 |
-
<frontend_model>bpost_shm/adminhtml_system_config_form_field_subheader</frontend_model>
|
806 |
-
<sort_order>5</sort_order>
|
807 |
-
<show_in_default>1</show_in_default>
|
808 |
-
<show_in_website>1</show_in_website>
|
809 |
-
<show_in_store>1</show_in_store>
|
810 |
-
</subheader_general>
|
811 |
-
|
812 |
-
<active translate="label,comment">
|
813 |
-
<label>Enabled</label>
|
814 |
-
<frontend_type>select</frontend_type>
|
815 |
-
<source_model>adminhtml/system_config_source_yesno</source_model>
|
816 |
-
<sort_order>10</sort_order>
|
817 |
-
<show_in_default>1</show_in_default>
|
818 |
-
<show_in_website>1</show_in_website>
|
819 |
-
<show_in_store>1</show_in_store>
|
820 |
-
<comment><![CDATA[Get your parcel delivered in one of our 1.250 pick-up points.]]></comment>
|
821 |
-
</active>
|
822 |
-
|
823 |
-
<subheader_rates translate="label">
|
824 |
-
<label>Rates</label>
|
825 |
-
<frontend_type>text</frontend_type>
|
826 |
-
<frontend_model>bpost_shm/adminhtml_system_config_form_field_subheader</frontend_model>
|
827 |
-
<sort_order>15</sort_order>
|
828 |
-
<show_in_default>1</show_in_default>
|
829 |
-
<show_in_website>1</show_in_website>
|
830 |
-
<show_in_store>1</show_in_store>
|
831 |
-
</subheader_rates>
|
832 |
-
|
833 |
-
<free_shipping translate="label,comment">
|
834 |
-
<label>Free shipping</label>
|
835 |
-
<frontend_type>select</frontend_type>
|
836 |
-
<source_model>adminhtml/system_config_source_yesno</source_model>
|
837 |
-
<sort_order>20</sort_order>
|
838 |
-
<show_in_default>1</show_in_default>
|
839 |
-
<show_in_website>1</show_in_website>
|
840 |
-
<show_in_store>1</show_in_store>
|
841 |
-
<comment><![CDATA[Allow free shipping]]></comment>
|
842 |
-
</free_shipping>
|
843 |
-
|
844 |
-
<free_shipping_from translate="label,comment">
|
845 |
-
<label>.. as of</label>
|
846 |
-
<frontend_type>text</frontend_type>
|
847 |
-
<sort_order>30</sort_order>
|
848 |
-
<depends>
|
849 |
-
<free_shipping>1</free_shipping>
|
850 |
-
</depends>
|
851 |
-
<show_in_default>1</show_in_default>
|
852 |
-
<show_in_website>1</show_in_website>
|
853 |
-
<show_in_store>1</show_in_store>
|
854 |
-
<comment><![CDATA[Free shipping will be applied as from a minimum amount]]></comment>
|
855 |
-
</free_shipping_from>
|
856 |
-
|
857 |
-
<rate_type translate="label,comment,tooltip">
|
858 |
-
<label>Rate type</label>
|
859 |
-
<frontend_type>select</frontend_type>
|
860 |
-
<source_model>bpost_shm/system_config_source_ratetypes</source_model>
|
861 |
-
<sort_order>40</sort_order>
|
862 |
-
<show_in_default>1</show_in_default>
|
863 |
-
<show_in_website>1</show_in_website>
|
864 |
-
<show_in_store>1</show_in_store>
|
865 |
-
<comment><![CDATA[Choose your rate type (Flat rate or Table rate)]]></comment>
|
866 |
-
<tooltip>Importing and exporting table rates only possible on website scope. View the documentation for more information.</tooltip>
|
867 |
-
</rate_type>
|
868 |
-
|
869 |
-
<flat_rate_price translate="label,comment">
|
870 |
-
<label>Flat rate price</label>
|
871 |
-
<frontend_type>text</frontend_type>
|
872 |
-
<sort_order>50</sort_order>
|
873 |
-
<depends>
|
874 |
-
<rate_type>0</rate_type>
|
875 |
-
</depends>
|
876 |
-
<show_in_default>1</show_in_default>
|
877 |
-
<show_in_website>1</show_in_website>
|
878 |
-
<show_in_store>1</show_in_store>
|
879 |
-
<comment><![CDATA[Fixed fee for bpost Pick-up point shipments, e.g.: 4.95.]]></comment>
|
880 |
-
</flat_rate_price>
|
881 |
-
|
882 |
-
<condition_name translate="label">
|
883 |
-
<label>Table rates condition</label>
|
884 |
-
<frontend_type>select</frontend_type>
|
885 |
-
<source_model>adminhtml/system_config_source_shipping_tablerate</source_model>
|
886 |
-
<sort_order>60</sort_order>
|
887 |
-
<depends>
|
888 |
-
<rate_type>1</rate_type>
|
889 |
-
</depends>
|
890 |
-
<show_in_default>1</show_in_default>
|
891 |
-
<show_in_website>1</show_in_website>
|
892 |
-
<show_in_store>0</show_in_store>
|
893 |
-
</condition_name>
|
894 |
-
|
895 |
-
<export translate="label,comment">
|
896 |
-
<label>Export table rates file</label>
|
897 |
-
<frontend_type>button</frontend_type>
|
898 |
-
<frontend_model>bpost_shm/adminhtml_system_config_form_tablerates_export_pickuppoint</frontend_model>
|
899 |
-
<sort_order>70</sort_order>
|
900 |
-
<depends>
|
901 |
-
<rate_type>1</rate_type>
|
902 |
-
</depends>
|
903 |
-
<show_in_default>0</show_in_default>
|
904 |
-
<show_in_website>1</show_in_website>
|
905 |
-
<show_in_store>0</show_in_store>
|
906 |
-
<comment><![CDATA[Export your table rates configuration here.]]></comment>
|
907 |
-
</export>
|
908 |
-
|
909 |
-
<import_pickuppoint translate="label,comment">
|
910 |
-
<label>Import table rates file</label>
|
911 |
-
<frontend_type>import</frontend_type>
|
912 |
-
<sort_order>80</sort_order>
|
913 |
-
<backend_model>bpost_shm/adminhtml_system_config_backend_shipping_tablerates_pickuppoint</backend_model>
|
914 |
-
<depends>
|
915 |
-
<rate_type>1</rate_type>
|
916 |
-
</depends>
|
917 |
-
<show_in_default>0</show_in_default>
|
918 |
-
<show_in_website>1</show_in_website>
|
919 |
-
<show_in_store>0</show_in_store>
|
920 |
-
<comment><![CDATA[Upload your table rates configuration here. Refer to the manual for more information.]]></comment>
|
921 |
-
</import_pickuppoint>
|
922 |
-
|
923 |
-
<subheader_options translate="label">
|
924 |
-
<label>Options</label>
|
925 |
-
<frontend_type>text</frontend_type>
|
926 |
-
<frontend_model>bpost_shm/adminhtml_system_config_form_field_subheader</frontend_model>
|
927 |
-
<sort_order>85</sort_order>
|
928 |
-
<show_in_default>1</show_in_default>
|
929 |
-
<show_in_website>1</show_in_website>
|
930 |
-
<show_in_store>1</show_in_store>
|
931 |
-
</subheader_options>
|
932 |
-
|
933 |
-
<insurance translate="label,comment">
|
934 |
-
<label>Insurance</label>
|
935 |
-
<frontend_type>select</frontend_type>
|
936 |
-
<source_model>adminhtml/system_config_source_yesno</source_model>
|
937 |
-
<sort_order>90</sort_order>
|
938 |
-
<show_in_default>1</show_in_default>
|
939 |
-
<show_in_website>1</show_in_website>
|
940 |
-
<show_in_store>1</show_in_store>
|
941 |
-
<comment><![CDATA[Insurance to insure your goods to a maximum of 500,00 euro.]]></comment>
|
942 |
-
</insurance>
|
943 |
-
|
944 |
-
<insurance_from translate="label">
|
945 |
-
<label>.. as from</label>
|
946 |
-
<frontend_type>text</frontend_type>
|
947 |
-
<sort_order>100</sort_order>
|
948 |
-
<depends>
|
949 |
-
<insurance>1</insurance>
|
950 |
-
</depends>
|
951 |
-
<show_in_default>1</show_in_default>
|
952 |
-
<show_in_website>1</show_in_website>
|
953 |
-
<show_in_store>1</show_in_store>
|
954 |
-
</insurance_from>
|
955 |
-
|
956 |
-
<saturday_delivery translate="label,comment">
|
957 |
-
<label>Saturday delivery</label>
|
958 |
-
<frontend_type>select</frontend_type>
|
959 |
-
<source_model>adminhtml/system_config_source_yesno</source_model>
|
960 |
-
<sort_order>110</sort_order>
|
961 |
-
<show_in_default>1</show_in_default>
|
962 |
-
<show_in_website>1</show_in_website>
|
963 |
-
<show_in_store>1</show_in_store>
|
964 |
-
<comment><![CDATA[The parcel is delivered on Saturday if it is timely dropped in the bpost network.]]></comment>
|
965 |
-
</saturday_delivery>
|
966 |
-
|
967 |
-
<saturday_delivery_from translate="label">
|
968 |
-
<label>.. as from</label>
|
969 |
-
<frontend_type>text</frontend_type>
|
970 |
-
<sort_order>120</sort_order>
|
971 |
-
<depends>
|
972 |
-
<saturday_delivery>1</saturday_delivery>
|
973 |
-
</depends>
|
974 |
-
<show_in_default>1</show_in_default>
|
975 |
-
<show_in_website>1</show_in_website>
|
976 |
-
<show_in_store>1</show_in_store>
|
977 |
-
</saturday_delivery_from>
|
978 |
-
</fields>
|
979 |
-
</bpost_pickuppoint>
|
980 |
-
<bpost_parcellocker translate="label" module="bpost_shm">
|
981 |
-
<label>bpost Parcel locker</label>
|
982 |
-
<frontend_type>text</frontend_type>
|
983 |
-
<sort_order>80</sort_order>
|
984 |
-
<show_in_default>1</show_in_default>
|
985 |
-
<show_in_website>1</show_in_website>
|
986 |
-
<show_in_store>1</show_in_store>
|
987 |
-
<fields>
|
988 |
-
<logo translate="label">
|
989 |
-
<label>Logoo</label>
|
990 |
-
<frontend_type>text</frontend_type>
|
991 |
-
<frontend_model>bpost_shm/adminhtml_system_config_form_field_logo</frontend_model>
|
992 |
-
<sort_order>0</sort_order>
|
993 |
-
<show_in_default>1</show_in_default>
|
994 |
-
<show_in_website>1</show_in_website>
|
995 |
-
<show_in_store>1</show_in_store>
|
996 |
-
</logo>
|
997 |
-
|
998 |
-
<subheader_general translate="label">
|
999 |
-
<label>General</label>
|
1000 |
-
<frontend_type>text</frontend_type>
|
1001 |
-
<frontend_model>bpost_shm/adminhtml_system_config_form_field_subheader</frontend_model>
|
1002 |
-
<sort_order>5</sort_order>
|
1003 |
-
<show_in_default>1</show_in_default>
|
1004 |
-
<show_in_website>1</show_in_website>
|
1005 |
-
<show_in_store>1</show_in_store>
|
1006 |
-
</subheader_general>
|
1007 |
-
|
1008 |
-
<active translate="label,comment">
|
1009 |
-
<label>Enabled</label>
|
1010 |
-
<frontend_type>select</frontend_type>
|
1011 |
-
<source_model>adminhtml/system_config_source_yesno</source_model>
|
1012 |
-
<sort_order>10</sort_order>
|
1013 |
-
<show_in_default>1</show_in_default>
|
1014 |
-
<show_in_website>1</show_in_website>
|
1015 |
-
<show_in_store>1</show_in_store>
|
1016 |
-
<comment><![CDATA[Have your parcels delivered in one of our parcel lockers. Very convenient, centrally located, always open, 24/7!]]></comment>
|
1017 |
-
</active>
|
1018 |
-
|
1019 |
-
<subheader_rates translate="label">
|
1020 |
-
<label>Rates</label>
|
1021 |
-
<frontend_type>text</frontend_type>
|
1022 |
-
<frontend_model>bpost_shm/adminhtml_system_config_form_field_subheader</frontend_model>
|
1023 |
-
<sort_order>15</sort_order>
|
1024 |
-
<show_in_default>1</show_in_default>
|
1025 |
-
<show_in_website>1</show_in_website>
|
1026 |
-
<show_in_store>1</show_in_store>
|
1027 |
-
</subheader_rates>
|
1028 |
-
|
1029 |
-
<free_shipping translate="label,comment">
|
1030 |
-
<label>Free shipping</label>
|
1031 |
-
<frontend_type>select</frontend_type>
|
1032 |
-
<source_model>adminhtml/system_config_source_yesno</source_model>
|
1033 |
-
<sort_order>20</sort_order>
|
1034 |
-
<show_in_default>1</show_in_default>
|
1035 |
-
<show_in_website>1</show_in_website>
|
1036 |
-
<show_in_store>1</show_in_store>
|
1037 |
-
<comment><![CDATA[Allow free shipping.]]></comment>
|
1038 |
-
</free_shipping>
|
1039 |
-
|
1040 |
-
<free_shipping_from translate="label,comment">
|
1041 |
-
<label>.. as of</label>
|
1042 |
-
<frontend_type>text</frontend_type>
|
1043 |
-
<sort_order>30</sort_order>
|
1044 |
-
<depends>
|
1045 |
-
<free_shipping>1</free_shipping>
|
1046 |
-
</depends>
|
1047 |
-
<show_in_default>1</show_in_default>
|
1048 |
-
<show_in_website>1</show_in_website>
|
1049 |
-
<show_in_store>1</show_in_store>
|
1050 |
-
<comment><![CDATA[Free shipping will be applied as from a minimum amount]]></comment>
|
1051 |
-
</free_shipping_from>
|
1052 |
-
|
1053 |
-
<rate_type translate="label,comment,tooltip">
|
1054 |
-
<label>Rate type</label>
|
1055 |
-
<frontend_type>select</frontend_type>
|
1056 |
-
<source_model>bpost_shm/system_config_source_ratetypes</source_model>
|
1057 |
-
<sort_order>40</sort_order>
|
1058 |
-
<show_in_default>1</show_in_default>
|
1059 |
-
<show_in_website>1</show_in_website>
|
1060 |
-
<show_in_store>1</show_in_store>
|
1061 |
-
<comment><![CDATA[Choose your rate type (Flat rate or Table rate)]]></comment>
|
1062 |
-
<tooltip>Importing and exporting table rates only possible on website scope. View the documentation for more information.</tooltip>
|
1063 |
-
</rate_type>
|
1064 |
-
|
1065 |
-
<flat_rate_price translate="label">
|
1066 |
-
<label>Flat rate price</label>
|
1067 |
-
<frontend_type>text</frontend_type>
|
1068 |
-
<sort_order>50</sort_order>
|
1069 |
-
<depends>
|
1070 |
-
<rate_type>0</rate_type>
|
1071 |
-
</depends>
|
1072 |
-
<show_in_default>1</show_in_default>
|
1073 |
-
<show_in_website>1</show_in_website>
|
1074 |
-
<show_in_store>1</show_in_store>
|
1075 |
-
<comment><![CDATA[Fixed fee for bpost Pick-up point shipments, e.g.: 4.95.]]></comment>
|
1076 |
-
</flat_rate_price>
|
1077 |
-
|
1078 |
-
<condition_name translate="label">
|
1079 |
-
<label>Table rates condition</label>
|
1080 |
-
<frontend_type>select</frontend_type>
|
1081 |
-
<source_model>adminhtml/system_config_source_shipping_tablerate</source_model>
|
1082 |
-
<sort_order>60</sort_order>
|
1083 |
-
<depends>
|
1084 |
-
<rate_type>1</rate_type>
|
1085 |
-
</depends>
|
1086 |
-
<show_in_default>1</show_in_default>
|
1087 |
-
<show_in_website>1</show_in_website>
|
1088 |
-
<show_in_store>0</show_in_store>
|
1089 |
-
</condition_name>
|
1090 |
-
|
1091 |
-
<export translate="label,comment">
|
1092 |
-
<label>Export table rates file</label>
|
1093 |
-
<frontend_type>button</frontend_type>
|
1094 |
-
<frontend_model>bpost_shm/adminhtml_system_config_form_tablerates_export_parcellocker</frontend_model>
|
1095 |
-
<sort_order>70</sort_order>
|
1096 |
-
<depends>
|
1097 |
-
<rate_type>1</rate_type>
|
1098 |
-
</depends>
|
1099 |
-
<show_in_default>0</show_in_default>
|
1100 |
-
<show_in_website>1</show_in_website>
|
1101 |
-
<show_in_store>0</show_in_store>
|
1102 |
-
<comment><![CDATA[Export your table rates configuration here.]]></comment>
|
1103 |
-
</export>
|
1104 |
-
|
1105 |
-
<import_parcellocker translate="label,comment">
|
1106 |
-
<label>Import table rates file</label>
|
1107 |
-
<frontend_type>import</frontend_type>
|
1108 |
-
<sort_order>80</sort_order>
|
1109 |
-
<backend_model>bpost_shm/adminhtml_system_config_backend_shipping_tablerates_parcellocker</backend_model>
|
1110 |
-
<depends>
|
1111 |
-
<rate_type>1</rate_type>
|
1112 |
-
</depends>
|
1113 |
-
<show_in_default>0</show_in_default>
|
1114 |
-
<show_in_website>1</show_in_website>
|
1115 |
-
<show_in_store>0</show_in_store>
|
1116 |
-
<comment><![CDATA[Upload your table rates configuration here. Refer to the manual for more information.]]></comment>
|
1117 |
-
</import_parcellocker>
|
1118 |
-
|
1119 |
-
<subheader_options translate="label">
|
1120 |
-
<label>Options</label>
|
1121 |
-
<frontend_type>text</frontend_type>
|
1122 |
-
<frontend_model>bpost_shm/adminhtml_system_config_form_field_subheader</frontend_model>
|
1123 |
-
<sort_order>85</sort_order>
|
1124 |
-
<show_in_default>1</show_in_default>
|
1125 |
-
<show_in_website>1</show_in_website>
|
1126 |
-
<show_in_store>1</show_in_store>
|
1127 |
-
</subheader_options>
|
1128 |
-
|
1129 |
-
<insurance translate="label,comment">
|
1130 |
-
<label>Insurance</label>
|
1131 |
-
<frontend_type>select</frontend_type>
|
1132 |
-
<source_model>adminhtml/system_config_source_yesno</source_model>
|
1133 |
-
<sort_order>90</sort_order>
|
1134 |
-
<show_in_default>1</show_in_default>
|
1135 |
-
<show_in_website>1</show_in_website>
|
1136 |
-
<show_in_store>1</show_in_store>
|
1137 |
-
<comment><![CDATA[Insurance to insure your goods to a maximum of 500,00 euro.]]></comment>
|
1138 |
-
</insurance>
|
1139 |
-
|
1140 |
-
<insurance_from translate="label">
|
1141 |
-
<label>.. as from</label>
|
1142 |
-
<frontend_type>text</frontend_type>
|
1143 |
-
<sort_order>100</sort_order>
|
1144 |
-
<depends>
|
1145 |
-
<insurance>1</insurance>
|
1146 |
-
</depends>
|
1147 |
-
<show_in_default>1</show_in_default>
|
1148 |
-
<show_in_website>1</show_in_website>
|
1149 |
-
<show_in_store>1</show_in_store>
|
1150 |
-
</insurance_from>
|
1151 |
-
|
1152 |
-
<saturday_delivery translate="label,comment">
|
1153 |
-
<label>Saturday delivery</label>
|
1154 |
-
<frontend_type>select</frontend_type>
|
1155 |
-
<source_model>adminhtml/system_config_source_yesno</source_model>
|
1156 |
-
<sort_order>110</sort_order>
|
1157 |
-
<show_in_default>1</show_in_default>
|
1158 |
-
<show_in_website>1</show_in_website>
|
1159 |
-
<show_in_store>1</show_in_store>
|
1160 |
-
<comment><![CDATA[The parcel is delivered on Saturday if it is timely dropped in the bpost network.]]></comment>
|
1161 |
-
</saturday_delivery>
|
1162 |
-
|
1163 |
-
<saturday_delivery_from translate="label">
|
1164 |
-
<label>.. as from</label>
|
1165 |
-
<frontend_type>text</frontend_type>
|
1166 |
-
<sort_order>120</sort_order>
|
1167 |
-
<depends>
|
1168 |
-
<saturday_delivery>1</saturday_delivery>
|
1169 |
-
</depends>
|
1170 |
-
<show_in_default>1</show_in_default>
|
1171 |
-
<show_in_website>1</show_in_website>
|
1172 |
-
<show_in_store>1</show_in_store>
|
1173 |
-
</saturday_delivery_from>
|
1174 |
-
</fields>
|
1175 |
-
</bpost_parcellocker>
|
1176 |
-
<bpost_clickcollect translate="label" module="bpost_shm">
|
1177 |
-
<label><![CDATA[bpost Click & Collect]]></label>
|
1178 |
-
<frontend_type>text</frontend_type>
|
1179 |
-
<sort_order>90</sort_order>
|
1180 |
-
<show_in_default>1</show_in_default>
|
1181 |
-
<show_in_website>1</show_in_website>
|
1182 |
-
<show_in_store>1</show_in_store>
|
1183 |
-
<fields>
|
1184 |
-
<logo translate="label">
|
1185 |
-
<label>Logo</label>
|
1186 |
-
<frontend_type>text</frontend_type>
|
1187 |
-
<frontend_model>bpost_shm/adminhtml_system_config_form_field_logo</frontend_model>
|
1188 |
-
<sort_order>0</sort_order>
|
1189 |
-
<show_in_default>1</show_in_default>
|
1190 |
-
<show_in_website>1</show_in_website>
|
1191 |
-
<show_in_store>1</show_in_store>
|
1192 |
-
</logo>
|
1193 |
-
|
1194 |
-
<clickcollect_info>
|
1195 |
-
<label>clickcollectinfo</label>
|
1196 |
-
<frontend_type>text</frontend_type>
|
1197 |
-
<frontend_model>bpost_shm/adminhtml_system_config_form_field_clickcollect</frontend_model>
|
1198 |
-
<sort_order>1</sort_order>
|
1199 |
-
<show_in_default>1</show_in_default>
|
1200 |
-
<show_in_website>1</show_in_website>
|
1201 |
-
<show_in_store>1</show_in_store>
|
1202 |
-
<depends>
|
1203 |
-
<activated>0</activated>
|
1204 |
-
</depends>
|
1205 |
-
</clickcollect_info>
|
1206 |
-
|
1207 |
-
<clickcollect_cache_info>
|
1208 |
-
<label>clickcollectcacheinfo</label>
|
1209 |
-
<frontend_type>text</frontend_type>
|
1210 |
-
<frontend_model>bpost_shm/adminhtml_system_config_form_field_cacheinfo</frontend_model>
|
1211 |
-
<sort_order>1</sort_order>
|
1212 |
-
<show_in_default>1</show_in_default>
|
1213 |
-
<show_in_website>1</show_in_website>
|
1214 |
-
<show_in_store>1</show_in_store>
|
1215 |
-
<depends>
|
1216 |
-
<activated>1</activated>
|
1217 |
-
</depends>
|
1218 |
-
</clickcollect_cache_info>
|
1219 |
-
|
1220 |
-
<subheader_general translate="label">
|
1221 |
-
<label>General</label>
|
1222 |
-
<frontend_type>text</frontend_type>
|
1223 |
-
<frontend_model>bpost_shm/adminhtml_system_config_form_field_subheader</frontend_model>
|
1224 |
-
<sort_order>5</sort_order>
|
1225 |
-
<show_in_default>1</show_in_default>
|
1226 |
-
<show_in_website>1</show_in_website>
|
1227 |
-
<show_in_store>1</show_in_store>
|
1228 |
-
<depends>
|
1229 |
-
<activated>1</activated>
|
1230 |
-
</depends>
|
1231 |
-
</subheader_general>
|
1232 |
-
|
1233 |
-
<active translate="label,comment">
|
1234 |
-
<label>Enabled</label>
|
1235 |
-
<frontend_type>select</frontend_type>
|
1236 |
-
<source_model>adminhtml/system_config_source_yesno</source_model>
|
1237 |
-
<sort_order>10</sort_order>
|
1238 |
-
<show_in_default>1</show_in_default>
|
1239 |
-
<show_in_website>1</show_in_website>
|
1240 |
-
<show_in_store>1</show_in_store>
|
1241 |
-
<comment><![CDATA[]]></comment>
|
1242 |
-
<depends>
|
1243 |
-
<activated>1</activated>
|
1244 |
-
</depends>
|
1245 |
-
</active>
|
1246 |
-
|
1247 |
-
<marker translate="label,comment">
|
1248 |
-
<label>Logo</label>
|
1249 |
-
<frontend_type>image</frontend_type>
|
1250 |
-
<backend_model>adminhtml/system_config_backend_image</backend_model>
|
1251 |
-
<upload_dir config="system/filesystem/media" scope_info="1">bpost</upload_dir>
|
1252 |
-
<base_url type="media" scope_info="1">bpost</base_url>
|
1253 |
-
<sort_order>11</sort_order>
|
1254 |
-
<show_in_default>1</show_in_default>
|
1255 |
-
<show_in_website>1</show_in_website>
|
1256 |
-
<show_in_store>1</show_in_store>
|
1257 |
-
<depends>
|
1258 |
-
<activated>1</activated>
|
1259 |
-
</depends>
|
1260 |
-
<comment><![CDATA[Upload a custom map marker (18x18 px)]]></comment>
|
1261 |
-
</marker>
|
1262 |
-
|
1263 |
-
<subheader_rates translate="label">
|
1264 |
-
<label>Rates</label>
|
1265 |
-
<frontend_type>text</frontend_type>
|
1266 |
-
<frontend_model>bpost_shm/adminhtml_system_config_form_field_subheader</frontend_model>
|
1267 |
-
<sort_order>15</sort_order>
|
1268 |
-
<show_in_default>1</show_in_default>
|
1269 |
-
<show_in_website>1</show_in_website>
|
1270 |
-
<show_in_store>1</show_in_store>
|
1271 |
-
<depends>
|
1272 |
-
<activated>1</activated>
|
1273 |
-
</depends>
|
1274 |
-
</subheader_rates>
|
1275 |
-
|
1276 |
-
<free_shipping translate="label,comment">
|
1277 |
-
<label>Free shipping</label>
|
1278 |
-
<frontend_type>select</frontend_type>
|
1279 |
-
<source_model>adminhtml/system_config_source_yesno</source_model>
|
1280 |
-
<sort_order>20</sort_order>
|
1281 |
-
<show_in_default>1</show_in_default>
|
1282 |
-
<show_in_website>1</show_in_website>
|
1283 |
-
<show_in_store>1</show_in_store>
|
1284 |
-
<depends>
|
1285 |
-
<activated>1</activated>
|
1286 |
-
</depends>
|
1287 |
-
<comment><![CDATA[Allow free shipping]]></comment>
|
1288 |
-
</free_shipping>
|
1289 |
-
|
1290 |
-
<free_shipping_from translate="label,comment">
|
1291 |
-
<label>.. as of</label>
|
1292 |
-
<frontend_type>text</frontend_type>
|
1293 |
-
<sort_order>30</sort_order>
|
1294 |
-
<depends>
|
1295 |
-
<free_shipping>1</free_shipping>
|
1296 |
-
<activated>1</activated>
|
1297 |
-
</depends>
|
1298 |
-
<show_in_default>1</show_in_default>
|
1299 |
-
<show_in_website>1</show_in_website>
|
1300 |
-
<show_in_store>1</show_in_store>
|
1301 |
-
<comment><![CDATA[Free shipping will be applied as from a minimum amount]]></comment>
|
1302 |
-
</free_shipping_from>
|
1303 |
-
|
1304 |
-
<rate_type translate="label,comment,tooltip">
|
1305 |
-
<label>Rate type</label>
|
1306 |
-
<frontend_type>select</frontend_type>
|
1307 |
-
<source_model>bpost_shm/system_config_source_ratetypes</source_model>
|
1308 |
-
<sort_order>40</sort_order>
|
1309 |
-
<show_in_default>1</show_in_default>
|
1310 |
-
<show_in_website>1</show_in_website>
|
1311 |
-
<show_in_store>1</show_in_store>
|
1312 |
-
<depends>
|
1313 |
-
<activated>1</activated>
|
1314 |
-
</depends>
|
1315 |
-
<comment><![CDATA[Choose your rate type (Flat rate or Table rate)]]></comment>
|
1316 |
-
<tooltip>Importing and exporting table rates only possible on website scope. View the documentation for more information.</tooltip>
|
1317 |
-
</rate_type>
|
1318 |
-
|
1319 |
-
<flat_rate_price translate="label,comment">
|
1320 |
-
<label>Flat rate price</label>
|
1321 |
-
<frontend_type>text</frontend_type>
|
1322 |
-
<sort_order>50</sort_order>
|
1323 |
-
<depends>
|
1324 |
-
<rate_type>0</rate_type>
|
1325 |
-
<activated>1</activated>
|
1326 |
-
</depends>
|
1327 |
-
<show_in_default>1</show_in_default>
|
1328 |
-
<show_in_website>1</show_in_website>
|
1329 |
-
<show_in_store>1</show_in_store>
|
1330 |
-
<comment><![CDATA[Fixed fee for bpost Click & Collect shipments, e.g.: 4.95.]]></comment>
|
1331 |
-
</flat_rate_price>
|
1332 |
-
|
1333 |
-
<condition_name translate="label">
|
1334 |
-
<label>Table rates condition</label>
|
1335 |
-
<frontend_type>select</frontend_type>
|
1336 |
-
<source_model>adminhtml/system_config_source_shipping_tablerate</source_model>
|
1337 |
-
<sort_order>60</sort_order>
|
1338 |
-
<depends>
|
1339 |
-
<rate_type>1</rate_type>
|
1340 |
-
<activated>1</activated>
|
1341 |
-
</depends>
|
1342 |
-
<show_in_default>1</show_in_default>
|
1343 |
-
<show_in_website>1</show_in_website>
|
1344 |
-
<show_in_store>0</show_in_store>
|
1345 |
-
</condition_name>
|
1346 |
-
|
1347 |
-
<export translate="label,comment">
|
1348 |
-
<label>Export table rates file</label>
|
1349 |
-
<frontend_type>button</frontend_type>
|
1350 |
-
<frontend_model>bpost_shm/adminhtml_system_config_form_tablerates_export_clickcollect</frontend_model>
|
1351 |
-
<sort_order>70</sort_order>
|
1352 |
-
<depends>
|
1353 |
-
<rate_type>1</rate_type>
|
1354 |
-
<activated>1</activated>
|
1355 |
-
</depends>
|
1356 |
-
<show_in_default>0</show_in_default>
|
1357 |
-
<show_in_website>1</show_in_website>
|
1358 |
-
<show_in_store>0</show_in_store>
|
1359 |
-
<comment><![CDATA[Export your table rates configuration here.]]></comment>
|
1360 |
-
</export>
|
1361 |
-
|
1362 |
-
<import_clickcollect translate="label,comment">
|
1363 |
-
<label>Import table rates file</label>
|
1364 |
-
<frontend_type>import</frontend_type>
|
1365 |
-
<sort_order>80</sort_order>
|
1366 |
-
<backend_model>bpost_shm/adminhtml_system_config_backend_shipping_tablerates_clickcollect</backend_model>
|
1367 |
-
<depends>
|
1368 |
-
<rate_type>1</rate_type>
|
1369 |
-
<activated>1</activated>
|
1370 |
-
</depends>
|
1371 |
-
<show_in_default>0</show_in_default>
|
1372 |
-
<show_in_website>1</show_in_website>
|
1373 |
-
<show_in_store>0</show_in_store>
|
1374 |
-
<comment><![CDATA[Upload your table rates configuration here. Refer to the manual for more information.]]></comment>
|
1375 |
-
</import_clickcollect>
|
1376 |
-
|
1377 |
-
<subheader_options translate="label">
|
1378 |
-
<label>Options</label>
|
1379 |
-
<frontend_type>text</frontend_type>
|
1380 |
-
<frontend_model>bpost_shm/adminhtml_system_config_form_field_subheader</frontend_model>
|
1381 |
-
<sort_order>85</sort_order>
|
1382 |
-
<show_in_default>1</show_in_default>
|
1383 |
-
<show_in_website>1</show_in_website>
|
1384 |
-
<show_in_store>1</show_in_store>
|
1385 |
-
<depends>
|
1386 |
-
<activated>1</activated>
|
1387 |
-
</depends>
|
1388 |
-
</subheader_options>
|
1389 |
-
|
1390 |
-
<insurance translate="label,comment">
|
1391 |
-
<label>Insurance</label>
|
1392 |
-
<frontend_type>select</frontend_type>
|
1393 |
-
<source_model>adminhtml/system_config_source_yesno</source_model>
|
1394 |
-
<sort_order>90</sort_order>
|
1395 |
-
<show_in_default>1</show_in_default>
|
1396 |
-
<show_in_website>1</show_in_website>
|
1397 |
-
<show_in_store>1</show_in_store>
|
1398 |
-
<depends>
|
1399 |
-
<activated>1</activated>
|
1400 |
-
</depends>
|
1401 |
-
<comment><![CDATA[Insurance to insure your goods to a maximum of 500,00 euro.]]></comment>
|
1402 |
-
</insurance>
|
1403 |
-
|
1404 |
-
<insurance_from translate="label">
|
1405 |
-
<label>.. as from</label>
|
1406 |
-
<frontend_type>text</frontend_type>
|
1407 |
-
<sort_order>100</sort_order>
|
1408 |
-
<depends>
|
1409 |
-
<insurance>1</insurance>
|
1410 |
-
<activated>1</activated>
|
1411 |
-
</depends>
|
1412 |
-
<show_in_default>1</show_in_default>
|
1413 |
-
<show_in_website>1</show_in_website>
|
1414 |
-
<show_in_store>1</show_in_store>
|
1415 |
-
</insurance_from>
|
1416 |
-
|
1417 |
-
<saturday_delivery translate="label,comment">
|
1418 |
-
<label>Saturday delivery</label>
|
1419 |
-
<frontend_type>select</frontend_type>
|
1420 |
-
<source_model>adminhtml/system_config_source_yesno</source_model>
|
1421 |
-
<sort_order>110</sort_order>
|
1422 |
-
<show_in_default>1</show_in_default>
|
1423 |
-
<show_in_website>1</show_in_website>
|
1424 |
-
<show_in_store>1</show_in_store>
|
1425 |
-
<comment><![CDATA[The parcel is delivered on Saturday if it is timely dropped in the bpost network.]]></comment>
|
1426 |
-
<depends>
|
1427 |
-
<activated>1</activated>
|
1428 |
-
</depends>
|
1429 |
-
</saturday_delivery>
|
1430 |
-
|
1431 |
-
<saturday_delivery_from translate="label">
|
1432 |
-
<label>.. as from</label>
|
1433 |
-
<frontend_type>text</frontend_type>
|
1434 |
-
<sort_order>120</sort_order>
|
1435 |
-
<depends>
|
1436 |
-
<saturday_delivery>1</saturday_delivery>
|
1437 |
-
<activated>1</activated>
|
1438 |
-
</depends>
|
1439 |
-
<show_in_default>1</show_in_default>
|
1440 |
-
<show_in_website>1</show_in_website>
|
1441 |
-
<show_in_store>1</show_in_store>
|
1442 |
-
</saturday_delivery_from>
|
1443 |
-
</fields>
|
1444 |
-
</bpost_clickcollect>
|
1445 |
-
</groups>
|
1446 |
-
</carriers>
|
1447 |
-
</sections>
|
1448 |
</config>
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<config>
|
3 |
+
<sections>
|
4 |
+
<shipping>
|
5 |
+
<groups>
|
6 |
+
<bpost_shm translate="label" module="bpost_shm">
|
7 |
+
<label>bpost Shipping Manager</label>
|
8 |
+
<frontend_type>text</frontend_type>
|
9 |
+
<sort_order>10</sort_order>
|
10 |
+
<show_in_default>1</show_in_default>
|
11 |
+
<show_in_website>1</show_in_website>
|
12 |
+
<show_in_store>0</show_in_store>
|
13 |
+
<fields>
|
14 |
+
|
15 |
+
<info_text translate="label">
|
16 |
+
<label>Info text</label>
|
17 |
+
<frontend_type>text</frontend_type>
|
18 |
+
<frontend_model>bpost_shm/adminhtml_system_config_form_field_info</frontend_model>
|
19 |
+
<sort_order>0</sort_order>
|
20 |
+
<show_in_default>1</show_in_default>
|
21 |
+
<show_in_website>1</show_in_website>
|
22 |
+
<show_in_store>1</show_in_store>
|
23 |
+
</info_text>
|
24 |
+
|
25 |
+
<logo translate="label">
|
26 |
+
<label>Logo</label>
|
27 |
+
<frontend_type>text</frontend_type>
|
28 |
+
<frontend_model>bpost_shm/adminhtml_system_config_form_field_logo</frontend_model>
|
29 |
+
<sort_order>5</sort_order>
|
30 |
+
<show_in_default>1</show_in_default>
|
31 |
+
<show_in_website>1</show_in_website>
|
32 |
+
<show_in_store>1</show_in_store>
|
33 |
+
</logo>
|
34 |
+
|
35 |
+
<accountid translate="label,comment">
|
36 |
+
<label>Account id</label>
|
37 |
+
<frontend_type>text</frontend_type>
|
38 |
+
<sort_order>10</sort_order>
|
39 |
+
<show_in_default>1</show_in_default>
|
40 |
+
<show_in_website>1</show_in_website>
|
41 |
+
<show_in_store>0</show_in_store>
|
42 |
+
<comment><![CDATA[Your 6 digits bpost account ID used for the Shipping Manager.<br/><a target='_blank' href='http://bpost.freshdesk.com/solution/articles/4000061189'>http://bpost.freshdesk.com/solution/articles/4000061189</a>]]></comment>
|
43 |
+
</accountid>
|
44 |
+
|
45 |
+
<passphrase translate="label,comment">
|
46 |
+
<label>Passphrase</label>
|
47 |
+
<frontend_type>password</frontend_type>
|
48 |
+
<backend_model>adminhtml/system_config_backend_encrypted</backend_model>
|
49 |
+
<sort_order>20</sort_order>
|
50 |
+
<show_in_default>1</show_in_default>
|
51 |
+
<show_in_website>1</show_in_website>
|
52 |
+
<show_in_store>0</show_in_store>
|
53 |
+
<comment><![CDATA[The passphrase you entered in bpost Shipping Manager back-office application. This is not the password used to access bpost portal.]]></comment>
|
54 |
+
</passphrase>
|
55 |
+
|
56 |
+
<api_url translate="label,comment">
|
57 |
+
<label>API url</label>
|
58 |
+
<frontend_type>text</frontend_type>
|
59 |
+
<sort_order>30</sort_order>
|
60 |
+
<show_in_default>1</show_in_default>
|
61 |
+
<show_in_website>1</show_in_website>
|
62 |
+
<show_in_store>0</show_in_store>
|
63 |
+
<comment><![CDATA[Do not modify this setting if you are not 100% sure of what you are doing.]]></comment>
|
64 |
+
</api_url>
|
65 |
+
|
66 |
+
|
67 |
+
<sender_name translate="label,comment">
|
68 |
+
<label>Sender name</label>
|
69 |
+
<frontend_type>text</frontend_type>
|
70 |
+
<sort_order>60</sort_order>
|
71 |
+
<show_in_default>1</show_in_default>
|
72 |
+
<show_in_website>1</show_in_website>
|
73 |
+
<show_in_store>0</show_in_store>
|
74 |
+
<comment><![CDATA[Used in the webservice calls.]]></comment>
|
75 |
+
</sender_name>
|
76 |
+
|
77 |
+
<sender_company translate="label,comment">
|
78 |
+
<label>Sender company</label>
|
79 |
+
<frontend_type>text</frontend_type>
|
80 |
+
<sort_order>70</sort_order>
|
81 |
+
<show_in_default>1</show_in_default>
|
82 |
+
<show_in_website>1</show_in_website>
|
83 |
+
<show_in_store>0</show_in_store>
|
84 |
+
<comment><![CDATA[Used in the webservice calls.]]></comment>
|
85 |
+
</sender_company>
|
86 |
+
|
87 |
+
<sender_streetname translate="label,comment">
|
88 |
+
<label>Sender streetname</label>
|
89 |
+
<frontend_type>text</frontend_type>
|
90 |
+
<sort_order>80</sort_order>
|
91 |
+
<show_in_default>1</show_in_default>
|
92 |
+
<show_in_website>1</show_in_website>
|
93 |
+
<show_in_store>0</show_in_store>
|
94 |
+
<comment><![CDATA[Used in the webservice calls.]]></comment>
|
95 |
+
</sender_streetname>
|
96 |
+
|
97 |
+
<sender_streetnumber translate="label,comment">
|
98 |
+
<label>Sender streetnumber</label>
|
99 |
+
<frontend_type>text</frontend_type>
|
100 |
+
<sort_order>90</sort_order>
|
101 |
+
<show_in_default>1</show_in_default>
|
102 |
+
<show_in_website>1</show_in_website>
|
103 |
+
<show_in_store>0</show_in_store>
|
104 |
+
<comment><![CDATA[Used in the webservice calls.]]></comment>
|
105 |
+
</sender_streetnumber>
|
106 |
+
|
107 |
+
<sender_boxnumber translate="label,comment">
|
108 |
+
<label>Sender boxnumber</label>
|
109 |
+
<frontend_type>text</frontend_type>
|
110 |
+
<sort_order>100</sort_order>
|
111 |
+
<show_in_default>1</show_in_default>
|
112 |
+
<show_in_website>1</show_in_website>
|
113 |
+
<show_in_store>0</show_in_store>
|
114 |
+
<comment><![CDATA[Used in the webservice calls.]]></comment>
|
115 |
+
</sender_boxnumber>
|
116 |
+
|
117 |
+
<sender_postal_code translate="label,comment">
|
118 |
+
<label>Sender postal code</label>
|
119 |
+
<frontend_type>text</frontend_type>
|
120 |
+
<sort_order>110</sort_order>
|
121 |
+
<show_in_default>1</show_in_default>
|
122 |
+
<show_in_website>1</show_in_website>
|
123 |
+
<show_in_store>0</show_in_store>
|
124 |
+
<comment><![CDATA[Used in the webservice calls.]]></comment>
|
125 |
+
</sender_postal_code>
|
126 |
+
|
127 |
+
<sender_city translate="label,comment">
|
128 |
+
<label>Sender city</label>
|
129 |
+
<frontend_type>text</frontend_type>
|
130 |
+
<sort_order>120</sort_order>
|
131 |
+
<show_in_default>1</show_in_default>
|
132 |
+
<show_in_website>1</show_in_website>
|
133 |
+
<show_in_store>0</show_in_store>
|
134 |
+
<comment><![CDATA[Used in the webservice calls.]]></comment>
|
135 |
+
</sender_city>
|
136 |
+
|
137 |
+
<sender_country translate="label,comment">
|
138 |
+
<label>Sender country</label>
|
139 |
+
<frontend_type>select</frontend_type>
|
140 |
+
<source_model>bpost_shm/adminhtml_system_config_source_shipping::getCountries</source_model>
|
141 |
+
<sort_order>130</sort_order>
|
142 |
+
<show_in_default>1</show_in_default>
|
143 |
+
<show_in_website>1</show_in_website>
|
144 |
+
<show_in_store>0</show_in_store>
|
145 |
+
<comment><![CDATA[Used in the webservice calls.]]></comment>
|
146 |
+
</sender_country>
|
147 |
+
|
148 |
+
<sender_email translate="label,comment">
|
149 |
+
<label>Sender email</label>
|
150 |
+
<frontend_type>text</frontend_type>
|
151 |
+
<sort_order>140</sort_order>
|
152 |
+
<show_in_default>1</show_in_default>
|
153 |
+
<show_in_website>1</show_in_website>
|
154 |
+
<show_in_store>0</show_in_store>
|
155 |
+
<comment><![CDATA[Used in the webservice calls.]]></comment>
|
156 |
+
</sender_email>
|
157 |
+
|
158 |
+
<sender_phonenumber translate="label,comment">
|
159 |
+
<label>Sender phonenumber</label>
|
160 |
+
<frontend_type>text</frontend_type>
|
161 |
+
<sort_order>150</sort_order>
|
162 |
+
<show_in_default>1</show_in_default>
|
163 |
+
<show_in_website>1</show_in_website>
|
164 |
+
<show_in_store>0</show_in_store>
|
165 |
+
<comment><![CDATA[Used in the webservice calls.]]></comment>
|
166 |
+
</sender_phonenumber>
|
167 |
+
|
168 |
+
<manage_labels_with_magento translate="label,comment">
|
169 |
+
<label>Use Magento to manage labels</label>
|
170 |
+
<frontend_type>select</frontend_type>
|
171 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
172 |
+
<sort_order>160</sort_order>
|
173 |
+
<show_in_default>1</show_in_default>
|
174 |
+
<show_in_website>0</show_in_website>
|
175 |
+
<show_in_store>0</show_in_store>
|
176 |
+
<comment><![CDATA[If you enable this option, labels are generated directly within Magento. It is not needed to use the bpost Shipping Manager for these tasks. Pop-ups must be enabled in your browser, in order to view the printed labels. Click <a href='http://bpost.freshdesk.com/solution/articles/4000061188' target='_blank'>here</a> to learn more about this option.]]></comment>
|
177 |
+
</manage_labels_with_magento>
|
178 |
+
|
179 |
+
|
180 |
+
<label_format translate="label,comment">
|
181 |
+
<label>Label format</label>
|
182 |
+
<frontend_type>select</frontend_type>
|
183 |
+
<source_model>bpost_shm/adminhtml_system_config_source_shipping::getLabelSizesOptionsArray</source_model>
|
184 |
+
<sort_order>170</sort_order>
|
185 |
+
<show_in_default>1</show_in_default>
|
186 |
+
<show_in_website>1</show_in_website>
|
187 |
+
<show_in_store>0</show_in_store>
|
188 |
+
<depends>
|
189 |
+
<manage_labels_with_magento>1</manage_labels_with_magento>
|
190 |
+
</depends>
|
191 |
+
<comment><![CDATA[Choose between A6 or A4 format]]></comment>
|
192 |
+
</label_format>
|
193 |
+
|
194 |
+
<automatic_retour_labels translate="label">
|
195 |
+
<label>Automatic retour labels</label>
|
196 |
+
<frontend_type>select</frontend_type>
|
197 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
198 |
+
<sort_order>180</sort_order>
|
199 |
+
<show_in_default>1</show_in_default>
|
200 |
+
<show_in_website>1</show_in_website>
|
201 |
+
<show_in_store>0</show_in_store>
|
202 |
+
<depends>
|
203 |
+
<manage_labels_with_magento>1</manage_labels_with_magento>
|
204 |
+
</depends>
|
205 |
+
<comment><![CDATA[If you enable this option, a retour label is automatically added and printed when generating labels. If disabled, you are able to manually create retour labels.]]></comment>
|
206 |
+
</automatic_retour_labels>
|
207 |
+
|
208 |
+
<automatic_track_and_trace_information translate="label,comment">
|
209 |
+
<label>Automatic track and trace information</label>
|
210 |
+
<frontend_type>select</frontend_type>
|
211 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
212 |
+
<sort_order>190</sort_order>
|
213 |
+
<show_in_default>1</show_in_default>
|
214 |
+
<show_in_website>1</show_in_website>
|
215 |
+
<show_in_store>0</show_in_store>
|
216 |
+
<depends>
|
217 |
+
<manage_labels_with_magento>1</manage_labels_with_magento>
|
218 |
+
</depends>
|
219 |
+
<comment><![CDATA[If you enable this option, the bpost Track & Trace link will be added in the Magento mail templates. It is always possible to manually send these emails.<br/><a href='http://bpost.freshdesk.com/solution/articles/4000062605' target='_blank'>http://bpost.freshdesk.com/solution/articles/4000062605</a>]]></comment>
|
220 |
+
</automatic_track_and_trace_information>
|
221 |
+
|
222 |
+
<display_delivery_date translate="label,comment">
|
223 |
+
<label>Display delivery date</label>
|
224 |
+
<frontend_type>select</frontend_type>
|
225 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
226 |
+
<sort_order>200</sort_order>
|
227 |
+
<show_in_default>1</show_in_default>
|
228 |
+
<show_in_website>1</show_in_website>
|
229 |
+
<show_in_store>0</show_in_store>
|
230 |
+
<comment><![CDATA[Displays calculated delivery date]]></comment>
|
231 |
+
<comment>
|
232 |
+
<model>bpost_shm/adminhtml_system_config_source_datecomment</model>
|
233 |
+
</comment>
|
234 |
+
</display_delivery_date>
|
235 |
+
|
236 |
+
<days_between_order_and_shipment translate="label">
|
237 |
+
<label>Days between order and shipment</label>
|
238 |
+
<frontend_type>text</frontend_type>
|
239 |
+
<sort_order>210</sort_order>
|
240 |
+
<show_in_default>1</show_in_default>
|
241 |
+
<show_in_website>1</show_in_website>
|
242 |
+
<show_in_store>0</show_in_store>
|
243 |
+
<depends><display_delivery_date>1</display_delivery_date></depends>
|
244 |
+
</days_between_order_and_shipment>
|
245 |
+
|
246 |
+
<choose_delivery_date translate="label,comment">
|
247 |
+
<label>Choose delivery date</label>
|
248 |
+
<frontend_type>select</frontend_type>
|
249 |
+
<frontend_model>bpost_shm/adminhtml_system_config_form_field_choose</frontend_model>
|
250 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
251 |
+
<sort_order>220</sort_order>
|
252 |
+
<show_in_default>1</show_in_default>
|
253 |
+
<show_in_website>1</show_in_website>
|
254 |
+
<show_in_store>0</show_in_store>
|
255 |
+
<depends><display_delivery_date>1</display_delivery_date></depends>
|
256 |
+
<comment><![CDATA[Allow customer to choose their delivery date]]></comment>
|
257 |
+
</choose_delivery_date>
|
258 |
+
|
259 |
+
<nr_of_delivery_days_shown translate="label">
|
260 |
+
<label>Number of delivery days shown</label>
|
261 |
+
<frontend_type>select</frontend_type>
|
262 |
+
<source_model>bpost_shm/adminhtml_system_config_source_shipping::nrOfDeliveryDaysShownOptionsArray</source_model>
|
263 |
+
<sort_order>230</sort_order>
|
264 |
+
<show_in_default>1</show_in_default>
|
265 |
+
<show_in_website>1</show_in_website>
|
266 |
+
<show_in_store>0</show_in_store>
|
267 |
+
<depends>
|
268 |
+
<display_delivery_date>1</display_delivery_date>
|
269 |
+
<choose_delivery_date>1</choose_delivery_date>
|
270 |
+
</depends>
|
271 |
+
</nr_of_delivery_days_shown>
|
272 |
+
|
273 |
+
<next_day_delivery_allowed_till translate="label,comment">
|
274 |
+
<label>Next day delivery allowed till</label>
|
275 |
+
<frontend_type>time</frontend_type>
|
276 |
+
<frontend_model>bpost_shm/adminhtml_system_config_form_field_hour</frontend_model>
|
277 |
+
<sort_order>240</sort_order>
|
278 |
+
<show_in_default>1</show_in_default>
|
279 |
+
<show_in_website>1</show_in_website>
|
280 |
+
<show_in_store>0</show_in_store>
|
281 |
+
<comment><![CDATA[If the order is placed after this cut-off time, an extra day is added to the displayed date. Order placed = end of checkout.]]></comment>
|
282 |
+
<depends>
|
283 |
+
<display_delivery_date>1</display_delivery_date>
|
284 |
+
</depends>
|
285 |
+
</next_day_delivery_allowed_till>
|
286 |
+
|
287 |
+
<saturday_delivery_cost translate="label,comment">
|
288 |
+
<label>Saturday delivery cost</label>
|
289 |
+
<frontend_type>text</frontend_type>
|
290 |
+
<sort_order>250</sort_order>
|
291 |
+
<show_in_default>1</show_in_default>
|
292 |
+
<show_in_website>1</show_in_website>
|
293 |
+
<show_in_store>0</show_in_store>
|
294 |
+
<comment><![CDATA[Additional fee when using saturday delivery option, e.g.: 4.95.<br />Dear customer, if you decide to offer your own consumers the option of Saturday delivery, you need to select 'Display delivery date' in the general parameters of the plugin and enter the requested information.]]></comment>
|
295 |
+
</saturday_delivery_cost>
|
296 |
+
|
297 |
+
<weight_unit translate="label,comment">
|
298 |
+
<label>Weight unit</label>
|
299 |
+
<frontend_type>select</frontend_type>
|
300 |
+
<source_model>bpost_shm/system_config_source_weightunit</source_model>
|
301 |
+
<sort_order>255</sort_order>
|
302 |
+
<show_in_default>1</show_in_default>
|
303 |
+
<show_in_website>1</show_in_website>
|
304 |
+
<show_in_store>0</show_in_store>
|
305 |
+
<comment>Used to calculate the weight before sending it to bpost</comment>
|
306 |
+
</weight_unit>
|
307 |
+
|
308 |
+
<browser_api_key translate="label,comment">
|
309 |
+
<label>Google browser API key</label>
|
310 |
+
<frontend_type>text</frontend_type>
|
311 |
+
<sort_order>260</sort_order>
|
312 |
+
<show_in_default>1</show_in_default>
|
313 |
+
<show_in_website>1</show_in_website>
|
314 |
+
<show_in_store>0</show_in_store>
|
315 |
+
<comment><![CDATA[bpost uses Google Maps API to display the map in the frontend. <strong>
Note:</strong> This is optional if you will not meet the usage limits. Visit Google’s online documentation for more information.]]></comment>
|
316 |
+
</browser_api_key>
|
317 |
+
|
318 |
+
<server_api_key translate="label,comment">
|
319 |
+
<label>Google server API key</label>
|
320 |
+
<frontend_type>text</frontend_type>
|
321 |
+
<sort_order>270</sort_order>
|
322 |
+
<show_in_default>1</show_in_default>
|
323 |
+
<show_in_website>1</show_in_website>
|
324 |
+
<show_in_store>0</show_in_store>
|
325 |
+
<comment><![CDATA[bpost uses Google Geocoding API to calculate GEO location based on the shipping address. <strong>
Note:</strong> This is optional if you will not meet the usage limits. Visit Google’s online documentation for more information.]]></comment>
|
326 |
+
</server_api_key>
|
327 |
+
</fields>
|
328 |
+
</bpost_shm>
|
329 |
+
</groups>
|
330 |
+
</shipping>
|
331 |
+
|
332 |
+
<carriers>
|
333 |
+
<groups>
|
334 |
+
<bpost_homedelivery translate="label" module="bpost_shm">
|
335 |
+
<label>bpost Home delivery</label>
|
336 |
+
<frontend_type>text</frontend_type>
|
337 |
+
<sort_order>50</sort_order>
|
338 |
+
<show_in_default>1</show_in_default>
|
339 |
+
<show_in_website>1</show_in_website>
|
340 |
+
<show_in_store>1</show_in_store>
|
341 |
+
<fields>
|
342 |
+
<logo translate="label">
|
343 |
+
<label>Logoo</label>
|
344 |
+
<frontend_type>text</frontend_type>
|
345 |
+
<frontend_model>bpost_shm/adminhtml_system_config_form_field_logo</frontend_model>
|
346 |
+
<sort_order>0</sort_order>
|
347 |
+
<show_in_default>1</show_in_default>
|
348 |
+
<show_in_website>1</show_in_website>
|
349 |
+
<show_in_store>1</show_in_store>
|
350 |
+
</logo>
|
351 |
+
|
352 |
+
|
353 |
+
<subheader_general translate="label">
|
354 |
+
<label>General</label>
|
355 |
+
<frontend_type>text</frontend_type>
|
356 |
+
<frontend_model>bpost_shm/adminhtml_system_config_form_field_subheader</frontend_model>
|
357 |
+
<sort_order>0</sort_order>
|
358 |
+
<show_in_default>1</show_in_default>
|
359 |
+
<show_in_website>1</show_in_website>
|
360 |
+
<show_in_store>1</show_in_store>
|
361 |
+
</subheader_general>
|
362 |
+
|
363 |
+
<active translate="label,comment">
|
364 |
+
<label>Enabled</label>
|
365 |
+
<frontend_type>select</frontend_type>
|
366 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
367 |
+
<sort_order>1</sort_order>
|
368 |
+
<show_in_default>1</show_in_default>
|
369 |
+
<show_in_website>1</show_in_website>
|
370 |
+
<show_in_store>1</show_in_store>
|
371 |
+
<comment><![CDATA[Delivery at your doorstep or at your office? bpack@home is the most convenient option for you!]]></comment>
|
372 |
+
</active>
|
373 |
+
|
374 |
+
<subheader_rates translate="label">
|
375 |
+
<label>Rates</label>
|
376 |
+
<frontend_type>text</frontend_type>
|
377 |
+
<frontend_model>bpost_shm/adminhtml_system_config_form_field_subheader</frontend_model>
|
378 |
+
<sort_order>5</sort_order>
|
379 |
+
<show_in_default>1</show_in_default>
|
380 |
+
<show_in_website>1</show_in_website>
|
381 |
+
<show_in_store>1</show_in_store>
|
382 |
+
</subheader_rates>
|
383 |
+
|
384 |
+
<free_shipping translate="label,comment">
|
385 |
+
<label>Free shipping</label>
|
386 |
+
<frontend_type>select</frontend_type>
|
387 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
388 |
+
<sort_order>10</sort_order>
|
389 |
+
<show_in_default>1</show_in_default>
|
390 |
+
<show_in_website>1</show_in_website>
|
391 |
+
<show_in_store>1</show_in_store>
|
392 |
+
<comment><![CDATA[Allow free shipping]]></comment>
|
393 |
+
</free_shipping>
|
394 |
+
|
395 |
+
<free_shipping_from translate="label,comment">
|
396 |
+
<label>.. as of</label>
|
397 |
+
<frontend_type>text</frontend_type>
|
398 |
+
<sort_order>20</sort_order>
|
399 |
+
<depends>
|
400 |
+
<free_shipping>1</free_shipping>
|
401 |
+
</depends>
|
402 |
+
<show_in_default>1</show_in_default>
|
403 |
+
<show_in_website>1</show_in_website>
|
404 |
+
<show_in_store>1</show_in_store>
|
405 |
+
<comment><![CDATA[Free shipping will be applied as from a minimum amount]]></comment>
|
406 |
+
</free_shipping_from>
|
407 |
+
|
408 |
+
<rate_type translate="label,comment,tooltip">
|
409 |
+
<label>Rate type</label>
|
410 |
+
<frontend_type>select</frontend_type>
|
411 |
+
<source_model>bpost_shm/system_config_source_ratetypes</source_model>
|
412 |
+
<sort_order>30</sort_order>
|
413 |
+
<show_in_default>1</show_in_default>
|
414 |
+
<show_in_website>1</show_in_website>
|
415 |
+
<show_in_store>1</show_in_store>
|
416 |
+
<comment><![CDATA[Choose your rate type (Flat rate or Table rate)]]></comment>
|
417 |
+
<tooltip>Importing and exporting table rates only possible on website scope. View the documentation for more information.</tooltip>
|
418 |
+
</rate_type>
|
419 |
+
|
420 |
+
<flat_rate_price translate="label,comment">
|
421 |
+
<label>Flat rate price</label>
|
422 |
+
<frontend_type>text</frontend_type>
|
423 |
+
<sort_order>40</sort_order>
|
424 |
+
<depends>
|
425 |
+
<rate_type>0</rate_type>
|
426 |
+
</depends>
|
427 |
+
<show_in_default>1</show_in_default>
|
428 |
+
<show_in_website>1</show_in_website>
|
429 |
+
<show_in_store>1</show_in_store>
|
430 |
+
<comment><![CDATA[Fixed fee for bpost Home delivery shipments, e.g.: 4.95.]]></comment>
|
431 |
+
</flat_rate_price>
|
432 |
+
|
433 |
+
<condition_name translate="label">
|
434 |
+
<label>Table rates condition</label>
|
435 |
+
<frontend_type>select</frontend_type>
|
436 |
+
<source_model>adminhtml/system_config_source_shipping_tablerate</source_model>
|
437 |
+
<sort_order>50</sort_order>
|
438 |
+
<depends>
|
439 |
+
<rate_type>1</rate_type>
|
440 |
+
</depends>
|
441 |
+
<show_in_default>1</show_in_default>
|
442 |
+
<show_in_website>1</show_in_website>
|
443 |
+
<show_in_store>0</show_in_store>
|
444 |
+
</condition_name>
|
445 |
+
|
446 |
+
<export translate="label,comment">
|
447 |
+
<label>Export table rates file</label>
|
448 |
+
<frontend_type>button</frontend_type>
|
449 |
+
<frontend_model>bpost_shm/adminhtml_system_config_form_tablerates_export_homedelivery</frontend_model>
|
450 |
+
<sort_order>60</sort_order>
|
451 |
+
<depends>
|
452 |
+
<rate_type>1</rate_type>
|
453 |
+
</depends>
|
454 |
+
<show_in_default>0</show_in_default>
|
455 |
+
<show_in_website>1</show_in_website>
|
456 |
+
<show_in_store>0</show_in_store>
|
457 |
+
<comment><![CDATA[Export your table rates configuration here.]]></comment>
|
458 |
+
</export>
|
459 |
+
|
460 |
+
<import_homedelivery translate="label,comment">
|
461 |
+
<label>Import table rates file</label>
|
462 |
+
<frontend_type>import</frontend_type>
|
463 |
+
<sort_order>70</sort_order>
|
464 |
+
<backend_model>bpost_shm/adminhtml_system_config_backend_shipping_tablerates_homedelivery</backend_model>
|
465 |
+
<depends>
|
466 |
+
<rate_type>1</rate_type>
|
467 |
+
</depends>
|
468 |
+
<show_in_default>0</show_in_default>
|
469 |
+
<show_in_website>1</show_in_website>
|
470 |
+
<show_in_store>0</show_in_store>
|
471 |
+
<comment><![CDATA[Upload your table rates configuration here. Refer to the manual for more information.]]></comment>
|
472 |
+
</import_homedelivery>
|
473 |
+
|
474 |
+
<subheader_options translate="label">
|
475 |
+
<label>Options</label>
|
476 |
+
<frontend_type>text</frontend_type>
|
477 |
+
<frontend_model>bpost_shm/adminhtml_system_config_form_field_subheader</frontend_model>
|
478 |
+
<sort_order>75</sort_order>
|
479 |
+
<show_in_default>1</show_in_default>
|
480 |
+
<show_in_website>1</show_in_website>
|
481 |
+
<show_in_store>1</show_in_store>
|
482 |
+
</subheader_options>
|
483 |
+
|
484 |
+
<second_presentation translate="label,comment">
|
485 |
+
<label>2nd presentation</label>
|
486 |
+
<frontend_type>select</frontend_type>
|
487 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
488 |
+
<sort_order>80</sort_order>
|
489 |
+
<show_in_default>1</show_in_default>
|
490 |
+
<show_in_website>1</show_in_website>
|
491 |
+
<show_in_store>1</show_in_store>
|
492 |
+
<comment><![CDATA[This options provides automatically a second presentation at the receiver's address should he be absent upon first presentation.]]></comment>
|
493 |
+
</second_presentation>
|
494 |
+
|
495 |
+
<second_presentation_from translate="label">
|
496 |
+
<label>.. as from</label>
|
497 |
+
<frontend_type>text</frontend_type>
|
498 |
+
<sort_order>90</sort_order>
|
499 |
+
<depends>
|
500 |
+
<second_presentation>1</second_presentation>
|
501 |
+
</depends>
|
502 |
+
<show_in_default>1</show_in_default>
|
503 |
+
<show_in_website>1</show_in_website>
|
504 |
+
<show_in_store>1</show_in_store>
|
505 |
+
</second_presentation_from>
|
506 |
+
|
507 |
+
<insurance translate="label,comment">
|
508 |
+
<label>Insurance</label>
|
509 |
+
<frontend_type>select</frontend_type>
|
510 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
511 |
+
<sort_order>100</sort_order>
|
512 |
+
<show_in_default>1</show_in_default>
|
513 |
+
<show_in_website>1</show_in_website>
|
514 |
+
<show_in_store>1</show_in_store>
|
515 |
+
<comment><![CDATA[Insurance to insure your goods to a maximum of 500,00 euro.]]></comment>
|
516 |
+
</insurance>
|
517 |
+
|
518 |
+
<insurance_from translate="label">
|
519 |
+
<label>.. as from</label>
|
520 |
+
<frontend_type>text</frontend_type>
|
521 |
+
<sort_order>110</sort_order>
|
522 |
+
<depends>
|
523 |
+
<insurance>1</insurance>
|
524 |
+
</depends>
|
525 |
+
<show_in_default>1</show_in_default>
|
526 |
+
<show_in_website>1</show_in_website>
|
527 |
+
<show_in_store>1</show_in_store>
|
528 |
+
</insurance_from>
|
529 |
+
|
530 |
+
<signature translate="label,comment">
|
531 |
+
<label>Signature</label>
|
532 |
+
<frontend_type>select</frontend_type>
|
533 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
534 |
+
<sort_order>120</sort_order>
|
535 |
+
<show_in_default>1</show_in_default>
|
536 |
+
<show_in_website>1</show_in_website>
|
537 |
+
<show_in_store>1</show_in_store>
|
538 |
+
<comment><![CDATA[The delivery happens against signature by the receiver.]]></comment>
|
539 |
+
</signature>
|
540 |
+
|
541 |
+
<signature_from translate="label">
|
542 |
+
<label>.. as from</label>
|
543 |
+
<frontend_type>text</frontend_type>
|
544 |
+
<sort_order>130</sort_order>
|
545 |
+
<depends>
|
546 |
+
<signature>1</signature>
|
547 |
+
</depends>
|
548 |
+
<show_in_default>1</show_in_default>
|
549 |
+
<show_in_website>1</show_in_website>
|
550 |
+
<show_in_store>1</show_in_store>
|
551 |
+
</signature_from>
|
552 |
+
|
553 |
+
<saturday_delivery translate="label,comment">
|
554 |
+
<label>Saturday delivery</label>
|
555 |
+
<frontend_type>select</frontend_type>
|
556 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
557 |
+
<sort_order>140</sort_order>
|
558 |
+
<show_in_default>1</show_in_default>
|
559 |
+
<show_in_website>1</show_in_website>
|
560 |
+
<show_in_store>1</show_in_store>
|
561 |
+
<comment><![CDATA[The parcel is delivered on Saturday if it is timely dropped in the bpost network.]]></comment>
|
562 |
+
</saturday_delivery>
|
563 |
+
|
564 |
+
<saturday_delivery_from translate="label">
|
565 |
+
<label>.. as from</label>
|
566 |
+
<frontend_type>text</frontend_type>
|
567 |
+
<sort_order>150</sort_order>
|
568 |
+
<depends>
|
569 |
+
<saturday_delivery>1</saturday_delivery>
|
570 |
+
</depends>
|
571 |
+
<show_in_default>1</show_in_default>
|
572 |
+
<show_in_website>1</show_in_website>
|
573 |
+
<show_in_store>1</show_in_store>
|
574 |
+
</saturday_delivery_from>
|
575 |
+
</fields>
|
576 |
+
</bpost_homedelivery>
|
577 |
+
<bpost_international translate="label" module="bpost_shm">
|
578 |
+
<label>bpost Home delivery international</label>
|
579 |
+
<frontend_type>text</frontend_type>
|
580 |
+
<sort_order>60</sort_order>
|
581 |
+
<show_in_default>1</show_in_default>
|
582 |
+
<show_in_website>1</show_in_website>
|
583 |
+
<show_in_store>1</show_in_store>
|
584 |
+
<fields>
|
585 |
+
<logo translate="label">
|
586 |
+
<label>Logoo</label>
|
587 |
+
<frontend_type>text</frontend_type>
|
588 |
+
<frontend_model>bpost_shm/adminhtml_system_config_form_field_logo</frontend_model>
|
589 |
+
<sort_order>0</sort_order>
|
590 |
+
<show_in_default>1</show_in_default>
|
591 |
+
<show_in_website>1</show_in_website>
|
592 |
+
<show_in_store>1</show_in_store>
|
593 |
+
</logo>
|
594 |
+
|
595 |
+
<subheader_general translate="label">
|
596 |
+
<label>General</label>
|
597 |
+
<frontend_type>text</frontend_type>
|
598 |
+
<frontend_model>bpost_shm/adminhtml_system_config_form_field_subheader</frontend_model>
|
599 |
+
<sort_order>10</sort_order>
|
600 |
+
<show_in_default>1</show_in_default>
|
601 |
+
<show_in_website>1</show_in_website>
|
602 |
+
<show_in_store>1</show_in_store>
|
603 |
+
</subheader_general>
|
604 |
+
|
605 |
+
<active translate="label,comment">
|
606 |
+
<label>Enabled</label>
|
607 |
+
<frontend_type>select</frontend_type>
|
608 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
609 |
+
<sort_order>20</sort_order>
|
610 |
+
<show_in_default>1</show_in_default>
|
611 |
+
<show_in_website>1</show_in_website>
|
612 |
+
<show_in_store>1</show_in_store>
|
613 |
+
<comment><![CDATA[Delivery at your doorstep or at your office outside Belgium? bpack@international is the most convenient option for you!]]></comment>
|
614 |
+
</active>
|
615 |
+
|
616 |
+
<product translate="label,comment">
|
617 |
+
<label>Product</label>
|
618 |
+
<frontend_type>select</frontend_type>
|
619 |
+
<source_model>bpost_shm/system_config_source_product</source_model>
|
620 |
+
<sort_order>30</sort_order>
|
621 |
+
<show_in_default>1</show_in_default>
|
622 |
+
<show_in_website>1</show_in_website>
|
623 |
+
<show_in_store>1</show_in_store>
|
624 |
+
<comment><![CDATA[Select which product to use for international shipments]]></comment>
|
625 |
+
</product>
|
626 |
+
|
627 |
+
<subheader_rates translate="label">
|
628 |
+
<label>Rates</label>
|
629 |
+
<frontend_type>text</frontend_type>
|
630 |
+
<frontend_model>bpost_shm/adminhtml_system_config_form_field_subheader</frontend_model>
|
631 |
+
<sort_order>40</sort_order>
|
632 |
+
<show_in_default>1</show_in_default>
|
633 |
+
<show_in_website>1</show_in_website>
|
634 |
+
<show_in_store>1</show_in_store>
|
635 |
+
</subheader_rates>
|
636 |
+
|
637 |
+
<free_shipping translate="label,comment">
|
638 |
+
<label>Free shipping</label>
|
639 |
+
<frontend_type>select</frontend_type>
|
640 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
641 |
+
<sort_order>50</sort_order>
|
642 |
+
<show_in_default>1</show_in_default>
|
643 |
+
<show_in_website>1</show_in_website>
|
644 |
+
<show_in_store>1</show_in_store>
|
645 |
+
<comment><![CDATA[Allow free shipping]]></comment>
|
646 |
+
</free_shipping>
|
647 |
+
|
648 |
+
<free_shipping_from translate="label,comment">
|
649 |
+
<label>.. as of</label>
|
650 |
+
<frontend_type>text</frontend_type>
|
651 |
+
<sort_order>60</sort_order>
|
652 |
+
<depends>
|
653 |
+
<free_shipping>1</free_shipping>
|
654 |
+
</depends>
|
655 |
+
<show_in_default>1</show_in_default>
|
656 |
+
<show_in_website>1</show_in_website>
|
657 |
+
<show_in_store>1</show_in_store>
|
658 |
+
<comment><![CDATA[Free shipping will be applied as from a minimum amount]]></comment>
|
659 |
+
</free_shipping_from>
|
660 |
+
|
661 |
+
<rate_type translate="label,comment,tooltip">
|
662 |
+
<label>Rate type</label>
|
663 |
+
<frontend_type>select</frontend_type>
|
664 |
+
<source_model>bpost_shm/system_config_source_ratetypes</source_model>
|
665 |
+
<sort_order>70</sort_order>
|
666 |
+
<show_in_default>1</show_in_default>
|
667 |
+
<show_in_website>1</show_in_website>
|
668 |
+
<show_in_store>1</show_in_store>
|
669 |
+
<comment><![CDATA[Choose your rate type (Flat rate or Table rate)]]></comment>
|
670 |
+
<tooltip>Importing and exporting table rates only possible on website scope. View the documentation for more information.</tooltip>
|
671 |
+
</rate_type>
|
672 |
+
|
673 |
+
<flat_rate_price translate="label,comment">
|
674 |
+
<label>Flat rate price</label>
|
675 |
+
<frontend_type>text</frontend_type>
|
676 |
+
<sort_order>80</sort_order>
|
677 |
+
<depends>
|
678 |
+
<rate_type>0</rate_type>
|
679 |
+
</depends>
|
680 |
+
<show_in_default>1</show_in_default>
|
681 |
+
<show_in_website>1</show_in_website>
|
682 |
+
<show_in_store>1</show_in_store>
|
683 |
+
<comment><![CDATA[Fixed fee for bpost Home delivery international shipments, e.g.: 4.95.]]></comment>
|
684 |
+
</flat_rate_price>
|
685 |
+
|
686 |
+
<condition_name translate="label">
|
687 |
+
<label>Table rates condition</label>
|
688 |
+
<frontend_type>select</frontend_type>
|
689 |
+
<source_model>adminhtml/system_config_source_shipping_tablerate</source_model>
|
690 |
+
<sort_order>90</sort_order>
|
691 |
+
<depends>
|
692 |
+
<rate_type>1</rate_type>
|
693 |
+
</depends>
|
694 |
+
<show_in_default>1</show_in_default>
|
695 |
+
<show_in_website>1</show_in_website>
|
696 |
+
<show_in_store>0</show_in_store>
|
697 |
+
</condition_name>
|
698 |
+
|
699 |
+
<export translate="label,comment">
|
700 |
+
<label>Export table rates file</label>
|
701 |
+
<frontend_type>button</frontend_type>
|
702 |
+
<frontend_model>bpost_shm/adminhtml_system_config_form_tablerates_export_international</frontend_model>
|
703 |
+
<sort_order>100</sort_order>
|
704 |
+
<depends>
|
705 |
+
<rate_type>1</rate_type>
|
706 |
+
</depends>
|
707 |
+
<show_in_default>0</show_in_default>
|
708 |
+
<show_in_website>1</show_in_website>
|
709 |
+
<show_in_store>0</show_in_store>
|
710 |
+
<comment><![CDATA[Export your table rates configuration here.]]></comment>
|
711 |
+
</export>
|
712 |
+
|
713 |
+
<import_international translate="label,comment">
|
714 |
+
<label>Import table rates file</label>
|
715 |
+
<frontend_type>import</frontend_type>
|
716 |
+
<sort_order>110</sort_order>
|
717 |
+
<backend_model>bpost_shm/adminhtml_system_config_backend_shipping_tablerates_international</backend_model>
|
718 |
+
<depends>
|
719 |
+
<rate_type>1</rate_type>
|
720 |
+
</depends>
|
721 |
+
<show_in_default>0</show_in_default>
|
722 |
+
<show_in_website>1</show_in_website>
|
723 |
+
<show_in_store>0</show_in_store>
|
724 |
+
<comment><![CDATA[Upload your table rates configuration here. Refer to the manual for more information.]]></comment>
|
725 |
+
</import_international>
|
726 |
+
|
727 |
+
<subheader_options translate="label">
|
728 |
+
<label>Options</label>
|
729 |
+
<frontend_type>text</frontend_type>
|
730 |
+
<frontend_model>bpost_shm/adminhtml_system_config_form_field_subheader</frontend_model>
|
731 |
+
<sort_order>120</sort_order>
|
732 |
+
<show_in_default>1</show_in_default>
|
733 |
+
<show_in_website>1</show_in_website>
|
734 |
+
<show_in_store>1</show_in_store>
|
735 |
+
</subheader_options>
|
736 |
+
|
737 |
+
<import_countries translate="label,comment">
|
738 |
+
<label>Import countries</label>
|
739 |
+
<frontend_type>button</frontend_type>
|
740 |
+
<frontend_model>bpost_shm/adminhtml_system_config_form_api_import_countries</frontend_model>
|
741 |
+
<sort_order>125</sort_order>
|
742 |
+
<show_in_default>1</show_in_default>
|
743 |
+
<show_in_website>1</show_in_website>
|
744 |
+
<show_in_store>1</show_in_store>
|
745 |
+
<comment><![CDATA[Import your bpost configured countries here.]]></comment>
|
746 |
+
</import_countries>
|
747 |
+
|
748 |
+
<specificcountry translate="label,comment">
|
749 |
+
<label>Allowed countries</label>
|
750 |
+
<frontend_type>multiselect</frontend_type>
|
751 |
+
<sort_order>125</sort_order>
|
752 |
+
<source_model>bpost_shm/system_config_source_country</source_model>
|
753 |
+
<show_in_default>1</show_in_default>
|
754 |
+
<show_in_website>1</show_in_website>
|
755 |
+
<show_in_store>0</show_in_store>
|
756 |
+
<can_be_empty>0</can_be_empty>
|
757 |
+
<comment><![CDATA[Select one or more countries where bpost Home delivery international should be available for. Make sure your bpost shipping manager is configured properly. Otherwise no countries will be shown in this list after saving the 'Shipping Settings' configuration.]]></comment>
|
758 |
+
</specificcountry>
|
759 |
+
|
760 |
+
<insurance translate="label,comment">
|
761 |
+
<label>International insurance</label>
|
762 |
+
<frontend_type>select</frontend_type>
|
763 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
764 |
+
<sort_order>130</sort_order>
|
765 |
+
<show_in_default>1</show_in_default>
|
766 |
+
<show_in_website>1</show_in_website>
|
767 |
+
<show_in_store>1</show_in_store>
|
768 |
+
<comment><![CDATA[Insurance to insure your goods to a maximum of 500,00 euro.]]></comment>
|
769 |
+
</insurance>
|
770 |
+
|
771 |
+
<insurance_from translate="label">
|
772 |
+
<label>.. as from</label>
|
773 |
+
<frontend_type>text</frontend_type>
|
774 |
+
<sort_order>140</sort_order>
|
775 |
+
<depends>
|
776 |
+
<insurance>1</insurance>
|
777 |
+
</depends>
|
778 |
+
<show_in_default>1</show_in_default>
|
779 |
+
<show_in_website>1</show_in_website>
|
780 |
+
<show_in_store>1</show_in_store>
|
781 |
+
</insurance_from>
|
782 |
+
</fields>
|
783 |
+
</bpost_international>
|
784 |
+
<bpost_pickuppoint translate="label" module="bpost_shm">
|
785 |
+
<label>bpost Pick-up point</label>
|
786 |
+
<frontend_type>text</frontend_type>
|
787 |
+
<sort_order>70</sort_order>
|
788 |
+
<show_in_default>1</show_in_default>
|
789 |
+
<show_in_website>1</show_in_website>
|
790 |
+
<show_in_store>1</show_in_store>
|
791 |
+
<fields>
|
792 |
+
<logo translate="label">
|
793 |
+
<label>Logo</label>
|
794 |
+
<frontend_type>text</frontend_type>
|
795 |
+
<frontend_model>bpost_shm/adminhtml_system_config_form_field_logo</frontend_model>
|
796 |
+
<sort_order>0</sort_order>
|
797 |
+
<show_in_default>1</show_in_default>
|
798 |
+
<show_in_website>1</show_in_website>
|
799 |
+
<show_in_store>1</show_in_store>
|
800 |
+
</logo>
|
801 |
+
|
802 |
+
<subheader_general translate="label">
|
803 |
+
<label>General</label>
|
804 |
+
<frontend_type>text</frontend_type>
|
805 |
+
<frontend_model>bpost_shm/adminhtml_system_config_form_field_subheader</frontend_model>
|
806 |
+
<sort_order>5</sort_order>
|
807 |
+
<show_in_default>1</show_in_default>
|
808 |
+
<show_in_website>1</show_in_website>
|
809 |
+
<show_in_store>1</show_in_store>
|
810 |
+
</subheader_general>
|
811 |
+
|
812 |
+
<active translate="label,comment">
|
813 |
+
<label>Enabled</label>
|
814 |
+
<frontend_type>select</frontend_type>
|
815 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
816 |
+
<sort_order>10</sort_order>
|
817 |
+
<show_in_default>1</show_in_default>
|
818 |
+
<show_in_website>1</show_in_website>
|
819 |
+
<show_in_store>1</show_in_store>
|
820 |
+
<comment><![CDATA[Get your parcel delivered in one of our 1.250 pick-up points.]]></comment>
|
821 |
+
</active>
|
822 |
+
|
823 |
+
<subheader_rates translate="label">
|
824 |
+
<label>Rates</label>
|
825 |
+
<frontend_type>text</frontend_type>
|
826 |
+
<frontend_model>bpost_shm/adminhtml_system_config_form_field_subheader</frontend_model>
|
827 |
+
<sort_order>15</sort_order>
|
828 |
+
<show_in_default>1</show_in_default>
|
829 |
+
<show_in_website>1</show_in_website>
|
830 |
+
<show_in_store>1</show_in_store>
|
831 |
+
</subheader_rates>
|
832 |
+
|
833 |
+
<free_shipping translate="label,comment">
|
834 |
+
<label>Free shipping</label>
|
835 |
+
<frontend_type>select</frontend_type>
|
836 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
837 |
+
<sort_order>20</sort_order>
|
838 |
+
<show_in_default>1</show_in_default>
|
839 |
+
<show_in_website>1</show_in_website>
|
840 |
+
<show_in_store>1</show_in_store>
|
841 |
+
<comment><![CDATA[Allow free shipping]]></comment>
|
842 |
+
</free_shipping>
|
843 |
+
|
844 |
+
<free_shipping_from translate="label,comment">
|
845 |
+
<label>.. as of</label>
|
846 |
+
<frontend_type>text</frontend_type>
|
847 |
+
<sort_order>30</sort_order>
|
848 |
+
<depends>
|
849 |
+
<free_shipping>1</free_shipping>
|
850 |
+
</depends>
|
851 |
+
<show_in_default>1</show_in_default>
|
852 |
+
<show_in_website>1</show_in_website>
|
853 |
+
<show_in_store>1</show_in_store>
|
854 |
+
<comment><![CDATA[Free shipping will be applied as from a minimum amount]]></comment>
|
855 |
+
</free_shipping_from>
|
856 |
+
|
857 |
+
<rate_type translate="label,comment,tooltip">
|
858 |
+
<label>Rate type</label>
|
859 |
+
<frontend_type>select</frontend_type>
|
860 |
+
<source_model>bpost_shm/system_config_source_ratetypes</source_model>
|
861 |
+
<sort_order>40</sort_order>
|
862 |
+
<show_in_default>1</show_in_default>
|
863 |
+
<show_in_website>1</show_in_website>
|
864 |
+
<show_in_store>1</show_in_store>
|
865 |
+
<comment><![CDATA[Choose your rate type (Flat rate or Table rate)]]></comment>
|
866 |
+
<tooltip>Importing and exporting table rates only possible on website scope. View the documentation for more information.</tooltip>
|
867 |
+
</rate_type>
|
868 |
+
|
869 |
+
<flat_rate_price translate="label,comment">
|
870 |
+
<label>Flat rate price</label>
|
871 |
+
<frontend_type>text</frontend_type>
|
872 |
+
<sort_order>50</sort_order>
|
873 |
+
<depends>
|
874 |
+
<rate_type>0</rate_type>
|
875 |
+
</depends>
|
876 |
+
<show_in_default>1</show_in_default>
|
877 |
+
<show_in_website>1</show_in_website>
|
878 |
+
<show_in_store>1</show_in_store>
|
879 |
+
<comment><![CDATA[Fixed fee for bpost Pick-up point shipments, e.g.: 4.95.]]></comment>
|
880 |
+
</flat_rate_price>
|
881 |
+
|
882 |
+
<condition_name translate="label">
|
883 |
+
<label>Table rates condition</label>
|
884 |
+
<frontend_type>select</frontend_type>
|
885 |
+
<source_model>adminhtml/system_config_source_shipping_tablerate</source_model>
|
886 |
+
<sort_order>60</sort_order>
|
887 |
+
<depends>
|
888 |
+
<rate_type>1</rate_type>
|
889 |
+
</depends>
|
890 |
+
<show_in_default>1</show_in_default>
|
891 |
+
<show_in_website>1</show_in_website>
|
892 |
+
<show_in_store>0</show_in_store>
|
893 |
+
</condition_name>
|
894 |
+
|
895 |
+
<export translate="label,comment">
|
896 |
+
<label>Export table rates file</label>
|
897 |
+
<frontend_type>button</frontend_type>
|
898 |
+
<frontend_model>bpost_shm/adminhtml_system_config_form_tablerates_export_pickuppoint</frontend_model>
|
899 |
+
<sort_order>70</sort_order>
|
900 |
+
<depends>
|
901 |
+
<rate_type>1</rate_type>
|
902 |
+
</depends>
|
903 |
+
<show_in_default>0</show_in_default>
|
904 |
+
<show_in_website>1</show_in_website>
|
905 |
+
<show_in_store>0</show_in_store>
|
906 |
+
<comment><![CDATA[Export your table rates configuration here.]]></comment>
|
907 |
+
</export>
|
908 |
+
|
909 |
+
<import_pickuppoint translate="label,comment">
|
910 |
+
<label>Import table rates file</label>
|
911 |
+
<frontend_type>import</frontend_type>
|
912 |
+
<sort_order>80</sort_order>
|
913 |
+
<backend_model>bpost_shm/adminhtml_system_config_backend_shipping_tablerates_pickuppoint</backend_model>
|
914 |
+
<depends>
|
915 |
+
<rate_type>1</rate_type>
|
916 |
+
</depends>
|
917 |
+
<show_in_default>0</show_in_default>
|
918 |
+
<show_in_website>1</show_in_website>
|
919 |
+
<show_in_store>0</show_in_store>
|
920 |
+
<comment><![CDATA[Upload your table rates configuration here. Refer to the manual for more information.]]></comment>
|
921 |
+
</import_pickuppoint>
|
922 |
+
|
923 |
+
<subheader_options translate="label">
|
924 |
+
<label>Options</label>
|
925 |
+
<frontend_type>text</frontend_type>
|
926 |
+
<frontend_model>bpost_shm/adminhtml_system_config_form_field_subheader</frontend_model>
|
927 |
+
<sort_order>85</sort_order>
|
928 |
+
<show_in_default>1</show_in_default>
|
929 |
+
<show_in_website>1</show_in_website>
|
930 |
+
<show_in_store>1</show_in_store>
|
931 |
+
</subheader_options>
|
932 |
+
|
933 |
+
<insurance translate="label,comment">
|
934 |
+
<label>Insurance</label>
|
935 |
+
<frontend_type>select</frontend_type>
|
936 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
937 |
+
<sort_order>90</sort_order>
|
938 |
+
<show_in_default>1</show_in_default>
|
939 |
+
<show_in_website>1</show_in_website>
|
940 |
+
<show_in_store>1</show_in_store>
|
941 |
+
<comment><![CDATA[Insurance to insure your goods to a maximum of 500,00 euro.]]></comment>
|
942 |
+
</insurance>
|
943 |
+
|
944 |
+
<insurance_from translate="label">
|
945 |
+
<label>.. as from</label>
|
946 |
+
<frontend_type>text</frontend_type>
|
947 |
+
<sort_order>100</sort_order>
|
948 |
+
<depends>
|
949 |
+
<insurance>1</insurance>
|
950 |
+
</depends>
|
951 |
+
<show_in_default>1</show_in_default>
|
952 |
+
<show_in_website>1</show_in_website>
|
953 |
+
<show_in_store>1</show_in_store>
|
954 |
+
</insurance_from>
|
955 |
+
|
956 |
+
<saturday_delivery translate="label,comment">
|
957 |
+
<label>Saturday delivery</label>
|
958 |
+
<frontend_type>select</frontend_type>
|
959 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
960 |
+
<sort_order>110</sort_order>
|
961 |
+
<show_in_default>1</show_in_default>
|
962 |
+
<show_in_website>1</show_in_website>
|
963 |
+
<show_in_store>1</show_in_store>
|
964 |
+
<comment><![CDATA[The parcel is delivered on Saturday if it is timely dropped in the bpost network.]]></comment>
|
965 |
+
</saturday_delivery>
|
966 |
+
|
967 |
+
<saturday_delivery_from translate="label">
|
968 |
+
<label>.. as from</label>
|
969 |
+
<frontend_type>text</frontend_type>
|
970 |
+
<sort_order>120</sort_order>
|
971 |
+
<depends>
|
972 |
+
<saturday_delivery>1</saturday_delivery>
|
973 |
+
</depends>
|
974 |
+
<show_in_default>1</show_in_default>
|
975 |
+
<show_in_website>1</show_in_website>
|
976 |
+
<show_in_store>1</show_in_store>
|
977 |
+
</saturday_delivery_from>
|
978 |
+
</fields>
|
979 |
+
</bpost_pickuppoint>
|
980 |
+
<bpost_parcellocker translate="label" module="bpost_shm">
|
981 |
+
<label>bpost Parcel locker</label>
|
982 |
+
<frontend_type>text</frontend_type>
|
983 |
+
<sort_order>80</sort_order>
|
984 |
+
<show_in_default>1</show_in_default>
|
985 |
+
<show_in_website>1</show_in_website>
|
986 |
+
<show_in_store>1</show_in_store>
|
987 |
+
<fields>
|
988 |
+
<logo translate="label">
|
989 |
+
<label>Logoo</label>
|
990 |
+
<frontend_type>text</frontend_type>
|
991 |
+
<frontend_model>bpost_shm/adminhtml_system_config_form_field_logo</frontend_model>
|
992 |
+
<sort_order>0</sort_order>
|
993 |
+
<show_in_default>1</show_in_default>
|
994 |
+
<show_in_website>1</show_in_website>
|
995 |
+
<show_in_store>1</show_in_store>
|
996 |
+
</logo>
|
997 |
+
|
998 |
+
<subheader_general translate="label">
|
999 |
+
<label>General</label>
|
1000 |
+
<frontend_type>text</frontend_type>
|
1001 |
+
<frontend_model>bpost_shm/adminhtml_system_config_form_field_subheader</frontend_model>
|
1002 |
+
<sort_order>5</sort_order>
|
1003 |
+
<show_in_default>1</show_in_default>
|
1004 |
+
<show_in_website>1</show_in_website>
|
1005 |
+
<show_in_store>1</show_in_store>
|
1006 |
+
</subheader_general>
|
1007 |
+
|
1008 |
+
<active translate="label,comment">
|
1009 |
+
<label>Enabled</label>
|
1010 |
+
<frontend_type>select</frontend_type>
|
1011 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
1012 |
+
<sort_order>10</sort_order>
|
1013 |
+
<show_in_default>1</show_in_default>
|
1014 |
+
<show_in_website>1</show_in_website>
|
1015 |
+
<show_in_store>1</show_in_store>
|
1016 |
+
<comment><![CDATA[Have your parcels delivered in one of our parcel lockers. Very convenient, centrally located, always open, 24/7!]]></comment>
|
1017 |
+
</active>
|
1018 |
+
|
1019 |
+
<subheader_rates translate="label">
|
1020 |
+
<label>Rates</label>
|
1021 |
+
<frontend_type>text</frontend_type>
|
1022 |
+
<frontend_model>bpost_shm/adminhtml_system_config_form_field_subheader</frontend_model>
|
1023 |
+
<sort_order>15</sort_order>
|
1024 |
+
<show_in_default>1</show_in_default>
|
1025 |
+
<show_in_website>1</show_in_website>
|
1026 |
+
<show_in_store>1</show_in_store>
|
1027 |
+
</subheader_rates>
|
1028 |
+
|
1029 |
+
<free_shipping translate="label,comment">
|
1030 |
+
<label>Free shipping</label>
|
1031 |
+
<frontend_type>select</frontend_type>
|
1032 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
1033 |
+
<sort_order>20</sort_order>
|
1034 |
+
<show_in_default>1</show_in_default>
|
1035 |
+
<show_in_website>1</show_in_website>
|
1036 |
+
<show_in_store>1</show_in_store>
|
1037 |
+
<comment><![CDATA[Allow free shipping.]]></comment>
|
1038 |
+
</free_shipping>
|
1039 |
+
|
1040 |
+
<free_shipping_from translate="label,comment">
|
1041 |
+
<label>.. as of</label>
|
1042 |
+
<frontend_type>text</frontend_type>
|
1043 |
+
<sort_order>30</sort_order>
|
1044 |
+
<depends>
|
1045 |
+
<free_shipping>1</free_shipping>
|
1046 |
+
</depends>
|
1047 |
+
<show_in_default>1</show_in_default>
|
1048 |
+
<show_in_website>1</show_in_website>
|
1049 |
+
<show_in_store>1</show_in_store>
|
1050 |
+
<comment><![CDATA[Free shipping will be applied as from a minimum amount]]></comment>
|
1051 |
+
</free_shipping_from>
|
1052 |
+
|
1053 |
+
<rate_type translate="label,comment,tooltip">
|
1054 |
+
<label>Rate type</label>
|
1055 |
+
<frontend_type>select</frontend_type>
|
1056 |
+
<source_model>bpost_shm/system_config_source_ratetypes</source_model>
|
1057 |
+
<sort_order>40</sort_order>
|
1058 |
+
<show_in_default>1</show_in_default>
|
1059 |
+
<show_in_website>1</show_in_website>
|
1060 |
+
<show_in_store>1</show_in_store>
|
1061 |
+
<comment><![CDATA[Choose your rate type (Flat rate or Table rate)]]></comment>
|
1062 |
+
<tooltip>Importing and exporting table rates only possible on website scope. View the documentation for more information.</tooltip>
|
1063 |
+
</rate_type>
|
1064 |
+
|
1065 |
+
<flat_rate_price translate="label">
|
1066 |
+
<label>Flat rate price</label>
|
1067 |
+
<frontend_type>text</frontend_type>
|
1068 |
+
<sort_order>50</sort_order>
|
1069 |
+
<depends>
|
1070 |
+
<rate_type>0</rate_type>
|
1071 |
+
</depends>
|
1072 |
+
<show_in_default>1</show_in_default>
|
1073 |
+
<show_in_website>1</show_in_website>
|
1074 |
+
<show_in_store>1</show_in_store>
|
1075 |
+
<comment><![CDATA[Fixed fee for bpost Pick-up point shipments, e.g.: 4.95.]]></comment>
|
1076 |
+
</flat_rate_price>
|
1077 |
+
|
1078 |
+
<condition_name translate="label">
|
1079 |
+
<label>Table rates condition</label>
|
1080 |
+
<frontend_type>select</frontend_type>
|
1081 |
+
<source_model>adminhtml/system_config_source_shipping_tablerate</source_model>
|
1082 |
+
<sort_order>60</sort_order>
|
1083 |
+
<depends>
|
1084 |
+
<rate_type>1</rate_type>
|
1085 |
+
</depends>
|
1086 |
+
<show_in_default>1</show_in_default>
|
1087 |
+
<show_in_website>1</show_in_website>
|
1088 |
+
<show_in_store>0</show_in_store>
|
1089 |
+
</condition_name>
|
1090 |
+
|
1091 |
+
<export translate="label,comment">
|
1092 |
+
<label>Export table rates file</label>
|
1093 |
+
<frontend_type>button</frontend_type>
|
1094 |
+
<frontend_model>bpost_shm/adminhtml_system_config_form_tablerates_export_parcellocker</frontend_model>
|
1095 |
+
<sort_order>70</sort_order>
|
1096 |
+
<depends>
|
1097 |
+
<rate_type>1</rate_type>
|
1098 |
+
</depends>
|
1099 |
+
<show_in_default>0</show_in_default>
|
1100 |
+
<show_in_website>1</show_in_website>
|
1101 |
+
<show_in_store>0</show_in_store>
|
1102 |
+
<comment><![CDATA[Export your table rates configuration here.]]></comment>
|
1103 |
+
</export>
|
1104 |
+
|
1105 |
+
<import_parcellocker translate="label,comment">
|
1106 |
+
<label>Import table rates file</label>
|
1107 |
+
<frontend_type>import</frontend_type>
|
1108 |
+
<sort_order>80</sort_order>
|
1109 |
+
<backend_model>bpost_shm/adminhtml_system_config_backend_shipping_tablerates_parcellocker</backend_model>
|
1110 |
+
<depends>
|
1111 |
+
<rate_type>1</rate_type>
|
1112 |
+
</depends>
|
1113 |
+
<show_in_default>0</show_in_default>
|
1114 |
+
<show_in_website>1</show_in_website>
|
1115 |
+
<show_in_store>0</show_in_store>
|
1116 |
+
<comment><![CDATA[Upload your table rates configuration here. Refer to the manual for more information.]]></comment>
|
1117 |
+
</import_parcellocker>
|
1118 |
+
|
1119 |
+
<subheader_options translate="label">
|
1120 |
+
<label>Options</label>
|
1121 |
+
<frontend_type>text</frontend_type>
|
1122 |
+
<frontend_model>bpost_shm/adminhtml_system_config_form_field_subheader</frontend_model>
|
1123 |
+
<sort_order>85</sort_order>
|
1124 |
+
<show_in_default>1</show_in_default>
|
1125 |
+
<show_in_website>1</show_in_website>
|
1126 |
+
<show_in_store>1</show_in_store>
|
1127 |
+
</subheader_options>
|
1128 |
+
|
1129 |
+
<insurance translate="label,comment">
|
1130 |
+
<label>Insurance</label>
|
1131 |
+
<frontend_type>select</frontend_type>
|
1132 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
1133 |
+
<sort_order>90</sort_order>
|
1134 |
+
<show_in_default>1</show_in_default>
|
1135 |
+
<show_in_website>1</show_in_website>
|
1136 |
+
<show_in_store>1</show_in_store>
|
1137 |
+
<comment><![CDATA[Insurance to insure your goods to a maximum of 500,00 euro.]]></comment>
|
1138 |
+
</insurance>
|
1139 |
+
|
1140 |
+
<insurance_from translate="label">
|
1141 |
+
<label>.. as from</label>
|
1142 |
+
<frontend_type>text</frontend_type>
|
1143 |
+
<sort_order>100</sort_order>
|
1144 |
+
<depends>
|
1145 |
+
<insurance>1</insurance>
|
1146 |
+
</depends>
|
1147 |
+
<show_in_default>1</show_in_default>
|
1148 |
+
<show_in_website>1</show_in_website>
|
1149 |
+
<show_in_store>1</show_in_store>
|
1150 |
+
</insurance_from>
|
1151 |
+
|
1152 |
+
<saturday_delivery translate="label,comment">
|
1153 |
+
<label>Saturday delivery</label>
|
1154 |
+
<frontend_type>select</frontend_type>
|
1155 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
1156 |
+
<sort_order>110</sort_order>
|
1157 |
+
<show_in_default>1</show_in_default>
|
1158 |
+
<show_in_website>1</show_in_website>
|
1159 |
+
<show_in_store>1</show_in_store>
|
1160 |
+
<comment><![CDATA[The parcel is delivered on Saturday if it is timely dropped in the bpost network.]]></comment>
|
1161 |
+
</saturday_delivery>
|
1162 |
+
|
1163 |
+
<saturday_delivery_from translate="label">
|
1164 |
+
<label>.. as from</label>
|
1165 |
+
<frontend_type>text</frontend_type>
|
1166 |
+
<sort_order>120</sort_order>
|
1167 |
+
<depends>
|
1168 |
+
<saturday_delivery>1</saturday_delivery>
|
1169 |
+
</depends>
|
1170 |
+
<show_in_default>1</show_in_default>
|
1171 |
+
<show_in_website>1</show_in_website>
|
1172 |
+
<show_in_store>1</show_in_store>
|
1173 |
+
</saturday_delivery_from>
|
1174 |
+
</fields>
|
1175 |
+
</bpost_parcellocker>
|
1176 |
+
<bpost_clickcollect translate="label" module="bpost_shm">
|
1177 |
+
<label><![CDATA[bpost Click & Collect]]></label>
|
1178 |
+
<frontend_type>text</frontend_type>
|
1179 |
+
<sort_order>90</sort_order>
|
1180 |
+
<show_in_default>1</show_in_default>
|
1181 |
+
<show_in_website>1</show_in_website>
|
1182 |
+
<show_in_store>1</show_in_store>
|
1183 |
+
<fields>
|
1184 |
+
<logo translate="label">
|
1185 |
+
<label>Logo</label>
|
1186 |
+
<frontend_type>text</frontend_type>
|
1187 |
+
<frontend_model>bpost_shm/adminhtml_system_config_form_field_logo</frontend_model>
|
1188 |
+
<sort_order>0</sort_order>
|
1189 |
+
<show_in_default>1</show_in_default>
|
1190 |
+
<show_in_website>1</show_in_website>
|
1191 |
+
<show_in_store>1</show_in_store>
|
1192 |
+
</logo>
|
1193 |
+
|
1194 |
+
<clickcollect_info>
|
1195 |
+
<label>clickcollectinfo</label>
|
1196 |
+
<frontend_type>text</frontend_type>
|
1197 |
+
<frontend_model>bpost_shm/adminhtml_system_config_form_field_clickcollect</frontend_model>
|
1198 |
+
<sort_order>1</sort_order>
|
1199 |
+
<show_in_default>1</show_in_default>
|
1200 |
+
<show_in_website>1</show_in_website>
|
1201 |
+
<show_in_store>1</show_in_store>
|
1202 |
+
<depends>
|
1203 |
+
<activated>0</activated>
|
1204 |
+
</depends>
|
1205 |
+
</clickcollect_info>
|
1206 |
+
|
1207 |
+
<clickcollect_cache_info>
|
1208 |
+
<label>clickcollectcacheinfo</label>
|
1209 |
+
<frontend_type>text</frontend_type>
|
1210 |
+
<frontend_model>bpost_shm/adminhtml_system_config_form_field_cacheinfo</frontend_model>
|
1211 |
+
<sort_order>1</sort_order>
|
1212 |
+
<show_in_default>1</show_in_default>
|
1213 |
+
<show_in_website>1</show_in_website>
|
1214 |
+
<show_in_store>1</show_in_store>
|
1215 |
+
<depends>
|
1216 |
+
<activated>1</activated>
|
1217 |
+
</depends>
|
1218 |
+
</clickcollect_cache_info>
|
1219 |
+
|
1220 |
+
<subheader_general translate="label">
|
1221 |
+
<label>General</label>
|
1222 |
+
<frontend_type>text</frontend_type>
|
1223 |
+
<frontend_model>bpost_shm/adminhtml_system_config_form_field_subheader</frontend_model>
|
1224 |
+
<sort_order>5</sort_order>
|
1225 |
+
<show_in_default>1</show_in_default>
|
1226 |
+
<show_in_website>1</show_in_website>
|
1227 |
+
<show_in_store>1</show_in_store>
|
1228 |
+
<depends>
|
1229 |
+
<activated>1</activated>
|
1230 |
+
</depends>
|
1231 |
+
</subheader_general>
|
1232 |
+
|
1233 |
+
<active translate="label,comment">
|
1234 |
+
<label>Enabled</label>
|
1235 |
+
<frontend_type>select</frontend_type>
|
1236 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
1237 |
+
<sort_order>10</sort_order>
|
1238 |
+
<show_in_default>1</show_in_default>
|
1239 |
+
<show_in_website>1</show_in_website>
|
1240 |
+
<show_in_store>1</show_in_store>
|
1241 |
+
<comment><![CDATA[]]></comment>
|
1242 |
+
<depends>
|
1243 |
+
<activated>1</activated>
|
1244 |
+
</depends>
|
1245 |
+
</active>
|
1246 |
+
|
1247 |
+
<marker translate="label,comment">
|
1248 |
+
<label>Logo</label>
|
1249 |
+
<frontend_type>image</frontend_type>
|
1250 |
+
<backend_model>adminhtml/system_config_backend_image</backend_model>
|
1251 |
+
<upload_dir config="system/filesystem/media" scope_info="1">bpost</upload_dir>
|
1252 |
+
<base_url type="media" scope_info="1">bpost</base_url>
|
1253 |
+
<sort_order>11</sort_order>
|
1254 |
+
<show_in_default>1</show_in_default>
|
1255 |
+
<show_in_website>1</show_in_website>
|
1256 |
+
<show_in_store>1</show_in_store>
|
1257 |
+
<depends>
|
1258 |
+
<activated>1</activated>
|
1259 |
+
</depends>
|
1260 |
+
<comment><![CDATA[Upload a custom map marker (18x18 px)]]></comment>
|
1261 |
+
</marker>
|
1262 |
+
|
1263 |
+
<subheader_rates translate="label">
|
1264 |
+
<label>Rates</label>
|
1265 |
+
<frontend_type>text</frontend_type>
|
1266 |
+
<frontend_model>bpost_shm/adminhtml_system_config_form_field_subheader</frontend_model>
|
1267 |
+
<sort_order>15</sort_order>
|
1268 |
+
<show_in_default>1</show_in_default>
|
1269 |
+
<show_in_website>1</show_in_website>
|
1270 |
+
<show_in_store>1</show_in_store>
|
1271 |
+
<depends>
|
1272 |
+
<activated>1</activated>
|
1273 |
+
</depends>
|
1274 |
+
</subheader_rates>
|
1275 |
+
|
1276 |
+
<free_shipping translate="label,comment">
|
1277 |
+
<label>Free shipping</label>
|
1278 |
+
<frontend_type>select</frontend_type>
|
1279 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
1280 |
+
<sort_order>20</sort_order>
|
1281 |
+
<show_in_default>1</show_in_default>
|
1282 |
+
<show_in_website>1</show_in_website>
|
1283 |
+
<show_in_store>1</show_in_store>
|
1284 |
+
<depends>
|
1285 |
+
<activated>1</activated>
|
1286 |
+
</depends>
|
1287 |
+
<comment><![CDATA[Allow free shipping]]></comment>
|
1288 |
+
</free_shipping>
|
1289 |
+
|
1290 |
+
<free_shipping_from translate="label,comment">
|
1291 |
+
<label>.. as of</label>
|
1292 |
+
<frontend_type>text</frontend_type>
|
1293 |
+
<sort_order>30</sort_order>
|
1294 |
+
<depends>
|
1295 |
+
<free_shipping>1</free_shipping>
|
1296 |
+
<activated>1</activated>
|
1297 |
+
</depends>
|
1298 |
+
<show_in_default>1</show_in_default>
|
1299 |
+
<show_in_website>1</show_in_website>
|
1300 |
+
<show_in_store>1</show_in_store>
|
1301 |
+
<comment><![CDATA[Free shipping will be applied as from a minimum amount]]></comment>
|
1302 |
+
</free_shipping_from>
|
1303 |
+
|
1304 |
+
<rate_type translate="label,comment,tooltip">
|
1305 |
+
<label>Rate type</label>
|
1306 |
+
<frontend_type>select</frontend_type>
|
1307 |
+
<source_model>bpost_shm/system_config_source_ratetypes</source_model>
|
1308 |
+
<sort_order>40</sort_order>
|
1309 |
+
<show_in_default>1</show_in_default>
|
1310 |
+
<show_in_website>1</show_in_website>
|
1311 |
+
<show_in_store>1</show_in_store>
|
1312 |
+
<depends>
|
1313 |
+
<activated>1</activated>
|
1314 |
+
</depends>
|
1315 |
+
<comment><![CDATA[Choose your rate type (Flat rate or Table rate)]]></comment>
|
1316 |
+
<tooltip>Importing and exporting table rates only possible on website scope. View the documentation for more information.</tooltip>
|
1317 |
+
</rate_type>
|
1318 |
+
|
1319 |
+
<flat_rate_price translate="label,comment">
|
1320 |
+
<label>Flat rate price</label>
|
1321 |
+
<frontend_type>text</frontend_type>
|
1322 |
+
<sort_order>50</sort_order>
|
1323 |
+
<depends>
|
1324 |
+
<rate_type>0</rate_type>
|
1325 |
+
<activated>1</activated>
|
1326 |
+
</depends>
|
1327 |
+
<show_in_default>1</show_in_default>
|
1328 |
+
<show_in_website>1</show_in_website>
|
1329 |
+
<show_in_store>1</show_in_store>
|
1330 |
+
<comment><![CDATA[Fixed fee for bpost Click & Collect shipments, e.g.: 4.95.]]></comment>
|
1331 |
+
</flat_rate_price>
|
1332 |
+
|
1333 |
+
<condition_name translate="label">
|
1334 |
+
<label>Table rates condition</label>
|
1335 |
+
<frontend_type>select</frontend_type>
|
1336 |
+
<source_model>adminhtml/system_config_source_shipping_tablerate</source_model>
|
1337 |
+
<sort_order>60</sort_order>
|
1338 |
+
<depends>
|
1339 |
+
<rate_type>1</rate_type>
|
1340 |
+
<activated>1</activated>
|
1341 |
+
</depends>
|
1342 |
+
<show_in_default>1</show_in_default>
|
1343 |
+
<show_in_website>1</show_in_website>
|
1344 |
+
<show_in_store>0</show_in_store>
|
1345 |
+
</condition_name>
|
1346 |
+
|
1347 |
+
<export translate="label,comment">
|
1348 |
+
<label>Export table rates file</label>
|
1349 |
+
<frontend_type>button</frontend_type>
|
1350 |
+
<frontend_model>bpost_shm/adminhtml_system_config_form_tablerates_export_clickcollect</frontend_model>
|
1351 |
+
<sort_order>70</sort_order>
|
1352 |
+
<depends>
|
1353 |
+
<rate_type>1</rate_type>
|
1354 |
+
<activated>1</activated>
|
1355 |
+
</depends>
|
1356 |
+
<show_in_default>0</show_in_default>
|
1357 |
+
<show_in_website>1</show_in_website>
|
1358 |
+
<show_in_store>0</show_in_store>
|
1359 |
+
<comment><![CDATA[Export your table rates configuration here.]]></comment>
|
1360 |
+
</export>
|
1361 |
+
|
1362 |
+
<import_clickcollect translate="label,comment">
|
1363 |
+
<label>Import table rates file</label>
|
1364 |
+
<frontend_type>import</frontend_type>
|
1365 |
+
<sort_order>80</sort_order>
|
1366 |
+
<backend_model>bpost_shm/adminhtml_system_config_backend_shipping_tablerates_clickcollect</backend_model>
|
1367 |
+
<depends>
|
1368 |
+
<rate_type>1</rate_type>
|
1369 |
+
<activated>1</activated>
|
1370 |
+
</depends>
|
1371 |
+
<show_in_default>0</show_in_default>
|
1372 |
+
<show_in_website>1</show_in_website>
|
1373 |
+
<show_in_store>0</show_in_store>
|
1374 |
+
<comment><![CDATA[Upload your table rates configuration here. Refer to the manual for more information.]]></comment>
|
1375 |
+
</import_clickcollect>
|
1376 |
+
|
1377 |
+
<subheader_options translate="label">
|
1378 |
+
<label>Options</label>
|
1379 |
+
<frontend_type>text</frontend_type>
|
1380 |
+
<frontend_model>bpost_shm/adminhtml_system_config_form_field_subheader</frontend_model>
|
1381 |
+
<sort_order>85</sort_order>
|
1382 |
+
<show_in_default>1</show_in_default>
|
1383 |
+
<show_in_website>1</show_in_website>
|
1384 |
+
<show_in_store>1</show_in_store>
|
1385 |
+
<depends>
|
1386 |
+
<activated>1</activated>
|
1387 |
+
</depends>
|
1388 |
+
</subheader_options>
|
1389 |
+
|
1390 |
+
<insurance translate="label,comment">
|
1391 |
+
<label>Insurance</label>
|
1392 |
+
<frontend_type>select</frontend_type>
|
1393 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
1394 |
+
<sort_order>90</sort_order>
|
1395 |
+
<show_in_default>1</show_in_default>
|
1396 |
+
<show_in_website>1</show_in_website>
|
1397 |
+
<show_in_store>1</show_in_store>
|
1398 |
+
<depends>
|
1399 |
+
<activated>1</activated>
|
1400 |
+
</depends>
|
1401 |
+
<comment><![CDATA[Insurance to insure your goods to a maximum of 500,00 euro.]]></comment>
|
1402 |
+
</insurance>
|
1403 |
+
|
1404 |
+
<insurance_from translate="label">
|
1405 |
+
<label>.. as from</label>
|
1406 |
+
<frontend_type>text</frontend_type>
|
1407 |
+
<sort_order>100</sort_order>
|
1408 |
+
<depends>
|
1409 |
+
<insurance>1</insurance>
|
1410 |
+
<activated>1</activated>
|
1411 |
+
</depends>
|
1412 |
+
<show_in_default>1</show_in_default>
|
1413 |
+
<show_in_website>1</show_in_website>
|
1414 |
+
<show_in_store>1</show_in_store>
|
1415 |
+
</insurance_from>
|
1416 |
+
|
1417 |
+
<saturday_delivery translate="label,comment">
|
1418 |
+
<label>Saturday delivery</label>
|
1419 |
+
<frontend_type>select</frontend_type>
|
1420 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
1421 |
+
<sort_order>110</sort_order>
|
1422 |
+
<show_in_default>1</show_in_default>
|
1423 |
+
<show_in_website>1</show_in_website>
|
1424 |
+
<show_in_store>1</show_in_store>
|
1425 |
+
<comment><![CDATA[The parcel is delivered on Saturday if it is timely dropped in the bpost network.]]></comment>
|
1426 |
+
<depends>
|
1427 |
+
<activated>1</activated>
|
1428 |
+
</depends>
|
1429 |
+
</saturday_delivery>
|
1430 |
+
|
1431 |
+
<saturday_delivery_from translate="label">
|
1432 |
+
<label>.. as from</label>
|
1433 |
+
<frontend_type>text</frontend_type>
|
1434 |
+
<sort_order>120</sort_order>
|
1435 |
+
<depends>
|
1436 |
+
<saturday_delivery>1</saturday_delivery>
|
1437 |
+
<activated>1</activated>
|
1438 |
+
</depends>
|
1439 |
+
<show_in_default>1</show_in_default>
|
1440 |
+
<show_in_website>1</show_in_website>
|
1441 |
+
<show_in_store>1</show_in_store>
|
1442 |
+
</saturday_delivery_from>
|
1443 |
+
</fields>
|
1444 |
+
</bpost_clickcollect>
|
1445 |
+
</groups>
|
1446 |
+
</carriers>
|
1447 |
+
</sections>
|
1448 |
</config>
|
app/code/community/Bpost/ShM/sql/bpost_shm_setup/install-0.0.1.php
CHANGED
@@ -1,30 +1,30 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Created by PHPro
|
4 |
-
*
|
5 |
-
* @package Bpost
|
6 |
-
* @subpackage ShM
|
7 |
-
* @category Checkout
|
8 |
-
* @author PHPro (info@phpro.be)
|
9 |
-
*/
|
10 |
-
|
11 |
-
if (!Mage::helper('core')->isModuleEnabled('Bpost_ShippingManager')) {
|
12 |
-
$installer = $this;
|
13 |
-
$installer->startSetup();
|
14 |
-
|
15 |
-
$installer->run("CREATE TABLE IF NOT EXISTS {$installer->getTable('bpost_tablerates_homedelivery')} (
|
16 |
-
`pk` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Primary key',
|
17 |
-
`website_id` int(11) NOT NULL DEFAULT '0' COMMENT 'Website Id',
|
18 |
-
`dest_country_id` varchar(4) NOT NULL DEFAULT '0' COMMENT 'Destination coutry ISO/2 or ISO/3 code',
|
19 |
-
`dest_region_id` int(11) NOT NULL DEFAULT '0' COMMENT 'Destination Region Id',
|
20 |
-
`dest_zip` varchar(10) NOT NULL DEFAULT '*' COMMENT 'Destination Post Code (Zip)',
|
21 |
-
`condition_name` varchar(20) NOT NULL COMMENT 'Rate Condition name',
|
22 |
-
`condition_value` decimal(12,4) NOT NULL DEFAULT '0.0000' COMMENT 'Rate condition value',
|
23 |
-
`price` decimal(12,4) NOT NULL DEFAULT '0.0000' COMMENT 'Price',
|
24 |
-
`cost` decimal(12,4) NOT NULL DEFAULT '0.0000' COMMENT 'Cost',
|
25 |
-
PRIMARY KEY (`pk`),
|
26 |
-
UNIQUE KEY `1sSnI1YRZBOJVxazlZlG4UQOe9JFMNOcz9b` (`website_id`,`dest_country_id`,`dest_region_id`,`dest_zip`,`condition_name`,`condition_value`)
|
27 |
-
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Bpost Homedelivery Tablerate'");
|
28 |
-
|
29 |
-
$installer->endSetup();
|
30 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Created by PHPro
|
4 |
+
*
|
5 |
+
* @package Bpost
|
6 |
+
* @subpackage ShM
|
7 |
+
* @category Checkout
|
8 |
+
* @author PHPro (info@phpro.be)
|
9 |
+
*/
|
10 |
+
|
11 |
+
if (!Mage::helper('core')->isModuleEnabled('Bpost_ShippingManager')) {
|
12 |
+
$installer = $this;
|
13 |
+
$installer->startSetup();
|
14 |
+
|
15 |
+
$installer->run("CREATE TABLE IF NOT EXISTS {$installer->getTable('bpost_tablerates_homedelivery')} (
|
16 |
+
`pk` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Primary key',
|
17 |
+
`website_id` int(11) NOT NULL DEFAULT '0' COMMENT 'Website Id',
|
18 |
+
`dest_country_id` varchar(4) NOT NULL DEFAULT '0' COMMENT 'Destination coutry ISO/2 or ISO/3 code',
|
19 |
+
`dest_region_id` int(11) NOT NULL DEFAULT '0' COMMENT 'Destination Region Id',
|
20 |
+
`dest_zip` varchar(10) NOT NULL DEFAULT '*' COMMENT 'Destination Post Code (Zip)',
|
21 |
+
`condition_name` varchar(20) NOT NULL COMMENT 'Rate Condition name',
|
22 |
+
`condition_value` decimal(12,4) NOT NULL DEFAULT '0.0000' COMMENT 'Rate condition value',
|
23 |
+
`price` decimal(12,4) NOT NULL DEFAULT '0.0000' COMMENT 'Price',
|
24 |
+
`cost` decimal(12,4) NOT NULL DEFAULT '0.0000' COMMENT 'Cost',
|
25 |
+
PRIMARY KEY (`pk`),
|
26 |
+
UNIQUE KEY `1sSnI1YRZBOJVxazlZlG4UQOe9JFMNOcz9b` (`website_id`,`dest_country_id`,`dest_region_id`,`dest_zip`,`condition_name`,`condition_value`)
|
27 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Bpost Homedelivery Tablerate'");
|
28 |
+
|
29 |
+
$installer->endSetup();
|
30 |
}
|
app/code/community/Bpost/ShM/sql/bpost_shm_setup/upgrade-0.0.1-0.0.2.php
CHANGED
@@ -1,27 +1,27 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Created by PHPro
|
4 |
-
*
|
5 |
-
* @package Bpost
|
6 |
-
* @subpackage ShM
|
7 |
-
* @category Checkout
|
8 |
-
* @author PHPro (info@phpro.be)
|
9 |
-
*/
|
10 |
-
if (!Mage::helper('core')->isModuleEnabled('Bpost_ShippingManager')) {
|
11 |
-
$installer = $this;
|
12 |
-
$installer->startSetup();
|
13 |
-
$installer->run("CREATE TABLE IF NOT EXISTS {$installer->getTable('bpost_tablerates_international')} (
|
14 |
-
`pk` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Primary key',
|
15 |
-
`website_id` int(11) NOT NULL DEFAULT '0' COMMENT 'Website Id',
|
16 |
-
`dest_country_id` varchar(4) NOT NULL DEFAULT '0' COMMENT 'Destination coutry ISO/2 or ISO/3 code',
|
17 |
-
`dest_region_id` int(11) NOT NULL DEFAULT '0' COMMENT 'Destination Region Id',
|
18 |
-
`dest_zip` varchar(10) NOT NULL DEFAULT '*' COMMENT 'Destination Post Code (Zip)',
|
19 |
-
`condition_name` varchar(20) NOT NULL COMMENT 'Rate Condition name',
|
20 |
-
`condition_value` decimal(12,4) NOT NULL DEFAULT '0.0000' COMMENT 'Rate condition value',
|
21 |
-
`price` decimal(12,4) NOT NULL DEFAULT '0.0000' COMMENT 'Price',
|
22 |
-
`cost` decimal(12,4) NOT NULL DEFAULT '0.0000' COMMENT 'Cost',
|
23 |
-
PRIMARY KEY (`pk`),
|
24 |
-
UNIQUE KEY `Ig6Km9sdgz94pqcZJIn6S8mQWTIdQ3O3E01` (`website_id`,`dest_country_id`,`dest_region_id`,`dest_zip`,`condition_name`,`condition_value`)
|
25 |
-
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Bpost International Tablerate'");
|
26 |
-
$installer->endSetup();
|
27 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Created by PHPro
|
4 |
+
*
|
5 |
+
* @package Bpost
|
6 |
+
* @subpackage ShM
|
7 |
+
* @category Checkout
|
8 |
+
* @author PHPro (info@phpro.be)
|
9 |
+
*/
|
10 |
+
if (!Mage::helper('core')->isModuleEnabled('Bpost_ShippingManager')) {
|
11 |
+
$installer = $this;
|
12 |
+
$installer->startSetup();
|
13 |
+
$installer->run("CREATE TABLE IF NOT EXISTS {$installer->getTable('bpost_tablerates_international')} (
|
14 |
+
`pk` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Primary key',
|
15 |
+
`website_id` int(11) NOT NULL DEFAULT '0' COMMENT 'Website Id',
|
16 |
+
`dest_country_id` varchar(4) NOT NULL DEFAULT '0' COMMENT 'Destination coutry ISO/2 or ISO/3 code',
|
17 |
+
`dest_region_id` int(11) NOT NULL DEFAULT '0' COMMENT 'Destination Region Id',
|
18 |
+
`dest_zip` varchar(10) NOT NULL DEFAULT '*' COMMENT 'Destination Post Code (Zip)',
|
19 |
+
`condition_name` varchar(20) NOT NULL COMMENT 'Rate Condition name',
|
20 |
+
`condition_value` decimal(12,4) NOT NULL DEFAULT '0.0000' COMMENT 'Rate condition value',
|
21 |
+
`price` decimal(12,4) NOT NULL DEFAULT '0.0000' COMMENT 'Price',
|
22 |
+
`cost` decimal(12,4) NOT NULL DEFAULT '0.0000' COMMENT 'Cost',
|
23 |
+
PRIMARY KEY (`pk`),
|
24 |
+
UNIQUE KEY `Ig6Km9sdgz94pqcZJIn6S8mQWTIdQ3O3E01` (`website_id`,`dest_country_id`,`dest_region_id`,`dest_zip`,`condition_name`,`condition_value`)
|
25 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Bpost International Tablerate'");
|
26 |
+
$installer->endSetup();
|
27 |
}
|
app/code/community/Bpost/ShM/sql/bpost_shm_setup/upgrade-0.0.10-0.1.0.php
CHANGED
@@ -1,18 +1,18 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Created by PHPro
|
4 |
-
*
|
5 |
-
* @subpackage Shipping
|
6 |
-
* @category Checkout
|
7 |
-
* @author PHPro (info@phpro.be)
|
8 |
-
*/
|
9 |
-
|
10 |
-
if (!Mage::helper('core')->isModuleEnabled('Bpost_ShippingManager')) {
|
11 |
-
/* @var $installer Mage_Core_Model_Resource_Setup */
|
12 |
-
$installer = $this;
|
13 |
-
$installer->startSetup();
|
14 |
-
|
15 |
-
$installer->getConnection()->addColumn($installer->getTable('sales/shipment_grid'), 'bpost_status', "varchar(255) null default ''");
|
16 |
-
|
17 |
-
$installer->endSetup();
|
18 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Created by PHPro
|
4 |
+
*
|
5 |
+
* @subpackage Shipping
|
6 |
+
* @category Checkout
|
7 |
+
* @author PHPro (info@phpro.be)
|
8 |
+
*/
|
9 |
+
|
10 |
+
if (!Mage::helper('core')->isModuleEnabled('Bpost_ShippingManager')) {
|
11 |
+
/* @var $installer Mage_Core_Model_Resource_Setup */
|
12 |
+
$installer = $this;
|
13 |
+
$installer->startSetup();
|
14 |
+
|
15 |
+
$installer->getConnection()->addColumn($installer->getTable('sales/shipment_grid'), 'bpost_status', "varchar(255) null default ''");
|
16 |
+
|
17 |
+
$installer->endSetup();
|
18 |
}
|
app/code/community/Bpost/ShM/sql/bpost_shm_setup/upgrade-0.0.2-0.0.3.php
CHANGED
@@ -1,27 +1,27 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Created by PHPro
|
4 |
-
*
|
5 |
-
* @package Bpost
|
6 |
-
* @subpackage ShM
|
7 |
-
* @category Checkout
|
8 |
-
* @author PHPro (info@phpro.be)
|
9 |
-
*/
|
10 |
-
if (!Mage::helper('core')->isModuleEnabled('Bpost_ShippingManager')) {
|
11 |
-
$installer = $this;
|
12 |
-
$installer->startSetup();
|
13 |
-
$installer->run("CREATE TABLE IF NOT EXISTS {$installer->getTable('bpost_tablerates_pickuppoint')} (
|
14 |
-
`pk` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Primary key',
|
15 |
-
`website_id` int(11) NOT NULL DEFAULT '0' COMMENT 'Website Id',
|
16 |
-
`dest_country_id` varchar(4) NOT NULL DEFAULT '0' COMMENT 'Destination coutry ISO/2 or ISO/3 code',
|
17 |
-
`dest_region_id` int(11) NOT NULL DEFAULT '0' COMMENT 'Destination Region Id',
|
18 |
-
`dest_zip` varchar(10) NOT NULL DEFAULT '*' COMMENT 'Destination Post Code (Zip)',
|
19 |
-
`condition_name` varchar(20) NOT NULL COMMENT 'Rate Condition name',
|
20 |
-
`condition_value` decimal(12,4) NOT NULL DEFAULT '0.0000' COMMENT 'Rate condition value',
|
21 |
-
`price` decimal(12,4) NOT NULL DEFAULT '0.0000' COMMENT 'Price',
|
22 |
-
`cost` decimal(12,4) NOT NULL DEFAULT '0.0000' COMMENT 'Cost',
|
23 |
-
PRIMARY KEY (`pk`),
|
24 |
-
UNIQUE KEY `QIMuM8yoQUkmjsNM6FmJFjBrOZHNJAEu8kP` (`website_id`,`dest_country_id`,`dest_region_id`,`dest_zip`,`condition_name`,`condition_value`)
|
25 |
-
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Bpost Pickuppoint Tablerate'");
|
26 |
-
$installer->endSetup();
|
27 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Created by PHPro
|
4 |
+
*
|
5 |
+
* @package Bpost
|
6 |
+
* @subpackage ShM
|
7 |
+
* @category Checkout
|
8 |
+
* @author PHPro (info@phpro.be)
|
9 |
+
*/
|
10 |
+
if (!Mage::helper('core')->isModuleEnabled('Bpost_ShippingManager')) {
|
11 |
+
$installer = $this;
|
12 |
+
$installer->startSetup();
|
13 |
+
$installer->run("CREATE TABLE IF NOT EXISTS {$installer->getTable('bpost_tablerates_pickuppoint')} (
|
14 |
+
`pk` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Primary key',
|
15 |
+
`website_id` int(11) NOT NULL DEFAULT '0' COMMENT 'Website Id',
|
16 |
+
`dest_country_id` varchar(4) NOT NULL DEFAULT '0' COMMENT 'Destination coutry ISO/2 or ISO/3 code',
|
17 |
+
`dest_region_id` int(11) NOT NULL DEFAULT '0' COMMENT 'Destination Region Id',
|
18 |
+
`dest_zip` varchar(10) NOT NULL DEFAULT '*' COMMENT 'Destination Post Code (Zip)',
|
19 |
+
`condition_name` varchar(20) NOT NULL COMMENT 'Rate Condition name',
|
20 |
+
`condition_value` decimal(12,4) NOT NULL DEFAULT '0.0000' COMMENT 'Rate condition value',
|
21 |
+
`price` decimal(12,4) NOT NULL DEFAULT '0.0000' COMMENT 'Price',
|
22 |
+
`cost` decimal(12,4) NOT NULL DEFAULT '0.0000' COMMENT 'Cost',
|
23 |
+
PRIMARY KEY (`pk`),
|
24 |
+
UNIQUE KEY `QIMuM8yoQUkmjsNM6FmJFjBrOZHNJAEu8kP` (`website_id`,`dest_country_id`,`dest_region_id`,`dest_zip`,`condition_name`,`condition_value`)
|
25 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Bpost Pickuppoint Tablerate'");
|
26 |
+
$installer->endSetup();
|
27 |
}
|
app/code/community/Bpost/ShM/sql/bpost_shm_setup/upgrade-0.0.3-0.0.4.php
CHANGED
@@ -1,36 +1,36 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Created by PHPro
|
4 |
-
*
|
5 |
-
* @package Bpost
|
6 |
-
* @subpackage ShM
|
7 |
-
* @category Checkout
|
8 |
-
* @author PHPro (info@phpro.be)
|
9 |
-
*/
|
10 |
-
if(!Mage::helper('core')->isModuleEnabled('Bpost_ShippingManager')){
|
11 |
-
$installer = $this;
|
12 |
-
$installer->startSetup();
|
13 |
-
$installer->run("CREATE TABLE IF NOT EXISTS {$installer->getTable('bpost_tablerates_parcellocker')} (
|
14 |
-
`pk` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Primary key',
|
15 |
-
`website_id` int(11) NOT NULL DEFAULT '0' COMMENT 'Website Id',
|
16 |
-
`dest_country_id` varchar(4) NOT NULL DEFAULT '0' COMMENT 'Destination coutry ISO/2 or ISO/3 code',
|
17 |
-
`dest_region_id` int(11) NOT NULL DEFAULT '0' COMMENT 'Destination Region Id',
|
18 |
-
`dest_zip` varchar(10) NOT NULL DEFAULT '*' COMMENT 'Destination Post Code (Zip)',
|
19 |
-
`condition_name` varchar(20) NOT NULL COMMENT 'Rate Condition name',
|
20 |
-
`condition_value` decimal(12,4) NOT NULL DEFAULT '0.0000' COMMENT 'Rate condition value',
|
21 |
-
`price` decimal(12,4) NOT NULL DEFAULT '0.0000' COMMENT 'Price',
|
22 |
-
`cost` decimal(12,4) NOT NULL DEFAULT '0.0000' COMMENT 'Cost',
|
23 |
-
PRIMARY KEY (`pk`),
|
24 |
-
UNIQUE KEY `pnHi2GLMpOEktcG4ZpVdrOImXhJkq3bwjKd` (`website_id`,`dest_country_id`,`dest_region_id`,`dest_zip`,`condition_name`,`condition_value`)
|
25 |
-
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Bpost Parcel Locker Tablerate'");
|
26 |
-
$installer->endSetup();
|
27 |
-
}
|
28 |
-
else{
|
29 |
-
$popupTitle = Mage::helper('bpost_shm')->__('A previous version of the bpost extension was detected!');
|
30 |
-
$popupMessage = Mage::helper('bpost_shm')->__('Please remove or disable the old bpost extension prior to the installation of the new one.');
|
31 |
-
Mage::getModel('adminnotification/inbox')->add('4', $popupTitle . ' ' . $popupMessage, '', '', true);
|
32 |
-
$installer = $this;
|
33 |
-
$installer->startSetup();
|
34 |
-
$installer->run("DELETE from {$installer->getTable('core_resource')} where code='bpost_shm_setup';");
|
35 |
-
$installer->endSetup();
|
36 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Created by PHPro
|
4 |
+
*
|
5 |
+
* @package Bpost
|
6 |
+
* @subpackage ShM
|
7 |
+
* @category Checkout
|
8 |
+
* @author PHPro (info@phpro.be)
|
9 |
+
*/
|
10 |
+
if(!Mage::helper('core')->isModuleEnabled('Bpost_ShippingManager')){
|
11 |
+
$installer = $this;
|
12 |
+
$installer->startSetup();
|
13 |
+
$installer->run("CREATE TABLE IF NOT EXISTS {$installer->getTable('bpost_tablerates_parcellocker')} (
|
14 |
+
`pk` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Primary key',
|
15 |
+
`website_id` int(11) NOT NULL DEFAULT '0' COMMENT 'Website Id',
|
16 |
+
`dest_country_id` varchar(4) NOT NULL DEFAULT '0' COMMENT 'Destination coutry ISO/2 or ISO/3 code',
|
17 |
+
`dest_region_id` int(11) NOT NULL DEFAULT '0' COMMENT 'Destination Region Id',
|
18 |
+
`dest_zip` varchar(10) NOT NULL DEFAULT '*' COMMENT 'Destination Post Code (Zip)',
|
19 |
+
`condition_name` varchar(20) NOT NULL COMMENT 'Rate Condition name',
|
20 |
+
`condition_value` decimal(12,4) NOT NULL DEFAULT '0.0000' COMMENT 'Rate condition value',
|
21 |
+
`price` decimal(12,4) NOT NULL DEFAULT '0.0000' COMMENT 'Price',
|
22 |
+
`cost` decimal(12,4) NOT NULL DEFAULT '0.0000' COMMENT 'Cost',
|
23 |
+
PRIMARY KEY (`pk`),
|
24 |
+
UNIQUE KEY `pnHi2GLMpOEktcG4ZpVdrOImXhJkq3bwjKd` (`website_id`,`dest_country_id`,`dest_region_id`,`dest_zip`,`condition_name`,`condition_value`)
|
25 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Bpost Parcel Locker Tablerate'");
|
26 |
+
$installer->endSetup();
|
27 |
+
}
|
28 |
+
else{
|
29 |
+
$popupTitle = Mage::helper('bpost_shm')->__('A previous version of the bpost extension was detected!');
|
30 |
+
$popupMessage = Mage::helper('bpost_shm')->__('Please remove or disable the old bpost extension prior to the installation of the new one.');
|
31 |
+
Mage::getModel('adminnotification/inbox')->add('4', $popupTitle . ' ' . $popupMessage, '', '', true);
|
32 |
+
$installer = $this;
|
33 |
+
$installer->startSetup();
|
34 |
+
$installer->run("DELETE from {$installer->getTable('core_resource')} where code='bpost_shm_setup';");
|
35 |
+
$installer->endSetup();
|
36 |
}
|
app/code/community/Bpost/ShM/sql/bpost_shm_setup/upgrade-0.0.4-0.0.5.php
CHANGED
@@ -1,19 +1,19 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Created by PHPro
|
4 |
-
*
|
5 |
-
* @package Bpost
|
6 |
-
* @subpackage ShM
|
7 |
-
* @author PHPro (info@phpro.be)
|
8 |
-
*/
|
9 |
-
if (!Mage::helper('core')->isModuleEnabled('Bpost_ShippingManager')) {
|
10 |
-
$installer = $this;
|
11 |
-
$installer->startSetup();
|
12 |
-
$installer->getConnection()->addColumn($installer->getTable('sales/shipment'), 'bpost_label_exported', "int(11) null");
|
13 |
-
$installer->getConnection()->addColumn($installer->getTable('sales/shipment'), 'bpost_label_path', "varchar(255) null default ''");
|
14 |
-
$installer->getConnection()->addColumn($installer->getTable('sales/shipment'), 'bpost_tracking_url', "varchar(255) null default ''");
|
15 |
-
$installer->getConnection()->addColumn($installer->getTable('sales/order'), 'bpost_label_exported', "bool null default 0");
|
16 |
-
$installer->getConnection()->addColumn($installer->getTable('sales/order'), 'bpost_label_exists', "bool null default 0");
|
17 |
-
|
18 |
-
$installer->endSetup();
|
19 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Created by PHPro
|
4 |
+
*
|
5 |
+
* @package Bpost
|
6 |
+
* @subpackage ShM
|
7 |
+
* @author PHPro (info@phpro.be)
|
8 |
+
*/
|
9 |
+
if (!Mage::helper('core')->isModuleEnabled('Bpost_ShippingManager')) {
|
10 |
+
$installer = $this;
|
11 |
+
$installer->startSetup();
|
12 |
+
$installer->getConnection()->addColumn($installer->getTable('sales/shipment'), 'bpost_label_exported', "int(11) null");
|
13 |
+
$installer->getConnection()->addColumn($installer->getTable('sales/shipment'), 'bpost_label_path', "varchar(255) null default ''");
|
14 |
+
$installer->getConnection()->addColumn($installer->getTable('sales/shipment'), 'bpost_tracking_url', "varchar(255) null default ''");
|
15 |
+
$installer->getConnection()->addColumn($installer->getTable('sales/order'), 'bpost_label_exported', "bool null default 0");
|
16 |
+
$installer->getConnection()->addColumn($installer->getTable('sales/order'), 'bpost_label_exists', "bool null default 0");
|
17 |
+
|
18 |
+
$installer->endSetup();
|
19 |
+
}
|
app/code/community/Bpost/ShM/sql/bpost_shm_setup/upgrade-0.0.5-0.0.6.php
CHANGED
@@ -1,23 +1,23 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Created by PHPro
|
4 |
-
*
|
5 |
-
* @package Bpost
|
6 |
-
* @subpackage ShM
|
7 |
-
* @author PHPro (info@phpro.be)
|
8 |
-
*/
|
9 |
-
if (!Mage::helper('core')->isModuleEnabled('Bpost_ShippingManager')) {
|
10 |
-
$installer = $this;
|
11 |
-
$installer->startSetup();
|
12 |
-
|
13 |
-
$installer->getConnection()->addColumn($installer->getTable('sales/quote'), 'bpost_drop_date', "date null");
|
14 |
-
|
15 |
-
$installer->getConnection()->addColumn($installer->getTable('sales/shipment'), 'bpost_status', "varchar(255) null default ''");
|
16 |
-
$installer->getConnection()->addColumn($installer->getTable('sales/shipment'), 'bpost_shipment_automated', "bool null default 0");
|
17 |
-
|
18 |
-
$installer->getConnection()->addColumn($installer->getTable('sales/order'), 'bpost_drop_date', "date null");
|
19 |
-
$installer->getConnection()->addColumn($installer->getTable('sales/order'), 'bpost_status', "varchar(255) null default ''");
|
20 |
-
|
21 |
-
|
22 |
-
$installer->endSetup();
|
23 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Created by PHPro
|
4 |
+
*
|
5 |
+
* @package Bpost
|
6 |
+
* @subpackage ShM
|
7 |
+
* @author PHPro (info@phpro.be)
|
8 |
+
*/
|
9 |
+
if (!Mage::helper('core')->isModuleEnabled('Bpost_ShippingManager')) {
|
10 |
+
$installer = $this;
|
11 |
+
$installer->startSetup();
|
12 |
+
|
13 |
+
$installer->getConnection()->addColumn($installer->getTable('sales/quote'), 'bpost_drop_date', "date null");
|
14 |
+
|
15 |
+
$installer->getConnection()->addColumn($installer->getTable('sales/shipment'), 'bpost_status', "varchar(255) null default ''");
|
16 |
+
$installer->getConnection()->addColumn($installer->getTable('sales/shipment'), 'bpost_shipment_automated', "bool null default 0");
|
17 |
+
|
18 |
+
$installer->getConnection()->addColumn($installer->getTable('sales/order'), 'bpost_drop_date', "date null");
|
19 |
+
$installer->getConnection()->addColumn($installer->getTable('sales/order'), 'bpost_status', "varchar(255) null default ''");
|
20 |
+
|
21 |
+
|
22 |
+
$installer->endSetup();
|
23 |
+
}
|
app/code/community/Bpost/ShM/sql/bpost_shm_setup/upgrade-0.0.6-0.0.7.php
CHANGED
@@ -1,16 +1,16 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Created by PHPro
|
4 |
-
*
|
5 |
-
* @package Bpost
|
6 |
-
* @subpackage ShM
|
7 |
-
* @author PHPro (info@phpro.be)
|
8 |
-
*/
|
9 |
-
|
10 |
-
if (!Mage::helper('core')->isModuleEnabled('Bpost_ShippingManager')) {
|
11 |
-
$installer = $this;
|
12 |
-
$installer->startSetup();
|
13 |
-
$installer->getConnection()->addColumn($installer->getTable('sales/order'), 'bpost_return_label_exists', "bool null default 0");
|
14 |
-
|
15 |
-
$installer->endSetup();
|
16 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Created by PHPro
|
4 |
+
*
|
5 |
+
* @package Bpost
|
6 |
+
* @subpackage ShM
|
7 |
+
* @author PHPro (info@phpro.be)
|
8 |
+
*/
|
9 |
+
|
10 |
+
if (!Mage::helper('core')->isModuleEnabled('Bpost_ShippingManager')) {
|
11 |
+
$installer = $this;
|
12 |
+
$installer->startSetup();
|
13 |
+
$installer->getConnection()->addColumn($installer->getTable('sales/order'), 'bpost_return_label_exists', "bool null default 0");
|
14 |
+
|
15 |
+
$installer->endSetup();
|
16 |
+
}
|
app/code/community/Bpost/ShM/sql/bpost_shm_setup/upgrade-0.0.7-0.0.8.php
CHANGED
@@ -1,39 +1,39 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Created by PHPro
|
4 |
-
*
|
5 |
-
* @package Bpost
|
6 |
-
* @subpackage ShM
|
7 |
-
* @author PHPro (info@phpro.be)
|
8 |
-
*/
|
9 |
-
|
10 |
-
if (!Mage::helper('core')->isModuleEnabled('Bpost_ShippingManager')) {
|
11 |
-
|
12 |
-
$installer = $this;
|
13 |
-
$installer->startSetup();
|
14 |
-
|
15 |
-
//create the return label table
|
16 |
-
$tableReturnLabel = $installer->getConnection()->newTable($installer->getTable('bpost_shm/returnlabel'))
|
17 |
-
->addColumn('label_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
18 |
-
'unsigned' => true,
|
19 |
-
'nullable' => false,
|
20 |
-
'primary' => true,
|
21 |
-
'identity' => true,
|
22 |
-
), 'Label unique ID')
|
23 |
-
->addColumn('label_barcode', Varien_Db_Ddl_Table::TYPE_VARCHAR, 255, array(
|
24 |
-
'nullable' => false,
|
25 |
-
'default' => "",
|
26 |
-
), "Barcode of the Label")
|
27 |
-
->addColumn('label_pdf_path', Varien_Db_Ddl_Table::TYPE_VARCHAR, 255, array(
|
28 |
-
'nullable' => false,
|
29 |
-
), "Local path of the pdf file")
|
30 |
-
->addColumn('order_id', Varien_Db_Ddl_Table::TYPE_INTEGER, 11, array(
|
31 |
-
'nullable' => false,
|
32 |
-
), "Id of the order")
|
33 |
-
->addColumn('date_created', Varien_Db_Ddl_Table::TYPE_DATETIME, null, array(), 'Creation Date')
|
34 |
-
->setComment('bpost Shipping Return Labels');
|
35 |
-
$installer->getConnection()->createTable($tableReturnLabel);
|
36 |
-
|
37 |
-
$installer->endSetup();
|
38 |
-
|
39 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Created by PHPro
|
4 |
+
*
|
5 |
+
* @package Bpost
|
6 |
+
* @subpackage ShM
|
7 |
+
* @author PHPro (info@phpro.be)
|
8 |
+
*/
|
9 |
+
|
10 |
+
if (!Mage::helper('core')->isModuleEnabled('Bpost_ShippingManager')) {
|
11 |
+
|
12 |
+
$installer = $this;
|
13 |
+
$installer->startSetup();
|
14 |
+
|
15 |
+
//create the return label table
|
16 |
+
$tableReturnLabel = $installer->getConnection()->newTable($installer->getTable('bpost_shm/returnlabel'))
|
17 |
+
->addColumn('label_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
18 |
+
'unsigned' => true,
|
19 |
+
'nullable' => false,
|
20 |
+
'primary' => true,
|
21 |
+
'identity' => true,
|
22 |
+
), 'Label unique ID')
|
23 |
+
->addColumn('label_barcode', Varien_Db_Ddl_Table::TYPE_VARCHAR, 255, array(
|
24 |
+
'nullable' => false,
|
25 |
+
'default' => "",
|
26 |
+
), "Barcode of the Label")
|
27 |
+
->addColumn('label_pdf_path', Varien_Db_Ddl_Table::TYPE_VARCHAR, 255, array(
|
28 |
+
'nullable' => false,
|
29 |
+
), "Local path of the pdf file")
|
30 |
+
->addColumn('order_id', Varien_Db_Ddl_Table::TYPE_INTEGER, 11, array(
|
31 |
+
'nullable' => false,
|
32 |
+
), "Id of the order")
|
33 |
+
->addColumn('date_created', Varien_Db_Ddl_Table::TYPE_DATETIME, null, array(), 'Creation Date')
|
34 |
+
->setComment('bpost Shipping Return Labels');
|
35 |
+
$installer->getConnection()->createTable($tableReturnLabel);
|
36 |
+
|
37 |
+
$installer->endSetup();
|
38 |
+
|
39 |
}
|
app/code/community/Bpost/ShM/sql/bpost_shm_setup/upgrade-0.0.8-0.0.9.php
CHANGED
@@ -1,18 +1,18 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Created by PHPro
|
4 |
-
*
|
5 |
-
* @subpackage Shipping
|
6 |
-
* @category Checkout
|
7 |
-
* @author PHPro (info@phpro.be)
|
8 |
-
*/
|
9 |
-
|
10 |
-
if (!Mage::helper('core')->isModuleEnabled('Bpost_ShippingManager')) {
|
11 |
-
/* @var $installer Mage_Core_Model_Resource_Setup */
|
12 |
-
$installer = $this;
|
13 |
-
$installer->startSetup();
|
14 |
-
|
15 |
-
$installer->getConnection()->addColumn($installer->getTable('sales/shipment'), 'bpost_return_barcode', "varchar(255) null default ''");
|
16 |
-
|
17 |
-
$installer->endSetup();
|
18 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Created by PHPro
|
4 |
+
*
|
5 |
+
* @subpackage Shipping
|
6 |
+
* @category Checkout
|
7 |
+
* @author PHPro (info@phpro.be)
|
8 |
+
*/
|
9 |
+
|
10 |
+
if (!Mage::helper('core')->isModuleEnabled('Bpost_ShippingManager')) {
|
11 |
+
/* @var $installer Mage_Core_Model_Resource_Setup */
|
12 |
+
$installer = $this;
|
13 |
+
$installer->startSetup();
|
14 |
+
|
15 |
+
$installer->getConnection()->addColumn($installer->getTable('sales/shipment'), 'bpost_return_barcode', "varchar(255) null default ''");
|
16 |
+
|
17 |
+
$installer->endSetup();
|
18 |
}
|
app/code/community/Bpost/ShM/sql/bpost_shm_setup/upgrade-0.0.9-0.0.10.php
CHANGED
@@ -1,31 +1,31 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Created by PHPro
|
4 |
-
*
|
5 |
-
* @package Bpost
|
6 |
-
* @subpackage ShM
|
7 |
-
* @author PHPro (info@phpro.be)
|
8 |
-
*/
|
9 |
-
|
10 |
-
if (!Mage::helper('core')->isModuleEnabled('Bpost_ShippingManager')) {
|
11 |
-
|
12 |
-
$installer = $this;
|
13 |
-
$installer->startSetup();
|
14 |
-
|
15 |
-
//create the return label table
|
16 |
-
$tableReturnLabel = $installer->getConnection()->newTable($installer->getTable('bpost_shm/bpost_country'))
|
17 |
-
->addColumn('country_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
18 |
-
'unsigned' => true,
|
19 |
-
'nullable' => false,
|
20 |
-
'primary' => true,
|
21 |
-
'identity' => true,
|
22 |
-
), 'country unique ID')
|
23 |
-
->addColumn('country_code', Varien_Db_Ddl_Table::TYPE_VARCHAR, 2, array(
|
24 |
-
'nullable' => false,
|
25 |
-
'default' => "",
|
26 |
-
), "country code")
|
27 |
-
->setComment('bpost country code');
|
28 |
-
$installer->getConnection()->createTable($tableReturnLabel);
|
29 |
-
$installer->endSetup();
|
30 |
-
|
31 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Created by PHPro
|
4 |
+
*
|
5 |
+
* @package Bpost
|
6 |
+
* @subpackage ShM
|
7 |
+
* @author PHPro (info@phpro.be)
|
8 |
+
*/
|
9 |
+
|
10 |
+
if (!Mage::helper('core')->isModuleEnabled('Bpost_ShippingManager')) {
|
11 |
+
|
12 |
+
$installer = $this;
|
13 |
+
$installer->startSetup();
|
14 |
+
|
15 |
+
//create the return label table
|
16 |
+
$tableReturnLabel = $installer->getConnection()->newTable($installer->getTable('bpost_shm/bpost_country'))
|
17 |
+
->addColumn('country_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
18 |
+
'unsigned' => true,
|
19 |
+
'nullable' => false,
|
20 |
+
'primary' => true,
|
21 |
+
'identity' => true,
|
22 |
+
), 'country unique ID')
|
23 |
+
->addColumn('country_code', Varien_Db_Ddl_Table::TYPE_VARCHAR, 2, array(
|
24 |
+
'nullable' => false,
|
25 |
+
'default' => "",
|
26 |
+
), "country code")
|
27 |
+
->setComment('bpost country code');
|
28 |
+
$installer->getConnection()->createTable($tableReturnLabel);
|
29 |
+
$installer->endSetup();
|
30 |
+
|
31 |
}
|
app/code/community/Bpost/ShM/sql/bpost_shm_setup/upgrade-0.1.0-0.1.1.php
CHANGED
@@ -1,18 +1,18 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Created by PHPro
|
4 |
-
*
|
5 |
-
* @subpackage Shipping
|
6 |
-
* @category Checkout
|
7 |
-
* @author PHPro (info@phpro.be)
|
8 |
-
*/
|
9 |
-
|
10 |
-
if (!Mage::helper('core')->isModuleEnabled('Bpost_ShippingManager')) {
|
11 |
-
/* @var $installer Mage_Core_Model_Resource_Setup */
|
12 |
-
$installer = $this;
|
13 |
-
$installer->startSetup();
|
14 |
-
|
15 |
-
$installer->getConnection()->addColumn($installer->getTable('sales/order'), 'bpost_reference', "varchar(20) null default ''");
|
16 |
-
|
17 |
-
$installer->endSetup();
|
18 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Created by PHPro
|
4 |
+
*
|
5 |
+
* @subpackage Shipping
|
6 |
+
* @category Checkout
|
7 |
+
* @author PHPro (info@phpro.be)
|
8 |
+
*/
|
9 |
+
|
10 |
+
if (!Mage::helper('core')->isModuleEnabled('Bpost_ShippingManager')) {
|
11 |
+
/* @var $installer Mage_Core_Model_Resource_Setup */
|
12 |
+
$installer = $this;
|
13 |
+
$installer->startSetup();
|
14 |
+
|
15 |
+
$installer->getConnection()->addColumn($installer->getTable('sales/order'), 'bpost_reference', "varchar(20) null default ''");
|
16 |
+
|
17 |
+
$installer->endSetup();
|
18 |
}
|
app/code/community/Bpost/ShM/sql/bpost_shm_setup/upgrade-0.1.1-0.1.2.php
CHANGED
@@ -1,18 +1,18 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Created by PHPro
|
4 |
-
*
|
5 |
-
* @subpackage Shipping
|
6 |
-
* @category Checkout
|
7 |
-
* @author PHPro (info@phpro.be)
|
8 |
-
*/
|
9 |
-
|
10 |
-
if (!Mage::helper('core')->isModuleEnabled('Bpost_ShippingManager')) {
|
11 |
-
/* @var $installer Mage_Core_Model_Resource_Setup */
|
12 |
-
$installer = $this;
|
13 |
-
$installer->startSetup();
|
14 |
-
|
15 |
-
$installer->getConnection()->addColumn($installer->getTable('sales/order_grid'), 'bpost_reference', "varchar(20) null default ''");
|
16 |
-
|
17 |
-
$installer->endSetup();
|
18 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Created by PHPro
|
4 |
+
*
|
5 |
+
* @subpackage Shipping
|
6 |
+
* @category Checkout
|
7 |
+
* @author PHPro (info@phpro.be)
|
8 |
+
*/
|
9 |
+
|
10 |
+
if (!Mage::helper('core')->isModuleEnabled('Bpost_ShippingManager')) {
|
11 |
+
/* @var $installer Mage_Core_Model_Resource_Setup */
|
12 |
+
$installer = $this;
|
13 |
+
$installer->startSetup();
|
14 |
+
|
15 |
+
$installer->getConnection()->addColumn($installer->getTable('sales/order_grid'), 'bpost_reference', "varchar(20) null default ''");
|
16 |
+
|
17 |
+
$installer->endSetup();
|
18 |
}
|
app/code/community/Bpost/ShM/sql/bpost_shm_setup/upgrade-0.1.2-0.1.3.php
CHANGED
@@ -1,24 +1,24 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Created by PHPro
|
4 |
-
*
|
5 |
-
* @subpackage Shipping
|
6 |
-
* @category Checkout
|
7 |
-
* @author PHPro (info@phpro.be)
|
8 |
-
*/
|
9 |
-
|
10 |
-
if (!Mage::helper('core')->isModuleEnabled('Bpost_ShippingManager')) {
|
11 |
-
/* @var $installer Mage_Core_Model_Resource_Setup */
|
12 |
-
$installer = $this;
|
13 |
-
$installer->startSetup();
|
14 |
-
|
15 |
-
$installer->getConnection()->addColumn($installer->getTable('sales/quote'), 'bpost_pickuplocation_id', "varchar(255) null");
|
16 |
-
$installer->getConnection()->addColumn($installer->getTable('sales/order'), 'bpost_pickuplocation_id', "varchar(255) null");
|
17 |
-
|
18 |
-
$installer->getConnection()->addColumn($installer->getTable('sales/order'), 'bpost_notification_sms', "varchar(255) null");
|
19 |
-
$installer->getConnection()->addColumn($installer->getTable('sales/order'), 'bpost_notification_email', "varchar(255) null");
|
20 |
-
$installer->getConnection()->addColumn($installer->getTable('sales/quote'), 'bpost_notification_sms', "varchar(255) null");
|
21 |
-
$installer->getConnection()->addColumn($installer->getTable('sales/quote'), 'bpost_notification_email', "varchar(255) null");
|
22 |
-
|
23 |
-
$installer->endSetup();
|
24 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Created by PHPro
|
4 |
+
*
|
5 |
+
* @subpackage Shipping
|
6 |
+
* @category Checkout
|
7 |
+
* @author PHPro (info@phpro.be)
|
8 |
+
*/
|
9 |
+
|
10 |
+
if (!Mage::helper('core')->isModuleEnabled('Bpost_ShippingManager')) {
|
11 |
+
/* @var $installer Mage_Core_Model_Resource_Setup */
|
12 |
+
$installer = $this;
|
13 |
+
$installer->startSetup();
|
14 |
+
|
15 |
+
$installer->getConnection()->addColumn($installer->getTable('sales/quote'), 'bpost_pickuplocation_id', "varchar(255) null");
|
16 |
+
$installer->getConnection()->addColumn($installer->getTable('sales/order'), 'bpost_pickuplocation_id', "varchar(255) null");
|
17 |
+
|
18 |
+
$installer->getConnection()->addColumn($installer->getTable('sales/order'), 'bpost_notification_sms', "varchar(255) null");
|
19 |
+
$installer->getConnection()->addColumn($installer->getTable('sales/order'), 'bpost_notification_email', "varchar(255) null");
|
20 |
+
$installer->getConnection()->addColumn($installer->getTable('sales/quote'), 'bpost_notification_sms', "varchar(255) null");
|
21 |
+
$installer->getConnection()->addColumn($installer->getTable('sales/quote'), 'bpost_notification_email', "varchar(255) null");
|
22 |
+
|
23 |
+
$installer->endSetup();
|
24 |
}
|
app/code/community/Bpost/ShM/sql/bpost_shm_setup/upgrade-0.1.3-0.1.4.php
CHANGED
@@ -1,66 +1,66 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Created by PHPro
|
4 |
-
*
|
5 |
-
* @package Bpost
|
6 |
-
* @subpackage ShM
|
7 |
-
* @author PHPro (info@phpro.be)
|
8 |
-
*/
|
9 |
-
|
10 |
-
if (!Mage::helper('core')->isModuleEnabled('Bpost_ShippingManager')) {
|
11 |
-
|
12 |
-
$installer = $this;
|
13 |
-
$installer->startSetup();
|
14 |
-
|
15 |
-
//create the return label table
|
16 |
-
$tableHolidays = $installer->getConnection()->newTable($installer->getTable('bpost_shm/bpost_holidays'))
|
17 |
-
->addColumn('holiday_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
18 |
-
'unsigned' => true,
|
19 |
-
'nullable' => false,
|
20 |
-
'primary' => true,
|
21 |
-
'identity' => true,
|
22 |
-
), 'holiday unique ID')
|
23 |
-
->addColumn('date', Varien_Db_Ddl_Table::TYPE_DATETIME, null, array(
|
24 |
-
'nullable' => true,
|
25 |
-
'default' => null,
|
26 |
-
), "date")
|
27 |
-
->setComment('bpost holiday list');
|
28 |
-
$installer->getConnection()->createTable($tableHolidays);
|
29 |
-
|
30 |
-
//import 2015 holidays
|
31 |
-
$installer->run("
|
32 |
-
INSERT INTO {$installer->getTable('bpost_shm/bpost_holidays')} (date) values ('2015-01-01');
|
33 |
-
INSERT INTO {$installer->getTable('bpost_shm/bpost_holidays')} (date) values ('2015-04-06');
|
34 |
-
INSERT INTO {$installer->getTable('bpost_shm/bpost_holidays')} (date) values ('2015-05-01');
|
35 |
-
INSERT INTO {$installer->getTable('bpost_shm/bpost_holidays')} (date) values ('2015-05-14');
|
36 |
-
INSERT INTO {$installer->getTable('bpost_shm/bpost_holidays')} (date) values ('2015-05-25');
|
37 |
-
INSERT INTO {$installer->getTable('bpost_shm/bpost_holidays')} (date) values ('2015-07-21');
|
38 |
-
INSERT INTO {$installer->getTable('bpost_shm/bpost_holidays')} (date) values ('2015-08-15');
|
39 |
-
INSERT INTO {$installer->getTable('bpost_shm/bpost_holidays')} (date) values ('2015-11-01');
|
40 |
-
INSERT INTO {$installer->getTable('bpost_shm/bpost_holidays')} (date) values ('2015-01-11');
|
41 |
-
INSERT INTO {$installer->getTable('bpost_shm/bpost_holidays')} (date) values ('2015-12-25');
|
42 |
-
INSERT INTO {$installer->getTable('bpost_shm/bpost_holidays')} (date) values ('2016-01-01');
|
43 |
-
INSERT INTO {$installer->getTable('bpost_shm/bpost_holidays')} (date) values ('2016-03-28');
|
44 |
-
INSERT INTO {$installer->getTable('bpost_shm/bpost_holidays')} (date) values ('2016-05-01');
|
45 |
-
INSERT INTO {$installer->getTable('bpost_shm/bpost_holidays')} (date) values ('2016-05-05');
|
46 |
-
INSERT INTO {$installer->getTable('bpost_shm/bpost_holidays')} (date) values ('2016-05-16');
|
47 |
-
INSERT INTO {$installer->getTable('bpost_shm/bpost_holidays')} (date) values ('2016-07-21');
|
48 |
-
INSERT INTO {$installer->getTable('bpost_shm/bpost_holidays')} (date) values ('2016-08-15');
|
49 |
-
INSERT INTO {$installer->getTable('bpost_shm/bpost_holidays')} (date) values ('2016-11-01');
|
50 |
-
INSERT INTO {$installer->getTable('bpost_shm/bpost_holidays')} (date) values ('2016-01-11');
|
51 |
-
INSERT INTO {$installer->getTable('bpost_shm/bpost_holidays')} (date) values ('2016-01-25');
|
52 |
-
INSERT INTO {$installer->getTable('bpost_shm/bpost_holidays')} (date) values ('2017-01-01');
|
53 |
-
INSERT INTO {$installer->getTable('bpost_shm/bpost_holidays')} (date) values ('2017-04-17');
|
54 |
-
INSERT INTO {$installer->getTable('bpost_shm/bpost_holidays')} (date) values ('2017-05-01');
|
55 |
-
INSERT INTO {$installer->getTable('bpost_shm/bpost_holidays')} (date) values ('2017-05-25');
|
56 |
-
INSERT INTO {$installer->getTable('bpost_shm/bpost_holidays')} (date) values ('2017-06-05');
|
57 |
-
INSERT INTO {$installer->getTable('bpost_shm/bpost_holidays')} (date) values ('2017-07-21');
|
58 |
-
INSERT INTO {$installer->getTable('bpost_shm/bpost_holidays')} (date) values ('2017-08-15');
|
59 |
-
INSERT INTO {$installer->getTable('bpost_shm/bpost_holidays')} (date) values ('2017-11-01');
|
60 |
-
INSERT INTO {$installer->getTable('bpost_shm/bpost_holidays')} (date) values ('2017-01-11');
|
61 |
-
INSERT INTO {$installer->getTable('bpost_shm/bpost_holidays')} (date) values ('2017-01-25');
|
62 |
-
");
|
63 |
-
|
64 |
-
$installer->endSetup();
|
65 |
-
|
66 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Created by PHPro
|
4 |
+
*
|
5 |
+
* @package Bpost
|
6 |
+
* @subpackage ShM
|
7 |
+
* @author PHPro (info@phpro.be)
|
8 |
+
*/
|
9 |
+
|
10 |
+
if (!Mage::helper('core')->isModuleEnabled('Bpost_ShippingManager')) {
|
11 |
+
|
12 |
+
$installer = $this;
|
13 |
+
$installer->startSetup();
|
14 |
+
|
15 |
+
//create the return label table
|
16 |
+
$tableHolidays = $installer->getConnection()->newTable($installer->getTable('bpost_shm/bpost_holidays'))
|
17 |
+
->addColumn('holiday_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
18 |
+
'unsigned' => true,
|
19 |
+
'nullable' => false,
|
20 |
+
'primary' => true,
|
21 |
+
'identity' => true,
|
22 |
+
), 'holiday unique ID')
|
23 |
+
->addColumn('date', Varien_Db_Ddl_Table::TYPE_DATETIME, null, array(
|
24 |
+
'nullable' => true,
|
25 |
+
'default' => null,
|
26 |
+
), "date")
|
27 |
+
->setComment('bpost holiday list');
|
28 |
+
$installer->getConnection()->createTable($tableHolidays);
|
29 |
+
|
30 |
+
//import 2015 holidays
|
31 |
+
$installer->run("
|
32 |
+
INSERT INTO {$installer->getTable('bpost_shm/bpost_holidays')} (date) values ('2015-01-01');
|
33 |
+
INSERT INTO {$installer->getTable('bpost_shm/bpost_holidays')} (date) values ('2015-04-06');
|
34 |
+
INSERT INTO {$installer->getTable('bpost_shm/bpost_holidays')} (date) values ('2015-05-01');
|
35 |
+
INSERT INTO {$installer->getTable('bpost_shm/bpost_holidays')} (date) values ('2015-05-14');
|
36 |
+
INSERT INTO {$installer->getTable('bpost_shm/bpost_holidays')} (date) values ('2015-05-25');
|
37 |
+
INSERT INTO {$installer->getTable('bpost_shm/bpost_holidays')} (date) values ('2015-07-21');
|
38 |
+
INSERT INTO {$installer->getTable('bpost_shm/bpost_holidays')} (date) values ('2015-08-15');
|
39 |
+
INSERT INTO {$installer->getTable('bpost_shm/bpost_holidays')} (date) values ('2015-11-01');
|
40 |
+
INSERT INTO {$installer->getTable('bpost_shm/bpost_holidays')} (date) values ('2015-01-11');
|
41 |
+
INSERT INTO {$installer->getTable('bpost_shm/bpost_holidays')} (date) values ('2015-12-25');
|
42 |
+
INSERT INTO {$installer->getTable('bpost_shm/bpost_holidays')} (date) values ('2016-01-01');
|
43 |
+
INSERT INTO {$installer->getTable('bpost_shm/bpost_holidays')} (date) values ('2016-03-28');
|
44 |
+
INSERT INTO {$installer->getTable('bpost_shm/bpost_holidays')} (date) values ('2016-05-01');
|
45 |
+
INSERT INTO {$installer->getTable('bpost_shm/bpost_holidays')} (date) values ('2016-05-05');
|
46 |
+
INSERT INTO {$installer->getTable('bpost_shm/bpost_holidays')} (date) values ('2016-05-16');
|
47 |
+
INSERT INTO {$installer->getTable('bpost_shm/bpost_holidays')} (date) values ('2016-07-21');
|
48 |
+
INSERT INTO {$installer->getTable('bpost_shm/bpost_holidays')} (date) values ('2016-08-15');
|
49 |
+
INSERT INTO {$installer->getTable('bpost_shm/bpost_holidays')} (date) values ('2016-11-01');
|
50 |
+
INSERT INTO {$installer->getTable('bpost_shm/bpost_holidays')} (date) values ('2016-01-11');
|
51 |
+
INSERT INTO {$installer->getTable('bpost_shm/bpost_holidays')} (date) values ('2016-01-25');
|
52 |
+
INSERT INTO {$installer->getTable('bpost_shm/bpost_holidays')} (date) values ('2017-01-01');
|
53 |
+
INSERT INTO {$installer->getTable('bpost_shm/bpost_holidays')} (date) values ('2017-04-17');
|
54 |
+
INSERT INTO {$installer->getTable('bpost_shm/bpost_holidays')} (date) values ('2017-05-01');
|
55 |
+
INSERT INTO {$installer->getTable('bpost_shm/bpost_holidays')} (date) values ('2017-05-25');
|
56 |
+
INSERT INTO {$installer->getTable('bpost_shm/bpost_holidays')} (date) values ('2017-06-05');
|
57 |
+
INSERT INTO {$installer->getTable('bpost_shm/bpost_holidays')} (date) values ('2017-07-21');
|
58 |
+
INSERT INTO {$installer->getTable('bpost_shm/bpost_holidays')} (date) values ('2017-08-15');
|
59 |
+
INSERT INTO {$installer->getTable('bpost_shm/bpost_holidays')} (date) values ('2017-11-01');
|
60 |
+
INSERT INTO {$installer->getTable('bpost_shm/bpost_holidays')} (date) values ('2017-01-11');
|
61 |
+
INSERT INTO {$installer->getTable('bpost_shm/bpost_holidays')} (date) values ('2017-01-25');
|
62 |
+
");
|
63 |
+
|
64 |
+
$installer->endSetup();
|
65 |
+
|
66 |
}
|
app/code/community/Bpost/ShM/sql/bpost_shm_setup/upgrade-0.1.4-0.1.5.php
CHANGED
@@ -1,19 +1,19 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Created by PHPro
|
4 |
-
*
|
5 |
-
* @package Bpost
|
6 |
-
* @subpackage ShM
|
7 |
-
* @author PHPro (info@phpro.be)
|
8 |
-
*/
|
9 |
-
|
10 |
-
if (!Mage::helper('core')->isModuleEnabled('Bpost_ShippingManager')) {
|
11 |
-
/* @var $installer Mage_Core_Model_Resource_Setup */
|
12 |
-
$installer = $this;
|
13 |
-
$installer->startSetup();
|
14 |
-
|
15 |
-
$installer->getConnection()->addColumn($installer->getTable('sales/quote'), 'bpost_reduced_mobility', "bool null default 0");
|
16 |
-
$installer->getConnection()->addColumn($installer->getTable('sales/order'), 'bpost_reduced_mobility', "bool null default 0");
|
17 |
-
|
18 |
-
$installer->endSetup();
|
19 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Created by PHPro
|
4 |
+
*
|
5 |
+
* @package Bpost
|
6 |
+
* @subpackage ShM
|
7 |
+
* @author PHPro (info@phpro.be)
|
8 |
+
*/
|
9 |
+
|
10 |
+
if (!Mage::helper('core')->isModuleEnabled('Bpost_ShippingManager')) {
|
11 |
+
/* @var $installer Mage_Core_Model_Resource_Setup */
|
12 |
+
$installer = $this;
|
13 |
+
$installer->startSetup();
|
14 |
+
|
15 |
+
$installer->getConnection()->addColumn($installer->getTable('sales/quote'), 'bpost_reduced_mobility', "bool null default 0");
|
16 |
+
$installer->getConnection()->addColumn($installer->getTable('sales/order'), 'bpost_reduced_mobility', "bool null default 0");
|
17 |
+
|
18 |
+
$installer->endSetup();
|
19 |
}
|
app/code/community/Bpost/ShM/sql/bpost_shm_setup/upgrade-0.1.5-0.1.6.php
CHANGED
@@ -1,19 +1,19 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Created by PHPro
|
4 |
-
*
|
5 |
-
* @package Bpost
|
6 |
-
* @subpackage ShM
|
7 |
-
* @author PHPro (info@phpro.be)
|
8 |
-
*/
|
9 |
-
|
10 |
-
if (!Mage::helper('core')->isModuleEnabled('Bpost_ShippingManager')) {
|
11 |
-
/* @var $installer Mage_Core_Model_Resource_Setup */
|
12 |
-
$installer = $this;
|
13 |
-
$installer->startSetup();
|
14 |
-
|
15 |
-
$installer->getConnection()->addColumn($installer->getTable('sales/quote'), 'bpost_disable_saturday_delivery', "bool null");
|
16 |
-
$installer->getConnection()->addColumn($installer->getTable('sales/order'), 'bpost_disable_saturday_delivery', "bool null");
|
17 |
-
|
18 |
-
$installer->endSetup();
|
19 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Created by PHPro
|
4 |
+
*
|
5 |
+
* @package Bpost
|
6 |
+
* @subpackage ShM
|
7 |
+
* @author PHPro (info@phpro.be)
|
8 |
+
*/
|
9 |
+
|
10 |
+
if (!Mage::helper('core')->isModuleEnabled('Bpost_ShippingManager')) {
|
11 |
+
/* @var $installer Mage_Core_Model_Resource_Setup */
|
12 |
+
$installer = $this;
|
13 |
+
$installer->startSetup();
|
14 |
+
|
15 |
+
$installer->getConnection()->addColumn($installer->getTable('sales/quote'), 'bpost_disable_saturday_delivery', "bool null");
|
16 |
+
$installer->getConnection()->addColumn($installer->getTable('sales/order'), 'bpost_disable_saturday_delivery', "bool null");
|
17 |
+
|
18 |
+
$installer->endSetup();
|
19 |
}
|
app/code/community/Bpost/ShM/sql/bpost_shm_setup/upgrade-0.1.6-0.1.7.php
CHANGED
@@ -1,17 +1,17 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Created by PHPro
|
4 |
-
*
|
5 |
-
* @package Bpost
|
6 |
-
* @subpackage ShM
|
7 |
-
* @author PHPro (info@phpro.be)
|
8 |
-
*/
|
9 |
-
if (!Mage::helper('core')->isModuleEnabled('Bpost_ShippingManager')) {
|
10 |
-
$installer = $this;
|
11 |
-
$installer->startSetup();
|
12 |
-
|
13 |
-
$installer->getConnection()->addColumn($installer->getTable('sales/quote'), 'bpost_delivery_date', "date null");
|
14 |
-
$installer->getConnection()->addColumn($installer->getTable('sales/order'), 'bpost_delivery_date', "date null");
|
15 |
-
|
16 |
-
$installer->endSetup();
|
17 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Created by PHPro
|
4 |
+
*
|
5 |
+
* @package Bpost
|
6 |
+
* @subpackage ShM
|
7 |
+
* @author PHPro (info@phpro.be)
|
8 |
+
*/
|
9 |
+
if (!Mage::helper('core')->isModuleEnabled('Bpost_ShippingManager')) {
|
10 |
+
$installer = $this;
|
11 |
+
$installer->startSetup();
|
12 |
+
|
13 |
+
$installer->getConnection()->addColumn($installer->getTable('sales/quote'), 'bpost_delivery_date', "date null");
|
14 |
+
$installer->getConnection()->addColumn($installer->getTable('sales/order'), 'bpost_delivery_date', "date null");
|
15 |
+
|
16 |
+
$installer->endSetup();
|
17 |
+
}
|
app/code/community/Bpost/ShM/sql/bpost_shm_setup/upgrade-0.1.7-0.1.8.php
CHANGED
@@ -1,14 +1,14 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Created by PHPro
|
4 |
-
*
|
5 |
-
* @package Bpost
|
6 |
-
* @subpackage ShM
|
7 |
-
* @author PHPro (info@phpro.be)
|
8 |
-
*/
|
9 |
-
if (!Mage::helper('core')->isModuleEnabled('Bpost_ShippingManager')) {
|
10 |
-
$installer = $this;
|
11 |
-
$installer->startSetup();
|
12 |
-
$installer->getConnection()->addColumn($installer->getTable('sales/quote'), 'bpost_saturday_cost_applied', "bool null");
|
13 |
-
$installer->endSetup();
|
14 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Created by PHPro
|
4 |
+
*
|
5 |
+
* @package Bpost
|
6 |
+
* @subpackage ShM
|
7 |
+
* @author PHPro (info@phpro.be)
|
8 |
+
*/
|
9 |
+
if (!Mage::helper('core')->isModuleEnabled('Bpost_ShippingManager')) {
|
10 |
+
$installer = $this;
|
11 |
+
$installer->startSetup();
|
12 |
+
$installer->getConnection()->addColumn($installer->getTable('sales/quote'), 'bpost_saturday_cost_applied', "bool null");
|
13 |
+
$installer->endSetup();
|
14 |
+
}
|
app/code/community/Bpost/ShM/sql/bpost_shm_setup/upgrade-0.1.8-1.1.3.php
CHANGED
@@ -1,27 +1,27 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Created by PHPro
|
4 |
-
*
|
5 |
-
* @package Bpost
|
6 |
-
* @subpackage ShM
|
7 |
-
* @category Checkout
|
8 |
-
* @author PHPro (info@phpro.be)
|
9 |
-
*/
|
10 |
-
if (!Mage::helper('core')->isModuleEnabled('Bpost_ShippingManager')) {
|
11 |
-
$installer = $this;
|
12 |
-
$installer->startSetup();
|
13 |
-
$installer->run("CREATE TABLE IF NOT EXISTS {$installer->getTable('bpost_tablerates_clickcollect')} (
|
14 |
-
`pk` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Primary key',
|
15 |
-
`website_id` int(11) NOT NULL DEFAULT '0' COMMENT 'Website Id',
|
16 |
-
`dest_country_id` varchar(4) NOT NULL DEFAULT '0' COMMENT 'Destination coutry ISO/2 or ISO/3 code',
|
17 |
-
`dest_region_id` int(11) NOT NULL DEFAULT '0' COMMENT 'Destination Region Id',
|
18 |
-
`dest_zip` varchar(10) NOT NULL DEFAULT '*' COMMENT 'Destination Post Code (Zip)',
|
19 |
-
`condition_name` varchar(20) NOT NULL COMMENT 'Rate Condition name',
|
20 |
-
`condition_value` decimal(12,4) NOT NULL DEFAULT '0.0000' COMMENT 'Rate condition value',
|
21 |
-
`price` decimal(12,4) NOT NULL DEFAULT '0.0000' COMMENT 'Price',
|
22 |
-
`cost` decimal(12,4) NOT NULL DEFAULT '0.0000' COMMENT 'Cost',
|
23 |
-
PRIMARY KEY (`pk`),
|
24 |
-
UNIQUE KEY `QIMuM8yoQUkmjsNM6FmJFjBrOZHNJAEu8kP` (`website_id`,`dest_country_id`,`dest_region_id`,`dest_zip`,`condition_name`,`condition_value`)
|
25 |
-
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Bpost ClickCollect Tablerate'");
|
26 |
-
$installer->endSetup();
|
27 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Created by PHPro
|
4 |
+
*
|
5 |
+
* @package Bpost
|
6 |
+
* @subpackage ShM
|
7 |
+
* @category Checkout
|
8 |
+
* @author PHPro (info@phpro.be)
|
9 |
+
*/
|
10 |
+
if (!Mage::helper('core')->isModuleEnabled('Bpost_ShippingManager')) {
|
11 |
+
$installer = $this;
|
12 |
+
$installer->startSetup();
|
13 |
+
$installer->run("CREATE TABLE IF NOT EXISTS {$installer->getTable('bpost_tablerates_clickcollect')} (
|
14 |
+
`pk` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Primary key',
|
15 |
+
`website_id` int(11) NOT NULL DEFAULT '0' COMMENT 'Website Id',
|
16 |
+
`dest_country_id` varchar(4) NOT NULL DEFAULT '0' COMMENT 'Destination coutry ISO/2 or ISO/3 code',
|
17 |
+
`dest_region_id` int(11) NOT NULL DEFAULT '0' COMMENT 'Destination Region Id',
|
18 |
+
`dest_zip` varchar(10) NOT NULL DEFAULT '*' COMMENT 'Destination Post Code (Zip)',
|
19 |
+
`condition_name` varchar(20) NOT NULL COMMENT 'Rate Condition name',
|
20 |
+
`condition_value` decimal(12,4) NOT NULL DEFAULT '0.0000' COMMENT 'Rate condition value',
|
21 |
+
`price` decimal(12,4) NOT NULL DEFAULT '0.0000' COMMENT 'Price',
|
22 |
+
`cost` decimal(12,4) NOT NULL DEFAULT '0.0000' COMMENT 'Cost',
|
23 |
+
PRIMARY KEY (`pk`),
|
24 |
+
UNIQUE KEY `QIMuM8yoQUkmjsNM6FmJFjBrOZHNJAEu8kP` (`website_id`,`dest_country_id`,`dest_region_id`,`dest_zip`,`condition_name`,`condition_value`)
|
25 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Bpost ClickCollect Tablerate'");
|
26 |
+
$installer->endSetup();
|
27 |
}
|
app/design/adminhtml/default/default/layout/bpost/shm.xml
CHANGED
@@ -1,71 +1,71 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
<layout>
|
3 |
-
|
4 |
-
<popup_handle>
|
5 |
-
<reference name="head">
|
6 |
-
<action method="addJS">
|
7 |
-
<script>bpost/shm/adminhtml/informationpopup.js</script>
|
8 |
-
</action>
|
9 |
-
<action method="addItem">
|
10 |
-
<type>js_css</type>
|
11 |
-
<name>prototype/windows/themes/default.css</name>
|
12 |
-
</action>
|
13 |
-
<action method="addItem">
|
14 |
-
<type helper="bpost_shm/data/getMagentoWindowCssItemType" />
|
15 |
-
<name helper="bpost_shm/data/getMageWindowCss" />
|
16 |
-
</action>
|
17 |
-
<action method="addCss">
|
18 |
-
<name>css/bpost/informationpopup.css</name>
|
19 |
-
</action>
|
20 |
-
</reference>
|
21 |
-
</popup_handle>
|
22 |
-
|
23 |
-
<adminhtml_bpost_shm_config_popup>
|
24 |
-
<reference name="root">
|
25 |
-
<action method="setTemplate">
|
26 |
-
<template>bpost/empty.phtml</template>
|
27 |
-
</action>
|
28 |
-
</reference>
|
29 |
-
<reference name="head">
|
30 |
-
<action method="addCss">
|
31 |
-
<name>css/bpost/informationpopup.css</name>
|
32 |
-
</action>
|
33 |
-
</reference>
|
34 |
-
</adminhtml_bpost_shm_config_popup>
|
35 |
-
|
36 |
-
<adminhtml_system_config_edit>
|
37 |
-
<update handle="popup_handle" />
|
38 |
-
</adminhtml_system_config_edit>
|
39 |
-
|
40 |
-
<adminhtml_bpost_shm_config_informationpopup>
|
41 |
-
<update handle="adminhtml_bpost_shm_config_popup"/>
|
42 |
-
<reference name="content">
|
43 |
-
<block type="core/template" name="informationPopup" template="bpost/informationpopup.phtml"/>
|
44 |
-
</reference>
|
45 |
-
</adminhtml_bpost_shm_config_informationpopup>
|
46 |
-
|
47 |
-
<adminhtml_bpost_shm_config_screenshotpopup>
|
48 |
-
<update handle="adminhtml_bpost_shm_config_popup"/>
|
49 |
-
|
50 |
-
<reference name="content">
|
51 |
-
<block type="core/template" name="screenshot.popup" template="bpost/screenshotpopup.phtml"/>
|
52 |
-
</reference>
|
53 |
-
</adminhtml_bpost_shm_config_screenshotpopup>
|
54 |
-
|
55 |
-
<adminhtml_sales_order_view>
|
56 |
-
<reference name="sales_order_tabs">
|
57 |
-
<action method="addTab">
|
58 |
-
<name>order_view_tab_bpostreturnlabeltab</name>
|
59 |
-
<block>bpost_shm/adminhtml_sales_order_view_tab_returnlabels</block>
|
60 |
-
</action>
|
61 |
-
</reference>
|
62 |
-
</adminhtml_sales_order_view>
|
63 |
-
|
64 |
-
<adminhtml_bpost_shm_allorders_index>
|
65 |
-
<update handle="popup_handle" />
|
66 |
-
</adminhtml_bpost_shm_allorders_index>
|
67 |
-
|
68 |
-
<adminhtml_bpost_shm_pendingorders_index>
|
69 |
-
<update handle="popup_handle" />
|
70 |
-
</adminhtml_bpost_shm_pendingorders_index>
|
71 |
</layout>
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout>
|
3 |
+
|
4 |
+
<popup_handle>
|
5 |
+
<reference name="head">
|
6 |
+
<action method="addJS">
|
7 |
+
<script>bpost/shm/adminhtml/informationpopup.js</script>
|
8 |
+
</action>
|
9 |
+
<action method="addItem">
|
10 |
+
<type>js_css</type>
|
11 |
+
<name>prototype/windows/themes/default.css</name>
|
12 |
+
</action>
|
13 |
+
<action method="addItem">
|
14 |
+
<type helper="bpost_shm/data/getMagentoWindowCssItemType" />
|
15 |
+
<name helper="bpost_shm/data/getMageWindowCss" />
|
16 |
+
</action>
|
17 |
+
<action method="addCss">
|
18 |
+
<name>css/bpost/informationpopup.css</name>
|
19 |
+
</action>
|
20 |
+
</reference>
|
21 |
+
</popup_handle>
|
22 |
+
|
23 |
+
<adminhtml_bpost_shm_config_popup>
|
24 |
+
<reference name="root">
|
25 |
+
<action method="setTemplate">
|
26 |
+
<template>bpost/empty.phtml</template>
|
27 |
+
</action>
|
28 |
+
</reference>
|
29 |
+
<reference name="head">
|
30 |
+
<action method="addCss">
|
31 |
+
<name>css/bpost/informationpopup.css</name>
|
32 |
+
</action>
|
33 |
+
</reference>
|
34 |
+
</adminhtml_bpost_shm_config_popup>
|
35 |
+
|
36 |
+
<adminhtml_system_config_edit>
|
37 |
+
<update handle="popup_handle" />
|
38 |
+
</adminhtml_system_config_edit>
|
39 |
+
|
40 |
+
<adminhtml_bpost_shm_config_informationpopup>
|
41 |
+
<update handle="adminhtml_bpost_shm_config_popup"/>
|
42 |
+
<reference name="content">
|
43 |
+
<block type="core/template" name="informationPopup" template="bpost/informationpopup.phtml"/>
|
44 |
+
</reference>
|
45 |
+
</adminhtml_bpost_shm_config_informationpopup>
|
46 |
+
|
47 |
+
<adminhtml_bpost_shm_config_screenshotpopup>
|
48 |
+
<update handle="adminhtml_bpost_shm_config_popup"/>
|
49 |
+
|
50 |
+
<reference name="content">
|
51 |
+
<block type="core/template" name="screenshot.popup" template="bpost/screenshotpopup.phtml"/>
|
52 |
+
</reference>
|
53 |
+
</adminhtml_bpost_shm_config_screenshotpopup>
|
54 |
+
|
55 |
+
<adminhtml_sales_order_view>
|
56 |
+
<reference name="sales_order_tabs">
|
57 |
+
<action method="addTab">
|
58 |
+
<name>order_view_tab_bpostreturnlabeltab</name>
|
59 |
+
<block>bpost_shm/adminhtml_sales_order_view_tab_returnlabels</block>
|
60 |
+
</action>
|
61 |
+
</reference>
|
62 |
+
</adminhtml_sales_order_view>
|
63 |
+
|
64 |
+
<adminhtml_bpost_shm_allorders_index>
|
65 |
+
<update handle="popup_handle" />
|
66 |
+
</adminhtml_bpost_shm_allorders_index>
|
67 |
+
|
68 |
+
<adminhtml_bpost_shm_pendingorders_index>
|
69 |
+
<update handle="popup_handle" />
|
70 |
+
</adminhtml_bpost_shm_pendingorders_index>
|
71 |
</layout>
|
app/design/adminhtml/default/default/template/bpost/empty.phtml
CHANGED
@@ -1,15 +1,15 @@
|
|
1 |
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
2 |
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->getLang() ?>" lang="<?php echo $this->getLang() ?>">
|
3 |
-
<head>
|
4 |
-
<?php echo $this->getChildHtml('head') ?>
|
5 |
-
</head>
|
6 |
-
<body class="page-empty <?php echo $this->getBodyClass()?$this->getBodyClass():'' ?>">
|
7 |
-
<div>
|
8 |
-
<?php echo $this->getChildHtml('after_body_start') ?>
|
9 |
-
<?php echo $this->getChildHtml('global_messages') ?>
|
10 |
-
<?php echo $this->getChildHtml('content') ?>
|
11 |
-
<?php echo $this->getChildHtml('before_body_end') ?>
|
12 |
-
<?php echo $this->getAbsoluteFooter() ?>
|
13 |
-
</div>
|
14 |
-
</body>
|
15 |
-
</html>
|
1 |
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
2 |
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->getLang() ?>" lang="<?php echo $this->getLang() ?>">
|
3 |
+
<head>
|
4 |
+
<?php echo $this->getChildHtml('head') ?>
|
5 |
+
</head>
|
6 |
+
<body class="page-empty <?php echo $this->getBodyClass()?$this->getBodyClass():'' ?>">
|
7 |
+
<div>
|
8 |
+
<?php echo $this->getChildHtml('after_body_start') ?>
|
9 |
+
<?php echo $this->getChildHtml('global_messages') ?>
|
10 |
+
<?php echo $this->getChildHtml('content') ?>
|
11 |
+
<?php echo $this->getChildHtml('before_body_end') ?>
|
12 |
+
<?php echo $this->getAbsoluteFooter() ?>
|
13 |
+
</div>
|
14 |
+
</body>
|
15 |
+
</html>
|
app/design/adminhtml/default/default/template/bpost/informationpopup.phtml
CHANGED
@@ -1,15 +1,15 @@
|
|
1 |
-
<?php $helper = Mage::helper('bpost_shm') ?>
|
2 |
-
<p><?php echo $helper->__('Bpost Shipping Manager is a service offered by Bpost,
|
3 |
-
Allowing your customer to chose their preferred delivery method when ordering in your webshop.') ?></p>
|
4 |
-
<p><?php echo $helper->__('The following delivery methods are currently supported:') ?></p>
|
5 |
-
<ul>
|
6 |
-
<li><?php echo $helper->__('Receive your parcel at home or at the office.') ?></li>
|
7 |
-
<li><?php echo $helper->__('Over 1.250 locations nearby home or the office.') ?></li>
|
8 |
-
<li><?php echo $helper->__('Pick-up your parcel whenever you want, thanks to the 24/7 service of bpost.') ?></li>
|
9 |
-
</ul>
|
10 |
-
<p><?php echo $helper->__('When activated and correctly installed,
|
11 |
-
this module also allows you to completely integrate the bpost administration into your webshop.') ?></p>
|
12 |
-
<p><?php echo $helper->__('This means that orders are automatically added to the bpost portal.') ?></p>
|
13 |
-
<p><?php echo $helper->__('Furthermore, if enabled, it is possible to generate your labels and trakcing codes directly from the Magento order admin page.') ?></p>
|
14 |
-
<p><?php echo $helper->__('No more hassle and 100% transparent!') ?></p>
|
15 |
<p><?php echo $helper->__('<a target="_blank" href="%s">Documentation</a>: links to the bpost freshdesk for Magento',"http://bpost.freshdesk.com/solution/categories/99521/folders/4000013305");?></p>
|
1 |
+
<?php $helper = Mage::helper('bpost_shm') ?>
|
2 |
+
<p><?php echo $helper->__('Bpost Shipping Manager is a service offered by Bpost,
|
3 |
+
Allowing your customer to chose their preferred delivery method when ordering in your webshop.') ?></p>
|
4 |
+
<p><?php echo $helper->__('The following delivery methods are currently supported:') ?></p>
|
5 |
+
<ul>
|
6 |
+
<li><?php echo $helper->__('Receive your parcel at home or at the office.') ?></li>
|
7 |
+
<li><?php echo $helper->__('Over 1.250 locations nearby home or the office.') ?></li>
|
8 |
+
<li><?php echo $helper->__('Pick-up your parcel whenever you want, thanks to the 24/7 service of bpost.') ?></li>
|
9 |
+
</ul>
|
10 |
+
<p><?php echo $helper->__('When activated and correctly installed,
|
11 |
+
this module also allows you to completely integrate the bpost administration into your webshop.') ?></p>
|
12 |
+
<p><?php echo $helper->__('This means that orders are automatically added to the bpost portal.') ?></p>
|
13 |
+
<p><?php echo $helper->__('Furthermore, if enabled, it is possible to generate your labels and trakcing codes directly from the Magento order admin page.') ?></p>
|
14 |
+
<p><?php echo $helper->__('No more hassle and 100% transparent!') ?></p>
|
15 |
<p><?php echo $helper->__('<a target="_blank" href="%s">Documentation</a>: links to the bpost freshdesk for Magento',"http://bpost.freshdesk.com/solution/categories/99521/folders/4000013305");?></p>
|
app/design/adminhtml/default/default/template/bpost/screenshotpopup.phtml
CHANGED
@@ -1 +1 @@
|
|
1 |
-
<img class="example-screenshot" src="<?php echo $this->getImagePath();?>" alt="<?php echo Mage::helper('bpost_shm')->__("Example screenshot of the bpost module.");?>" />
|
1 |
+
<img class="example-screenshot" src="<?php echo $this->getImagePath();?>" alt="<?php echo Mage::helper('bpost_shm')->__("Example screenshot of the bpost module.");?>" />
|
app/design/adminhtml/default/default/template/bpost/widget/grid/massaction.phtml
CHANGED
@@ -1,86 +1,86 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Magento
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |
-
* that is bundled with this package in the file LICENSE_AFL.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/afl-3.0.php
|
11 |
-
* If you did not receive a copy of the license and are unable to
|
12 |
-
* obtain it through the world-wide-web, please send an email
|
13 |
-
* to license@magento.com so we can send you a copy immediately.
|
14 |
-
*
|
15 |
-
* DISCLAIMER
|
16 |
-
*
|
17 |
-
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
-
* versions in the future. If you wish to customize Magento for your
|
19 |
-
* needs please refer to http://www.magento.com for more information.
|
20 |
-
*
|
21 |
-
* @category design
|
22 |
-
* @package default_default
|
23 |
-
* @copyright Copyright (c) 2006-2015 X.commerce, Inc. (http://www.magento.com)
|
24 |
-
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
25 |
-
*/
|
26 |
-
?>
|
27 |
-
<div id="<?php echo $this->getHtmlId() ?>">
|
28 |
-
<table cellspacing="0" cellpadding="0" class="massaction">
|
29 |
-
<tr>
|
30 |
-
<td><?php if ($this->getUseSelectAll()):?>
|
31 |
-
<a href="#" onclick="return <?php echo $this->getJsObjectName() ?>.selectAll()"><?php echo $this->__('Select All') ?></a>
|
32 |
-
<span class="separator">|</span>
|
33 |
-
<a href="#" onclick="return <?php echo $this->getJsObjectName() ?>.unselectAll()"><?php echo $this->__('Unselect All') ?></a>
|
34 |
-
<span class="separator">|</span>
|
35 |
-
<?php endif; ?>
|
36 |
-
<a href="#" onclick="return <?php echo $this->getJsObjectName() ?>.selectVisible()"><?php echo $this->__('Select Visible') ?></a>
|
37 |
-
<span class="separator">|</span>
|
38 |
-
<a href="#" onclick="return <?php echo $this->getJsObjectName() ?>.unselectVisible()"><?php echo $this->__('Unselect Visible') ?></a>
|
39 |
-
<span class="separator">|</span>
|
40 |
-
<strong id="<?php echo $this->getHtmlId() ?>-count">0</strong> <?php echo $this->__('items selected') ?>
|
41 |
-
</td>
|
42 |
-
<td>
|
43 |
-
<div class="right">
|
44 |
-
<div class="entry-edit">
|
45 |
-
<?php if ($this->getHideFormElement() !== true):?>
|
46 |
-
<form action="" id="<?php echo $this->getHtmlId() ?>-form" method="post">
|
47 |
-
<?php endif ?>
|
48 |
-
<?php echo $this->getBlockHtml('formkey')?>
|
49 |
-
<fieldset>
|
50 |
-
<span class="field-row">
|
51 |
-
<label><?php echo $this->__('Actions') ?></label>
|
52 |
-
<select id="<?php echo $this->getHtmlId() ?>-select" class="required-entry select absolute-advice local-validation">
|
53 |
-
<option value=""></option>
|
54 |
-
<?php foreach($this->getItems() as $_item): ?>
|
55 |
-
<option value="<?php echo $_item->getId() ?>"<?php echo ($_item->getSelected() ? ' selected="selected"' : '')?>><?php echo $_item->getLabel() ?></option>
|
56 |
-
<?php endforeach; ?>
|
57 |
-
</select>
|
58 |
-
</span>
|
59 |
-
<span class="outer-span" id="<?php echo $this->getHtmlId() ?>-form-hiddens"></span>
|
60 |
-
<span class="outer-span" id="<?php echo $this->getHtmlId() ?>-form-additional"></span>
|
61 |
-
<span class="field-row">
|
62 |
-
<?php echo $this->getSubmitButtonHtml() ?>
|
63 |
-
</span>
|
64 |
-
</fieldset>
|
65 |
-
<?php if ($this->getHideFormElement() !== true):?>
|
66 |
-
</form>
|
67 |
-
<?php endif ?>
|
68 |
-
</div>
|
69 |
-
|
70 |
-
<div class="no-display">
|
71 |
-
<?php foreach($this->getItems() as $_item): ?>
|
72 |
-
<div id="<?php echo $this->getHtmlId() ?>-item-<?php echo $_item->getId() ?>-block">
|
73 |
-
<?php echo $_item->getAdditionalActionBlockHtml() ?>
|
74 |
-
</div>
|
75 |
-
<?php endforeach; ?>
|
76 |
-
</div>
|
77 |
-
</div>
|
78 |
-
</td>
|
79 |
-
</tr>
|
80 |
-
</table>
|
81 |
-
<?php if(!$this->getParentBlock()->canDisplayContainer()): ?>
|
82 |
-
<script type="text/javascript">
|
83 |
-
<?php echo $this->getJsObjectName() ?>.setGridIds('<?php echo $this->getGridIdsJson() ?>');
|
84 |
-
</script>
|
85 |
-
<?php endif; ?>
|
86 |
-
</div>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magento.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magento.com for more information.
|
20 |
+
*
|
21 |
+
* @category design
|
22 |
+
* @package default_default
|
23 |
+
* @copyright Copyright (c) 2006-2015 X.commerce, Inc. (http://www.magento.com)
|
24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
25 |
+
*/
|
26 |
+
?>
|
27 |
+
<div id="<?php echo $this->getHtmlId() ?>">
|
28 |
+
<table cellspacing="0" cellpadding="0" class="massaction">
|
29 |
+
<tr>
|
30 |
+
<td><?php if ($this->getUseSelectAll()):?>
|
31 |
+
<a href="#" onclick="return <?php echo $this->getJsObjectName() ?>.selectAll()"><?php echo $this->__('Select All') ?></a>
|
32 |
+
<span class="separator">|</span>
|
33 |
+
<a href="#" onclick="return <?php echo $this->getJsObjectName() ?>.unselectAll()"><?php echo $this->__('Unselect All') ?></a>
|
34 |
+
<span class="separator">|</span>
|
35 |
+
<?php endif; ?>
|
36 |
+
<a href="#" onclick="return <?php echo $this->getJsObjectName() ?>.selectVisible()"><?php echo $this->__('Select Visible') ?></a>
|
37 |
+
<span class="separator">|</span>
|
38 |
+
<a href="#" onclick="return <?php echo $this->getJsObjectName() ?>.unselectVisible()"><?php echo $this->__('Unselect Visible') ?></a>
|
39 |
+
<span class="separator">|</span>
|
40 |
+
<strong id="<?php echo $this->getHtmlId() ?>-count">0</strong> <?php echo $this->__('items selected') ?>
|
41 |
+
</td>
|
42 |
+
<td>
|
43 |
+
<div class="right">
|
44 |
+
<div class="entry-edit">
|
45 |
+
<?php if ($this->getHideFormElement() !== true):?>
|
46 |
+
<form action="" id="<?php echo $this->getHtmlId() ?>-form" method="post">
|
47 |
+
<?php endif ?>
|
48 |
+
<?php echo $this->getBlockHtml('formkey')?>
|
49 |
+
<fieldset>
|
50 |
+
<span class="field-row">
|
51 |
+
<label><?php echo $this->__('Actions') ?></label>
|
52 |
+
<select id="<?php echo $this->getHtmlId() ?>-select" class="required-entry select absolute-advice local-validation">
|
53 |
+
<option value=""></option>
|
54 |
+
<?php foreach($this->getItems() as $_item): ?>
|
55 |
+
<option value="<?php echo $_item->getId() ?>"<?php echo ($_item->getSelected() ? ' selected="selected"' : '')?>><?php echo $_item->getLabel() ?></option>
|
56 |
+
<?php endforeach; ?>
|
57 |
+
</select>
|
58 |
+
</span>
|
59 |
+
<span class="outer-span" id="<?php echo $this->getHtmlId() ?>-form-hiddens"></span>
|
60 |
+
<span class="outer-span" id="<?php echo $this->getHtmlId() ?>-form-additional"></span>
|
61 |
+
<span class="field-row">
|
62 |
+
<?php echo $this->getSubmitButtonHtml() ?>
|
63 |
+
</span>
|
64 |
+
</fieldset>
|
65 |
+
<?php if ($this->getHideFormElement() !== true):?>
|
66 |
+
</form>
|
67 |
+
<?php endif ?>
|
68 |
+
</div>
|
69 |
+
|
70 |
+
<div class="no-display">
|
71 |
+
<?php foreach($this->getItems() as $_item): ?>
|
72 |
+
<div id="<?php echo $this->getHtmlId() ?>-item-<?php echo $_item->getId() ?>-block">
|
73 |
+
<?php echo $_item->getAdditionalActionBlockHtml() ?>
|
74 |
+
</div>
|
75 |
+
<?php endforeach; ?>
|
76 |
+
</div>
|
77 |
+
</div>
|
78 |
+
</td>
|
79 |
+
</tr>
|
80 |
+
</table>
|
81 |
+
<?php if(!$this->getParentBlock()->canDisplayContainer()): ?>
|
82 |
+
<script type="text/javascript">
|
83 |
+
<?php echo $this->getJsObjectName() ?>.setGridIds('<?php echo $this->getGridIdsJson() ?>');
|
84 |
+
</script>
|
85 |
+
<?php endif; ?>
|
86 |
+
</div>
|
app/design/frontend/base/default/layout/bpost/shm.xml
CHANGED
@@ -1,36 +1,36 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
<layout>
|
3 |
-
<checkout_header>
|
4 |
-
<reference name="head">
|
5 |
-
<action method="addJs">
|
6 |
-
<script>bpost/shm/checkout.js</script>
|
7 |
-
</action>
|
8 |
-
|
9 |
-
<action method="addCss">
|
10 |
-
<name>css/bpost/checkout.css</name>
|
11 |
-
</action>
|
12 |
-
|
13 |
-
<block type="core/template" name="gmapsapi" template="bpost/shm/gmapsapi.phtml"/>
|
14 |
-
</reference>
|
15 |
-
</checkout_header>
|
16 |
-
|
17 |
-
<checkout_onepage_index>
|
18 |
-
<update handle="checkout_header"/>
|
19 |
-
</checkout_onepage_index>
|
20 |
-
|
21 |
-
<onestepcheckout_index_index>
|
22 |
-
<update handle="checkout_header"/>
|
23 |
-
|
24 |
-
<reference name="head">
|
25 |
-
<block type="core/template" name="oscwindowjs" template="bpost/shm/oscwindowjs.phtml"/>
|
26 |
-
|
27 |
-
<action method="addJs">
|
28 |
-
<script>bpost/shm/onestepcheckout_shipping.js</script>
|
29 |
-
</action>
|
30 |
-
|
31 |
-
<action method="addItem">
|
32 |
-
<type>skin_js</type><name>js/bpost/onestepcheckout.js</name>
|
33 |
-
</action>
|
34 |
-
</reference>
|
35 |
-
</onestepcheckout_index_index>
|
36 |
</layout>
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout>
|
3 |
+
<checkout_header>
|
4 |
+
<reference name="head">
|
5 |
+
<action method="addJs">
|
6 |
+
<script>bpost/shm/checkout.js</script>
|
7 |
+
</action>
|
8 |
+
|
9 |
+
<action method="addCss">
|
10 |
+
<name>css/bpost/checkout.css</name>
|
11 |
+
</action>
|
12 |
+
|
13 |
+
<block type="core/template" name="gmapsapi" template="bpost/shm/gmapsapi.phtml"/>
|
14 |
+
</reference>
|
15 |
+
</checkout_header>
|
16 |
+
|
17 |
+
<checkout_onepage_index>
|
18 |
+
<update handle="checkout_header"/>
|
19 |
+
</checkout_onepage_index>
|
20 |
+
|
21 |
+
<onestepcheckout_index_index>
|
22 |
+
<update handle="checkout_header"/>
|
23 |
+
|
24 |
+
<reference name="head">
|
25 |
+
<block type="core/template" name="oscwindowjs" template="bpost/shm/oscwindowjs.phtml"/>
|
26 |
+
|
27 |
+
<action method="addJs">
|
28 |
+
<script>bpost/shm/onestepcheckout_shipping.js</script>
|
29 |
+
</action>
|
30 |
+
|
31 |
+
<action method="addItem">
|
32 |
+
<type>skin_js</type><name>js/bpost/onestepcheckout.js</name>
|
33 |
+
</action>
|
34 |
+
</reference>
|
35 |
+
</onestepcheckout_index_index>
|
36 |
</layout>
|
app/design/frontend/base/default/template/bpost/shm/append_bpost_shippingmethod.phtml
CHANGED
@@ -1,128 +1,128 @@
|
|
1 |
-
<?php $settings = $this->getSettings() ?>
|
2 |
-
<?php $bpostHelper = Mage::helper("bpost_shm");?>
|
3 |
-
|
4 |
-
<div id="bpostShm" class="bpostspotswrapper">
|
5 |
-
<?php if($bpostHelper->isOnestepCheckout()){ ?>
|
6 |
-
<div id="bpost-info-wrapper">
|
7 |
-
<div id="bpostinfo"></div>
|
8 |
-
</div>
|
9 |
-
<?php }else{ ?>
|
10 |
-
<div id="bpostinfo"></div>
|
11 |
-
<?php } ?>
|
12 |
-
|
13 |
-
<div id="bpostresult"></div>
|
14 |
-
|
15 |
-
<?php if($this->getCurrentShippingMethod() == "bpostshm_bpost_pickuppoint"){ ?>
|
16 |
-
<a href="#" id="selectPickupPoint" type="<?php echo Bpost_ShM_Model_Api::TYPE_PICKUP_POINT; ?>">
|
17 |
-
<?php echo $settings['select_text'] ?>
|
18 |
-
</a>
|
19 |
-
<?php }elseif($this->getCurrentShippingMethod() == "bpostshm_bpost_clickcollect"){ ?>
|
20 |
-
<a href="#" id="selectPickupPoint" type="<?php echo Bpost_ShM_Model_Api::TYPE_CLICK_COLLECT; ?>">
|
21 |
-
<?php echo $settings['select_text_clickcollect'] ?>
|
22 |
-
</a>
|
23 |
-
<?php }else{ ?>
|
24 |
-
<a href="#" id="selectPickupPoint" type="<?php echo Bpost_ShM_Model_Api::TYPE_PARCEL_LOCKER; ?>">
|
25 |
-
<?php echo $settings['select_text_parcel_locker'] ?>
|
26 |
-
</a>
|
27 |
-
<?php } ?>
|
28 |
-
|
29 |
-
<input id="bpost-id" type="hidden" name="bpost[id]" class="validate-bpostspot validate-parcel validate-clickcollect"/>
|
30 |
-
<input type="hidden" name="bpost[street]"/>
|
31 |
-
<input type="hidden" name="bpost[city]"/>
|
32 |
-
<input type="hidden" name="bpost[postcode]"/>
|
33 |
-
<input type="hidden" name="bpost[name]"/>
|
34 |
-
|
35 |
-
<div class="notifications" id="notifications-pick-up-point">
|
36 |
-
<h5><?php echo $settings['notifications_text_pickup_point'] ?></h5>
|
37 |
-
<label for="pickup-point-notification-sms"<?php echo !$this->getBpostNotificationSms() || $this->getBpostNotificationSms() == "-" ? ' class="disabled"' : ''; ?>><input id="pickup-point-notification-sms" type="radio" value="sms" name="notification"<?php echo !$this->getBpostNotificationSms() || $this->getBpostNotificationSms() == "-" ? ' disabled="disabled"' : ''; ?>/> <?php echo $settings['notifications_sms_pickup_point'] ?> (<?php echo ($this->getBpostNotificationSms() ?: '<span class="error">'.$settings['no_telephone_number'].'</span>'); ?>)</label>
|
38 |
-
<label for="pickup-point-notification-email"><input type="radio" id="pickup-point-notification-email" name="notification" value="email"/> <?php echo $settings['notifications_email'] ?> (<?php echo $this->getBpostNotificationEmail(); ?>)</label>
|
39 |
-
</div>
|
40 |
-
|
41 |
-
<div class="notifications" id="notifications-parcel-locker">
|
42 |
-
<h5><?php echo $settings['notifications_text_parcel_locker'] ?></h5>
|
43 |
-
<label for="notification-sms"<?php echo !$this->getBpostNotificationSms() || $this->getBpostNotificationSms() == "-" ? ' class="disabled"' : ''; ?>><input type="checkbox" id="notification-sms" value="sms" name="parcel-notification"<?php echo !$this->getBpostNotificationSms() || $this->getBpostNotificationSms() == "-" ? ' disabled="disabled"' : ''; ?>/> <?php echo $settings['notifications_sms_parcel_locker'] ?> (<?php echo ($this->getBpostNotificationSms() ?: '<span class="error">'.$settings['no_telephone_number'].'</span>'); ?>)</label>
|
44 |
-
<br/>
|
45 |
-
<div id="reduced-mobility-wrapper">
|
46 |
-
<label for="reduced-mobility"><input type="checkbox" id="reduced-mobility" name="reduced-mobility"/> <?php echo $bpostHelper->__("I wish to use the reduced mobility zone"); ?></label>
|
47 |
-
<div class="reduced-mobility-tooltip"><?php echo $bpostHelper->__("By using this option, customers with reduced mobility can use the lockers of the machine easiest to reach.");?></div>
|
48 |
-
</div>
|
49 |
-
</div>
|
50 |
-
</div>
|
51 |
-
|
52 |
-
<div id="bpostDelivery">
|
53 |
-
<div class="bpost-deliverydate-wrapper">
|
54 |
-
<h5><?php echo $settings['datepicker_delivery_date_text'] ?></h5>
|
55 |
-
<div class="bpost-display-deliverydate"></div>
|
56 |
-
</div>
|
57 |
-
<div class="bpost-choose-deliverydate"></div>
|
58 |
-
<div class="cf"></div>
|
59 |
-
<div class="bpost-saturday-delivery">
|
60 |
-
<label for="bpost-saturday">
|
61 |
-
<input type="checkbox" <?php if($bpostHelper->isOnestepCheckout()){ echo 'onclick="stopObserving(); triggerAjaxCallGetSeparateSaveMethods(\'' . $this->getUrl('onestepcheckout/ajax/set_methods_separate', array('_secure'=>true)) . '\', false);"';}?> name="bpost_saturday_delivery" id="bpost-saturday" value="1" />
|
62 |
-
<div class="bpost-label-text"><?php echo $settings['datepicker_saturday_delivery_text'] ?><?php if($this->getSaturdayDeliveryCost()) { ?><br /><small><?php echo sprintf($settings['datepicker_saturday_delivery_cost'], $this->getSaturdayDeliveryCost()) ?></small><?php } ?></div>
|
63 |
-
</label>
|
64 |
-
</div>
|
65 |
-
<input type="hidden" name="bpost[deliverydate]" class="deliverydate-required-entry"/>
|
66 |
-
</div>
|
67 |
-
|
68 |
-
<script type="text/javascript">
|
69 |
-
window.onestepcheckout_set_methods_separate = '<?php echo $this->getUrl('onestepcheckout/ajax/set_methods_separate', array('_secure'=>true));?>';
|
70 |
-
window.bpostSettings = <?php echo json_encode($settings); ?>;
|
71 |
-
window.bpostShM = new Bpost.ShM(window.bpostSettings, "<?php echo $this->getCurrentShippingMethod(); ?>");
|
72 |
-
|
73 |
-
Validation.add('deliverydate-required-entry', "<?php echo Mage::helper('bpost_shm')->__('This is a required field.'); ?>", function (v) {
|
74 |
-
if($('bpostDelivery').getStyle('display') == 'none'){
|
75 |
-
return true;
|
76 |
-
}
|
77 |
-
return !Validation.get('IsEmpty').test(v);
|
78 |
-
});
|
79 |
-
|
80 |
-
Validation.add('validate-bpostspot', "<?php echo Mage::helper('bpost_shm')->__('Please select a bpost pick-up point'); ?>", function (v) {
|
81 |
-
if($('s_method_bpostshm_bpost_pickuppoint')) {
|
82 |
-
return !($('s_method_bpostshm_bpost_pickuppoint').checked && Validation.get('IsEmpty').test(v))
|
83 |
-
}
|
84 |
-
else{
|
85 |
-
return true;
|
86 |
-
}
|
87 |
-
});
|
88 |
-
|
89 |
-
Validation.add('validate-clickcollect', "<?php echo Mage::helper('bpost_shm')->__('Please select a bpost Click & Collect point'); ?>", function (v) {
|
90 |
-
if($('s_method_bpostshm_bpost_clickcollect')) {
|
91 |
-
return !($('s_method_bpostshm_bpost_clickcollect').checked && Validation.get('IsEmpty').test(v))
|
92 |
-
}
|
93 |
-
else{
|
94 |
-
return true;
|
95 |
-
}
|
96 |
-
});
|
97 |
-
|
98 |
-
Validation.add('validate-parcel', "<?php echo Mage::helper('bpost_shm')->__('Please select a bpost parcel locker'); ?>", function (v) {
|
99 |
-
if($('s_method_bpostshm_bpost_parcellocker')) {
|
100 |
-
return !($('s_method_bpostshm_bpost_parcellocker').checked && Validation.get('IsEmpty').test(v))
|
101 |
-
}
|
102 |
-
else{
|
103 |
-
return true;
|
104 |
-
}
|
105 |
-
});
|
106 |
-
|
107 |
-
Validation.add('validate-multiple-delivery-dates', "<?php echo Mage::helper('bpost_shm')->__('Please select a delivery date'); ?>", function (v,elm) {
|
108 |
-
var inputs = $$('input[name="bpost[deliverydate]"]');
|
109 |
-
|
110 |
-
var error = 1;
|
111 |
-
for(var i=0;i<inputs.length;i++) {
|
112 |
-
if((inputs[i].type == 'checkbox' || inputs[i].type == 'radio') && inputs[i].checked == true) {
|
113 |
-
error = 0;
|
114 |
-
}
|
115 |
-
|
116 |
-
if(Validation.isOnChange && (inputs[i].type == 'checkbox' || inputs[i].type == 'radio')) {
|
117 |
-
Validation.reset(inputs[i]);
|
118 |
-
}
|
119 |
-
}
|
120 |
-
|
121 |
-
if( error == 0 ) {
|
122 |
-
return true;
|
123 |
-
} else {
|
124 |
-
|
125 |
-
}
|
126 |
-
});
|
127 |
-
|
128 |
-
</script>
|
1 |
+
<?php $settings = $this->getSettings() ?>
|
2 |
+
<?php $bpostHelper = Mage::helper("bpost_shm");?>
|
3 |
+
|
4 |
+
<div id="bpostShm" class="bpostspotswrapper">
|
5 |
+
<?php if($bpostHelper->isOnestepCheckout()){ ?>
|
6 |
+
<div id="bpost-info-wrapper">
|
7 |
+
<div id="bpostinfo"></div>
|
8 |
+
</div>
|
9 |
+
<?php }else{ ?>
|
10 |
+
<div id="bpostinfo"></div>
|
11 |
+
<?php } ?>
|
12 |
+
|
13 |
+
<div id="bpostresult"></div>
|
14 |
+
|
15 |
+
<?php if($this->getCurrentShippingMethod() == "bpostshm_bpost_pickuppoint"){ ?>
|
16 |
+
<a href="#" id="selectPickupPoint" type="<?php echo Bpost_ShM_Model_Api::TYPE_PICKUP_POINT; ?>">
|
17 |
+
<?php echo $settings['select_text'] ?>
|
18 |
+
</a>
|
19 |
+
<?php }elseif($this->getCurrentShippingMethod() == "bpostshm_bpost_clickcollect"){ ?>
|
20 |
+
<a href="#" id="selectPickupPoint" type="<?php echo Bpost_ShM_Model_Api::TYPE_CLICK_COLLECT; ?>">
|
21 |
+
<?php echo $settings['select_text_clickcollect'] ?>
|
22 |
+
</a>
|
23 |
+
<?php }else{ ?>
|
24 |
+
<a href="#" id="selectPickupPoint" type="<?php echo Bpost_ShM_Model_Api::TYPE_PARCEL_LOCKER; ?>">
|
25 |
+
<?php echo $settings['select_text_parcel_locker'] ?>
|
26 |
+
</a>
|
27 |
+
<?php } ?>
|
28 |
+
|
29 |
+
<input id="bpost-id" type="hidden" name="bpost[id]" class="validate-bpostspot validate-parcel validate-clickcollect"/>
|
30 |
+
<input type="hidden" name="bpost[street]"/>
|
31 |
+
<input type="hidden" name="bpost[city]"/>
|
32 |
+
<input type="hidden" name="bpost[postcode]"/>
|
33 |
+
<input type="hidden" name="bpost[name]"/>
|
34 |
+
|
35 |
+
<div class="notifications" id="notifications-pick-up-point">
|
36 |
+
<h5><?php echo $settings['notifications_text_pickup_point'] ?></h5>
|
37 |
+
<label for="pickup-point-notification-sms"<?php echo !$this->getBpostNotificationSms() || $this->getBpostNotificationSms() == "-" ? ' class="disabled"' : ''; ?>><input id="pickup-point-notification-sms" type="radio" value="sms" name="notification"<?php echo !$this->getBpostNotificationSms() || $this->getBpostNotificationSms() == "-" ? ' disabled="disabled"' : ''; ?>/> <?php echo $settings['notifications_sms_pickup_point'] ?> (<?php echo ($this->getBpostNotificationSms() ?: '<span class="error">'.$settings['no_telephone_number'].'</span>'); ?>)</label>
|
38 |
+
<label for="pickup-point-notification-email"><input type="radio" id="pickup-point-notification-email" name="notification" value="email"/> <?php echo $settings['notifications_email'] ?> (<?php echo $this->getBpostNotificationEmail(); ?>)</label>
|
39 |
+
</div>
|
40 |
+
|
41 |
+
<div class="notifications" id="notifications-parcel-locker">
|
42 |
+
<h5><?php echo $settings['notifications_text_parcel_locker'] ?></h5>
|
43 |
+
<label for="notification-sms"<?php echo !$this->getBpostNotificationSms() || $this->getBpostNotificationSms() == "-" ? ' class="disabled"' : ''; ?>><input type="checkbox" id="notification-sms" value="sms" name="parcel-notification"<?php echo !$this->getBpostNotificationSms() || $this->getBpostNotificationSms() == "-" ? ' disabled="disabled"' : ''; ?>/> <?php echo $settings['notifications_sms_parcel_locker'] ?> (<?php echo ($this->getBpostNotificationSms() ?: '<span class="error">'.$settings['no_telephone_number'].'</span>'); ?>)</label>
|
44 |
+
<br/>
|
45 |
+
<div id="reduced-mobility-wrapper">
|
46 |
+
<label for="reduced-mobility"><input type="checkbox" id="reduced-mobility" name="reduced-mobility"/> <?php echo $bpostHelper->__("I wish to use the reduced mobility zone"); ?></label>
|
47 |
+
<div class="reduced-mobility-tooltip"><?php echo $bpostHelper->__("By using this option, customers with reduced mobility can use the lockers of the machine easiest to reach.");?></div>
|
48 |
+
</div>
|
49 |
+
</div>
|
50 |
+
</div>
|
51 |
+
|
52 |
+
<div id="bpostDelivery">
|
53 |
+
<div class="bpost-deliverydate-wrapper">
|
54 |
+
<h5><?php echo $settings['datepicker_delivery_date_text'] ?></h5>
|
55 |
+
<div class="bpost-display-deliverydate"></div>
|
56 |
+
</div>
|
57 |
+
<div class="bpost-choose-deliverydate"></div>
|
58 |
+
<div class="cf"></div>
|
59 |
+
<div class="bpost-saturday-delivery">
|
60 |
+
<label for="bpost-saturday">
|
61 |
+
<input type="checkbox" <?php if($bpostHelper->isOnestepCheckout()){ echo 'onclick="stopObserving(); triggerAjaxCallGetSeparateSaveMethods(\'' . $this->getUrl('onestepcheckout/ajax/set_methods_separate', array('_secure'=>true)) . '\', false);"';}?> name="bpost_saturday_delivery" id="bpost-saturday" value="1" />
|
62 |
+
<div class="bpost-label-text"><?php echo $settings['datepicker_saturday_delivery_text'] ?><?php if($this->getSaturdayDeliveryCost()) { ?><br /><small><?php echo sprintf($settings['datepicker_saturday_delivery_cost'], $this->getSaturdayDeliveryCost()) ?></small><?php } ?></div>
|
63 |
+
</label>
|
64 |
+
</div>
|
65 |
+
<input type="hidden" name="bpost[deliverydate]" class="deliverydate-required-entry"/>
|
66 |
+
</div>
|
67 |
+
|
68 |
+
<script type="text/javascript">
|
69 |
+
window.onestepcheckout_set_methods_separate = '<?php echo $this->getUrl('onestepcheckout/ajax/set_methods_separate', array('_secure'=>true));?>';
|
70 |
+
window.bpostSettings = <?php echo json_encode($settings); ?>;
|
71 |
+
window.bpostShM = new Bpost.ShM(window.bpostSettings, "<?php echo $this->getCurrentShippingMethod(); ?>");
|
72 |
+
|
73 |
+
Validation.add('deliverydate-required-entry', "<?php echo Mage::helper('bpost_shm')->__('This is a required field.'); ?>", function (v) {
|
74 |
+
if($('bpostDelivery').getStyle('display') == 'none'){
|
75 |
+
return true;
|
76 |
+
}
|
77 |
+
return !Validation.get('IsEmpty').test(v);
|
78 |
+
});
|
79 |
+
|
80 |
+
Validation.add('validate-bpostspot', "<?php echo Mage::helper('bpost_shm')->__('Please select a bpost pick-up point'); ?>", function (v) {
|
81 |
+
if($('s_method_bpostshm_bpost_pickuppoint')) {
|
82 |
+
return !($('s_method_bpostshm_bpost_pickuppoint').checked && Validation.get('IsEmpty').test(v))
|
83 |
+
}
|
84 |
+
else{
|
85 |
+
return true;
|
86 |
+
}
|
87 |
+
});
|
88 |
+
|
89 |
+
Validation.add('validate-clickcollect', "<?php echo Mage::helper('bpost_shm')->__('Please select a bpost Click & Collect point'); ?>", function (v) {
|
90 |
+
if($('s_method_bpostshm_bpost_clickcollect')) {
|
91 |
+
return !($('s_method_bpostshm_bpost_clickcollect').checked && Validation.get('IsEmpty').test(v))
|
92 |
+
}
|
93 |
+
else{
|
94 |
+
return true;
|
95 |
+
}
|
96 |
+
});
|
97 |
+
|
98 |
+
Validation.add('validate-parcel', "<?php echo Mage::helper('bpost_shm')->__('Please select a bpost parcel locker'); ?>", function (v) {
|
99 |
+
if($('s_method_bpostshm_bpost_parcellocker')) {
|
100 |
+
return !($('s_method_bpostshm_bpost_parcellocker').checked && Validation.get('IsEmpty').test(v))
|
101 |
+
}
|
102 |
+
else{
|
103 |
+
return true;
|
104 |
+
}
|
105 |
+
});
|
106 |
+
|
107 |
+
Validation.add('validate-multiple-delivery-dates', "<?php echo Mage::helper('bpost_shm')->__('Please select a delivery date'); ?>", function (v,elm) {
|
108 |
+
var inputs = $$('input[name="bpost[deliverydate]"]');
|
109 |
+
|
110 |
+
var error = 1;
|
111 |
+
for(var i=0;i<inputs.length;i++) {
|
112 |
+
if((inputs[i].type == 'checkbox' || inputs[i].type == 'radio') && inputs[i].checked == true) {
|
113 |
+
error = 0;
|
114 |
+
}
|
115 |
+
|
116 |
+
if(Validation.isOnChange && (inputs[i].type == 'checkbox' || inputs[i].type == 'radio')) {
|
117 |
+
Validation.reset(inputs[i]);
|
118 |
+
}
|
119 |
+
}
|
120 |
+
|
121 |
+
if( error == 0 ) {
|
122 |
+
return true;
|
123 |
+
} else {
|
124 |
+
|
|
|
|
|
|
|
|