Brunobrasilweb_FreteGratis - Version 0.1.0

Version Notes

A extensão está prontinha você pode instalar e configurar.

Download this release

Release Info

Developer Bruno Brasil
Extension Brunobrasilweb_FreteGratis
Version 0.1.0
Comparing to
See all releases


Version 0.1.0

app/code/community/Brunobrasilweb/FreteGratis/Helper/Data.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* ========================================================================
3
+ * Extensão Frete Grátis
4
+ * http://brunobrasilweb.com.br
5
+ * ========================================================================
6
+ * Copyright (c) 2013 @brunobrasilweb.
7
+ *
8
+ * Licensed under the Apache License, Version 2.0 (the "License");
9
+ * you may not use this file except in compliance with the License.
10
+ * You may obtain a copy of the License at
11
+ *
12
+ * thtp://www.apache.org/licenses/LICENSE-2.0
13
+ *
14
+ * Unless required by applicable law or agreed to in writing, software
15
+ * distributed under the License is distributed on an "AS IS" BASIS,
16
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ * See the License for the specific language governing permissions and
18
+ * limitations under the License.
19
+ * ======================================================================== */
20
+
21
+ /**
22
+ * Brunobrasilweb_FreteGratis_Helper_Data
23
+ *
24
+ * @category Brunobrasilweb
25
+ * @package Brunobrasilweb_FreteGratis
26
+ * @author Bruno Brasil <contato@brunobrasilweb.com.br>
27
+ */
28
+ class Brunobrasilweb_FreteGratis_Helper_Data extends Mage_Core_Helper_Abstract {
29
+
30
+ }
app/code/community/Brunobrasilweb/FreteGratis/Model/Carrier/Fretegratis.php ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* ========================================================================
3
+ * Extensão Frete Grátis
4
+ * http://brunobrasilweb.com.br
5
+ * ========================================================================
6
+ * Copyright (c) 2013 @brunobrasilweb.
7
+ *
8
+ * Licensed under the Apache License, Version 2.0 (the "License");
9
+ * you may not use this file except in compliance with the License.
10
+ * You may obtain a copy of the License at
11
+ *
12
+ * thtp://www.apache.org/licenses/LICENSE-2.0
13
+ *
14
+ * Unless required by applicable law or agreed to in writing, software
15
+ * distributed under the License is distributed on an "AS IS" BASIS,
16
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ * See the License for the specific language governing permissions and
18
+ * limitations under the License.
19
+ * ======================================================================== */
20
+
21
+ /**
22
+ * Brunobrasilweb_FreteGratis_Model_Carrier_Fretegratis
23
+ *
24
+ * @category Brunobrasilweb
25
+ * @package Brunobrasilweb_FreteGratis
26
+ * @author Bruno Brasil <contato@brunobrasilweb.com.br>
27
+ */
28
+
29
+ class Brunobrasilweb_FreteGratis_Model_Carrier_Fretegratis extends Mage_Shipping_Model_Carrier_Abstract implements Mage_Shipping_Model_Carrier_Interface {
30
+
31
+ protected $_code = 'fretegratis';
32
+ protected $_name = 'Gratis';
33
+
34
+ public function collectRates(Mage_Shipping_Model_Rate_Request $request) {
35
+ $cep = $request->getDestPostcode();
36
+ $totalPedido = $request->getPackageValue();
37
+ $result = Mage::getModel('shipping/rate_result');
38
+
39
+ if ($this->getConfigData('active') && (!$this->getConfigData('valor_pedido') || $totalPedido >= $this->getConfigData('valor_pedido'))) {
40
+ if (($this->cepNaFaixa($cep) && $this->getConfigData('frete_gratis_por_faixa')) || !$this->getConfigData('frete_gratis_por_faixa')) {
41
+ $method = Mage::getModel('shipping/rate_result_method');
42
+ $method->setCarrier($this->_code);
43
+ $method->setCarrierTitle($this->getConfigData('title'));
44
+ $method->setMethod($this->_code);
45
+ $method->setMethodTitle($this->_name);
46
+ $method->setPrice('0.00');
47
+ $method->setCost('0.00');
48
+ $result->append($method);
49
+ }
50
+ }
51
+
52
+ return $result;
53
+ }
54
+
55
+ public function getAllowedMethods() {
56
+ return array($this->_code => $this->_name);
57
+ }
58
+
59
+ private function cepNaFaixa($cep) {
60
+ $cep = preg_replace("/[^0-9]/", "", $cep);
61
+ $faixasCep = explode("\n", $this->getConfigData('faixas_frete_gratis'));
62
+
63
+ foreach ($faixasCep as $faixa) {
64
+ $f = explode('|', $faixa);
65
+ $de = preg_replace("/[^0-9]/", "", $f[0]);
66
+ $ate = preg_replace("/[^0-9]/", "", $f[1]);
67
+
68
+ if ($cep >= $de && $cep <= $ate)
69
+ return true;
70
+ }
71
+
72
+ return false;
73
+ }
74
+
75
+ }
app/code/community/Brunobrasilweb/FreteGratis/etc/config.xml ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Brunobrasilweb_FreteGratis>
5
+ <version>0.1.0</version>
6
+ </Brunobrasilweb_FreteGratis>
7
+ </modules>
8
+ <global>
9
+ <helpers>
10
+ <fretegratis>
11
+ <class>Brunobrasilweb_FreteGratis_Helper</class>
12
+ </fretegratis>
13
+ </helpers>
14
+ <resources>
15
+ <fretegratis_setup>
16
+ <setup>
17
+ <module>Brunobrasilweb_FreteGratis</module>
18
+ </setup>
19
+ <connection>
20
+ <use>core_setup</use>
21
+ </connection>
22
+ </fretegratis_setup>
23
+ <fretegratis_write>
24
+ <connection>
25
+ <use>core_write</use>
26
+ </connection>
27
+ </fretegratis_write>
28
+ <fretegratis_read>
29
+ <connection>
30
+ <use>core_read</use>
31
+ </connection>
32
+ </fretegratis_read>
33
+ </resources>
34
+ </global>
35
+ <default>
36
+ <carriers>
37
+ <fretegratis>
38
+ <active>1</active>
39
+ <model>Brunobrasilweb_FreteGratis_Model_Carrier_Fretegratis</model>
40
+ <title>Frete Grátis</title>
41
+ <sort_order>0</sort_order>
42
+ </fretegratis>
43
+ </carriers>
44
+ </default>
45
+ </config>
app/code/community/Brunobrasilweb/FreteGratis/etc/system.xml ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <sections>
4
+ <carriers translate="label" module="fretegratis">
5
+ <groups>
6
+ <fretegratis translate="label">
7
+ <label>Frete Grátis - Brunobrasilweb</label>
8
+ <frontend_type>text</frontend_type>
9
+ <sort_order>0</sort_order>
10
+ <show_in_default>1</show_in_default>
11
+ <show_in_website>1</show_in_website>
12
+ <show_in_store>1</show_in_store>
13
+ <model>fretegratis/carrier_fretegratis</model>
14
+ <fields>
15
+ <active translate="label">
16
+ <label>Enabled</label>
17
+ <frontend_type>select</frontend_type>
18
+ <source_model>adminhtml/system_config_source_yesno</source_model>
19
+ <sort_order>10</sort_order>
20
+ <show_in_default>1</show_in_default>
21
+ <show_in_website>1</show_in_website>
22
+ <show_in_store>1</show_in_store>
23
+ </active>
24
+ <title translate="label">
25
+ <label>Titulo</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
+ </title>
32
+ <frete_gratis_por_faixa translate="label">
33
+ <label>Frete Grátis por Faixa de CEP?</label>
34
+ <frontend_type>select</frontend_type>
35
+ <source_model>adminhtml/system_config_source_yesno</source_model>
36
+ <sort_order>30</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
+ </frete_gratis_por_faixa>
41
+ <faixas_frete_gratis translate="label">
42
+ <label>Faixas CEP do Frete Grátis</label>
43
+ <frontend_type>textarea</frontend_type>
44
+ <sort_order>40</sort_order>
45
+ <show_in_default>1</show_in_default>
46
+ <show_in_website>1</show_in_website>
47
+ <show_in_store>1</show_in_store>
48
+ <depends><frete_gratis_por_faixa>1</frete_gratis_por_faixa></depends>
49
+ </faixas_frete_gratis>
50
+ <valor_pedido translate="label">
51
+ <label>Valor Mínimo do Pedido</label>
52
+ <frontend_type>text</frontend_type>
53
+ <sort_order>50</sort_order>
54
+ <show_in_default>1</show_in_default>
55
+ <show_in_website>1</show_in_website>
56
+ <show_in_store>1</show_in_store>
57
+ <comment>Valor mínimo do pedido, se for vázio é ilimitado. Colocar no formato decimal.</comment>
58
+ </valor_pedido>
59
+ <sort_order translate="label">
60
+ <label>Sort Order</label>
61
+ <frontend_type>text</frontend_type>
62
+ <sort_order>60</sort_order>
63
+ <show_in_default>1</show_in_default>
64
+ <show_in_website>1</show_in_website>
65
+ <show_in_store>1</show_in_store>
66
+ <sort_order>100</sort_order>
67
+ </sort_order>
68
+ </fields>
69
+ </fretegratis>
70
+ </groups>
71
+ </carriers>
72
+ </sections>
73
+ </config>
app/code/community/Brunobrasilweb/FreteGratis/sql/fretegratis_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $installer = $this;
3
+ $installer->startSetup();
4
+ $sql=<<<SQLTEXT
5
+ --
6
+ SQLTEXT;
7
+
8
+ $installer->run($sql);
9
+ //demo
10
+ //Mage::getModel('core/url_rewrite')->setId(null);
11
+ //demo
12
+ $installer->endSetup();
13
+
app/etc/modules/Brunobrasilweb_FreteGratis.xml ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /* ========================================================================
4
+ * Extensão Frete Grátis
5
+ * http://brunobrasilweb.com.br
6
+ * ========================================================================
7
+ * Copyright (c) 2013 @brunobrasilweb.
8
+ *
9
+ * Licensed under the Apache License, Version 2.0 (the "License");
10
+ * you may not use this file except in compliance with the License.
11
+ * You may obtain a copy of the License at
12
+ *
13
+ * http://www.apache.org/licenses/LICENSE-2.0
14
+ *
15
+ * Unless required by applicable law or agreed to in writing, software
16
+ * distributed under the License is distributed on an "AS IS" BASIS,
17
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
+ * See the License for the specific language governing permissions and
19
+ * limitations under the License.
20
+ * ======================================================================== */
21
+ -->
22
+ <config>
23
+ <modules>
24
+ <Brunobrasilweb_FreteGratis>
25
+ <active>true</active>
26
+ <codePool>community</codePool>
27
+ <depends>
28
+ <Mage_Shipping />
29
+ </depends>
30
+ <version>0.1.0</version>
31
+ </Brunobrasilweb_FreteGratis>
32
+ </modules>
33
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Brunobrasilweb_FreteGratis</name>
4
+ <version>0.1.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Extens&#xE3;o para frete gr&#xE1;tis por faixa de CEP Brasileiro.</summary>
10
+ <description>Extens&#xE3;o para frete gr&#xE1;tis por faixa de CEP Brasileiro.</description>
11
+ <notes>A extens&#xE3;o est&#xE1; prontinha voc&#xEA; pode instalar e configurar.</notes>
12
+ <authors><author><name>Bruno Brasil</name><user>brunobrasilweb</user><email>brunobrasilweb@gmail.com</email></author></authors>
13
+ <date>2014-01-08</date>
14
+ <time>13:10:18</time>
15
+ <contents><target name="magecommunity"><dir name="Brunobrasilweb"><dir name="FreteGratis"><dir name="Helper"><file name="Data.php" hash="52e65c87f549ed71fc416aa4a913a19a"/></dir><dir name="Model"><dir name="Carrier"><file name="Fretegratis.php" hash="ada2731cebcc19e5f20122ee3e0bb85c"/></dir></dir><dir name="etc"><file name="config.xml" hash="38f5cfa53748a33c48617cfe2302aa94"/><file name="system.xml" hash="91c2722e4da59f168091a44e86a62f9e"/></dir><dir name="sql"><dir name="fretegratis_setup"><file name="mysql4-install-0.1.0.php" hash="639c8dd51301489ba9959a02708e37d2"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Brunobrasilweb_FreteGratis.xml" hash="32cc813f473e18f18ee0f54939994df8"/></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.0.0</min><max>6.0.0</max></php></required></dependencies>
18
+ </package>