Code: Select all
<?php
class ModelShippingCost extends Model {
function getQuote($country_id, $zone_id) {
$this->load->language('shipping/cost');
if ($this->config->get('cost_status')) {
$query = $this->db->query("SELECT geo_zone_id FROM " . DB_PREFIX . "zone_to_geo_zone WHERE country_id = '" . (int)$country_id . "' AND (zone_id = '" . (int)$zone_id . "' OR zone_id = '0')");
$method_data = array();
$quote_data = array();
$costes = unserialize($this->config->get('cost_zone_geozone'));
$totalEnvio = null;
$impuestoEnvio = null;
$minimo = 0;
foreach($costes as $coste) {
if ($query->row['geo_zone_id'] == $coste['geo_zone_id'] && $this->cart->getSubTotal() > $coste['total'] && $minimo <= $coste['total']) {
$minimo = $coste['total'];
$totalEnvio = $coste['cost'];
$impuestoEnvio = $coste['tax_class_id'];
}
}
if ($totalEnvio == null) {
$text = $this->language->get('consultar');
} else {
$text = $this->currency->format($this->tax->calculate($totalEnvio, $impuestoEnvio, $this->config->get('config_tax')));
}
$quote_data['cost'] = array(
'id' => 'cost.cost',
'title' => $this->language->get('text_description'),
'cost' => $totalEnvio,
'tax_class_id' => $impuestoEnvio,
'text' => $text
);
$method_data = array(
'id' => 'cost',
'title' => $this->language->get('text_title'),
'quote' => $quote_data,
'sort_order' => $this->config->get('cost_sort_order'),
'error' => FALSE
);
}
return $method_data;
}
}
?>
if ($totalEnvio == null) {
$text = $this->language->get('consultar');