Shipping_Nacex - Version 1.0.0

Version Notes

* Version estable del metodo de envio para la empresa Nacex

Download this release

Release Info

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


Version 1.0.0

app/code/community/Nacex/Shipping/Helper/Data.php ADDED
@@ -0,0 +1,29 @@
1
+ <?php
2
+ /**
3
+ * Magento Nacex Shipping
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 Nacex
16
+ * @package Nacex_Shipping
17
+ * @copyright
18
+ * @author
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Catalog data helper
24
+ *
25
+ */
26
+ class Nacex_Shipping_Helper_Data extends Mage_Core_Helper_Abstract
27
+ {
28
+
29
+ }
app/code/community/Nacex/Shipping/Model/Carrier/Spainpost.php ADDED
@@ -0,0 +1,265 @@
1
+ <?php
2
+ class Nacex_Shipping_Model_Carrier_Spainpost
3
+ extends Mage_Shipping_Model_Carrier_Abstract
4
+ implements Mage_Shipping_Model_Carrier_Interface
5
+ {
6
+ var $_regions = array(
7
+ 'ANDALUCIA' =>array('04','11','14','18','21','23','29','41'),
8
+ 'ARAGON' =>array('22','44','50'),
9
+ 'BALEARES' =>array('07'),
10
+ 'CANARIAS' =>array('35','38'),
11
+ 'CANTABRIA' =>array('39'),
12
+ 'CASTILLA Y LEON' =>array('05','09','24','34','37','40','42','47','49'),
13
+ 'CASTILLA LA MANCA' =>array('02','13','16','19','45'),
14
+ 'CATALU�A' =>array('08','17','25','43'),
15
+ 'CEUTA' =>array('51'),
16
+ 'COMUNIDAD DE MADRID' =>array('28'),
17
+ 'COMUNIDAD FORAL DE NAVARRA'=>array('31'),
18
+ 'COMUNIDAD VALENCIANA' =>array('03','12','46'),
19
+ 'EUSKADI - PAIS VASCO' =>array('01','20','48'),
20
+ 'EXTREMADURA' =>array('06','10'),
21
+ 'GALICIA' =>array('15','27','32','36'),
22
+ 'LA RIOJA' =>array('26'),
23
+ 'MELILLA' =>array('52'),
24
+ 'PRINCIPADO DE ASTURIAS' =>array('33'),
25
+ 'MURCIA' =>array('30')
26
+ );
27
+
28
+ var $_prov = array(
29
+ "01"=>"ALAVA",
30
+ "02"=>"ALBACETE",
31
+ "03"=>"ALICANTE",
32
+ "04"=>"ALMERIA",
33
+ "33"=>"ASTURIAS",
34
+ "05"=>"AVILA",
35
+ "06"=>"BADAJOZ",
36
+ "08"=>"BARCELONA",
37
+ "09"=>"BURGOS",
38
+ "10"=>"CACERES",
39
+ "11"=>"CADIZ",
40
+ "39"=>"CANTABRIA",
41
+ "12"=>"CASTELLON",
42
+ "51"=>"CEUTA",
43
+ "13"=>"CIUDAD REAL",
44
+ "14"=>"CORDOBA",
45
+ "15"=>"CORU�A, LA",
46
+ "16"=>"CUENCA",
47
+ "17"=>"GIRONA",
48
+ "18"=>"GRANADA",
49
+ "19"=>"GUADALAJARA",
50
+ "20"=>"GUIPUZCOA",
51
+ "21"=>"HUELVA",
52
+ "22"=>"HUESCA",
53
+ "07"=>"ILLES BALEARS",
54
+ "23"=>"JAEN",
55
+ "24"=>"LEON",
56
+ "25"=>"LLEIDA",
57
+ "27"=>"LUGO",
58
+ "28"=>"MADRID",
59
+ "29"=>"MALAGA",
60
+ "52"=>"MELILLA",
61
+ "30"=>"MURCIA",
62
+ "31"=>"NAVARRA",
63
+ "32"=>"OURENSE",
64
+ "34"=>"PALENCIA",
65
+ "35"=>"PALMAS, LAS",
66
+ "36"=>"PONTEVEDRA",
67
+ "26"=>"RIOJA, LA",
68
+ "37"=>"SALAMANCA",
69
+ "38"=>"SANTA CRUZ DE TENERIFE",
70
+ "40"=>"SEGOVIA",
71
+ "41"=>"SEVILLA",
72
+ "42"=>"SORIA",
73
+ "43"=>"TARRAGONA",
74
+ "44"=>"TERUEL",
75
+ "45"=>"TOLEDO",
76
+ "46"=>"VALENCIA",
77
+ "47"=>"VALLADOLID",
78
+ "48"=>"VIZCAYA",
79
+ "49"=>"ZAMORA",
80
+ "50"=>"ZARAGOZA"
81
+ );
82
+ protected $_code = 'spainpost';
83
+
84
+ /**
85
+ * Collects the shipping rates for Spain Post from the DRC API.
86
+ *
87
+ * @param Mage_Shipping_Model_Rate_Request $data
88
+ * @return Mage_Shipping_Model_Rate_Result
89
+ */
90
+ public function collectRates(Mage_Shipping_Model_Rate_Request $request)
91
+ {
92
+ // Check if this method is active
93
+ if (!$this->getConfigFlag('active'))
94
+ {
95
+ return false;
96
+ }
97
+
98
+ // Check if this method is even applicable (must ship from Spain)
99
+ $origCountry = Mage::getStoreConfig('shipping/origin/country_id', $this->getStore());
100
+
101
+ if ($origCountry != "ES"){
102
+ return false;
103
+ }
104
+
105
+ //check if cart order value falls between the minimum and maximum order amounts required
106
+ $packagevalue = $request->getBaseCurrency()->convert($request->getPackageValue(), $request->getPackageCurrency());
107
+ $minorderval = $this->getConfigData('min_order_value');
108
+ $maxorderval = $this->getConfigData('max_order_value');
109
+ if($packagevalue <= $minorderval || $packagevalue >= $maxorderval){
110
+ return false;
111
+ }
112
+
113
+ $result = Mage::getModel('shipping/rate_result');
114
+
115
+ $frompcode = Mage::getStoreConfig('shipping/origin/postcode', $this->getStore()); // CODIGO POSTAL DE LA TIENDA
116
+ $topcode = $request->getDestPostcode(); // CODIGO POSTAL DEL COMPRADOR
117
+ file_put_contents("pais.txt",$request->getDestCountryId());
118
+ if ($request->getDestCountryId())
119
+ {
120
+ $destCountry = $request->getDestCountryId();
121
+ }
122
+ else
123
+ {
124
+ $destCountry = "ES";
125
+ }
126
+
127
+ $sweightunit = 1; //$this->getConfigData('weight_units');
128
+
129
+ $sweight = $request->getPackageWeight()*$sweightunit;
130
+
131
+ // En el caso de que sea dentro de espa�a se muestra
132
+ // en caso contrario no
133
+ if($destCountry == "ES")
134
+ {
135
+ if($frompcode == $topcode){
136
+ // PRECIO PROVINCIAL
137
+ $servicio='PROVINCIAL';
138
+ } else {
139
+ $id_region = $this->getRegion($topcode,$frompcode);
140
+ if($id_region == true){
141
+ // PRECIO REGIONAL PARA PROVINCIAS DE LA MISMA REGION
142
+ $servicio='REGIONAL';
143
+ } else {
144
+ // PRECIO NACIONAL PARA TODA ESPA�A
145
+ $servicio='NACIONAL';
146
+ }
147
+ }
148
+ switch($servicio){
149
+ case 'PROVINCIAL':
150
+ $shipping_method = 'PACK';
151
+ if($sweight <= '2000') {
152
+ $shipping_method = 'BAG';
153
+ $price = 6.01;
154
+ } elseif(($sweight > '2000') && ($sweight <='5000')){
155
+ $price = 6.74;
156
+ } elseif(($sweight > '5000') && ($sweight <='10000')){
157
+ $price = 8.49;
158
+ } else {
159
+ $price = 8.49;
160
+ $peso=$sweight - 10000;
161
+ $price += (ceil($peso / 5000)) * 1.91;
162
+ }
163
+ break;
164
+ case 'REGIONAL':
165
+ $shipping_method = 'PACK';
166
+ if($sweight <= '2000') {
167
+ $shipping_method = 'BAG';
168
+ $price = 7.11;
169
+ } elseif(($sweight > '2000') && ($sweight <='5000')){
170
+ $price = 18.88;
171
+ } elseif(($sweight > '5000') && ($sweight <='10000')){
172
+ $price = 25.84;
173
+ } else {
174
+ $price = 25.84;
175
+ $peso=$sweight - 10000;
176
+ $price += (ceil($peso / 5000)) * 3.62;
177
+ }
178
+ break;
179
+ case 'NACIONAL':
180
+ $shipping_method = 'PACK';
181
+ if($sweight <= '2000') {
182
+ $shipping_method = 'BAG';
183
+ $price = 7.58;
184
+ } elseif(($sweight > '2000') && ($sweight <='5000')){
185
+ $price = 9.57;
186
+ } elseif(($sweight > '5000') && ($sweight <='10000')){
187
+ $price = 13.54;
188
+ } else {
189
+ $price = 13.54;
190
+ $peso=$sweight - 10000;
191
+ $price += (ceil($peso / 5000)) * 3.96;
192
+ }
193
+ break;
194
+ }
195
+
196
+ $price=($price * 1.16) + 1;
197
+
198
+ $method = Mage::getModel('shipping/rate_result_method');
199
+ // set the shipping type....
200
+ $type = $this->getConfigData('type');
201
+ $qty = $request->getPackageQty();
202
+
203
+ $tot = ($qty * $price);
204
+
205
+ if ($this->getConfigData('type') == 'O') { // by order
206
+ $shippingPrice = $price;
207
+ } elseif ($type == 'I') { // by item
208
+ $shippingPrice = ($qty * $price);
209
+ } else {
210
+ $shippingPrice = false;
211
+ }
212
+
213
+ // set the handling fee type....
214
+ $calculateHandlingFee = $this->getConfigData('handling_type');
215
+ $handlingFee = $this->getConfigData('handling_fee');
216
+ if ($this->getConfigData('handling_type') == 'F') {
217
+ $shippingPrice += $this->getConfigData('handling_fee');
218
+ } else {
219
+ $handlingFee = ($shippingPrice * $this->getConfigData('handling_fee'))/100;
220
+ $shippingPrice += $handlingFee;
221
+ }
222
+
223
+ $method->setCarrier('spainpost');
224
+ $method->setCarrierTitle($this->getConfigData('title'));
225
+ $method->setMethod($shipping_method);
226
+ $method->setMethodTitle($this->getConfigData('title') . ": $shipping_method");
227
+ $method->setPrice($shippingPrice);
228
+ $method->setCost($shippingPrice);
229
+ $result->append($method);
230
+ } else {
231
+ return false;
232
+ }
233
+ return $result;
234
+ }
235
+
236
+ public function getRegion($topcode,$compare=null){
237
+ $ind=substr($topcode,0,2);
238
+ $prov=$this->_prov[$ind];
239
+ foreach($this->_regions as $id => $val){
240
+ if(in_array($ind,$val)){
241
+ $region=$id;
242
+ }
243
+ }
244
+ if($compare !== null){
245
+ $compare=$this->getRegion($compare);
246
+ if($region === $compare)
247
+ return true;
248
+ else
249
+ return false;
250
+ }
251
+ return $region;
252
+ }
253
+
254
+
255
+ /**
256
+ * Get allowed shipping methods
257
+ *
258
+ * @return array
259
+ */
260
+ public function getAllowedMethods()
261
+ {
262
+ return array('spainpost' => $this->getConfigData('name'));
263
+ }
264
+
265
+ }
app/code/community/Nacex/Shipping/etc/config.xml ADDED
@@ -0,0 +1,59 @@
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Nacex_Shipping>
5
+ <version>0.1.0</version>
6
+ <depends>
7
+ <Mage_Shipping />
8
+ </depends>
9
+ </Nacex_Shipping>
10
+ </modules>
11
+ <global>
12
+ <models>
13
+ <nxshipping>
14
+ <class>Nacex_Shipping</class>
15
+ </nxshipping>
16
+ </models>
17
+ <resources>
18
+ <nxshipping_setup>
19
+ <setup>
20
+ <module>Nacex_Shipping</module>
21
+ </setup>
22
+ <connection>
23
+ <use>directory_setup</use>
24
+ </connection>
25
+ </nxshipping_setup>
26
+ <nxshipping_read>
27
+ <connection>
28
+ <use>local_read</use>
29
+ </connection>
30
+ </nxshipping_read>
31
+ </resources>
32
+ <sales>
33
+ <shipping>
34
+ <carriers>
35
+ <spainpost>
36
+ <class>Nacex_Shipping_Model_Carrier_Spainpost</class>
37
+ </spainpost>
38
+ </carriers>
39
+ </shipping>
40
+ </sales>
41
+ </global>
42
+
43
+ <default>
44
+ <carriers>
45
+ <spainpost>
46
+ <active>1</active>
47
+ <model>nacex_shipping_model_carrier_spainpost</model>
48
+ <name>Nacex</name>
49
+ <type>O</type>
50
+ <title>Nacex</title>
51
+ <min_order_value>0</min_order_value>
52
+ <max_order_value>9999999999999</max_order_value>
53
+ <weight_units>1</weight_units>
54
+ <handling_fee>0</handling_fee>
55
+ <specificerrmsg>This shipping method is currently unavailable. If you would like to ship using this shipping method, please contact us.</specificerrmsg>
56
+ </spainpost>
57
+ </carriers>
58
+ </default>
59
+ </config>
app/code/community/Nacex/Shipping/etc/system.xml ADDED
@@ -0,0 +1,94 @@
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <sections>
4
+ <carriers>
5
+ <groups>
6
+ <spainpost translate="label" module="shipping">
7
+ <label>Nacex</label>
8
+ <frontend_type>text</frontend_type>
9
+ <sort_order>1</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
+ <fields>
14
+ <active translate="label">
15
+ <label>Enabled</label>
16
+ <frontend_type>select</frontend_type>
17
+ <source_model>adminhtml/system_config_source_yesno</source_model>
18
+ <sort_order>1</sort_order>
19
+ <show_in_default>1</show_in_default>
20
+ <show_in_website>1</show_in_website>
21
+ <show_in_store>1</show_in_store>
22
+ </active>
23
+ <min_order_value translate="label">
24
+ <label>Minimum Order Value</label>
25
+ <frontend_type>text</frontend_type>
26
+ <sort_order>6</sort_order>
27
+ <show_in_default>1</show_in_default>
28
+ <show_in_website>1</show_in_website>
29
+ <show_in_store>1</show_in_store>
30
+ </min_order_value>
31
+ <max_order_value translate="label">
32
+ <label>Maximum Order Value</label>
33
+ <frontend_type>text</frontend_type>
34
+ <sort_order>5</sort_order>
35
+ <show_in_default>1</show_in_default>
36
+ <show_in_website>1</show_in_website>
37
+ <show_in_store>1</show_in_store>
38
+ </max_order_value>
39
+ <handling_type translate="label">
40
+ <label>Calculate Handling Fee</label>
41
+ <frontend_type>select</frontend_type>
42
+ <source_model>shipping/source_handlingType</source_model>
43
+ <sort_order>4</sort_order>
44
+ <show_in_default>1</show_in_default>
45
+ <show_in_website>1</show_in_website>
46
+ <show_in_store>0</show_in_store>
47
+ </handling_type>
48
+ <handling_fee translate="label">
49
+ <label>Handling Fee</label>
50
+ <frontend_type>text</frontend_type>
51
+ <sort_order>5</sort_order>
52
+ <show_in_default>1</show_in_default>
53
+ <show_in_website>1</show_in_website>
54
+ <show_in_store>1</show_in_store>
55
+ </handling_fee>
56
+ <sort_order translate="label">
57
+ <label>Sort order</label>
58
+ <frontend_type>text</frontend_type>
59
+ <sort_order>11</sort_order>
60
+ <show_in_default>1</show_in_default>
61
+ <show_in_website>1</show_in_website>
62
+ <show_in_store>1</show_in_store>
63
+ </sort_order>
64
+ <title translate="label">
65
+ <label>Title</label>
66
+ <frontend_type>text</frontend_type>
67
+ <sort_order>2</sort_order>
68
+ <show_in_default>1</show_in_default>
69
+ <show_in_website>1</show_in_website>
70
+ <show_in_store>1</show_in_store>
71
+ </title>
72
+ <showmethod translate="label">
73
+ <label>Show method if not applicable</label>
74
+ <frontend_type>select</frontend_type>
75
+ <sort_order>11</sort_order>
76
+ <source_model>adminhtml/system_config_source_yesno</source_model>
77
+ <show_in_default>1</show_in_default>
78
+ <show_in_website>1</show_in_website>
79
+ <show_in_store>1</show_in_store>
80
+ </showmethod>
81
+ <specificerrmsg translate="label">
82
+ <label>Displayed Error Message</label>
83
+ <frontend_type>textarea</frontend_type>
84
+ <sort_order>12</sort_order>
85
+ <show_in_default>1</show_in_default>
86
+ <show_in_website>1</show_in_website>
87
+ <show_in_store>1</show_in_store>
88
+ </specificerrmsg>
89
+ </fields>
90
+ </spainpost>
91
+ </groups>
92
+ </carriers>
93
+ </sections>
94
+ </config>
app/code/community/Nacex/Shipping/sql/shipping_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,23 @@
1
+ <?php
2
+ /**
3
+ * Magento Nacex Shipping
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 Nacex
16
+ * @package Nacex_Shipping
17
+ * @copyright
18
+ * @author
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+
23
+ ?>
app/etc/modules/Nacex_Shipping.xml ADDED
@@ -0,0 +1,30 @@
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Magento Nacex Shipping
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @category Nacex
17
+ * @package Nacex_Shipping
18
+ * @copyright
19
+ * @author
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+ -->
23
+ <config>
24
+ <modules>
25
+ <Nacex_Shipping>
26
+ <active>true</active>
27
+ <codePool>community</codePool>
28
+ </Nacex_Shipping>
29
+ </modules>
30
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Shipping_Nacex</name>
4
+ <version>1.0.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>Metodo de envio para nacex</summary>
10
+ <description>Metodo de envio para nacex</description>
11
+ <notes>* Version estable del metodo de envio para la empresa Nacex</notes>
12
+ <authors><author><name>Manuel</name><user>auto-converted</user><email>manuelcanepa@gmail.com</email></author></authors>
13
+ <date>2008-08-22</date>
14
+ <time>16:16:41</time>
15
+ <contents><target name="mageetc"><dir name="modules"><file name="Nacex_Shipping.xml" hash="900734fd3feec45c7276f7ad762b7013"/></dir></target><target name="magecommunity"><dir name="Nacex"><dir name="Shipping"><dir name="etc"><file name="config.xml" hash="520c2766de44cf2fc53f1c2118a5cd69"/><file name="system.xml" hash="b1feee308b495e57dff8db7722d25998"/></dir><dir name="Helper"><file name="Data.php" hash="92d6c5b5abad03866fef51c768e3ebdd"/></dir><dir name="Model"><dir name="Carrier"><file name="Spainpost.php" hash="0bcbe05270488db95d7bbfa5e1ad40da"/></dir></dir><dir name="sql"><dir name="shipping_setup"><file name="mysql4-install-0.1.0.php" hash="e28973e4c3edf00b284a998b32f53829"/></dir></dir></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies/>
18
+ </package>