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 +2 -2
- app/code/community/Mymonki/Ship2pay/Block/Onepage/Payment/Methods.php +9 -3
- app/code/community/Mymonki/Ship2pay/Helper/Data.php +31 -5
- app/code/community/Mymonki/Ship2pay/Model/System/Config/Backend/Serialized/Ship2pay.php +30 -0
- app/code/community/Mymonki/Ship2pay/etc/config.xml +1 -1
- app/code/community/Mymonki/Ship2pay/etc/system.xml +1 -1
- package.xml +7 -8
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=""
|
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=""
|
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 |
-
$
|
71 |
-
|
72 |
//Ship2Pay avaiable methods
|
73 |
$avaiable = array();
|
74 |
foreach($ship2pay['shipping_method'] as $key => $smethod)
|
75 |
{
|
76 |
-
if($smethod == $
|
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 |
-
|
64 |
-
|
65 |
-
|
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
|
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>
|
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
|
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
|
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
|
13 |
<authors><author><name>Paweł</name><user>krzaczek</user><email>pawel@freshmind.pl</email></author></authors>
|
14 |
-
<date>2012-
|
15 |
-
<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="
|
17 |
<compatible/>
|
18 |
-
<dependencies><required><php><min>5.2.0</min><max>5.
|
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ł</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>
|