Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Inclusing Tax Class in ZonesWorld


munguia

Recommended Posts

I have installed zonesword.php but it does not include taxes.

 

I would like to include the neccessary elements in the code, without much success.

 

Might be there some person with experience in this sort of problems to offer me a piece of advice on it?

 

The zonesworld.php code:

 

<?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 = 'PT';

$shipping_table = '2:17,8:23,10000:45';

}

if ($i == 2) {

$default_countries = 'FR,BE,NL,LU';

$shipping_table = '2:21,8:29,10000:63';

}

if ($i == 3) {

$default_countries = 'All Others'; // this must be the lastest zone

$shipping_table = '';

}

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 ." 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 ." 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;

$keys[] = 'MODULE_SHIPPING_ZONESWORLD_HANDLING_' . $i;

}

 

return $keys;

}

}

?>

 

 

the ups.php code, with the tax elements:

 

<?php

class ups {

var $code, $title, $description, $icon, $enabled;

 

// class constructor

function ups() {

global $order;

 

$this->code = 'ups';

$this->title = MODULE_SHIPPING_UPS_TEXT_TITLE;

$this->description = MODULE_SHIPPING_UPS_TEXT_DESCRIPTION;

$this->sort_order = MODULE_SHIPPING_UPS_SORT_ORDER;

$this->icon = '';

$this->tax_class = MODULE_SHIPPING_UPS_TAX_CLASS;

$this->enabled = ((MODULE_SHIPPING_UPS_STATUS == 'True') ? true : false);

 

if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_UPS_ZONE > 0) ) {

$check_flag = false;

$check_query = tep_db_query("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_SHIPPING_UPS_ZONE . "' and zone_country_id = '" . $order->delivery['country']['id'] . "' order by zone_id");

while ($check = tep_db_fetch_array($check_query)) {

if ($check['zone_id'] < 1) {

$check_flag = true;

break;

} elseif ($check['zone_id'] == $order->delivery['zone_id']) {

$check_flag = true;

break;

}

}

 

if ($check_flag == false) {

$this->enabled = false;

}

}

}

 

// class methods

function quote($method = '') {

global $order;

 

$this->quotes = array('id' => $this->code,

'module' => MODULE_SHIPPING_UPS_TEXT_TITLE,

'methods' => array(array('id' => $this->code,

'title' => MODULE_SHIPPING_UPS_TEXT_WAY,

'cost' => MODULE_SHIPPING_UPS_COST)));

 

if ($this->tax_class > 0) {

$this->quotes['tax'] = tep_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);

}

 

if (tep_not_null($this->icon)) $this->quotes['icon'] = tep_image($this->icon, $this->title);

 

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_UPS_STATUS'");

$this->_check = tep_db_num_rows($check_query);

}

return $this->_check;

}

 

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 UPS Shipping', 'MODULE_SHIPPING_UPS_STATUS', 'True', 'Do you want to offer UPS 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 ('Shipping Cost', 'MODULE_SHIPPING_UPS_COST', '5.00', 'The shipping cost for all orders using this shipping method.', '6', '0', now())");

tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Tax Class', 'MODULE_SHIPPING_UPS_TAX_CLASS', '0', 'Use the following tax class on the shipping fee.', '6', '0', 'tep_get_tax_class_title', 'tep_cfg_pull_down_tax_classes(', now())");

tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Shipping Zone', 'MODULE_SHIPPING_UPS_ZONE', '0', 'If a zone is selected, only enable this shipping method for that zone.', '6', '0', 'tep_get_zone_class_title', 'tep_cfg_pull_down_zone_classes(', 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', 'MODULE_SHIPPING_UPS_SORT_ORDER', '0', 'Sort order of display.', '6', '0', now())");

}

 

function remove() {

tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");

}

 

function keys() {

return array('MODULE_SHIPPING_UPS_STATUS', 'MODULE_SHIPPING_UPS_COST', 'MODULE_SHIPPING_UPS_TAX_CLASS', 'MODULE_SHIPPING_UPS_ZONE', 'MODULE_SHIPPING_UPS_SORT_ORDER');

}

}

?>

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...