ayuda con modificación (Extensión de Nacex)

juancarlos

Nuevo usuario
buenos días,
quería modificar la extensión de Nacex para adaptarla a mi tienda y con precios nuevos.
He tomado el archivo data.php para modificar unos datos.
<?php
class Nacex_Shipping_Model_Standard_Data {

public function getRegion($topcode,$compare=null){
$region = null;
$ind=substr($topcode,0,2);
foreach($this->getRegions() as $id => $val){
if(in_array($ind,$val)){
$region = $id;
continue;
}
}
if($compare !== null){
$compare=$this->getRegion($compare);
if($region === $compare)
return true;
else
return false;
}
return $region;
}

/*
* Setea el tipo de servicio segun la ubicacion del cliente
* con respecto a la tienda
*/
public function setServicio($_frompcode,$_topcode){
$code_store = substr($_frompcode,0,2);
$_topcode = substr($_topcode,0,2);
$servicio = '';
if($code_store == '07' || substr($_topcode,0,2) == '07'){
if($this->getRegion($code_store,$_topcode)){
// PRECIO INTRAISLAS
return 'INTRAISLAS';
} else {
// PRECIO NACIONAL PARA TODA ESPAÑA
return 'NACIONAL_BALEARES';
}
} else {
// PARA LA TIENDA EN EL RESTO DE ESPAÑA
if($code_store == $_topcode){
// PRECIO PROVINCIAL
return 'PROVINCIAL';
} else {
$id_region = $this->getRegion($_topcode,$code_store);
if($id_region == true){
// PRECIO REGIONAL PARA PROVINCIAS DE LA MISMA REGION
return 'REGIONAL';
} else {
// PRECIO NACIONAL PARA TODA ESPAÑA
return 'NACIONAL';
}
}
}
}

public function getRegions(){
return array(
'ANDALUCIA' =>array('04','11','14','18','21','23','29','41'),
'ARAGON' =>array('22','44','50'),
'BALEARES' =>array('07'),
'CANARIAS' =>array('35','38'),
'CANTABRIA' =>array('39'),
'CASTILLA Y LEON' =>array('05','09','24','34','37','40','42','47','49'),
'CASTILLA LA MANCA' =>array('02','13','16','19','45'),
'CATALUÑA' =>array('08','17','25','43'),
'CEUTA' =>array('51'),
'COMUNIDAD DE MADRID' =>array('28'),
'COMUNIDAD FORAL DE NAVARRA' =>array('31'),
'COMUNIDAD VALENCIANA' =>array('03','12','46'),
'EUSKADI - PAIS VASCO' =>array('01','20','48'),
'EXTREMADURA' =>array('06','10'),
'GALICIA' =>array('15','27','32','36'),
'LA RIOJA' =>array('26'),
'MELILLA' =>array('52'),
'PRINCIPADO DE ASTURIAS' =>array('33'),
'MURCIA' =>array('30')
);
}

public function getPrecio($params){
$code = (isset($params['code'])) ? $params['code'] : '';
$servicio = $params['servicio'];
$sweight = $params['sweight'];
if(!$servicio) Mage::log(Mage::helper('nacex')->__('Servicio no disponible, alerta en linea: #%s de "%s"',__LINE__,__FILE__),Zend_Log::ALERT);
if(!$sweight) Mage::log(Mage::helper('nacex')->__('Peso no disponible. Se tomara el importe minimo del servicio, para una mayor precision por favor cargue el peso de los productos'),Zend_Log::ALERT);
$params = array('price'=>0);
try {
switch($servicio){
case 'PROVINCIAL':
$params['shipping_method'] = 'PACK';
if($sweight <= '0000') {
$params['shipping_method'] = 'BAG';
$params['price'] = 0.00;
} elseif(($sweight > '0000') && ($sweight <='1000')){
$params['price'] = 0.00;
} elseif(($sweight > '2000') && ($sweight <='3000')){
$params['price'] = 5.93;
} elseif(($sweight > '4000') && ($sweight <='5000')){
$params['price'] = 10.00;
} elseif(($sweight > '5000') && ($sweight <='10000')){
$params['price'] = 16.95;
} elseif(($sweight > '11000') && ($sweight <='20000')){
$params['price'] = 25.00;
} else {
$params['price'] = 16.95;
$peso=$sweight - 21000;
$params['price'] += (ceil($peso / 10000)) * 2.37;
}
break;
case 'REGIONAL':
$params['shipping_method'] = 'PACK';
if($sweight <= '0000') {
$params['shipping_method'] = 'BAG';
$params['price'] = 0.00;
} elseif(($sweight > '0000') && ($sweight <='1000')){
$params['price'] = 0.00;
} elseif(($sweight > '2000') && ($sweight <='3000')){
$params['price'] = 5.93;
} elseif(($sweight > '4000') && ($sweight <='5000')){
$params['price'] = 10.00;
} elseif(($sweight > '5000') && ($sweight <='10000')){
$params['price'] = 16.95;
} elseif(($sweight > '11000') && ($sweight <='20000')){
$params['price'] = 25.00;
} else {
$params['price'] = 16.95;
$peso=$sweight - 21000;
$params['price'] += (ceil($peso / 10000)) * 2.37;
}
break;
case 'NACIONAL':
$params['shipping_method'] = 'PACK';
if($sweight <= '0000') {
$params['shipping_method'] = 'BAG';
$params['price'] = 0.00;
} elseif(($sweight > '0000') && ($sweight <='1000')){
$params['price'] = 0.00;
} elseif(($sweight > '2000') && ($sweight <='3000')){
$params['price'] = 5.93;
} elseif(($sweight > '4000') && ($sweight <='5000')){
$params['price'] = 10.00;
} elseif(($sweight > '5000') && ($sweight <='10000')){
$params['price'] = 16.95;
} elseif(($sweight > '11000') && ($sweight <='20000')){
$params['price'] = 25.00;
} else {
$params['price'] = 16.95;
$peso=$sweight - 21000;
$params['price'] += (ceil($peso / 10000)) * 2.37;
}
break;
case 'NACIONAL_BALEARES':
$params['shipping_method'] = 'PACK';
if($sweight <= '0000') {
$params['shipping_method'] = 'BAG';
$params['price'] = 0.00;
} elseif(($sweight > '0000') && ($sweight <='1000')){
$params['price'] = 0.00;
} elseif(($sweight > '2000') && ($sweight <='3000')){
$params['price'] = 5.93;
} elseif(($sweight > '4000') && ($sweight <='5000')){
$params['price'] = 10.00;
} elseif(($sweight > '5000') && ($sweight <='10000')){
$params['price'] = 16.95;
} elseif(($sweight > '11000') && ($sweight <='20000')){
$params['price'] = 25.00;
} else {
$params['price'] = 16.95;
$peso=$sweight - 21000;
$params['price'] += (ceil($peso / 10000)) * 2.37;
}
break;
case 'INTRAISLAS':
$params['shipping_method'] = 'PACK';
if($sweight <= '0000') {
$params['shipping_method'] = 'BAG';
$params['price'] = 0.00;
} elseif(($sweight > '0000') && ($sweight <='1000')){
$params['price'] = 0.00;
} elseif(($sweight > '2000') && ($sweight <='3000')){
$params['price'] = 5.93;
} elseif(($sweight > '4000') && ($sweight <='5000')){
$params['price'] = 10.00;
} elseif(($sweight > '5000') && ($sweight <='10000')){
$params['price'] = 16.95;
} elseif(($sweight > '11000') && ($sweight <='20000')){
$params['price'] = 25.00;
} else {
$params['price'] = 16.95;
$peso=$sweight - 21000;
$params['price'] += (ceil($peso / 10000)) * 2.37;
}
break;
case 'Portugal':
$params['shipping_method'] = 'PACK';
if($sweight <= '0000') {
$params['shipping_method'] = 'BAG';
$params['price'] = 10.00;
} elseif(($sweight > '0000') && ($sweight <='5000')){
$params['price'] = 10.00;
} elseif(($sweight > '6000') && ($sweight <='10000')){
$params['price'] = 18.64;
} elseif(($sweight > '11000') && ($sweight <='20000')){
$params['price'] = 25.00;
} else {
$params['price'] = 16.95;
$peso=$sweight - 21000;
$params['price'] += (ceil($peso / 10000)) * 3.47;
}
break;
case 'Francia':
$params['shipping_method'] = 'PACK';
if($sweight <= '0000') {
$params['shipping_method'] = 'BAG';
$params['price'] = 10.00;
} elseif(($sweight > '0000') && ($sweight <='5000')){
$params['price'] = 10.00;
} elseif(($sweight > '6000') && ($sweight <='10000')){
$params['price'] = 18.64;
} elseif(($sweight > '11000') && ($sweight <='20000')){
$params['price'] = 25.00;
} else {
$params['price'] = 16.95;
$peso=$sweight - 21000;
$params['price'] += (ceil($peso / 10000)) * 3.47;
}
break;
case 'Italia':
$params['shipping_method'] = 'PACK';
if($sweight <= '0000') {
$params['shipping_method'] = 'BAG';
$params['price'] = 10.00;
} elseif(($sweight > '0000') && ($sweight <='5000')){
$params['price'] = 10.00;
} elseif(($sweight > '6000') && ($sweight <='10000')){
$params['price'] = 18.64;
} elseif(($sweight > '11000') && ($sweight <='20000')){
$params['price'] = 25.00;
} else {
$params['price'] = 16.95;
$peso=$sweight - 21000;
$params['price'] += (ceil($peso / 10000)) * 3.47;
}
break;
default:
$params['shipping_method'] = 'BAG';
$params['price'] = 0.00;
break;
}
} catch (Exception $e) {
Mage::logException($e);
}
switch($code){
case 'naxgab':
// En caso de ida y vuelta duplica el valor
$params['price'] *= 2.50;
break;
}
return $params;
}

public function getProvincias(){
return array(
"01"=>"ALAVA",
"02"=>"ALBACETE",
"03"=>"ALICANTE",
"04"=>"ALMERIA",
"33"=>"ASTURIAS",
"05"=>"AVILA",
"06"=>"BADAJOZ",
"08"=>"BARCELONA",
"09"=>"BURGOS",
"10"=>"CACERES",
"11"=>"CADIZ",
"39"=>"CANTABRIA",
"12"=>"CASTELLON",
"51"=>"CEUTA",
"13"=>"CIUDAD REAL",
"14"=>"CORDOBA",
.................................................
}
}
hice una modificación anteriormente de pesos y € la cual resulto perfecta.
ahora esta vez he colocado mas opciones de peso y he querido aumentar el radio de acción añadiendo Portugal, Francia e Italia.
podría funcionar o no es tan fácil como parece
gracias
 

Tamagochi

Nuevo usuario
Hola

Perdona que no te responda pero soy un poco inutil, te escribo para ver si podrias compartir esa modificacion que dices que hiciste antes, ya que yo no tengo pensado al menos en principio en ampliar fuera de españa, pero me vendria bien la primera que hiciste.

Salu2
 

Srwhites

Nuevo usuario
Aprovecho para abrir de nuevo el hilo...

Recientemente acabo de instalar el nuevo modulo de Nacex, una vez instalado me dado cuenta que a la hora de hacer conexión con mi table rates especifico parece que no la hace y coge otro table rates por defecto que vendrá en mi servidor, alguien sabría decirme donde se aloja el table rates que viene por defecto en Magento.

Gracias. Saludos.
 
Arriba