Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Shipping Zones ..


zboyblue

Recommended Posts

Posted

I am sure this has been talked about somewhere already but I could not find anything. : (

 

I have UPS, FedEx, and USPS shipping modules installed and would like FedEx and UPS to be available to US customers and FedEx and USPS be available to international customers. In all the shipping modules I can choose a "zone" which will limit the use of that shipping method to that zone. The only place I can set the zone up is in "Tax Zones" which seems to work but I can only set one country per zone as it seems. Is there some way I can make a zone that contains ALL countries except the US? (Or some other way to limit the shipping modules in this way).

 

I tried only having USPS show international services and UPS only showing domestic services but for some reason the USPS module will not LET me only choose international and also if you check out with an international address UPS is still there just with no choices. So it seems like the zone thing is the way to go ...

 

can anyone help? : )

 

Craig

Posted

Ok there was a similar question about it with some code you could try it.

 

Basically you could filter countries in the shipping module. eww implement this with his shop with the table and table2 shipping modules. Modifications were on the class constructor for the shipping that enable/disable the module based on country.

 

Module Table

  class table {
var $code, $title, $description, $icon, $enabled;

// class constructor
function table() {
  global $order;

  $this->code = 'table';
  $this->title = MODULE_SHIPPING_TABLE_TEXT_TITLE;
  $this->description = MODULE_SHIPPING_TABLE_TEXT_DESCRIPTION;
  $this->sort_order = MODULE_SHIPPING_TABLE_SORT_ORDER;
  $this->icon = '';
  $this->tax_class = MODULE_SHIPPING_TABLE_TAX_CLASS;
  $this->enabled = ((MODULE_SHIPPING_TABLE_STATUS == 'True') ? true : false);

  $check_flag == $this->enabled;
  $check_query = tep_db_query("select zone_id, zone_country_id from " . TABLE_ZONES . " where zone_country_id = '" . (int)$order->delivery['country']['id'] . "' order by zone_id");
  if($check = tep_db_fetch_array($check_query)) {
	if( $check['zone_country_id'] == 223 || $check['zone_country_id'] == 38 ) {
	  $check_flag = true;
	} else {
	  $check_flag = false;
	}
  } else {
	$check_flag = false;
  }
  $this->enabled = $check_flag;

  if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_TABLE_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_TABLE_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;
	}
  }
}

 

Table2

// class constructor
function table2() {
  global $order;

  $this->code = 'table2';
  $this->title = MODULE_SHIPPING_TABLE2_TEXT_TITLE;
  $this->description = MODULE_SHIPPING_TABLE2_TEXT_DESCRIPTION;
  $this->sort_order = MODULE_SHIPPING_TABLE2_SORT_ORDER;
  $this->icon = '';
  $this->tax_class = MODULE_SHIPPING_TABLE2_TAX_CLASS;
  $this->enabled = ((MODULE_SHIPPING_TABLE2_STATUS == 'True') ? true : false);

  $check_flag == $this->enabled;
  $check_query = tep_db_query("select zone_id, zone_country_id from " . TABLE_ZONES . " where zone_country_id = '" . (int)$order->delivery['country']['id'] . "' order by zone_id");
  if($check = tep_db_fetch_array($check_query)) {
	if( $check['zone_country_id'] == 223 || $check['zone_country_id'] == 38 ) {
	  $check_flag = false;
	} else {
	  $check_flag = true;
	}
  } else {
	$check_flag = true;
  }

  $this->enabled = $check_flag;


  if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_TABLE2_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_TABLE2_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;
	}
  }
}

 

In this case the country codes are hard-coded 223 is US and 38 is Canada with the default osc. If the country id does not match the shipping requirements the module is basically disabled.

 

See how the code filters the countries. You will have to implement something similar for your shipping modules.

Posted

I sortof understand what you are saying to do but I do not know enough about php to do it myself ... : )

 

If I were to paste the code for my USPS module would you be able to tell me the code to change to make this work properly?

 

I appreciate your help very much!

 

Craig

Posted

ok, start with the USPS module (just post the constructor as I did not the whole file). Lets see if that works. Now the USPS module should only be used with US addresses right?

Archived

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

×
×
  • Create New...