Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Integration Multi vendor and Multi zones shipping


Guest

Recommended Posts

Hi , I install multi vendor shipping (mvs) and I need to install the contibution MultiGeoZone MultiTable Shipping (mzmt)

 

now I follow the instruction to modifie mzmt, but he dont load the shipping price...cold soebody help me?

 

this is my code:

 

<?php


 class mzmt {
var $code, $title, $description, $icon, $enabled, $num_zones, $num_tables, $delivery_geozone, $geozone_mode, $order_total, $vendors_id;

function mzmt() {
  global $order;

  $this->code = 'mzmt';
  $this->title = MODULE_SHIPPING_MZMT_TEXT_TITLE;
  $this->description = MODULE_SHIPPING_MZMT_TEXT_DESCRIPTION;
  /*   $this->sort_order = MODULE_SHIPPING_MZMT_SORT_ORDER;
  $this->tax_class = MODULE_SHIPPING_MZMT_TAX_CLASS;
  $this->enabled = ((MODULE_SHIPPING_MZMT_STATUS == 'True') ? true : false);*/

  $this->num_geozones = MODULE_SHIPPING_MZMT_NUMBER_GEOZONES;
  $this->num_tables = MODULE_SHIPPING_MZMT_NUMBER_TABLES;

  /*   if ($this->enabled == true) {
	$this->enabled = false;
	for ($n=1; $n<=$this->num_geozones; $n++) {
	  if ( ((int)constant('MODULE_SHIPPING_MZMT_GEOZONE_' . $n . '_ID') > 0) && ((int)constant('MODULE_SHIPPING_MZMT_GEOZONE_' . $n . '_ID') == $this->getGeoZoneID($order->delivery['country']['id'], $order->delivery['zone_id'])) ) {
		$this->enabled = true;
		$this->delivery_geozone = $n;
		break;
	  } elseif ( ((int)constant('MODULE_SHIPPING_MZMT_GEOZONE_' . $n . '_ID') == 0) && ($n == (int)$this->num_geozones) ) {
		$this->enabled = true;
		$this->delivery_geozone = $n;
		break;
	  }
	}
  }*/
}

 function sort_order($vendors_id='1') {
  if (defined (@constant ('MODULE_SHIPPING_MZMT_SORT_ORDER_' . $vendors_id))) {
	$this->sort_order = @constant('MODULE_SHIPPING_MZMT_SORT_ORDER_' . $vendors_id);
  } else {
	$this->sort_order = '0';
  }
  return $this->sort_order;
}

function tax_class($vendors_id='1') {
  $this->tax_class = constant('MODULE_SHIPPING_MZMT_TAX_CLASS_' . $vendors_id);
  return $this->tax_class;
}

function enabled($vendors_id='1') {
  $this->enabled = false;
  $status = @constant('MODULE_SHIPPING_MZMT_STATUS_' . $vendors_id);
		if (isset ($status) && $status != '') {
	$this->enabled = (($status == 'True') ? true : false);

	 if ($this->enabled == true) {
	$this->enabled = false;
	for ($n=1; $n<=$this->num_geozones; $n++) {
	  if ( ((int)constant('MODULE_SHIPPING_MZMT_GEOZONE_' . $n . '_ID') > 0) && ((int)constant('MODULE_SHIPPING_MZMT_GEOZONE_' . $n . '_ID') == $this->getGeoZoneID($order->delivery['country']['id'], $order->delivery['zone_id'])) ) {
		$this->enabled = true;
		$this->delivery_geozone = $n;
		break;
	  } elseif ( ((int)constant('MODULE_SHIPPING_MZMT_GEOZONE_' . $n . '_ID') == 0) && ($n == (int)$this->num_geozones) ) {
		$this->enabled = true;
		$this->delivery_geozone = $n;
		break;
	  }
	}
  }
  }
  return $this->enabled;
}

function zones($vendors_id='1') {
  if ( ($this->enabled == true) && ((int)constant('MODULE_SHIPPING_MZMT_ZONE_' . $vendors_id) > 0) ) {
	$check_flag = false;
	$check_query = tep_db_query("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . (int)constant('MODULE_SHIPPING_MZMT_ZONE_' . $vendors_id) . "' 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
	}//while

	if ($check_flag == false) {
	  $this->enabled = false;
	}//if
  }//if
  return $this->enabled;
}//function

// class methods
function quote($method = '', $module = '', $vendors_id = '1') {
 global $order, $shipping_weight, $shipping_num_boxes;
 	  $combined_quote_weight = ($shipping_num_boxes * $shipping_weight);
  $this->quotes = array('id' => $this->code,
						'module' => constant('MODULE_SHIPPING_MZMT_GEOZONE_' . $this->delivery_geozone . '_TEXT_TITLE') . '',
						'methods' => array());

  $this->determineTableMethod(constant('MODULE_SHIPPING_MZMT_GEOZONE_' . $this->delivery_geozone . '_MODE'));  

  if ($method) {
	$j = substr($method, 5);

	$shipping = $this->determineShipping(split("[:,]" , constant('MODULE_SHIPPING_MZMT_GEOZONE_' . $this->delivery_geozone . '_TABLE_' . $j )));

		  $vendors_data_query = tep_db_query("select handling_charge, 
											 handling_per_box,
					 vendor_country 
									  from " . TABLE_VENDORS . " 
									  where vendors_id = '" . (int)$vendors_id . "'"
									);
  $vendors_data = tep_db_fetch_array($vendors_data_query);
  $country_name = tep_get_countries($vendors_data['vendor_country'], true); 	

  $handling_charge = $vendors_data['handling_charge'];
  $handling_per_box = $vendors_data['handling_per_box'];
  if ($handling_charge > $handling_per_box*$shipping_num_boxes) {
	$handling = $handling_charge;
  } else {
	$handling = $handling_per_box*$shipping_num_boxes;
  }


	$this->quotes['methods'][] = array('id' => 'table' . $j,
									   'title' => constant('MODULE_SHIPPING_MZMT_GEOZONE_' . $this->delivery_geozone . '_TABLE_' . $j . '_TEXT_WAY'),
									  'cost' => $shipping + constant('MODULE_SHIPPING_MZMT_GEOZONE_' . $this->delivery_geozone . '_HANDLING'));
									  //  'cost' => $shipping + $handling);
  } else {
	for ($j=1; $j<=$this->num_tables; $j++) {
	  if (!tep_not_null(constant('MODULE_SHIPPING_MZMT_GEOZONE_' . $this->delivery_geozone . '_TABLE_' . $j .'_' . $vendors_id))) continue;

	  $shipping = $this->determineShipping(split("[:,]" , constant('MODULE_SHIPPING_MZMT_GEOZONE_' . $this->delivery_geozone . '_TABLE_' . $j )));

	  $this->quotes['methods'][] = array('id' => 'table' . $j,
										 'title' => constant('MODULE_SHIPPING_MZMT_GEOZONE_' . $this->delivery_geozone . '_TABLE_' . $j . '_TEXT_WAY'),
										 'cost' => $shipping + constant('MODULE_SHIPPING_MZMT_GEOZONE_' . $this->delivery_geozone . '_HANDLING'));
	}
  }

  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(constant('MODULE_SHIPPING_MZMT_GEOZONE_' . $this->delivery_geozone . '_ICON'))) $this->quotes['icon'] = tep_image(DIR_WS_ICONS . constant('MODULE_SHIPPING_MZMT_GEOZONE_' . $this->delivery_geozone . '_ICON'), $this->title);

  return $this->quotes;
}  

function check($vendors_id='1') {
  if (!isset($this->_check)) {
//	$check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_MZMT_STATUS'");
	$check_query = tep_db_query("select configuration_value from " . TABLE_VENDOR_CONFIGURATION . " where vendors_id = '". $vendors_id ."' and configuration_key = 'MODULE_SHIPPING_MZMT_STATUS_" . $vendors_id . "'");
	$this->_check = mysql_num_rows($check_query);
  }
  return $this->_check;
}

function install($vendors_id='1') {
  tep_db_query("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added, vendors_id) VALUES ('Enable MultiRegion MultiTable Method', 'MODULE_SHIPPING_MZMT_STATUS_" . $vendors_id . "', 'True', 'Do you want to offer multi-region multi-table rate shipping?', '6', '0', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now(), '" . $vendors_id . "')");
  tep_db_query("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added, vendors_id) values ('Tax Class', 'MODULE_SHIPPING_MZMT_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(), '" . $vendors_id . "')");
  tep_db_query("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, vendors_id) values ('Sort Order', 'MODULE_SHIPPING_MZMT_SORT_ORDER', '0', 'Sort order of display.', '6', '0', now(), '" . $vendors_id . "')");

  for ($n=1; $n<=$this->num_geozones; $n++) {
	tep_db_query("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added, vendors_id) values ('<hr />Geo Zone $n', 'MODULE_SHIPPING_MZMT_GEOZONE_{$n}_ID', '', 'Enable this for the following geo zone.', '6', '0', 'tep_get_zone_class_title', '_cfg_pull_down_geozones(', now(), '" . $vendors_id . "')");

	tep_db_query("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added, vendors_id) values ('Geo Zone $n Table Method', 'MODULE_SHIPPING_MZMT_GEOZONE_{$n}_MODE', 'weight', 'The shipping cost is based on the total weight, total price, or total count of the items ordered.', '6', '0', 'tep_cfg_select_option(array(\'weight\', \'price\', \'count\'), ', now(), '" . $vendors_id . "')");

	for ($j=1; $j<=$this->num_tables; $j++) {
	  tep_db_query("insert into " . TABLE_VENDOR_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, vendors_id) values ('Geo Zone $n Shipping Table $j', 'MODULE_SHIPPING_MZMT_GEOZONE_{$n}_TABLE_{$j}', '', 'Shipping table $j for this geo zone', '6', '0', now(), '" . $vendors_id . "')");
	}

	tep_db_query("insert into " . TABLE_VENDOR_CONFIGURATION. " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, vendors_id) values ('Geo Zone $n Handling Fee', 'MODULE_SHIPPING_MZMT_GEOZONE_{$n}_HANDLING', '0', 'Handling Fee for this shipping geo zone', '6', '0', now(), '" . $vendors_id . "')");
  }
}

 /*  function remove() {
  tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
}*/

	function remove($vendors_id) {
  tep_db_query("delete from " . TABLE_VENDOR_CONFIGURATION . " where vendors_id = '". $vendors_id ."' and configuration_key in ('" . implode("', '", $this->keys($vendors_id)) . "')");
}

function keys($vendors_id) {
  $keys = array('MODULE_SHIPPING_MZMT_STATUS_' . $vendors_id, 'MODULE_SHIPPING_MZMT_TAX_CLASS', 'MODULE_SHIPPING_MZMT_SORT_ORDER');

  for ($n=1; $n<=$this->num_geozones; $n++) {
	$keys[] = 'MODULE_SHIPPING_MZMT_GEOZONE_' . $n . '_ID';
	$keys[] = 'MODULE_SHIPPING_MZMT_GEOZONE_' . $n . '_MODE';
	$keys[] = 'MODULE_SHIPPING_MZMT_GEOZONE_' . $n . '_HANDLING';

	for ($j=1; $j<=$this->num_tables; $j++) {
	  $keys[] = 'MODULE_SHIPPING_MZMT_GEOZONE_' . $n . '_TABLE_' . $j;
	}
  }

  return $keys;
}

function determineTableMethod($geozone_mode) {
  global $total_count, $shipping_weight;

  $this->geozone_mode = $geozone_mode;

  if ($this->geozone_mode == 'price') {
	$this->order_total = $_SESSION['cart']->show_total();
  } elseif ($this->geozone_mode == 'count') {
	$this->order_total = $total_count;
  } else {
	$this->order_total = $shipping_weight;
  }

  return true;	
}

function determineShipping($table_cost) {
  global $shipping_num_boxes;

  for ($i=0, $n=sizeof($table_cost); $i<$n; $i+=2) {
	if ($this->order_total >= $table_cost[$i]) {
	  $shipping_factor = $table_cost[$i+1];
	}
  }

  if (substr_count($shipping_factor, '%') > 0) {
	$shipping = ((($this->order_total*10)/10)*((str_replace('%', '', $shipping_factor))/100));
  } else {
	$shipping = str_replace('$', '', $shipping_factor);
  }

  if ($this->geozone_mode == 'weight') {
	$shipping = $shipping * $shipping_num_boxes;
  }

  return $shipping;
}

function getGeoZoneID($country_id, $zone_id) {
  // First, check for a Geo Zone that explicity includes the country & specific zone (useful for splitting countries with zones up)
  $zone_query = tep_db_query("select gz.geo_zone_id from " . TABLE_GEO_ZONES . " gz left join " . TABLE_ZONES_TO_GEO_ZONES . " ztgz on (gz.geo_zone_id = ztgz.geo_zone_id) where ztgz.zone_country_id = '" . (int)$country_id . "' and ztgz.zone_id = '" . (int)$zone_id . "' and LOWER(gz.geo_zone_name) like 'shp%'");

  if (mysql_num_rows($zone_query)) {
	$zone = mysql_fetch_assoc($zone_query);
	return $zone['geo_zone_id'];
  } else {
	// No luck…  Now check for a Geo Zone for the country and "All Zones" of the country.
	$zone_query = tep_db_query("select gz.geo_zone_id from " . TABLE_GEO_ZONES . " gz left join " . TABLE_ZONES_TO_GEO_ZONES . " ztgz on (gz.geo_zone_id = ztgz.geo_zone_id) where ztgz.zone_country_id = '" . (int)$country_id . "' and (ztgz.zone_id = '0' or ztgz.zone_id is NULL) and LOWER(gz.geo_zone_name) like 'shp%'");

	if (mysql_num_rows($zone_query)) {
	  $zone = mysql_fetch_assoc($zone_query);
	  return $zone['geo_zone_id'];
	} else {
	  return false;
	}
  }
}

 }

 function _cfg_pull_down_geozones($zone_class_id, $key = '') {
$name = (($key) ? 'configuration[' . $key . ']' : 'configuration_value');

$zone_class_array = array(array('id' => '0', 'text' => 'Rest of the World'));
$zone_class_query = tep_db_query("select geo_zone_id, geo_zone_name from " . TABLE_GEO_ZONES . " where LOWER(geo_zone_name) like 'shp%' order by geo_zone_name");

while ($zone_class = mysql_fetch_assoc($zone_class_query)) {
  $zone_class_array[] = array('id' => $zone_class['geo_zone_id'],
							  'text' => $zone_class['geo_zone_name']);
}

return tep_draw_pull_down_menu($name, $zone_class_array, $zone_class_id);
 }
?>

Link to comment
Share on other sites

this are the istructions:

 

==============

Modifications:

==============

 

Now open the code file in your editor and we'll get started. Look for code similar to

the following lines. These lines will be near the top, mixed in with a series

of similar definitions. They may not occur on consecutive lines like I've placed them

here -- you will need to find each line individually. Also, the constants will be

different. Since I'm using the Table module as an example, the constants all contain

the string _TABLE_. Your module will have a different string in this position, but

the remainder of the constant will be the same. For example, the UPS module has the

string _UPS_, while the UPS XML module has the string _UPSXML_RATES_. You will need to

know and be able to recognize the string for your module, so do the comparison now.

 

On to the code to find:

 

---------------------------------------------------------------------------------------

$this->sort_order = MODULE_SHIPPING_TABLE_SORT_ORDER;

$this->tax_class = MODULE_SHIPPING_TABLE_TAX_CLASS;

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

 

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;

}

}

---------------------------------------------------------------------------------------

 

 

Comment out the above lines. Don't delete them; we'll need to refer to them later. Now

find code that looks something like this:

 

---------------------------------------------------------------------------------------

// class methods

function quote($method = '') {

---------------------------------------------------------------------------------------

 

 

The comment may not be the same, or may be missing entirely. The following line should

look the same. Now paste the following code just above those lines.

 

---------------------------------------------------------------------------------------

function sort_order($vendors_id='1') {

if (defined (@constant ('MODULE_SHIPPING_TABLE_SORT_ORDER_' . $vendors_id))) {

$this->sort_order = @constant('MODULE_SHIPPING_TABLE_SORT_ORDER_' . $vendors_id);

} else {

$this->sort_order = '0';

}

return $this->sort_order;

}

 

function tax_class($vendors_id='1') {

$this->tax_class = constant('MODULE_SHIPPING_TABLE_TAX_CLASS_' . $vendors_id);

return $this->tax_class;

}

 

function enabled($vendors_id='1') {

$this->enabled = false;

$status = @constant('MODULE_SHIPPING_TABLE_STATUS_' . $vendors_id);

if (isset ($status) && $status != '') {

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

}

return $this->enabled;

}

 

function zones($vendors_id='1') {

if ( ($this->enabled == true) && ((int)constant('MODULE_SHIPPING_TABLE_ZONE_' . $vendors_id) > 0) ) {

$check_flag = false;

$check_query = tep_db_query("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . (int)constant('MODULE_SHIPPING_TABLE_ZONE_' . $vendors_id) . "' 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

}//while

 

if ($check_flag == false) {

$this->enabled = false;

}//if

}//if

return $this->enabled;

}//function

---------------------------------------------------------------------------------------

 

 

Now we need to modify that code to suit your module. There are six constants in the above

code that need to be changed. They are similar to the constants that we commented

out in the previous section. Using the commented-out code, make changes to the above

constants to make them match the ones that we removed. Don't delete the underscore at the

end of the new constants; we need that.

 

Next, look at the rest of the constants listed near the ones that you commented out. You

can ignore any of the constants that contain the string _TEXT_; those will not change. If

there are more that are similar to the ones you have commented out, you'll need to make

changes to those as well. For example (from a different module of course), you might have

a module that requires a username and password to access a remote server:

 

---------------------------------------------------------------------------------------

$this->access_username = MODULE_SHIPPING_BAX_USERNAME; //Set in admin

$this->access_password = MODULE_SHIPPING_BAX_PASSWORD; //Set in admin

---------------------------------------------------------------------------------------

 

 

First, comment those lines out. Next, copy the following code for each of the constants

that you have found:

 

---------------------------------------------------------------------------------------

function foo($vendors_id='1') {

$this->foo = constant('CONSTANT_' . $vendors_id);

return $this->foo;

}

---------------------------------------------------------------------------------------

 

 

For each of the new methods that you have copied in, replace ' foo' with the

variable from the line that you commented out. In the above examples, this will be

'access_username' and 'access_password'. Next, replace the 'CONSTANT' with the constant

from the code that you commented out. Leave the single quotes and the underscore at the

end alone. Our two example lines above would then become:

 

---------------------------------------------------------------------------------------

function access_username($vendors_id='1') {

$this->access_username = constant('MODULE_SHIPPING_BAX_USERNAME_' . $vendors_id);

return $this->access_username;

}

 

function access_password($vendors_id='1') {

$this->access_password = constant('MODULE_SHIPPING_BAX_PASSWORD_' . $vendors_id);

return $this->access_password;

}

---------------------------------------------------------------------------------------

 

 

Now find this code again:

 

---------------------------------------------------------------------------------------

// class methods

function quote($method = '') {

---------------------------------------------------------------------------------------

 

 

and change the second line to this:

 

---------------------------------------------------------------------------------------

function quote($method = '', $module = '', $vendors_id = '1') {

---------------------------------------------------------------------------------------

 

 

Now look for code similar to this:

 

---------------------------------------------------------------------------------------

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

'module' => MODULE_SHIPPING_TABLE_TEXT_TITLE,

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

'title' => MODULE_SHIPPING_TABLE_TEXT_WAY,

'cost' => $shipping + MODULE_SHIPPING_TABLE_HANDLING)));

---------------------------------------------------------------------------------------

 

 

and change the constant in the last line to a variable, like this:

 

---------------------------------------------------------------------------------------

'cost' => $shipping + $handling)));

---------------------------------------------------------------------------------------

 

 

Now insert the following code just above the block of lines that we modified in the

previous step:

 

---------------------------------------------------------------------------------------

$vendors_data_query = tep_db_query("select handling_charge,

handling_per_box,

vendor_country

from " . TABLE_VENDORS . "

where vendors_id = '" . (int)$vendors_id . "'"

);

$vendors_data = tep_db_fetch_array($vendors_data_query);

$country_name = tep_get_countries($vendors_data['vendor_country'], true);

 

$handling_charge = $vendors_data['handling_charge'];

$handling_per_box = $vendors_data['handling_per_box'];

if ($handling_charge > $handling_per_box*$shipping_num_boxes) {

$handling = $handling_charge;

} else {

$handling = $handling_per_box*$shipping_num_boxes;

}

---------------------------------------------------------------------------------------

 

 

Now things get interesting. The changes in this section vary widely between modules, so I

can only give you general instructions. You need to make changes to all of the constants

in the quote method, which is all of the code between these lines (where the row of dots

is):

 

---------------------------------------------------------------------------------------

// class methods

function quote($method = '', $module = '', $vendors_id = '1') {

 

...............

 

return $this->quotes;

}

---------------------------------------------------------------------------------------

 

 

Basically, you need to change all of the non-text constants in this method. This applies

to any constant that does not contain the string _TEXT_ (those get left the same.) For

example, again from the Table module:

 

---------------------------------------------------------------------------------------

if (MODULE_SHIPPING_TABLE_MODE == 'price') {

---------------------------------------------------------------------------------------

 

 

gets changed to:

 

---------------------------------------------------------------------------------------

if (constant('MODULE_SHIPPING_TABLE_MODE_' . $vendors_id) == 'price') {

---------------------------------------------------------------------------------------

 

 

Of course your module will have constants with the _TABLE_ string replaced with some

other string. You need to keep the constant the same, just make the modifications to it

that I've made above, i.e. add "constant(" to the front, add the underscore to the end, and

add " . $vendors_id)" after. So go find all of your constants and change them.

 

Now look for code similar to this:

 

---------------------------------------------------------------------------------------

function check() {

if (!isset($this->_check)) {

$check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_TABLE_STATUS'");

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

}

return $this->_check;

}

---------------------------------------------------------------------------------------

 

 

First, change the first line to this:

 

---------------------------------------------------------------------------------------

function check($vendors_id='1') {

---------------------------------------------------------------------------------------

 

 

Next, you need to change the query in the third line to this:

 

---------------------------------------------------------------------------------------

$check_query = tep_db_query("select configuration_value from " . TABLE_VENDOR_CONFIGURATION . " where vendors_id = '". $vendors_id ."' and configuration_key = 'MODULE_SHIPPING_TABLE_STATUS_" . $vendors_id . "'");

---------------------------------------------------------------------------------------

 

 

You'll need to change the constant in the above line to match the one in your module.

Now look for code similar to this:

 

---------------------------------------------------------------------------------------

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 Table Method', 'MODULE_SHIPPING_TABLE_STATUS', 'True', 'Do you want to offer table rate shipping?', '6', '0', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())");

---------------------------------------------------------------------------------------

 

 

First, change the first line to this:

 

---------------------------------------------------------------------------------------

function install($vendors_id='1') {

---------------------------------------------------------------------------------------

 

 

Next, you need to make changes to every line in this method. I'll walk you through one

as an example. First, change the constant TABLE_CONFIGURATION to TABLE_VENDOR_CONFIGURATION.

Second, find the end of the column list. In the example line above, it looks like this:

 

---------------------------------------------------------------------------------------

set_function, date_added)

---------------------------------------------------------------------------------------

 

 

Now add ", vendors_id" just before the right parenthesis. The example string then looks

like this:

 

---------------------------------------------------------------------------------------

set_function, date_added, vendors_id)

---------------------------------------------------------------------------------------

 

 

Next, find the constant. In our example, this is:

 

---------------------------------------------------------------------------------------

'MODULE_SHIPPING_TABLE_STATUS'

---------------------------------------------------------------------------------------

 

 

and change the constant to look like this:

 

---------------------------------------------------------------------------------------

'MODULE_SHIPPING_TABLE_STATUS_" . $vendors_id . "'

---------------------------------------------------------------------------------------

 

 

Of course your constants will be different.

 

Now look for the end of the string, which should look something like this:

 

---------------------------------------------------------------------------------------

, ', now())");

---------------------------------------------------------------------------------------

 

 

and add the vendors id just after the now(), like this:

 

---------------------------------------------------------------------------------------

, ', now(), '" . $vendors_id . "')");

---------------------------------------------------------------------------------------

 

 

Now do this to all of the query lines in this method.

 

Next, find this code:

 

---------------------------------------------------------------------------------------

function remove() {

tep_db_query("delete from " . TABLE_VENDOR_CONFIGURATION . " where vendors_id = '" . $vendors_id . "' and configuration_key in ('" . implode("', '", $this->keys($vendors_id)) . "')");

}

---------------------------------------------------------------------------------------

 

 

and replace it with this:

 

---------------------------------------------------------------------------------------

function remove($vendors_id) {

tep_db_query("delete from " . TABLE_VENDOR_CONFIGURATION . " where vendors_id = '". $vendors_id ."' and configuration_key in ('" . implode("', '", $this->keys($vendors_id)) . "')");

}

---------------------------------------------------------------------------------------

 

 

Finally (yes, we're almost done), find code similar to this:

 

---------------------------------------------------------------------------------------

function keys() {

return array('MODULE_SHIPPING_TABLE_STATUS', 'MODULE_SHIPPING_TABLE_COST', 'MODULE_SHIPPING_TABLE_MODE', 'MODULE_SHIPPING_TABLE_HANDLING', 'MODULE_SHIPPING_TABLE_TAX_CLASS', 'MODULE_SHIPPING_TABLE_ZONE', 'MODULE_SHIPPING_TABLE_SORT_ORDER');

}

---------------------------------------------------------------------------------------

 

 

First, replace the first line with this:

 

---------------------------------------------------------------------------------------

function keys($vendors_id) {

---------------------------------------------------------------------------------------

 

 

Next, you need to modify each one of the constants in the list by adding an underscore to

the end of it, then adding " . $vendors_id" (withougt the quotes) after it. So the first

constant in the example would be changed from this:

 

---------------------------------------------------------------------------------------

'MODULE_SHIPPING_TABLE_STATUS',

---------------------------------------------------------------------------------------

 

to this:

 

---------------------------------------------------------------------------------------

'MODULE_SHIPPING_TABLE_STATUS_' . $vendors_id,

---------------------------------------------------------------------------------------

 

 

One last caveat: If your module contains code after this point, you may not be done. Look

through that code to see if any constants are used. If they are, and they match any of the

constants that you have modified in the quote method or in the code above that, you will

need to make the same modifications to these constants. My example does not have this

extra code, but if it did, I would need to change this:

 

---------------------------------------------------------------------------------------

MODULE_SHIPPING_TABLE_MODE

---------------------------------------------------------------------------------------

 

 

to this:

 

---------------------------------------------------------------------------------------

constant('MODULE_SHIPPING_TABLE_MODE_' . $vendors_id)

---------------------------------------------------------------------------------------

 

Then you need to get the variable $vendors_id passed to this method. Find the beginning

of the method -- it should look something like this:

 

---------------------------------------------------------------------------------------

function foo() {

---------------------------------------------------------------------------------------

 

 

and change it to this:

 

---------------------------------------------------------------------------------------

function foo($vendors_id) {

---------------------------------------------------------------------------------------

 

 

If it already has a variable like this:

 

---------------------------------------------------------------------------------------

function foo($method='') {

---------------------------------------------------------------------------------------

 

 

then just add to it like this:

 

---------------------------------------------------------------------------------------

function foo($method='', $vendors_id) {

---------------------------------------------------------------------------------------

 

 

Then you need to get the variable passed to the method every time that it is called. To

do this, search your file for any instances of $this->foo() and change them to

$this->foo($vendors_id). Cases where the method already has one or more variables being

passed will look similar.

 

If your module contains system constants (such as SHIPPING_ORIGIN_COUNTRY or

SHIPPING_ORIGIN_ZIP), you will need to replace those as well. Using an example from another

module:

 

---------------------------------------------------------------------------------------

$country_name = tep_get_countries(SHIPPING_ORIGIN_COUNTRY, true);

---------------------------------------------------------------------------------------

 

You would need to replace this with:

 

---------------------------------------------------------------------------------------

$vendors_data_query = tep_db_query("select vendor_country

from " . TABLE_VENDORS . "

where vendors_id = '" . (int)$vendors_id . "'"

);

$vendors_data = tep_db_fetch_array($vendors_data_query);

$country_name = tep_get_countries($vendors_data['vendor_country'], true);

---------------------------------------------------------------------------------------

 

 

Just find the appropriate column in the Vendors database and use that data to replace the

store's default constant. You can also combine the $vendors_data_query with another query

in the same method (if one exists.) A common combined query might look like this:

 

---------------------------------------------------------------------------------------

$vendors_data_query = tep_db_query("select handling_charge,

handling_per_box,

vendor_country,

vendors_zipcode

from " . TABLE_VENDORS . "

where vendors_id = '" . (int)$vendors_id . "'"

);

---------------------------------------------------------------------------------------

 

 

Now save the file to includes/modules/vendor_shipping/and close it. That's it for the

modifications.

 

 

 

===========

How to Use:

===========

 

Open your Admin panel and install the module just like any other shipping module in this

contribution. Please refer to the contribution readme file for details.

 

 

 

========

Support:

========

 

Please post any questions on the Contributions Support Forum. Also, if you have any

suggestions or requests for improvements to this Contribution, please post them to the

Forum. I can't modify every module out there for you, but I'll do whatever I can to help.

 

 

 

========

Credits:

========

 

I would like to thank Craig for doing all of the research and design for this contribution,

and all of the developers who worked so hard to give us osCommerce. And, of course, many

thanks go to everyone on the Forum who gave suggestions, help, and free beta testing for

this Contribution.

 

Regards

Jim Keebaugh

Link to comment
Share on other sites

  • 6 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...