Thebod_Shippingrates - Version 1.0.0

Version Notes

* Tested on 1.6, should work on Magento >= 1.4

Download this release

Release Info

Developer Magento Core Team
Extension Thebod_Shippingrates
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

app/code/community/Thebod/Shippingrates/Block/Adminhtml/Config.php ADDED
@@ -0,0 +1,166 @@
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-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@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Thebod
16
+ * @package Thebod_Shippingrates
17
+ * @copyright Copyright (c) 2012 Bastian Ike (http://thebod.de/)
18
+ * @author Bastian Ike <b-ike@b-ike.de>
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+ class Thebod_Shippingrates_Block_Adminhtml_Config extends Mage_Adminhtml_Block_System_Config_Form_Field {
22
+
23
+ protected $_addRowButtonHtml = array();
24
+ protected $_removeRowButtonHtml = array();
25
+
26
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) {
27
+ $this->setElement($element);
28
+
29
+ $html = '<div id="shippingconfig_template" style="display:none">';
30
+ $html .= $this->_getRowTemplateHtml();
31
+ $html .= '</div>';
32
+
33
+ $html .= '
34
+ <script type="text/javascript">
35
+ /* sorry, i\'m not a js-wizard :( */
36
+
37
+ var filter_btn;
38
+
39
+ function shippingconfig_filter_show(btn) {
40
+ filter_btn = btn;
41
+ $(\'shippingconfig_filter_name\').update($(btn).up(1).down(\'.name\').value);
42
+ if($(btn).up(1).down(\'.filter\').value == \'\') {
43
+ $(btn).up(1).down(\'.filter\').value = \'min_qty:;max_qty:;min_subtotal:;max_subtotal:;min_weight:;max_weight:;\';
44
+ }
45
+
46
+ filter = $(btn).up(1).down(\'.filter\').value.split(\';\').each(function(e,i) {
47
+ e = e.split(\':\');
48
+ if($(\'shippingconfig_filter_\' + e[0])) {
49
+ $(\'shippingconfig_filter_\' + e[0]).value = e[1];
50
+ }
51
+ } );
52
+ $(\'shippingconfig_filter\').show();
53
+ }
54
+
55
+ function shippingconfig_filter_hide() {
56
+ btn = filter_btn;
57
+ $(\'shippingconfig_filter\').hide();
58
+
59
+ filter = \'min_qty:\' + $(\'shippingconfig_filter_min_qty\').value + \';\';
60
+ filter += \'max_qty:\' + $(\'shippingconfig_filter_max_qty\').value + \';\';
61
+ filter += \'min_subtotal:\' + $(\'shippingconfig_filter_min_subtotal\').value + \';\';
62
+ filter += \'max_subtotal:\' + $(\'shippingconfig_filter_max_subtotal\').value + \';\';
63
+ filter += \'min_weight:\' + $(\'shippingconfig_filter_min_weight\').value + \';\';
64
+ filter += \'max_weight:\' + $(\'shippingconfig_filter_max_weight\').value + \';\';
65
+
66
+ $(btn).up(1).down(\'.filter\').value = filter;
67
+
68
+ }
69
+ </script>
70
+ <div id="shippingconfig_filter" style="width:500px;position:absolute;z-index:999;display: none;">
71
+ <div class="entry-edit-head"><strong>' . $this->__('configure filter') . ' <span id="shippingconfig_filter_name"></span></strong></div>
72
+ <div class="box">
73
+ ' . $this->__('(empty fields will be ignored)') . '<br/>
74
+ <table border="0">
75
+ <tr>
76
+ <td>' . $this->__('min. QTY:') . '</td><td><input class="input-text" style="width: 100px;" id="shippingconfig_filter_min_qty"/></td>
77
+ <td>' . $this->__('max. QTY:') . '</td><td><input class="input-text" style="width: 100px;" id="shippingconfig_filter_max_qty"/></td>
78
+ </tr>
79
+ <tr>
80
+ <td>' . $this->__('min. subtotal:') . '</td><td><input class="input-text" style="width: 100px;" id="shippingconfig_filter_min_subtotal"/></td>
81
+ <td>' . $this->__('max. subtotal:') . '</td><td><input class="input-text" style="width: 100px;" id="shippingconfig_filter_max_subtotal"/></td>
82
+ </tr>
83
+ <tr>
84
+ <td>' . $this->__('min. weight:') . '</td><td><input class="input-text" style="width: 100px;" id="shippingconfig_filter_min_weight"/></td>
85
+ <td>' . $this->__('max. weight:') . '</td><td><input class="input-text" style="width: 100px;" id="shippingconfig_filter_max_weight"/></td>
86
+ </tr>
87
+ </table>
88
+ <div style="text-align: right;">
89
+ <button onclick="shippingconfig_filter_hide()" type="button">' . $this->__('save filter') . '</button>
90
+ </div>
91
+ </div>
92
+ </div>';
93
+
94
+ $html .= $this->_getAddRowButtonHtml('shippingconfig_container', 'shippingconfig_template', $this->__('Add'));
95
+
96
+ $html .= '<ul id="shippingconfig_container">';
97
+ $html .= '<li style="width: 500px;">
98
+ <span style="border-left: dotted 1px #888; padding: 0 5px;margin: 0 2px;width: 100px;display: inline-block;">' . $this->__('code') . '</span>
99
+ <span style="border-left: dotted 1px #888; padding: 0 5px;margin: 0 2px;width: 30px;display: inline-block;">' . $this->__('price') . '</span>
100
+ <span style="border-left: dotted 1px #888; padding: 0 5px;margin: 0 2px;width: 150px;display: inline-block;">' . $this->__('description') . '</span>
101
+ <span style="border-left: dotted 1px #888; padding: 0 5px;margin: 0 2px;width: 100px;display: inline-block;">' . $this->__('notification mail (optional)') . '</span>
102
+ <span style="border-left: dotted 1px #888; padding: 0 5px;margin: 0 2px;width: 100px;display: none;">' . $this->__('filter') . '</span>
103
+ </li>';
104
+
105
+ if ($this->_getValue('code')) {
106
+ foreach ($this->_getValue('code') as $k => $v) {
107
+ if ($k) {
108
+ $html .= $this->_getRowTemplateHtml($k);
109
+ }
110
+ }
111
+ }
112
+ $html .= '</ul>';
113
+
114
+ return $html;
115
+ }
116
+
117
+ protected function _getRowTemplateHtml($key = 0) {
118
+ $html = '<li style="display: block; width: 550px;">';
119
+ $html .= '<div style="float: left;">';
120
+ $html .= '<input class="name input-text ' . $this->_getDisabled() . '" style="vertical-align: top; width: 100px; margin: 0 6px;" name="' . $this->getElement()->getName() . '[code][]" value="' . $this->_getValue('code/' . $key) . '"/>';
121
+ $html .= '<input class="input-text ' . $this->_getDisabled() . '" style="vertical-align: top; width: 30px; margin: 0 6px;" name="' . $this->getElement()->getName() . '[price][]" value="' . $this->_getValue('price/' . $key) . '"/>';
122
+ $html .= '<textarea onfocus="this.style.height=\'100px\'" onblur="this.style.height=\'16px\'" style="vertical-align: top; width: 150px; margin: 0 6px; height:16px;" name="' . $this->getElement()->getName() . '[description][]" class="' . $this->_getDisabled() . '">' . $this->_getValue('description/' . $key) . '</textarea>';
123
+ $html .= '<input class="input-text ' . $this->_getDisabled() . '" style="vertical-align: top; width: 100px; margin: 0 6px;" name="' . $this->getElement()->getName() . '[email][]" value="' . $this->_getValue('email/' . $key) . '" />';
124
+ $html .= '<input style="display:none" class="filter" name="' . $this->getElement()->getName() . '[filter][]" value="' . $this->_getValue('filter/' . $key) . '" />';
125
+ $html .= '<button class="show-hide v-middle ' . $this->_getDisabled() . '" type="button" onclick="shippingconfig_filter_show(this)"><span></span></button>&nbsp;';
126
+ $html .= $this->_getRemoveRowButtonHtml();
127
+ $html .= '</div>';
128
+ $html .= '</li>';
129
+
130
+ return $html;
131
+ }
132
+
133
+ protected function _getDisabled() {
134
+ return $this->getElement()->getDisabled() ? ' disabled' : '';
135
+ }
136
+
137
+ protected function _getValue($key) {
138
+ return $this->getElement()->getData('value/' . $key);
139
+ }
140
+
141
+ protected function _getAddRowButtonHtml($container, $template, $title = 'Add') {
142
+ if (!isset($this->_addRowButtonHtml[$container])) {
143
+ $this->_addRowButtonHtml[$container] = $this->getLayout()->createBlock('adminhtml/widget_button')
144
+ ->setType('button')
145
+ ->setClass('add ' . $this->_getDisabled())
146
+ ->setLabel($this->__($title))
147
+ ->setOnClick("Element.insert($('" . $container . "'), {bottom: $('" . $template . "').innerHTML})")
148
+ ->setDisabled($this->_getDisabled())
149
+ ->toHtml();
150
+ }
151
+ return $this->_addRowButtonHtml[$container];
152
+ }
153
+
154
+ protected function _getRemoveRowButtonHtml($selector = 'li', $title = 'Delete') {
155
+ if (!$this->_removeRowButtonHtml) {
156
+ $this->_removeRowButtonHtml = $this->getLayout()->createBlock('adminhtml/widget_button')
157
+ ->setType('button')
158
+ ->setClass('delete ' . $this->_getDisabled())
159
+ ->setOnClick("Element.remove($(this).up('" . $selector . "'))")
160
+ ->setDisabled($this->_getDisabled())
161
+ ->toHtml();
162
+ }
163
+ return $this->_removeRowButtonHtml;
164
+ }
165
+
166
+ }
app/code/community/Thebod/Shippingrates/Helper/Data.php ADDED
@@ -0,0 +1,23 @@
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-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@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Thebod
16
+ * @package Thebod_Shippingrates
17
+ * @copyright Copyright (c) 2012 Bastian Ike (http://thebod.de/)
18
+ * @author Bastian Ike <b-ike@b-ike.de>
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+ class Thebod_Shippingrates_Helper_Data extends Mage_Core_Helper_Abstract {
22
+
23
+ }
app/code/community/Thebod/Shippingrates/Model/Carrier.php ADDED
@@ -0,0 +1,214 @@
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-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@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Thebod
16
+ * @package Thebod_Shippingrates
17
+ * @copyright Copyright (c) 2012 Bastian Ike (http://thebod.de/)
18
+ * @author Bastian Ike <b-ike@b-ike.de>
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+ class Thebod_Shippingrates_Model_Carrier extends Mage_Shipping_Model_Carrier_Abstract {
22
+ protected $_code = 'shippingrates';
23
+
24
+ /**
25
+ * returns notification mail address for given rate
26
+ *
27
+ * @param string $code
28
+ * @return string
29
+ */
30
+ public function getNotificationMail($code) {
31
+ $data = $this->getConfigData('shippingconfig');
32
+
33
+ if(!is_array($data)) {
34
+ $data = unserialize(base64_decode($data));
35
+ }
36
+
37
+ foreach($data['code'] as $k => $v) {
38
+ if($this->_code . '_' . $v == $code) {
39
+ return $data['email'][$k];
40
+ }
41
+ }
42
+ }
43
+
44
+ /**
45
+ * applies filters for rate on request
46
+ *
47
+ * @param array $rate
48
+ * @param Mage_Shipping_Model_Rate_Request $request
49
+ * @return boolean
50
+ */
51
+ public function checkRate(array $rate, Mage_Shipping_Model_Rate_Request $request) {
52
+ if(!Mage::getSingleton('checkout/session')->hasQuote()) {
53
+ return true;
54
+ }
55
+
56
+ if(!isset($rate['filter'])) {
57
+ return true;
58
+ }
59
+
60
+ $filter = explode(';', $rate['filter']);
61
+ $passed = true;
62
+ foreach($filter as $f) {
63
+ $f = explode(':', $f);
64
+ $condition = $f[0];
65
+ $value = isset($f[1]) && $f[1] ? $f[1] : false;
66
+
67
+ if($value === false) {
68
+ continue;
69
+ }
70
+
71
+ switch($condition) {
72
+ case 'min_qty':
73
+ if($request->getPackageQty() < $value) {
74
+ $passed = false;
75
+ }
76
+ break;
77
+
78
+ case 'max_qty':
79
+ if($request->getPackageQty() > $value) {
80
+ $passed = false;
81
+ }
82
+ break;
83
+
84
+ case 'min_subtotal':
85
+ Mage::getSingleton('checkout/session')->getQuote()->collectTotals();
86
+ $subtotal = Mage::getSingleton('checkout/session')->getQuote()->getSubtotal();
87
+ if($subtotal < $value) {
88
+ $passed = false;
89
+ }
90
+ break;
91
+
92
+ case 'max_subtotal':
93
+ Mage::getSingleton('checkout/session')->getQuote()->collectTotals();
94
+ $subtotal = Mage::getSingleton('checkout/session')->getQuote()->getSubtotal();
95
+ if($subtotal > $value) {
96
+ $passed = false;
97
+ }
98
+ break;
99
+
100
+ case 'min_weight':
101
+ if($request->getPackageWeight() < $value) {
102
+ $passed = false;
103
+ }
104
+ break;
105
+
106
+ case 'max_weight':
107
+ if($request->getPackageWeight() > $value) {
108
+ $passed = false;
109
+ }
110
+ break;
111
+ }
112
+ }
113
+ return $passed;
114
+ }
115
+
116
+ /**
117
+ * collect shipping rates
118
+ *
119
+ * @param Mage_Shipping_Model_Rate_Request $request
120
+ * @return Mage_Shipping_Model_Rate_Result
121
+ */
122
+ public function collectRates(Mage_Shipping_Model_Rate_Request $request)
123
+ {
124
+ if(!$this->getConfigFlag('active')) {
125
+ return false;
126
+ }
127
+
128
+ $result = Mage::getModel('shipping/rate_result');
129
+
130
+ $rates = $this->getRate($this->getConfigData('shippingconfig'));
131
+
132
+ foreach($rates as $rate) {
133
+ if($this->checkRate($rate, $request)) {
134
+ $method = Mage::getModel('shipping/rate_result_method');
135
+
136
+ $method->setCarrier($this->_code);
137
+ $method->setCarrierTitle($this->getConfigData('title'));
138
+
139
+ //$method->setMethod($this->_code . '_' . $rate['code']);
140
+ $method->setMethod($rate['code']);
141
+ $method->setMethodTitle($rate['title']);
142
+
143
+ $method->setPrice($rate['price']);
144
+
145
+ $result->append($method);
146
+ }
147
+ }
148
+
149
+ return $result;
150
+ }
151
+
152
+ /**
153
+ * return shipping table rates
154
+ *
155
+ * @param Mage_Shipping_Model_Rate_Request $data
156
+ * @return array
157
+ */
158
+ public function getRate($data) {
159
+ $rates = array();
160
+ $methods = array();
161
+
162
+ if(!is_array($data)) {
163
+ $data = unserialize(base64_decode($data));
164
+ }
165
+
166
+ /* rearrange array */
167
+ /* $data: array(code => array('', 'a', 'b'), price => array('', 10, 20), description => array('', 'desc1', 'desc2')) */
168
+ /* $key: code, then price, then data - $value: array*/
169
+ foreach($data as $key => $value) {
170
+ /* $value: array, $methodid: id of this method, $methodvalue: value of this entry */
171
+ foreach($value as $methodid => $methodvalue) {
172
+ /* we ignore this if methodid == 0 */
173
+ if($methodid) {
174
+ /* methods = array(methodid => array(code => 'a', price => 10, description => 'desc1')) ... */
175
+ $methods[$methodid][$key] = $methodvalue;
176
+ }
177
+ }
178
+ }
179
+
180
+ foreach($methods as $method) {
181
+ $code = trim($method['code']);
182
+ $price = trim($method['price']);
183
+ $filter = trim($method['filter']);
184
+ $title = nl2br(trim($method['description']));
185
+
186
+ $title = str_replace(array('=>', '<='), array('<strong>', '</strong>'), $title);
187
+
188
+ $rates[] = array(
189
+ 'code' => $code,
190
+ 'title' => $title,
191
+ 'price' => $price,
192
+ 'filter' => $filter,
193
+ );
194
+ }
195
+
196
+ krsort($rates);
197
+
198
+ return $rates;
199
+ }
200
+
201
+ /**
202
+ * return allowed shipping methods
203
+ *
204
+ * @return array
205
+ */
206
+ public function getAllowedMethods()
207
+ {
208
+ $allowedMethods = array(
209
+ $this->_code => $this->getConfigData('name'),
210
+ );
211
+
212
+ return $allowedMethods;
213
+ }
214
+ }
app/code/community/Thebod/Shippingrates/Model/Email.php ADDED
@@ -0,0 +1,82 @@
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-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@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Thebod
16
+ * @package Thebod_Shippingrates
17
+ * @copyright Copyright (c) 2012 Bastian Ike (http://thebod.de/)
18
+ * @author Bastian Ike <b-ike@b-ike.de>
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+ class Thebod_Shippingrates_Model_Email extends Mage_Core_Model_Abstract {
22
+ /* code based on Mage_Sales_Model_Order::sendNewOrderEmail() */
23
+ public function sendEmailNotification($order) {
24
+ if(strncmp($order->getShippingMethod(), 'shippingrates_', 14) != 0) {
25
+ return;
26
+ }
27
+
28
+ $notificationMail = $order->getShippingCarrier()->getNotificationMail($order->getShippingMethod());
29
+ if(!strlen(trim($notificationMail))) {
30
+ return;
31
+ }
32
+
33
+ $storeId = $order->getStore()->getId();
34
+
35
+ // Start store emulation process
36
+ $appEmulation = Mage::getSingleton('core/app_emulation');
37
+ $initialEnvironmentInfo = $appEmulation->startEnvironmentEmulation($storeId);
38
+
39
+ try {
40
+ // Retrieve specified view block from appropriate design package (depends on emulated store)
41
+ $paymentBlock = Mage::helper('payment')->getInfoBlock($order->getPayment())
42
+ ->setIsSecureMode(true);
43
+ $paymentBlock->getMethod()->setStore($storeId);
44
+ $paymentBlockHtml = $paymentBlock->toHtml();
45
+ } catch (Exception $exception) {
46
+ // Stop store emulation process
47
+ $appEmulation->stopEnvironmentEmulation($initialEnvironmentInfo);
48
+ throw $exception;
49
+ }
50
+
51
+ // Stop store emulation process
52
+ $appEmulation->stopEnvironmentEmulation($initialEnvironmentInfo);
53
+
54
+ // Retrieve corresponding email template id and customer name
55
+ if ($order->getCustomerIsGuest()) {
56
+ $templateId = Mage::getStoreConfig(Mage_Sales_Model_Order::XML_PATH_EMAIL_GUEST_TEMPLATE, $storeId);
57
+ $customerName = $order->getBillingAddress()->getName();
58
+ } else {
59
+ $templateId = Mage::getStoreConfig(Mage_Sales_Model_Order::XML_PATH_EMAIL_TEMPLATE, $storeId);
60
+ $customerName = $order->getCustomerName();
61
+ }
62
+
63
+ $mailer = Mage::getModel('core/email_template_mailer');
64
+ $emailInfo = Mage::getModel('core/email_info');
65
+
66
+ $emailInfo->addTo($notificationMail);
67
+
68
+ $mailer->addEmailInfo($emailInfo);
69
+
70
+ // Set all required params and send emails
71
+ $mailer->setSender(Mage::getStoreConfig(Mage_Sales_Model_Order::XML_PATH_EMAIL_IDENTITY, $storeId));
72
+ $mailer->setStoreId($storeId);
73
+ $mailer->setTemplateId($templateId);
74
+ $mailer->setTemplateParams(array(
75
+ 'order' => $order,
76
+ 'billing' => $order->getBillingAddress(),
77
+ 'payment_html' => $paymentBlockHtml
78
+ )
79
+ );
80
+ $mailer->send();
81
+ }
82
+ }
app/code/community/Thebod/Shippingrates/Model/Observer.php ADDED
@@ -0,0 +1,26 @@
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-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@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Thebod
16
+ * @package Thebod_Shippingrates
17
+ * @copyright Copyright (c) 2012 Bastian Ike (http://thebod.de/)
18
+ * @author Bastian Ike <b-ike@b-ike.de>
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+ class Thebod_Shippingrates_Model_Observer {
22
+ public function checkout_type_onepage_save_order_after($event) {
23
+ $shippingModel = Mage::getModel('shippingrates/email');
24
+ $shippingModel->sendEmailNotification($event->getOrder());
25
+ }
26
+ }
app/code/community/Thebod/Shippingrates/Model/System/Config.php ADDED
@@ -0,0 +1,41 @@
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-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@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Thebod
16
+ * @package Thebod_Shippingrates
17
+ * @copyright Copyright (c) 2012 Bastian Ike (http://thebod.de/)
18
+ * @author Bastian Ike <b-ike@b-ike.de>
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+ class Thebod_Shippingrates_Model_System_Config extends Mage_Core_Model_Config_Data {
22
+
23
+ /**
24
+ * serializes array before saving
25
+ */
26
+ protected function _beforeSave() {
27
+ if (is_array($this->getValue())) {
28
+ $this->setValue(base64_encode(serialize($this->getValue())));
29
+ }
30
+ }
31
+
32
+ /**
33
+ * unserializes array after loading
34
+ */
35
+ protected function _afterLoad() {
36
+ if(!is_array($this->getValue())) {
37
+ $value = $this->getValue();
38
+ $this->setValue(empty($value) ? false : unserialize(base64_decode($value)));
39
+ }
40
+ }
41
+ }
app/code/community/Thebod/Shippingrates/etc/config.xml ADDED
@@ -0,0 +1,56 @@
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <global>
4
+ <models>
5
+ <shippingrates>
6
+ <class>Thebod_Shippingrates_Model</class>
7
+ </shippingrates>
8
+ </models>
9
+
10
+ <helpers>
11
+ <shippingrates>
12
+ <class>Thebod_Shippingrates_Helper</class>
13
+ </shippingrates>
14
+ </helpers>
15
+
16
+ <blocks>
17
+ <shippingrates>
18
+ <class>Thebod_Shippingrates_Block</class>
19
+ </shippingrates>
20
+ </blocks>
21
+
22
+ <events>
23
+ <checkout_type_onepage_save_order_after>
24
+ <observers>
25
+ <shippingrates>
26
+ <type>singleton</type>
27
+ <class>shippingrates/observer</class>
28
+ <method>checkout_type_onepage_save_order_after</method>
29
+ </shippingrates>
30
+ </observers>
31
+ </checkout_type_onepage_save_order_after>
32
+ </events>
33
+ </global>
34
+
35
+ <adminhtml>
36
+ <translate>
37
+ <modules>
38
+ <Thebod_Shippingrates>
39
+ <files>
40
+ <default>Thebod_Shippingrates.csv</default>
41
+ </files>
42
+ </Thebod_Shippingrates>
43
+ </modules>
44
+ </translate>
45
+ </adminhtml>
46
+
47
+ <default>
48
+ <carriers>
49
+ <shippingrates>
50
+ <active>1</active>
51
+ <model>shippingrates/carrier</model>
52
+ <title>Shippingrates</title>
53
+ </shippingrates>
54
+ </carriers>
55
+ </default>
56
+ </config>
app/code/community/Thebod/Shippingrates/etc/system.xml ADDED
@@ -0,0 +1,58 @@
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <sections>
4
+ <carriers>
5
+ <groups>
6
+ <shippingrates translate="label" module="shippingrates">
7
+ <label>Thebod Shippingrates</label>
8
+ <sort_order>1</sort_order>
9
+ <show_in_default>1</show_in_default>
10
+ <show_in_website>1</show_in_website>
11
+ <show_in_store>1</show_in_store>
12
+ <fields>
13
+ <active translate="label comment" module="shippingrates">
14
+ <label>Enabled</label>
15
+ <frontend_type>select</frontend_type>
16
+ <source_model>adminhtml/system_config_source_yesno</source_model>
17
+ <sort_order>10</sort_order>
18
+ <show_in_default>1</show_in_default>
19
+ <show_in_website>1</show_in_website>
20
+ <show_in_store>1</show_in_store>
21
+ <comment>Enable Shippingrates?</comment>
22
+ </active>
23
+
24
+ <title translate="label comment" module="shippingrates">
25
+ <label>Method name</label>
26
+ <frontend_type>text</frontend_type>
27
+ <sort_order>20</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
+ <comment>Displayed above shipping rates</comment>
32
+ </title>
33
+
34
+ <shippingconfig translate="label tooltip" module="shippingrates">
35
+ <label>Shipping methods</label>
36
+ <frontend_model>shippingrates/adminhtml_config</frontend_model>
37
+ <backend_model>shippingrates/system_config</backend_model>
38
+ <sort_order>30</sort_order>
39
+ <show_in_default>1</show_in_default>
40
+ <show_in_website>1</show_in_website>
41
+ <show_in_store>1</show_in_store>
42
+ <tooltip><![CDATA[<b>code</b>: internal code, must be unique<br/><b>price</b>: price for this shipping method<br/><b>description</b>: description shown at checkout, html code supported, or use => and <= to bold text<br/><b>notification mail</b>: optional, if set a mail is send to this address after an order is placed using this shipping rate (useful for pickup-at-store configurations)]]></tooltip>
43
+ </shippingconfig>
44
+
45
+ <sort_order translate="label" module="shippingrates">
46
+ <label>Sort order</label>
47
+ <frontend_type>text</frontend_type>
48
+ <sort_order>100</sort_order>
49
+ <show_in_default>1</show_in_default>
50
+ <show_in_website>1</show_in_website>
51
+ <show_in_store>1</show_in_store>
52
+ </sort_order>
53
+ </fields>
54
+ </shippingrates>
55
+ </groups>
56
+ </carriers>
57
+ </sections>
58
+ </config>
app/etc/modules/Thebod_Shippingrates.xml ADDED
@@ -0,0 +1,9 @@
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Thebod_Shippingrates>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </Thebod_Shippingrates>
8
+ </modules>
9
+ </config>
app/locale/de_DE/Thebod_Shippingrates.csv ADDED
@@ -0,0 +1,22 @@
1
+ "Thebod Shippingrates","Thebod Shippingrates"
2
+ "Enabled","Aktiv"
3
+ "Enable Shippingrates?","Shippingrates aktivieren?"
4
+ "Method name","Name der Versandart"
5
+ "Displayed above shipping rates","Anzeige oberhalb der Versandkosten"
6
+ "Shipping methods","Versandarten"
7
+ "<b>code</b>: internal code, must be unique<br/><b>price</b>: price for this shipping method<br/><b>description</b>: description shown at checkout, html code supported, or use => and <= to bold text<br/><b>notification mail</b>: optional, if set a mail is send to this address after an order is placed using this shipping rate (useful for pickup-at-store configurations)","<b>Code</b>: Interner Code, muss einmalig sein<br/><b>Preis</b>: Preis der Versandart<br/><b>Beschreibung</b>: Beschreibung wird beim Checkout angezeigt, HTML Code wird unterstützt, benutze => und <= für Fett-Text<br/><b>Benachrichtigungs E-Mail</b>: Optional, falls spezifiziert wird eine Email nach Abschluss eine Bestellung mit der Versandart dorthin geschickt (nützlich für Laden-Abholung)"
8
+ "Sort order","Sortierreihenfolge"
9
+ "Add","Hinzufügen"
10
+ "Delete","Delete"
11
+ "code","Code"
12
+ "price","Preis"
13
+ "description","Beschreibung"
14
+ "notification mail (optional)","Benachrichtigungs E-Mail (Optional)"
15
+ "configure filter","Konfiguriere Filter"
16
+ "min. QTY:","min. Menge"
17
+ "max. QTY:","max. Menge"
18
+ "min. subtotal","min. Bestellwert"
19
+ "max. subtotal","max. Bestellwert"
20
+ "min. weight","min. Gewicht"
21
+ "max. weight","max. Gewicht"
22
+ "save filter","Filter speichern"
app/locale/pt_PT/Thebod_Shippingrates.csv ADDED
@@ -0,0 +1,14 @@
1
+ "Thebod Shippingrates","Thebod Shippingrates"
2
+ "Enabled","Activo"
3
+ "Enable Shippingrates?","Activar Portes de Envio?"
4
+ "Method name","Método"
5
+ "Displayed above shipping rates","Apresentar por cima dos portes de envio"
6
+ "Shipping methods","Métodos de envio"
7
+ "<b>code</b>: internal code, must be unique<br/><b>price</b>: price for this shipping method<br/><b>description</b>: description shown at checkout, html code supported, or use => and <= to bold text<br/><b>notification mail</b>: optional, if set a mail is send to this address after an order is placed using this shipping rate (useful for pickup-at-store configurations)","<b>código</b>: código interno, tem que ser único<br/><b>preço</b>: preço para este método de envio<br/><b>descrição</b>: descrição apresentada no checkout, suporta código html, ou o uso de => e <= para que o texto fique a negrito<br/><b>email para notificação</b>: opcional, se atribuído será enviado um email sempre que for efectuada uma encomenda com este método de envio (útil para configurações levantar na loja)"
8
+ "Sort order","Ordenação"
9
+ "Add","Adicionar"
10
+ "Delete","Apagar"
11
+ "code","código"
12
+ "price","preço"
13
+ "description","descrição"
14
+ "notification mail (optional)","notificação de email (opcional)"
package.xml ADDED
@@ -0,0 +1,23 @@
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Thebod_Shippingrates</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL 3.0)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Simple configurable shippingrates for Magento</summary>
10
+ <description>Thebod_Shippingrates&#xD;
11
+ &#xD;
12
+ Simple configurable shippingrates for Magento.&#xD;
13
+ &#xD;
14
+ This simple module lets you define as many shipping methods as you need, with an optional 'notification e-mail'.&#xD;
15
+ Very useful for 'pickup-at-store' or if you need a few self-specified fixed rates shipping methods.</description>
16
+ <notes>* Tested on 1.6, should work on Magento &gt;= 1.4</notes>
17
+ <authors><author><name>Bastian Ike</name><user>auto-converted</user><email>thebod@thebod.de</email></author></authors>
18
+ <date>2012-02-03</date>
19
+ <time>07:44:50</time>
20
+ <contents><target name="magecommunity"><dir name="Thebod"><dir name="Shippingrates"><dir name="Block"><dir name="Adminhtml"><file name="Config.php" hash="e5b88b7f739ef069d4a5c0a915105714"/></dir></dir><dir name="Helper"><file name="Data.php" hash="5a0d2237d0cb5c658c431216005b8443"/></dir><dir name="Model"><dir name="System"><file name="Config.php" hash="d5cc2bc66d01f10939f86fade97d2f12"/></dir><file name="Carrier.php" hash="83c71ed3668963c6742b9f675f8353b7"/><file name="Email.php" hash="4ca850ca6a5de4d9a4b7d3f704ce055d"/><file name="Observer.php" hash="5730e4b8e21425a8545a3ee12f854e73"/></dir><dir name="etc"><file name="config.xml" hash="74172e5d3095c124373e2a11efdf6190"/><file name="system.xml" hash="1b5ed3db08ed13d21c7686705f5f193d"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Thebod_Shippingrates.xml" hash="f4baeb06eea903395d8ef19b187961e0"/></dir></target><target name="magelocale"><dir name="de_DE"><file name="Thebod_Shippingrates.csv" hash="c0e42c61094aa36c8b699b909581615f"/></dir><dir name="pt_PT"><file name="Thebod_Shippingrates.csv" hash="7873741ed92a4370a7280d4c76e7c1ee"/></dir></target></contents>
21
+ <compatible/>
22
+ <dependencies/>
23
+ </package>