Version Notes
* Hide PostPal from shopping cart if it's not available for the entered address
* Option for disabling PostPal for selected products
Download this release
Release Info
Developer | PostPal |
Extension | PostPal_Shipping |
Version | 0.1.6 |
Comparing to | |
See all releases |
Code changes from version 0.1.5 to 0.1.6
app/code/community/PostPal/Shipping/Model/Carrier.php
CHANGED
@@ -1 +1 @@
|
|
1 |
-
<?php
|
2 |
* @author Jana Vassiljeva <jana@artmarka.com>
|
3 |
*/
|
4 |
protected $_code = 'postpal_shipping';
|
5 |
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
|
6 |
{
|
7 |
$result = Mage::getModel('shipping/rate_result');
|
8 |
/* @var $result Mage_Shipping_Model_Rate_Result */
|
9 |
if(!$this->_isAvailable($request))
|
10 |
return $result;
|
11 |
$result->append($this->_getStandardShippingRate());
|
12 |
return $result;
|
13 |
}
|
14 |
public function isTrackingAvailable()
|
15 |
{
|
16 |
return true;
|
17 |
}
|
18 |
protected function _getStandardShippingRate()
|
19 |
{
|
20 |
$rate = Mage::getModel('shipping/rate_result_method');
|
21 |
/* @var $rate Mage_Shipping_Model_Rate_Result_Method */
|
22 |
$rate->setCarrier($this->_code);
|
23 |
/**
|
24 |
* getConfigData(config_key) returns the configuration value for the
|
25 |
* carriers/[carrier_code]/[config_key]
|
26 |
*/
|
27 |
$rate->setCarrierTitle($this->getConfigData('title'));
|
28 |
$rate->setMethod('fixed');
|
29 |
$result = Mage::getModel('postpal_shipping/api')->getDeliveryArrivalEstimation();
|
30 |
if (empty($result) || $result->status == false)
|
31 |
return false;
|
32 |
$formatedTime = date('d.m.Y H:i', strtotime($result->estimate));
|
33 |
$rate->setMethodTitle($this->getConfigData('name'). ' ('. Mage::helper('postpal')->__('ETA: '). ' ' . $formatedTime . ') ');
|
34 |
$rate->setPrice($this->getConfigData('default_price'));
|
35 |
$rate->setCost(0);
|
36 |
return $rate;
|
37 |
}
|
38 |
protected function _isAvailable(Mage_Shipping_Model_Rate_Request $request) {
|
39 |
$productItem = true;
|
40 |
if ($this->getConfigData('checkitems') == 1) {
|
41 |
$productItem = true;
|
42 |
if ($request->getAllItems()) {
|
43 |
foreach ($request->getAllItems() as $item) {
|
44 |
$custom = Mage::getModel('catalog/product')->load($item->getProduct()->getId());
|
45 |
$notAvailableByPostPal = $custom->getData('nopostpal'); // Product attribute nopostpal
|
46 |
if ($notAvailableByPostPal) {
|
47 |
$productItem = false;
|
48 |
break;
|
49 |
}
|
50 |
}
|
51 |
}
|
52 |
}
|
53 |
if (!$productItem)
|
54 |
return false;
|
55 |
return true;
|
56 |
}
|
57 |
public function getAllowedMethods() {
|
58 |
return array();
|
59 |
}
|
|
|
60 |
* @author Jana Vassiljeva <jana@artmarka.com>
|
61 |
*/
|
62 |
protected $_code = 'postpal_shipping';
|
63 |
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
|
64 |
{
|
65 |
$result = Mage::getModel('shipping/rate_result');
|
66 |
/* @var $result Mage_Shipping_Model_Rate_Result */
|
67 |
if(!$this->_isAvailable($request))
|
68 |
return $result;
|
69 |
if(!$this->_isAddressAvailable($request))
|
70 |
return $result;
|
71 |
$result->append($this->_getStandardShippingRate());
|
72 |
return $result;
|
73 |
}
|
74 |
public function isTrackingAvailable()
|
75 |
{
|
76 |
return true;
|
77 |
}
|
78 |
protected function _isAddressAvailable($request)
|
79 |
{
|
80 |
$shipping = Mage::getSingleton('checkout/session')->getQuote()->getShippingAddress();
|
81 |
if(empty($shipping))
|
82 |
return true;
|
83 |
$data = array(
|
84 |
'shippingAddress' => array(
|
85 |
'firstname' => $shipping->getFirstname(),
|
86 |
'lastname' => $shipping->getLastname(),
|
87 |
'company' => '',
|
88 |
'email' => '',
|
89 |
'street' => $request->getDestStreet(),
|
90 |
'city' => $request->getDestCity(),
|
91 |
'country_id' => $request->getDestCountryId(),
|
92 |
'postcode' => $request->getDestPostcode(),
|
93 |
'telephone' => $shipping->getTelephone(),
|
94 |
),
|
95 |
'packageSize' => 'size20x36x60D10W'
|
96 |
);
|
97 |
$result = Mage::getModel('postpal_shipping/api')->getOrderValidation($data);
|
98 |
if (!empty($result) && $result->status == 'true')
|
99 |
return true;
|
100 |
return false;
|
101 |
}
|
102 |
protected function _getStandardShippingRate()
|
103 |
{
|
104 |
$rate = Mage::getModel('shipping/rate_result_method');
|
105 |
/* @var $rate Mage_Shipping_Model_Rate_Result_Method */
|
106 |
$rate->setCarrier($this->_code);
|
107 |
/**
|
108 |
* getConfigData(config_key) returns the configuration value for the
|
109 |
* carriers/[carrier_code]/[config_key]
|
110 |
*/
|
111 |
$rate->setCarrierTitle($this->getConfigData('title'));
|
112 |
$rate->setMethod('fixed');
|
113 |
$result = Mage::getModel('postpal_shipping/api')->getDeliveryArrivalEstimation();
|
114 |
if (empty($result) || $result->status == false)
|
115 |
return false;
|
116 |
$formatedTime = date('d.m.Y H:i', strtotime($result->estimate));
|
117 |
$rate->setMethodTitle($this->getConfigData('name'). ' ('. Mage::helper('postpal')->__('ETA: '). ' ' . $formatedTime . ') ');
|
118 |
$rate->setPrice($this->getConfigData('default_price'));
|
119 |
$rate->setCost(0);
|
120 |
return $rate;
|
121 |
}
|
122 |
protected function _isAvailable(Mage_Shipping_Model_Rate_Request $request) {
|
123 |
$productItem = true;
|
124 |
if ($request->getAllItems()) {
|
125 |
foreach ($request->getAllItems() as $item) {
|
126 |
$custom = Mage::getModel('catalog/product')->load($item->getProduct()->getId());
|
127 |
$notAvailableByPostPal = $custom->getData('nopostpal'); // Product attribute nopostpal
|
128 |
if ($notAvailableByPostPal) {
|
129 |
$productItem = false;
|
130 |
break;
|
131 |
}
|
132 |
}
|
133 |
}
|
134 |
if (!$productItem)
|
135 |
return false;
|
136 |
return true;
|
137 |
}
|
138 |
public function getAllowedMethods() {
|
139 |
return array();
|
140 |
}
|
|
|
1 |
* @author Jana Vassiljeva <jana@artmarka.com>
|
2 |
*/
|
3 |
protected $_code = 'postpal_shipping';
|
4 |
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
|
5 |
{
|
6 |
$result = Mage::getModel('shipping/rate_result');
|
7 |
/* @var $result Mage_Shipping_Model_Rate_Result */
|
8 |
if(!$this->_isAvailable($request))
|
9 |
return $result;
|
10 |
$result->append($this->_getStandardShippingRate());
|
11 |
return $result;
|
12 |
}
|
13 |
public function isTrackingAvailable()
|
14 |
{
|
15 |
return true;
|
16 |
}
|
17 |
protected function _getStandardShippingRate()
|
18 |
{
|
19 |
$rate = Mage::getModel('shipping/rate_result_method');
|
20 |
/* @var $rate Mage_Shipping_Model_Rate_Result_Method */
|
21 |
$rate->setCarrier($this->_code);
|
22 |
/**
|
23 |
* getConfigData(config_key) returns the configuration value for the
|
24 |
* carriers/[carrier_code]/[config_key]
|
25 |
*/
|
26 |
$rate->setCarrierTitle($this->getConfigData('title'));
|
27 |
$rate->setMethod('fixed');
|
28 |
$result = Mage::getModel('postpal_shipping/api')->getDeliveryArrivalEstimation();
|
29 |
if (empty($result) || $result->status == false)
|
30 |
return false;
|
31 |
$formatedTime = date('d.m.Y H:i', strtotime($result->estimate));
|
32 |
$rate->setMethodTitle($this->getConfigData('name'). ' ('. Mage::helper('postpal')->__('ETA: '). ' ' . $formatedTime . ') ');
|
33 |
$rate->setPrice($this->getConfigData('default_price'));
|
34 |
$rate->setCost(0);
|
35 |
return $rate;
|
36 |
}
|
37 |
protected function _isAvailable(Mage_Shipping_Model_Rate_Request $request) {
|
38 |
$productItem = true;
|
39 |
if ($this->getConfigData('checkitems') == 1) {
|
40 |
$productItem = true;
|
41 |
if ($request->getAllItems()) {
|
42 |
foreach ($request->getAllItems() as $item) {
|
43 |
$custom = Mage::getModel('catalog/product')->load($item->getProduct()->getId());
|
44 |
$notAvailableByPostPal = $custom->getData('nopostpal'); // Product attribute nopostpal
|
45 |
if ($notAvailableByPostPal) {
|
46 |
$productItem = false;
|
47 |
break;
|
48 |
}
|
49 |
}
|
50 |
}
|
51 |
}
|
52 |
if (!$productItem)
|
53 |
return false;
|
54 |
return true;
|
55 |
}
|
56 |
public function getAllowedMethods() {
|
57 |
return array();
|
58 |
}
|
59 |
+
<?php
|
60 |
* @author Jana Vassiljeva <jana@artmarka.com>
|
61 |
*/
|
62 |
protected $_code = 'postpal_shipping';
|
63 |
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
|
64 |
{
|
65 |
$result = Mage::getModel('shipping/rate_result');
|
66 |
/* @var $result Mage_Shipping_Model_Rate_Result */
|
67 |
if(!$this->_isAvailable($request))
|
68 |
return $result;
|
69 |
if(!$this->_isAddressAvailable($request))
|
70 |
return $result;
|
71 |
$result->append($this->_getStandardShippingRate());
|
72 |
return $result;
|
73 |
}
|
74 |
public function isTrackingAvailable()
|
75 |
{
|
76 |
return true;
|
77 |
}
|
78 |
protected function _isAddressAvailable($request)
|
79 |
{
|
80 |
$shipping = Mage::getSingleton('checkout/session')->getQuote()->getShippingAddress();
|
81 |
if(empty($shipping))
|
82 |
return true;
|
83 |
$data = array(
|
84 |
'shippingAddress' => array(
|
85 |
'firstname' => $shipping->getFirstname(),
|
86 |
'lastname' => $shipping->getLastname(),
|
87 |
'company' => '',
|
88 |
'email' => '',
|
89 |
'street' => $request->getDestStreet(),
|
90 |
'city' => $request->getDestCity(),
|
91 |
'country_id' => $request->getDestCountryId(),
|
92 |
'postcode' => $request->getDestPostcode(),
|
93 |
'telephone' => $shipping->getTelephone(),
|
94 |
),
|
95 |
'packageSize' => 'size20x36x60D10W'
|
96 |
);
|
97 |
$result = Mage::getModel('postpal_shipping/api')->getOrderValidation($data);
|
98 |
if (!empty($result) && $result->status == 'true')
|
99 |
return true;
|
100 |
return false;
|
101 |
}
|
102 |
protected function _getStandardShippingRate()
|
103 |
{
|
104 |
$rate = Mage::getModel('shipping/rate_result_method');
|
105 |
/* @var $rate Mage_Shipping_Model_Rate_Result_Method */
|
106 |
$rate->setCarrier($this->_code);
|
107 |
/**
|
108 |
* getConfigData(config_key) returns the configuration value for the
|
109 |
* carriers/[carrier_code]/[config_key]
|
110 |
*/
|
111 |
$rate->setCarrierTitle($this->getConfigData('title'));
|
112 |
$rate->setMethod('fixed');
|
113 |
$result = Mage::getModel('postpal_shipping/api')->getDeliveryArrivalEstimation();
|
114 |
if (empty($result) || $result->status == false)
|
115 |
return false;
|
116 |
$formatedTime = date('d.m.Y H:i', strtotime($result->estimate));
|
117 |
$rate->setMethodTitle($this->getConfigData('name'). ' ('. Mage::helper('postpal')->__('ETA: '). ' ' . $formatedTime . ') ');
|
118 |
$rate->setPrice($this->getConfigData('default_price'));
|
119 |
$rate->setCost(0);
|
120 |
return $rate;
|
121 |
}
|
122 |
protected function _isAvailable(Mage_Shipping_Model_Rate_Request $request) {
|
123 |
$productItem = true;
|
124 |
if ($request->getAllItems()) {
|
125 |
foreach ($request->getAllItems() as $item) {
|
126 |
$custom = Mage::getModel('catalog/product')->load($item->getProduct()->getId());
|
127 |
$notAvailableByPostPal = $custom->getData('nopostpal'); // Product attribute nopostpal
|
128 |
if ($notAvailableByPostPal) {
|
129 |
$productItem = false;
|
130 |
break;
|
131 |
}
|
132 |
}
|
133 |
}
|
134 |
if (!$productItem)
|
135 |
return false;
|
136 |
return true;
|
137 |
}
|
138 |
public function getAllowedMethods() {
|
139 |
return array();
|
140 |
}
|
app/code/community/PostPal/Shipping/etc/config.xml
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
<config>
|
3 |
<modules>
|
4 |
<PostPal_Shipping>
|
5 |
-
<
|
6 |
</PostPal_Shipping>
|
7 |
</modules>
|
8 |
<frontend>
|
@@ -24,6 +24,26 @@
|
|
24 |
</layout>
|
25 |
</frontend>
|
26 |
<global>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
<models>
|
28 |
<postpal_shipping>
|
29 |
<class>PostPal_Shipping_Model</class>
|
2 |
<config>
|
3 |
<modules>
|
4 |
<PostPal_Shipping>
|
5 |
+
<version>1.0.0</version>
|
6 |
</PostPal_Shipping>
|
7 |
</modules>
|
8 |
<frontend>
|
24 |
</layout>
|
25 |
</frontend>
|
26 |
<global>
|
27 |
+
<resources>
|
28 |
+
<postpal_shipping_setup>
|
29 |
+
<setup>
|
30 |
+
<module>PostPal_Shipping</module>
|
31 |
+
</setup>
|
32 |
+
<connection>
|
33 |
+
<use>core_setup</use>
|
34 |
+
</connection>
|
35 |
+
</postpal_shipping_setup>
|
36 |
+
<postpal_write>
|
37 |
+
<connection>
|
38 |
+
<use>core_write</use>
|
39 |
+
</connection>
|
40 |
+
</postpal_write>
|
41 |
+
<postpal_read>
|
42 |
+
<connection>
|
43 |
+
<use>core_read</use>
|
44 |
+
</connection>
|
45 |
+
</postpal_read>
|
46 |
+
</resources>
|
47 |
<models>
|
48 |
<postpal_shipping>
|
49 |
<class>PostPal_Shipping_Model</class>
|
app/code/community/PostPal/Shipping/sql/postpal_shipping_setup/mysql4-install-1.0.0.php
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$installer = $this;
|
4 |
+
$installer->startSetup();
|
5 |
+
|
6 |
+
$attributeGroup = 'PostPal Shipping';
|
7 |
+
|
8 |
+
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
|
9 |
+
|
10 |
+
$entity = 'catalog_product';
|
11 |
+
|
12 |
+
$setup->removeAttribute($entity, 'nopostpal');
|
13 |
+
$setup->addAttribute($entity, 'nopostpal', array(
|
14 |
+
'group' => $attributeGroup,
|
15 |
+
'position' => 1,
|
16 |
+
'type' => 'int',
|
17 |
+
'label' => 'PostPal delivery disabled',
|
18 |
+
'input' => 'boolean',
|
19 |
+
'global' => 1,
|
20 |
+
'visible' => 1,
|
21 |
+
'required' => 0,
|
22 |
+
'user_defined' => 1,
|
23 |
+
'searchable' => 0,
|
24 |
+
'filterable' => 0,
|
25 |
+
'comparable' => 0,
|
26 |
+
'visible_on_front' => 0,
|
27 |
+
'visible_in_advanced_search' => 0,
|
28 |
+
'unique' => 0,
|
29 |
+
'is_configurable' => 0
|
30 |
+
));
|
31 |
+
|
32 |
+
$installer->endSetup();
|
package.xml
CHANGED
@@ -1,18 +1,19 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>PostPal_Shipping</name>
|
4 |
-
<version>0.1.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://creativecommons.org/licenses/by-sa/4.0/">Creative Commons Attribution-ShareAlike 4.0 International</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>PostPal shipping extension</summary>
|
10 |
<description>This extension adds PostPal on-demand courier service to your shopping cart.</description>
|
11 |
-
<notes
|
|
|
12 |
<authors><author><name>PostPal</name><user>PostPal</user><email>hello@postpal.ee</email></author></authors>
|
13 |
-
<date>2016-02
|
14 |
-
<time>
|
15 |
-
<contents><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="postpal"><dir name="css"><file name="postpal.css" hash="5b3f0d0cce5377aa5bf6978865d0061b"/></dir><dir name="img"><file name="postpal_logo.png" hash="fc3f0bbb0d70f229321bcdd31eaa7549"/></dir><dir name="js"><file name="opcheckout_postpal.js" hash="ddbd3e07a118291edf36c077e1ecc2d1"/></dir></dir></dir></dir></dir></target><target name="magecommunity"><dir name="PostPal"><dir name="Shipping"><dir name="Block"><dir name="Adminhtml"><dir name="Sales"><dir name="Order"><dir name="Shipment"><file name="View.php" hash="edc39b75e3b0e69ae5dc122c4078ac7a"/></dir></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="9dfca5f43c00ccab5f1f5b8ac5445c8e"/></dir><dir name="Model"><file name="Api.php" hash="fd8bd87f5798e5da81a1d5dcdf58f020"/><file name="Carrier.php" hash="
|
16 |
<compatible/>
|
17 |
<dependencies><required><php><min>5.3.0</min><max>7.0.0</max></php><extension><name>json</name><min/><max/></extension></required></dependencies>
|
18 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>PostPal_Shipping</name>
|
4 |
+
<version>0.1.6</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://creativecommons.org/licenses/by-sa/4.0/">Creative Commons Attribution-ShareAlike 4.0 International</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>PostPal shipping extension</summary>
|
10 |
<description>This extension adds PostPal on-demand courier service to your shopping cart.</description>
|
11 |
+
<notes>* Hide PostPal from shopping cart if it's not available for the entered address
|
12 |
+
* Option for disabling PostPal for selected products </notes>
|
13 |
<authors><author><name>PostPal</name><user>PostPal</user><email>hello@postpal.ee</email></author></authors>
|
14 |
+
<date>2016-03-02</date>
|
15 |
+
<time>17:07:54</time>
|
16 |
+
<contents><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="postpal"><dir name="css"><file name="postpal.css" hash="5b3f0d0cce5377aa5bf6978865d0061b"/></dir><dir name="img"><file name="postpal_logo.png" hash="fc3f0bbb0d70f229321bcdd31eaa7549"/></dir><dir name="js"><file name="opcheckout_postpal.js" hash="ddbd3e07a118291edf36c077e1ecc2d1"/></dir></dir></dir></dir></dir></target><target name="magecommunity"><dir name="PostPal"><dir name="Shipping"><dir name="Block"><dir name="Adminhtml"><dir name="Sales"><dir name="Order"><dir name="Shipment"><file name="View.php" hash="edc39b75e3b0e69ae5dc122c4078ac7a"/></dir></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="9dfca5f43c00ccab5f1f5b8ac5445c8e"/></dir><dir name="Model"><file name="Api.php" hash="fd8bd87f5798e5da81a1d5dcdf58f020"/><file name="Carrier.php" hash="27a1e9c96b353befbb292cf7f12b8e1a"/><file name="Observer.php" hash="1e61ca4d0cb36d73137d4110ad4070b6"/><file name="Shipping.php" hash="5f3ceaa12a412f8c9bcf50551292dcf7"/></dir><dir name="etc"><file name="config.xml" hash="8015eb414c6b8d11e80713d8a32b2393"/><file name="system.xml" hash="ed221153d603cfa5f3bfaae51d5ab896"/></dir><dir name="sql"><dir name="postpal_shipping_setup"><file name="mysql4-install-1.0.0.php" hash="64c8c72e0b52b2737367ac5fb8e502cf"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><dir name="postpal"><file name="shipping.xml" hash="cbc63d0c8072bf83685e9a19db8aeaac"/></dir></dir><dir name="template"><dir name="postpal"><file name="extras.phtml" hash="8bad02b894d8fc8da8dbd5729dfceff1"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="PostPal_Shipping.xml" hash="8336b32b2ec54a8ebf90029265ab5729"/></dir></target><target name="magelocale"><dir><dir name="en_US"><file name="PostPal_Shipping.csv" hash="50052dc9f9a55bc8a4ff56ce43606eff"/></dir><dir name="et_EE"><file name="PostPal_Shipping.csv" hash="d9d64841396d1a0fb705246409ea7933"/></dir></dir></target></contents>
|
17 |
<compatible/>
|
18 |
<dependencies><required><php><min>5.3.0</min><max>7.0.0</max></php><extension><name>json</name><min/><max/></extension></required></dependencies>
|
19 |
</package>
|