Mymonki_Ship2pay - Version 1.1.0

Version Notes

- added ability to select delivery method and not only the delivery company. Now UPS Standard and UPS Express can have different payment methods.

Download this release

Release Info

Developer Paweł
Extension Mymonki_Ship2pay
Version 1.1.0
Comparing to
See all releases


Code changes from version 1.0.8 to 1.1.0

app/code/community/Mymonki/Ship2pay/Block/Adminhtml/Ship2pay.php CHANGED
@@ -65,7 +65,7 @@ class Mymonki_Ship2pay_Block_Adminhtml_Ship2pay extends Mage_Adminhtml_Block_Sys
65
  $html = '<tr>';
66
  $html .= '<td>';
67
  $html .= '<select id="ship2pay_shipping" class="option-control" style="width: 150px" value="" name="'.$this->getElement()->getName().'[shipping_method][]" >';
68
- $html .= '<option value=""></option>';
69
  foreach($shipping_methods as $shipping_method)
70
  {
71
  if($shipping_method['value'] == $this->_getValue('shipping_method/'.$i))
@@ -77,7 +77,7 @@ class Mymonki_Ship2pay_Block_Adminhtml_Ship2pay extends Mage_Adminhtml_Block_Sys
77
  $html .= '</td>';
78
  $html .= '<td>';
79
  $html .= '<select id="ship2pay_payment" class="option-control" style="width: 150px" value="" name="'.$this->getElement()->getName().'[payment_method][]" >';
80
- $html .= '<option value=""></option>';
81
  foreach($payment_methods as $payment_method)
82
  {
83
  //Mage::log('Payment Method: '.var_export($payment_method, true));
65
  $html = '<tr>';
66
  $html .= '<td>';
67
  $html .= '<select id="ship2pay_shipping" class="option-control" style="width: 150px" value="" name="'.$this->getElement()->getName().'[shipping_method][]" >';
68
+ $html .= '<option value="__empty">-- select shipping</option>';
69
  foreach($shipping_methods as $shipping_method)
70
  {
71
  if($shipping_method['value'] == $this->_getValue('shipping_method/'.$i))
77
  $html .= '</td>';
78
  $html .= '<td>';
79
  $html .= '<select id="ship2pay_payment" class="option-control" style="width: 150px" value="" name="'.$this->getElement()->getName().'[payment_method][]" >';
80
+ $html .= '<option value="__empty">-- select payment</option>';
81
  foreach($payment_methods as $payment_method)
82
  {
83
  //Mage::log('Payment Method: '.var_export($payment_method, true));
app/code/community/Mymonki/Ship2pay/Block/Onepage/Payment/Methods.php CHANGED
@@ -67,15 +67,21 @@ class Mymonki_Ship2pay_Block_Onepage_Payment_Methods extends Mage_Checkout_Block
67
  $shippingMethod = "free"; //Grand total eq 0 - set shipping method to dump "free"
68
  }
69
 
70
- $shippingMethod = explode('_', $shippingMethod);
71
-
72
  //Ship2Pay avaiable methods
73
  $avaiable = array();
74
  foreach($ship2pay['shipping_method'] as $key => $smethod)
75
  {
76
- if($smethod == $shippingMethod[0])
77
  $avaiable[$ship2pay['payment_method'][$key]] = true;
78
  }
 
 
 
 
 
 
79
 
80
  //Mage::log(var_export($avaiable, true));
81
 
67
  $shippingMethod = "free"; //Grand total eq 0 - set shipping method to dump "free"
68
  }
69
 
70
+ $shippingMethodFlat = explode('_', $shippingMethod);
71
+
72
  //Ship2Pay avaiable methods
73
  $avaiable = array();
74
  foreach($ship2pay['shipping_method'] as $key => $smethod)
75
  {
76
+ if($smethod == $shippingMethodFlat[0])
77
  $avaiable[$ship2pay['payment_method'][$key]] = true;
78
  }
79
+
80
+ foreach($ship2pay['shipping_method'] as $key => $smethod)
81
+ {
82
+ if($smethod == $shippingMethod)
83
+ $avaiable[$ship2pay['payment_method'][$key]] = true;
84
+ }
85
 
86
  //Mage::log(var_export($avaiable, true));
87
 
app/code/community/Mymonki/Ship2pay/Helper/Data.php CHANGED
@@ -57,13 +57,39 @@ class Mymonki_Ship2pay_Helper_Data extends Mage_Core_Helper_Abstract {
57
 
58
  $carriers = Mage::getSingleton('shipping/config')->getAllCarriers($storeId);
59
  $options = array();
60
-
61
  foreach($carriers as $carrierCode=>$carrierConfig)
62
  {
63
- array_unshift($options, array(
64
- 'value' => $carrierCode,
65
- 'label' => $this->getCarrierName($carrierCode)
66
- ));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67
  }
68
 
69
  return $options;
57
 
58
  $carriers = Mage::getSingleton('shipping/config')->getAllCarriers($storeId);
59
  $options = array();
60
+
61
  foreach($carriers as $carrierCode=>$carrierConfig)
62
  {
63
+ if(version_compare(Mage::getVersion(), '1.5.0', '>='))
64
+ {
65
+ $methods = $carrierConfig->getAllowedMethods();
66
+
67
+ if($methods)
68
+ {
69
+ if(count($methods) > 1)
70
+ {
71
+ foreach($methods as $method=>$methodName)
72
+ {
73
+ if(!is_array($methodName))
74
+ {
75
+ if(preg_match('#^([a-zA-Z0-9])+$#', $method))
76
+ {
77
+ array_unshift($options, array(
78
+ 'value' => $carrierCode.'_'.$method,
79
+ 'label' => $this->getCarrierName($carrierCode) . ' - ' .$methodName
80
+ ));
81
+ }
82
+ }
83
+ }
84
+ }
85
+ }
86
+ }
87
+
88
+ array_unshift($options, array(
89
+ 'value' => $carrierCode,
90
+ 'label' => $this->getCarrierName($carrierCode)
91
+ ));
92
+
93
  }
94
 
95
  return $options;
app/code/community/Mymonki/Ship2pay/Model/System/Config/Backend/Serialized/Ship2pay.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Backend for serialized array data
4
+ *
5
+ */
6
+ class Mymonki_Ship2pay_Model_System_Config_Backend_Serialized_Ship2pay extends Mage_Adminhtml_Model_System_Config_Backend_Serialized
7
+ {
8
+ /**
9
+ * Unset array element with '__empty' key
10
+ *
11
+ */
12
+ protected function _beforeSave()
13
+ {
14
+ $value = $this->getValue();
15
+
16
+ $rows = count($value['shipping_method']);
17
+
18
+ for($i=0; $i<$rows; $i++)
19
+ {
20
+ if($value['shipping_method'][$i] == '__empty' || $value['payment_method'][$i] == '__empty')
21
+ {
22
+ unset($value['shipping_method'][$i]);
23
+ unset($value['payment_method'][$i]);
24
+ }
25
+ }
26
+
27
+ $this->setValue($value);
28
+ parent::_beforeSave();
29
+ }
30
+ }
app/code/community/Mymonki/Ship2pay/etc/config.xml CHANGED
@@ -10,7 +10,7 @@
10
  <config>
11
  <modules>
12
  <Mymonki_Ship2pay>
13
- <version>1.0.8</version>
14
  </Mymonki_Ship2pay>
15
  </modules>
16
  <global>
10
  <config>
11
  <modules>
12
  <Mymonki_Ship2pay>
13
+ <version>1.1.0</version>
14
  </Mymonki_Ship2pay>
15
  </modules>
16
  <global>
app/code/community/Mymonki/Ship2pay/etc/system.xml CHANGED
@@ -23,7 +23,7 @@
23
  <ship2pay translate="label,comment">
24
  <label>Ship to Pay</label>
25
  <frontend_model>ship2pay/adminhtml_ship2pay</frontend_model>
26
- <backend_model>adminhtml/system_config_backend_serialized_array</backend_model>
27
  <sort_order>20</sort_order>
28
  <show_in_default>1</show_in_default>
29
  <show_in_website>0</show_in_website>
23
  <ship2pay translate="label,comment">
24
  <label>Ship to Pay</label>
25
  <frontend_model>ship2pay/adminhtml_ship2pay</frontend_model>
26
+ <backend_model>ship2pay/system_config_backend_serialized_ship2pay</backend_model>
27
  <sort_order>20</sort_order>
28
  <show_in_default>1</show_in_default>
29
  <show_in_website>0</show_in_website>
package.xml CHANGED
@@ -1,19 +1,18 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Mymonki_Ship2pay</name>
4
- <version>1.0.8</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
  <channel>community</channel>
8
  <extends/>
9
- <summary>Shows payment methods depending on shipping method.&#xD;
10
- - fix for "No payment information necessary" - when cart grandtotal is 0</summary>
11
  <description>Module that limits the number of payment options depending on the chosen shipping method. For example When my client chooses pickup at store he should not be able to select bank transfer</description>
12
- <notes>fix for "No payment information necessary" - when cart grandtotal is 0</notes>
13
  <authors><author><name>Pawe&#x142;</name><user>krzaczek</user><email>pawel@freshmind.pl</email></author></authors>
14
- <date>2012-01-27</date>
15
- <time>12:21:45</time>
16
- <contents><target name="magelocale"><dir name="pl_PL"><file name="Mymonki_Ship2pay.csv" hash="7723347de6de6068f8d8b6b9fa227a15"/></dir></target><target name="magecommunity"><dir name="Mymonki"><dir name="Ship2pay"><dir name="Block"><dir name="Adminhtml"><file name="Ship2pay.php" hash="076e6e0840129b8517df6b92d177d352"/></dir><dir name="Onepage"><dir name="Payment"><file name="Methods.php" hash="d915e85e2de05e6dbdcc7f60ebed8f80"/></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="ca0768ee6a5da7e940fd642e5463093d"/></dir><dir name="Model"><file name="Ship2pay.php" hash="14a17e4d4ef83622e40d81e6b770736d"/></dir><dir name="etc"><file name="config.xml" hash="8262c9a95211ddc89da0e776bdeb6a70"/><file name="system.xml" hash="3f9c3640c298ba4db33a43e80b0a9bba"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Mymonki_Ship2pay.xml" hash="7faf6630d1abba5fb960ece11c1c1c12"/></dir></target></contents>
17
  <compatible/>
18
- <dependencies><required><php><min>5.2.0</min><max>5.4.0</max></php></required></dependencies>
19
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Mymonki_Ship2pay</name>
4
+ <version>1.1.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
  <channel>community</channel>
8
  <extends/>
9
+ <summary>Shows payment methods depending on shipping method.</summary>
 
10
  <description>Module that limits the number of payment options depending on the chosen shipping method. For example When my client chooses pickup at store he should not be able to select bank transfer</description>
11
+ <notes>- added ability to select delivery method and not only the delivery company. Now UPS Standard and UPS Express can have different payment methods.</notes>
12
  <authors><author><name>Pawe&#x142;</name><user>krzaczek</user><email>pawel@freshmind.pl</email></author></authors>
13
+ <date>2012-04-25</date>
14
+ <time>10:54:11</time>
15
+ <contents><target name="magelocale"><dir name="pl_PL"><file name="Mymonki_Ship2pay.csv" hash="7723347de6de6068f8d8b6b9fa227a15"/></dir></target><target name="magecommunity"><dir name="Mymonki"><dir name="Ship2pay"><dir name="Block"><dir name="Adminhtml"><file name="Ship2pay.php" hash="de741f53018f738f032a970982e59f35"/></dir><dir name="Onepage"><dir name="Payment"><file name="Methods.php" hash="a5638284f2ae6696adf2882886ec9a4d"/></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="657f06adda0a4d27606fbfa9de5c4a8e"/></dir><dir name="Model"><file name="Ship2pay.php" hash="14a17e4d4ef83622e40d81e6b770736d"/><dir name="System"><dir name="Config"><dir name="Backend"><dir name="Serialized"><file name="Ship2pay.php" hash="1da7e1d823c9f22f003a20d41e272a66"/></dir></dir></dir></dir></dir><dir name="etc"><file name="config.xml" hash="b8982d58ae06f2abbf5c6fa38976da5a"/><file name="system.xml" hash="4b152022408b4881422ac3d347ea7d9f"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Mymonki_Ship2pay.xml" hash="7faf6630d1abba5fb960ece11c1c1c12"/></dir></target></contents>
16
  <compatible/>
17
+ <dependencies><required><php><min>5.2.0</min><max>5.5.0</max></php></required></dependencies>
18
  </package>