HEM_Simpleshipping - Version 0.1.0

Version Notes

Tested in 1.4.2.0, should work in 1.5.0.0 without any problems.

Download this release

Release Info

Developer Hucke EDV
Extension HEM_Simpleshipping
Version 0.1.0
Comparing to
See all releases


Version 0.1.0

app/code/community/HEM/Simpleshipping/Helper/Data.php ADDED
@@ -0,0 +1,28 @@
1
+ <?php
2
+
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ *
12
+ * @category HEM
13
+ * @package HEM_Simplepayment
14
+ * @copyright Copyright (c) 2011 Hucke EDV & Media e.K. (http://www.hucke-media.de/)
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+ /**
19
+ * HEM Simpleshipping Helper
20
+ *
21
+ * @category HEM
22
+ * @package HEM_Simpleshipping
23
+ * @author Hucke EDV & Media e.K. <magento@hucke.net>
24
+ */
25
+
26
+ class HEM_Simpleshipping_Helper_Data extends Mage_Core_Helper_Abstract
27
+ {
28
+ }
app/code/community/HEM/Simpleshipping/Model/Carrier/Simpleshipping.php ADDED
@@ -0,0 +1,87 @@
1
+ <?php
2
+
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ *
12
+ * @category HEM
13
+ * @package HEM_Simplepayment
14
+ * @copyright Copyright (c) 2011 Hucke EDV & Media e.K. (http://www.hucke-media.de/)
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+ /**
19
+ * HEM Simpleshipping Carrier Model
20
+ *
21
+ * @category HEM
22
+ * @package HEM_Simpleshipping
23
+ * @author Hucke EDV & Media e.K. <magento@hucke.net>
24
+ */
25
+ class HEM_Simpleshipping_Model_Carrier_Simpleshipping extends Mage_Shipping_Model_Carrier_Abstract
26
+ {
27
+ protected $_code = 'simpleshipping';
28
+
29
+ /**
30
+ * collect shipping rates
31
+ *
32
+ * @param Mage_Shipping_Model_Rate_Request $request
33
+ * @return Mage_Shipping_Model_Rate_Result
34
+ */
35
+ public function collectRates(Mage_Shipping_Model_Rate_Request $request)
36
+ {
37
+ if(!$this->getConfigFlag('active')) {
38
+ return false;
39
+ }
40
+
41
+ $result = Mage::getModel('shipping/rate_result');
42
+
43
+ $rates = $this->getRate($this->getConfigData('shippingconf'));
44
+
45
+ foreach($rates as $rate) {
46
+ $method = Mage::getModel('shipping/rate_result_method');
47
+
48
+ $method->setCarrier('simpleshipping');
49
+ $method->setCarrierTitle($this->getConfigData('title'));
50
+
51
+ $method->setMethod('simpleshipping_' . $rate['code']);
52
+ $method->setMethodTitle($rate['title']);
53
+
54
+ $method->setPrice($rate['price']);
55
+ //$method->setCost(0);
56
+
57
+ $result->append($method);
58
+ }
59
+
60
+ return $result;
61
+ }
62
+
63
+ /**
64
+ * return simple shipping table rates
65
+ *
66
+ * @param Mage_Shipping_Model_Rate_Request $data
67
+ * @return array
68
+ */
69
+ public function getRate($data)
70
+ {
71
+ return Mage::getModel('simpleshipping/simpleshipping')->getRate($data);
72
+ }
73
+
74
+ /**
75
+ * return allowed shipping methods
76
+ *
77
+ * @return array
78
+ */
79
+ public function getAllowedMethods()
80
+ {
81
+ $allowedMethods = array(
82
+ 'simpleshipping' => $this->getConfigData('name'),
83
+ );
84
+
85
+ return $allowedMethods;
86
+ }
87
+ }
app/code/community/HEM/Simpleshipping/Model/Simpleshipping.php ADDED
@@ -0,0 +1,70 @@
1
+ <?php
2
+
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ *
12
+ * @category HEM
13
+ * @package HEM_Simplepayment
14
+ * @copyright Copyright (c) 2011 Hucke EDV & Media e.K. (http://www.hucke-media.de/)
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+ /**
19
+ * HEM Simpleshipping Model
20
+ *
21
+ * @category HEM
22
+ * @package HEM_Simpleshipping
23
+ * @author Hucke EDV & Media e.K. <magento@hucke.net>
24
+ */
25
+ class HEM_Simpleshipping_Model_Simpleshipping extends Mage_Core_Model_Abstract
26
+ {
27
+ const _field_SORT_ORDER = 0;
28
+ const _field_CODE = 1;
29
+ const _field_PRICE = 2;
30
+ const _field_DESCRIPTION = 3;
31
+
32
+ /**
33
+ * return simple shipping table rates
34
+ *
35
+ * @param Mage_Shipping_Model_Rate_Request $data
36
+ * @return array
37
+ */
38
+ public function getRate($data)
39
+ {
40
+ $rates = array();
41
+ $methods = explode("\n", $data);
42
+
43
+ foreach($methods as $method) {
44
+ $method = trim($method);
45
+ $method = explode('|', $method);
46
+
47
+ $sortOrder = trim($method[self::_field_SORT_ORDER]);
48
+ $code = trim($method[self::_field_CODE]);
49
+ $price = trim($method[self::_field_PRICE]);
50
+ $title = trim($method[self::_field_DESCRIPTION]);
51
+
52
+ $title = str_replace(array('=>', '<='), array('<strong>', '</strong>'), $title);
53
+
54
+ /* workaround for methods with the same sort_order */
55
+ while(isset($rate[$sortOrder]['code'])) {
56
+ $sortOrder++;
57
+ }
58
+
59
+ $rates[$sortOrder] = array(
60
+ 'code' => $code,
61
+ 'title' => $title,
62
+ 'price' => $price,
63
+ );
64
+ }
65
+
66
+ krsort($rates);
67
+
68
+ return $rates;
69
+ }
70
+ }
app/code/community/HEM/Simpleshipping/etc/config.xml ADDED
@@ -0,0 +1,71 @@
1
+ <?xml version="1.0"?>
2
+
3
+ <!--
4
+ /**
5
+ * Magento
6
+ *
7
+ * NOTICE OF LICENSE
8
+ *
9
+ * This source file is subject to the Open Software License (OSL 3.0)
10
+ * that is available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ *
13
+ * @package HEM_Simplepayment
14
+ * @copyright Copyright (c) 2011 Hucke EDV & Media e.K. - http://www.hucke-media.de/ - Bastian Ike
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+ -->
18
+
19
+ <config>
20
+ <global>
21
+ <models>
22
+ <simpleshipping>
23
+ <class>HEM_Simpleshipping_Model</class>
24
+ </simpleshipping>
25
+ </models>
26
+
27
+ <helpers>
28
+ <simpleshipping>
29
+ <class>HEM_Simpleshipping_Helper</class>
30
+ </simpleshipping>
31
+ </helpers>
32
+ </global>
33
+
34
+ <frontend>
35
+ <translate>
36
+ <modules>
37
+ <HEM_Simpleshipping>
38
+ <files>
39
+ <default>HEM_Simpleshipping.csv</default>
40
+ </files>
41
+ </HEM_Simpleshipping>
42
+ </modules>
43
+ </translate>
44
+ </frontend>
45
+
46
+ <adminhtml>
47
+ <translate>
48
+ <modules>
49
+ <HEM_Simpleshipping>
50
+ <files>
51
+ <default>HEM_Simpleshipping.csv</default>
52
+ </files>
53
+ </HEM_Simpleshipping>
54
+ </modules>
55
+ </translate>
56
+ </adminhtml>
57
+
58
+ <!--
59
+ Simpleshipping Carrier
60
+ simpleshipping/carrier_simpleshipping generates the shipping-list based on the configuration in the backend
61
+ -->
62
+ <default>
63
+ <carriers>
64
+ <simpleshipping>
65
+ <active>1</active>
66
+ <model>simpleshipping/carrier_simpleshipping</model>
67
+ <title>Simpleshipping</title>
68
+ </simpleshipping>
69
+ </carriers>
70
+ </default>
71
+ </config>
app/code/community/HEM/Simpleshipping/etc/system.xml ADDED
@@ -0,0 +1,74 @@
1
+ <?xml version="1.0"?>
2
+
3
+ <!--
4
+ /**
5
+ * Magento
6
+ *
7
+ * NOTICE OF LICENSE
8
+ *
9
+ * This source file is subject to the Open Software License (OSL 3.0)
10
+ * that is available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ *
13
+ * @category HEM
14
+ * @package HEM_Simplepayment
15
+ * @copyright Copyright (c) 2011 Hucke EDV & Media e.K. (http://www.hucke-media.de/)
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ -->
19
+
20
+ <config>
21
+ <sections>
22
+ <carriers translate="label" module="shipping">
23
+ <groups>
24
+ <simpleshipping translate="label">
25
+ <label>HEM Simpleshipping</label>
26
+ <frontend_type>text</frontend_type>
27
+ <sort_order>2</sort_order>
28
+ <show_in_default>1</show_in_default>
29
+ <show_in_website>1</show_in_website>
30
+ <show_in_store>1</show_in_store>
31
+ <fields>
32
+ <active translate="label">
33
+ <label>Enabled</label>
34
+ <frontend_type>select</frontend_type>
35
+ <source_model>adminhtml/system_config_source_yesno</source_model>
36
+ <sort_order>1</sort_order>
37
+ <show_in_default>1</show_in_default>
38
+ <show_in_website>1</show_in_website>
39
+ <show_in_store>1</show_in_store>
40
+ </active>
41
+
42
+ <title translate="label">
43
+ <label>Method name</label>
44
+ <frontend_type>text</frontend_type>
45
+ <sort_order>10</sort_order>
46
+ <show_in_default>1</show_in_default>
47
+ <show_in_website>1</show_in_website>
48
+ <show_in_store>1</show_in_store>
49
+ </title>
50
+
51
+ <shippingconf translate="label">
52
+ <label>Shipping configuration</label>
53
+ <frontend_type>textarea</frontend_type>
54
+ <sort_order>20</sort_order>
55
+ <show_in_default>1</show_in_default>
56
+ <show_in_website>1</show_in_website>
57
+ <show_in_store>1</show_in_store>
58
+ <comment>format: sortorder|code|price|description - use =&gt;text&lt;= to output bold text, set price to 0 to hide</comment>
59
+ </shippingconf>
60
+
61
+ <sort_order translate="label">
62
+ <label>Sort order</label>
63
+ <frontend_type>text</frontend_type>
64
+ <sort_order>100</sort_order>
65
+ <show_in_default>1</show_in_default>
66
+ <show_in_website>1</show_in_website>
67
+ <show_in_store>1</show_in_store>
68
+ </sort_order>
69
+ </fields>
70
+ </simpleshipping>
71
+ </groups>
72
+ </carriers>
73
+ </sections>
74
+ </config>
app/etc/modules/HEM_Simpleshipping.xml ADDED
@@ -0,0 +1 @@
0
<modules>
1
<HEM_Simpleshipping>
2
<active>true</active>
3
<codePool>local</codePool>
4
</HEM_Simpleshipping>
5
</modules>
1
+ <?xml version="1.0"?>
2
<modules>
3
<HEM_Simpleshipping>
4
<active>true</active>
5
<codePool>local</codePool>
6
</HEM_Simpleshipping>
7
</modules>
app/locale/de_DE/HEM_Simpleshipping.csv ADDED
@@ -0,0 +1,5 @@
1
+ "Enabled","Aktiviert"
2
+ "Method name","Name der Versandart"
3
+ "Shipping configuration","Versandarten konfigurieren"
4
+ "format: sortorder|code|price|description - use =>text<= to output bold text, set price to 0 to hide","Format: Reihenfolge|Code|Preis|Beschreibung - =>test<= zeigt den Text fett an"
5
+ "Sort order","Reihenfolge"
package.xml ADDED
@@ -0,0 +1,29 @@
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>HEM_Simpleshipping</name>
4
+ <version>0.1.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">OSL 3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>HEM Simpleshipping - simple shipping methods generator.</summary>
10
+ <description>HEM Simpleshipping generates skeleton carriers based on a simple CSV-configuration.&#xD;
11
+ You can easily define a list of carriers that will be displayed in the shipping-section in your checkout.&#xD;
12
+ &#xD;
13
+ This Extension is particularly useful to add some shipping options to your shop which can have a fixed price (i.e. no weight calculation). F.e. cash on delivery or pickup.&#xD;
14
+ &#xD;
15
+ CSV columns:&#xD;
16
+ sort order|code|price|description&#xD;
17
+ &#xD;
18
+ sort order: for sorting in frontend&#xD;
19
+ code: shipping_method (getShippingMethod), e.g. simpleshipping_pickup&#xD;
20
+ price: price for this shipping method&#xD;
21
+ description: text that will show in storefront</description>
22
+ <notes>Tested in 1.4.2.0, should work in 1.5.0.0 without any problems.</notes>
23
+ <authors><author><name>Hucke EDV </name><user>hucke-media</user><email>magento@hucke.net</email></author></authors>
24
+ <date>2011-03-28</date>
25
+ <time>11:05:33</time>
26
+ <contents><target name="mageetc"><dir name="modules"><file name="HEM_Simpleshipping.xml" hash="e339834a6cdc78bd230377dbea80acd5"/></dir></target><target name="magecommunity"><dir name="HEM"><dir name="Simpleshipping"><dir name="Helper"><file name="Data.php" hash="d053ebd30042512be08a35a244258c7a"/></dir><dir name="Model"><dir name="Carrier"><file name="Simpleshipping.php" hash="3f0f37e3906bb452229f6b9e9ea2307d"/></dir><file name="Simpleshipping.php" hash="91bd9ceb2bde85791f723ea52e573e75"/></dir><dir name="etc"><file name="config.xml" hash="98eea019ceeeedbc9145b6d233b5cede"/><file name="system.xml" hash="80022d662be540ca255bcd0ed1e19734"/></dir></dir></dir></target><target name="magelocale"><dir name="de_DE"><file name="HEM_Simpleshipping.csv" hash="ac84fba6c9e25a8aa487a67aec75bad8"/></dir></target></contents>
27
+ <compatible/>
28
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
29
+ </package>