Bueno, tengo a osCOmmerce como mi Web de Venta, entonses utiliso un Calculador de Shipping que osCommerce trae. El archivo se llama zonesworld.php
Solo trae para 3 Zonas. Yo nesesito ese mismo pero para 8 Zona. Tiene el Siguinete Codigo ese Archivo.
Código PHP:
<?php
class zonesworld {
var $code, $title, $description, $enabled, $num_zonesworld;
// class constructor
function zonesworld() {
$this->code = 'zonesworld';
$this->title = MODULE_SHIPPING_ZONESWORLD_TEXT_TITLE;
$this->description = MODULE_SHIPPING_ZONESWORLD_TEXT_DESCRIPTION;
$this->sort_order = MODULE_SHIPPING_ZONESWORLD_SORT_ORDER;
$this->icon = '';
$this->enabled = ((MODULE_SHIPPING_ZONESWORLD_STATUS == 'True') ? true : false);
// CUSTOMIZE THIS SETTING FOR THE NUMBER OF ZONES NEEDED
$this->num_zonesworld = 3;
}
// class methods
function quote($method = '') {
global $order, $shipping_weight;
$dest_country = $order->delivery['country']['iso_code_2'];
$dest_zone = 0;
$error = false;
for ($i=1; $i<=$this->num_zonesworld; $i++) {
$countries_table = constant('MODULE_SHIPPING_ZONESWORLD_COUNTRIES_' . $i);
$country_zones = split("[,]", $countries_table);
if (in_array($dest_country, $country_zones)) {
$dest_zone = $i;
break;
}
}
// elari - Added to select default country if not in listing
if ($dest_zone == 0) {
$dest_zone = $this->num_zonesworld; // the zone is the lastest zone avalaible
}
// elari - Added to select default country if not in listing
if ($dest_zone == 0) {
$error = true; // this can no more achieve since by default the value is set to the max number of zones
} else {
$shipping = -1;
$zones_cost = constant('MODULE_SHIPPING_ZONESWORLD_COST_' . $dest_zone);
$zones_table = split("[:,]" , $zones_cost);
$size = sizeof($zones_table);
for ($i=0; $i<$size; $i+=2) {
if ($shipping_weight <= $zones_table[$i]) {
$shipping = $zones_table[$i+1];
$shipping_method = MODULE_SHIPPING_ZONESWORLD_TEXT_WAY . ' ' . $dest_country . ' : ' . $shipping_weight . ' ' . MODULE_SHIPPING_ZONESWORLD_TEXT_UNITS;
break;
}
}
if ($shipping == -1) {
$shipping_cost = 0;
$shipping_method = MODULE_SHIPPING_ZONESWORLD_UNDEFINED_RATE;
} else {
$shipping_cost = ($shipping + constant('MODULE_SHIPPING_ZONESWORLD_HANDLING_' . $dest_zone));
}
}
$this->quotes = array('id' => $this->code,
'module' => MODULE_SHIPPING_ZONESWORLD_TEXT_TITLE,
'methods' => array(array('id' => $this->code,
'title' => $shipping_method,
'cost' => $shipping_cost)));
if (tep_not_null($this->icon)) $this->quotes['icon'] = tep_image($this->icon, $this->title);
if ($error == true) $this->quotes['error'] = MODULE_SHIPPING_ZONESWORLD_INVALID_ZONE;
return $this->quotes;
}
function check() {
if (!isset($this->_check)) {
$check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_ZONESWORLD_STATUS'");
$this->_check = tep_db_num_rows($check_query);
}
return $this->_check;
}
// elari - Added to select default country if not in listing
function install() {
tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) VALUES ('Enable Zones Method', 'MODULE_SHIPPING_ZONESWORLD_STATUS', 'True', 'Do you want to offer zone rate shipping?', '6', '0', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())");
tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort order of display.', 'MODULE_SHIPPING_ZONESWORLD_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '0', now())");
for ($i = 1; $i <= $this->num_zonesworld; $i++) {
$default_countries = '';
if ($i == 1) {
$default_countries = 'FR';
$shipping_table = '3:6,7:10.50,99:100.00';
}
if ($i == 2) {
$default_countries = 'AT,BE,GB,DE,GL,IS,IE,IT,NO,NL,DK,PL,ES,SE,CH,FI,PT,IL,GR';
$shipping_table = '3:7,7:11,99:150.00';
}
if ($i == 3) {
$default_countries = 'All Others'; // this must be the lastest zone
$shipping_table = '3:8,7:12,99:200.00';
}
tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Zone " . $i ." Countries', 'MODULE_SHIPPING_ZONESWORLD_COUNTRIES_" . $i ."', '" . $default_countries . "', 'Comma separated list of two character ISO country codes that are part of Zone " . $i . ".', '6', '0', now())");
tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Zone " . $i ." Shipping Table', 'MODULE_SHIPPING_ZONESWORLD_COST_" . $i ."', '" . $shipping_table . "', 'Shipping rates to Zone " . $i . " destinations based on a group of maximum order weights. Example: 3:8.50,7:10.50,... Weights less than or equal to 3 would cost 8.50 for Zone " . $i . " destinations.', '6', '0', now())");
tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Zone " . $i ." Handling Fee', 'MODULE_SHIPPING_ZONESWORLD_HANDLING_" . $i ."', '0', 'Handling Fee for this shipping zone', '6', '0', now())");
}
}
// elari - Added to select default country if not in listing
function remove() {
tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
}
function keys() {
$keys = array('MODULE_SHIPPING_ZONESWORLD_STATUS', 'MODULE_SHIPPING_ZONESWORLD_SORT_ORDER');
for ($i=1; $i<=$this->num_zonesworld; $i++) {
$keys[] = 'MODULE_SHIPPING_ZONESWORLD_COUNTRIES_' . $i;
$keys[] = 'MODULE_SHIPPING_ZONESWORLD_COST_' . $i;
}
return $keys;
}
}
?>
Ayudenme por Favor. .