- 04 Dez 2011, 09:54
#12579
Olá, estou tentando criar um modulo para uma transportadora mas quando modifico o função getQuote o modulo 4 para de funcionar. O sistema não passa do modulo 3. Alguém sabe me dizer onde estou errando?
Código; frete.php;
<?php
class ModelShippingFrete extends Model {
function getQuote($address) {
$this->load->language('shipping/frete');
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "zone_to_geo_zone WHERE geo_zone_id = '" . (int)$this->config->get('frete_geo_zone_id') . "' AND country_id = '" . (int)$address['country_id'] . "' AND (zone_id = '" . (int)$address['zone_id'] . "' OR zone_id = '0')");
if (!$this->config->get('frete_geo_zone_id')) {
$status = true;
} elseif ($query->num_rows) {
$status = true;
} else {
$status = false;
}
$method_data = array();
if ($status) {
$quote_data = array();
$quote_data['frete'] = array(
'code' => 'frete.frete',
'title' => $this->language->get('text_description'),
'cost' => 26.00,
'tax_class_id' => 0,
'text' => $this->currency->format(0.00)
);
$method_data = array(
'code' => 'frete',
'title' => $this->language->get('text_title'),
'quote' => $quote_data,
'sort_order' => $this->config->get('frete_sort_order'),
'error' => false
);
}
return $method_data;
}
//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
function getEstado($address){
$query = $this->db->query("SELECT zone_id FROM address WHERE address_id = '".(int)$address['address_id']."'");
$estado = $this->db->query("SELECT name FROM zone WHERE zone_id = '".$query."'");
return $estado;
}
function getCidade(){
$cidade = $this->db->query("SELECT city FROM address WHERE address_id = '".(int)$address['address_id']."'");
return $cidade;
}
function getTabela(){
$this->getEstado();
$this->getCidade();
$capital = $this->db->query("SELECT nm_capital FROM frete_us WHERE nm_estado ='".$estado."'");
if($capital == $cidade){
$tabela = "valor_capital";
}
else{
$tabela = "valor_interior";
}
return $tabela;
}
function getValor(){
$weight = $this->cart->getWeight();
$this->getEstado();
$this->getTabela();
if ($weight<=10){
$coluna="valor_dez";
}
elseif (($weight>10)&&($weight<=20)){
$coluna="valor_vin";
}
elseif (($weight>20)&&($weight<=30)){
$coluna="valor_tri";
}
elseif (($weight>30)&&($weight<=50)){
$coluna="valor_cin";
}
elseif (($weight>50)&&($weight<=70)){
$coluna="valor_set";
}
elseif (($weight>70)&&($weight<=100)){
$coluna="valor_cem";
}
else{
$coluna="valor_aci";
}
$id_estado = $this->db->query("SELECT id_estado FROM frete_us WHERE nm_estado = '".$estado."'");
$valor = $this->db->query("SELECT ".$coluna." FROM ".$tabela."WHERE id_estado = '".$id_estado."'");
return $valor;
}
function getPorcentagem(){
$this->getEstado();
$this->getTabela();
$porcentagem = $this->db->query("SELECT valor_por FROM ".$tabela." WHERE nm_estado = '".$estado."'")
return $porcentagem;
}
function getFrete(){
$total = $this->cart->getSubTotal();
$this->getPorcentagem();
$this->getValor();
$valor_frete = $total*($porcentagem/100);
$valor_seguro = ($total/100)*0.20;
$valor_final = ($valor_frete+$valor_seguro+$valor)/0.88;
return $valor_final;
}
//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
}//fim da class
?>
Código; frete.php;
<?php
class ModelShippingFrete extends Model {
function getQuote($address) {
$this->load->language('shipping/frete');
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "zone_to_geo_zone WHERE geo_zone_id = '" . (int)$this->config->get('frete_geo_zone_id') . "' AND country_id = '" . (int)$address['country_id'] . "' AND (zone_id = '" . (int)$address['zone_id'] . "' OR zone_id = '0')");
if (!$this->config->get('frete_geo_zone_id')) {
$status = true;
} elseif ($query->num_rows) {
$status = true;
} else {
$status = false;
}
$method_data = array();
if ($status) {
$quote_data = array();
$quote_data['frete'] = array(
'code' => 'frete.frete',
'title' => $this->language->get('text_description'),
'cost' => 26.00,
'tax_class_id' => 0,
'text' => $this->currency->format(0.00)
);
$method_data = array(
'code' => 'frete',
'title' => $this->language->get('text_title'),
'quote' => $quote_data,
'sort_order' => $this->config->get('frete_sort_order'),
'error' => false
);
}
return $method_data;
}
//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
function getEstado($address){
$query = $this->db->query("SELECT zone_id FROM address WHERE address_id = '".(int)$address['address_id']."'");
$estado = $this->db->query("SELECT name FROM zone WHERE zone_id = '".$query."'");
return $estado;
}
function getCidade(){
$cidade = $this->db->query("SELECT city FROM address WHERE address_id = '".(int)$address['address_id']."'");
return $cidade;
}
function getTabela(){
$this->getEstado();
$this->getCidade();
$capital = $this->db->query("SELECT nm_capital FROM frete_us WHERE nm_estado ='".$estado."'");
if($capital == $cidade){
$tabela = "valor_capital";
}
else{
$tabela = "valor_interior";
}
return $tabela;
}
function getValor(){
$weight = $this->cart->getWeight();
$this->getEstado();
$this->getTabela();
if ($weight<=10){
$coluna="valor_dez";
}
elseif (($weight>10)&&($weight<=20)){
$coluna="valor_vin";
}
elseif (($weight>20)&&($weight<=30)){
$coluna="valor_tri";
}
elseif (($weight>30)&&($weight<=50)){
$coluna="valor_cin";
}
elseif (($weight>50)&&($weight<=70)){
$coluna="valor_set";
}
elseif (($weight>70)&&($weight<=100)){
$coluna="valor_cem";
}
else{
$coluna="valor_aci";
}
$id_estado = $this->db->query("SELECT id_estado FROM frete_us WHERE nm_estado = '".$estado."'");
$valor = $this->db->query("SELECT ".$coluna." FROM ".$tabela."WHERE id_estado = '".$id_estado."'");
return $valor;
}
function getPorcentagem(){
$this->getEstado();
$this->getTabela();
$porcentagem = $this->db->query("SELECT valor_por FROM ".$tabela." WHERE nm_estado = '".$estado."'")
return $porcentagem;
}
function getFrete(){
$total = $this->cart->getSubTotal();
$this->getPorcentagem();
$this->getValor();
$valor_frete = $total*($porcentagem/100);
$valor_seguro = ($total/100)*0.20;
$valor_final = ($valor_frete+$valor_seguro+$valor)/0.88;
return $valor_final;
}
//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
}//fim da class
?>



