Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

MVS and table rate - count (number if items)


Recommended Posts

Posted (edited)

Hi there.

I have successfully installed MVS v1.1 but I need to add a table rate that uses 'count' number of items instead of weight or price.

 

Can any one help??

 

I have found a contribution that caters for this but I dont know how to merge the two together because I dont know a lot of php.

 

Any help would be gratefully appreciated.

 

Thanks :)

Edited by sdavies77
Posted

Why not use the Per Item module? Do you not have an even scale (ie give discounts on high-quantity orders?)

 

What contribution are you looking at for the shipping? Normally you should have no problem using shipping modules with MVS. Most shipping modules don't require changes to code that would affect the MVS. You can usually just drop them in the modules directory.

Contributions

 

Discount Coupon Codes

Donations

Posted

The shipping table I need is 1-4 items ?18.95, 4-8 items ?29.95, more than 8 items ?40. So the per item wouldnt work.

 

The shipping contribution that I mentioned is: http://www.oscommerce.com/community/contri...ons,1718/page,9

 

What I need to be able to do when I manage each Vendors shipping module is add the 'count' function to the table rate.

 

Any ideas?

 

Thanks

Posted

That contribution was fairly old. I added the function to the existing (current) table module. Try this one:

 

<?php
/*
 $Id: table.php,v 1.27 2003/02/05 22:41:52 hpdl Exp $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

 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);

  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;
	}
  }
}

// class methods
function quote($method = '') {
  global $order, $cart, $shipping_weight, $shipping_num_boxes;

  if (MODULE_SHIPPING_TABLE_MODE == 'price') {
	$order_total = $cart->show_total();
  } else if (MODULE_SHIPPING_TABLE_MODE == 'count') {
	$order_total = $cart->count_contents();
  } else {
	$order_total = $shipping_weight;
  }

  $table_cost = split("[:,]" , MODULE_SHIPPING_TABLE_COST);
  $size = sizeof($table_cost);
  for ($i=0, $n=$size; $i<$n; $i+=2) {
	if ($order_total <= $table_cost[$i]) {
	  $shipping = $table_cost[$i+1];
	  break;
	}
  }

  if (MODULE_SHIPPING_TABLE_MODE == 'weight') {
	$shipping = $shipping * $shipping_num_boxes;
  }

  $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)));

  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_TABLE_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 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())");
  tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Shipping Table', 'MODULE_SHIPPING_TABLE_COST', '25:8.50,50:5.50,10000:0.00', 'The shipping cost is based on the total cost or weight of items. Example: 25:8.50,50:5.50,etc.. Up to 25 charge 8.50, from there to 50 charge 5.50, etc', '6', '0', now())");
  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 ('Table Method', 'MODULE_SHIPPING_TABLE_MODE', 'weight', 'The shipping cost is based on the order total or the total weight of the items ordered.', '6', '0', 'tep_cfg_select_option(array(\'weight\', \'price\', \'count\'), ', now())");
  tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Handling Fee', 'MODULE_SHIPPING_TABLE_HANDLING', '0', 'Handling fee for 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_TABLE_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_TABLE_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_TABLE_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_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');
}
 }
?>

 

I tested it and it seems to work fine for me. Let me know if you have any problems. Otherwise, I can just go ahead and add this new file to the contribution.

Contributions

 

Discount Coupon Codes

Donations

Posted (edited)

Thanks for that but im not sure that it's the right file (catalog/includes/modules/shipping/table.php).

 

Im using Multi Vendor Shipping v1.1 so I need each vendor to be able to add a 'count' onto the table rate. I think I need to amend: catalog/includes/modules/vendors_shipping/table.php - dont I?

 

<?php

/*

$Id: table.php,v 1.27 2003/02/05 22:41:52 hpdl Exp $

Modified for MVS V1.0 2006/03/25 JCK/CWG

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright © 2006 osCommerce

 

Released under the GNU General Public License

*/

 

class table {

var $code, $title, $description, $icon, $enabled, $vendors_id, $sort_order; //multi vendor

 

// class constructor

function table() {

global $order, $vendors_id;

 

//MVS

// $this->vendors_id = ($products['vendors_id'] <= 0) ? 1 : $products['vendors_id'];

$this->code = 'table';

$this->title = MODULE_SHIPPING_TABLE_TEXT_TITLE;

$this->description = MODULE_SHIPPING_TABLE_TEXT_DESCRIPTION;

$this->icon = '';

$this->delivery_country_id = $order->delivery['country']['id'];

$this->delivery_zone_id = $order->delivery['zone_id'];

}

 

//MVS start

function sort_order($vendors_id='1') {

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

if (isset ($sort_order)) { $this->sort_order = $sort_order;

} else {

$this->sort_order = '-';

}

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);

}

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 = '" . $this->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'] == $this->delivery_zone_id) {

$check_flag = true;

break;

}

}

 

if ($check_flag == false) {

$this->enabled = false;

}//if

}//if

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 = '" . $this->delivery_zone_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'] == $this->delivery_zone_id) {

$check_flag = true;

break;

} //if

}//while

 

if ($check_flag == false) {

$this->enabled = false;

}//if

}//if

return $this->enabled;

}//function

//MVS End

 

//Get a quote

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

global $HTTP_POST_VARS, $shipping_weight, $order, $cart, $shipping_num_boxes;

 

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

$order_total = $shipping_cost;

} else {

$order_total = $shipping_weight;

}

 

$table_cost = split("[:,]" , @constant('MODULE_SHIPPING_TABLE_COST_' . $vendors_id));

$size = sizeof($table_cost);

for ($i=0, $n=$size; $i<$n; $i+=2) {

if ($order_total <= $table_cost[$i]) {

$shipping = $table_cost[$i+1];

break;

}

}

 

if (@constant('MODULE_SHIPPING_TABLE_MODE_' . $vendors_id) == 'weight') {

$shipping = $shipping * $shipping_num_boxes;

}

 

//MVS Start

$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 . "'"

);

$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;

}

//MVS End

 

//MVS - Changed 'cost' => $shipping + $handling

$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 + $handling)));

 

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

if ($this->tax_class($vendors_id) > 0) {

$this->quotes['tax'] = tep_get_tax_rate($this->tax_class($vendors_id), $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($vendors_id='1') {

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

//multi vendor add "vendors_id = '". $vendors_id ."' and"

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

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

}

return $this->_check;

} /////VID

 

function install($vendors_id) {

//multi vendor add 'vendors_id' to field names and '" . $vendors_id . "', to values

// $vendors_id = $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 ('Enable Table Method', 'MODULE_SHIPPING_TABLE_STATUS_" . $vendors_id . "', 'True', 'Do you want to offer 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, date_added, vendors_id) values ('Shipping Table', 'MODULE_SHIPPING_TABLE_COST_" . $vendors_id . "', '25:8.50,50:5.50,10000:0.00', 'The shipping cost is based on the total cost or weight of items. Example: 25:8.50,50:5.50,etc.. Up to 25 charge 8.50, from there to 50 charge 5.50, etc', '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, set_function, date_added, vendors_id) values ('Table Method', 'MODULE_SHIPPING_TABLE_MODE_" . $vendors_id . "', 'weight', 'The shipping cost is based on the order total or the total weight of the items ordered.', '6', '0', 'tep_cfg_select_option(array(\'weight\', \'price\'), ', 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 ('Handling Fee', 'MODULE_SHIPPING_TABLE_HANDLING_" . $vendors_id . "', '0', 'Handling fee for this shipping method.', '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, use_function, set_function, date_added, vendors_id) values ('Tax Class', 'MODULE_SHIPPING_TABLE_TAX_CLASS_" . $vendors_id . "', '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, use_function, set_function, date_added, vendors_id) values ('Shipping Zone', 'MODULE_SHIPPING_TABLE_ZONE_" . $vendors_id . "', '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(), '" . $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_TABLE_SORT_ORDER_" . $vendors_id . "', '0', 'Sort order of display.', '6', '0', now(), '" . $vendors_id . "')");

}

 

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) {

return array('MODULE_SHIPPING_TABLE_STATUS_' . $vendors_id, 'MODULE_SHIPPING_TABLE_COST_' . $vendors_id, 'MODULE_SHIPPING_TABLE_MODE_' . $vendors_id, 'MODULE_SHIPPING_TABLE_HANDLING_' . $vendors_id, 'MODULE_SHIPPING_TABLE_TAX_CLASS_' . $vendors_id, 'MODULE_SHIPPING_TABLE_ZONE_' . $vendors_id, 'MODULE_SHIPPING_TABLE_SORT_ORDER_' . $vendors_id);

}

}

?>

Edited by sdavies77
Posted

Ive just used BBEdit to compare and edit the vendor_shipping.table.php with the contribution and it works fine.

 

Thank you for your help with this.

 

Here's the code for anyone else who needs it...

 

<?php
/*
 $Id: table.php,v 1.27 2003/02/05 22:41:52 hpdl Exp $
 Modified for MVS V1.0 2006/03/25 JCK/CWG
 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2006 osCommerce

 Released under the GNU General Public License
*/

 class table {
var $code, $title, $description, $icon, $enabled, $vendors_id, $sort_order; //multi vendor

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

//MVS
//	  $this->vendors_id = ($products['vendors_id'] <= 0) ? 1 : $products['vendors_id'];
  $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->delivery_country_id = $order->delivery['country']['id'];
  $this->delivery_zone_id = $order->delivery['zone_id'];
}

//MVS start
  function sort_order($vendors_id='1') {
 $sort_order = @constant ('MODULE_SHIPPING_TABLE_SORT_ORDER_' . $vendors_id);
 if (isset ($sort_order)) {		$this->sort_order = $sort_order;
 } else {
   $this->sort_order = '-';
 }
 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);
  }
  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 = '" . $this->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'] == $this->delivery_zone_id) {
		$check_flag = true;
		break;
		}
	}

	if ($check_flag == false) {
	  $this->enabled = false;
	}//if
  }//if
  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 = '" . $this->delivery_zone_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'] == $this->delivery_zone_id) {
		$check_flag = true;
		break;
	  } //if
	}//while

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

//Get a quote
function quote($method = '', $module = '', $vendors_id = '1') {
  global $HTTP_POST_VARS, $shipping_weight, $order, $cart, $shipping_num_boxes;

  if (@constant('MODULE_SHIPPING_TABLE_MODE_' . $vendors_id) == 'price') {
	$order_total = $shipping_cost;
  } else if (@constant('MODULE_SHIPPING_TABLE_MODE_' . $vendors_id) == 'count') {
	$cart->count_contents();
	$order_total = $cart->count_contents();
  } else { 
   $order_total = $shipping_weight;
  }

  $table_cost = split("[:,]" , @constant('MODULE_SHIPPING_TABLE_COST_' . $vendors_id));
  $size = sizeof($table_cost);
  for ($i=0, $n=$size; $i<$n; $i+=2) {
	if ($order_total <= $table_cost[$i]) {
	if ('MODULE_SHIPPING_TABLE_MODE_' . $vendors_id == 'price') {
			$shipping = $table_cost[$i+1];
			  break;
		  } else if ('MODULE_SHIPPING_TABLE_MODE_' . $vendors_id == 'count') {
			$shipping = $table_cost[$i+1] * $order_total;
			  break;
		  } else {
			$shipping = $table_cost[$i+1];
			  break;
		  }	
	}
  }

  if (@constant('MODULE_SHIPPING_TABLE_MODE_' . $vendors_id) == 'weight') {
	$shipping = $shipping * $shipping_num_boxes;
  }

//MVS Start
  $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 . "'"
									);
  $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;
  }
//MVS End

//MVS - Changed 'cost' => $shipping + $handling
  $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 + $handling)));

  //	$this->tax_class = constant(MODULE_SHIPPING_TABLE_TAX_CLASS_ . $vendors_id);
  if ($this->tax_class($vendors_id) > 0) {
	   $this->quotes['tax'] = tep_get_tax_rate($this->tax_class($vendors_id), $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($vendors_id='1') {
  if (!isset($this->_check)) {
  //multi vendor add  "vendors_id = '". $vendors_id ."' and"
	$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 . "'");
	$this->_check = tep_db_num_rows($check_query);
  }
  return $this->_check;
}						 /////VID

function install($vendors_id) {
//multi vendor add 'vendors_id' to field names and '" . $vendors_id . "', to values
  // $vendors_id = $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 ('Enable Table Method', 'MODULE_SHIPPING_TABLE_STATUS_" . $vendors_id . "', 'True', 'Do you want to offer 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, date_added, vendors_id) values ('Shipping Table', 'MODULE_SHIPPING_TABLE_COST_" . $vendors_id . "', '25:8.50,50:5.50,10000:0.00', 'The shipping cost is based on the total weight, cost or number of items. Example: 25:8.50,50:5.50,etc.. Up to 25 charge 8.50, from there to 50 charge 5.50, etc', '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, set_function, date_added, vendors_id) values ('Table Method', 'MODULE_SHIPPING_TABLE_MODE_" . $vendors_id . "', 'weight', 'The shipping cost is based on the total weight, or the order total, or the number of items ordered.', '6', '0', 'tep_cfg_select_option(array(\'weight\', \'price\', \'count\'), ', 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 ('Handling Fee', 'MODULE_SHIPPING_TABLE_HANDLING_" . $vendors_id . "', '0', 'Handling fee for this shipping method.', '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, use_function, set_function, date_added, vendors_id) values ('Tax Class', 'MODULE_SHIPPING_TABLE_TAX_CLASS_" . $vendors_id . "', '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, use_function, set_function, date_added, vendors_id) values ('Shipping Zone', 'MODULE_SHIPPING_TABLE_ZONE_" . $vendors_id . "', '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(), '" . $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_TABLE_SORT_ORDER_" . $vendors_id . "', '0', 'Sort order of display.', '6', '0', now(), '" . $vendors_id . "')");
}

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) {
  return array('MODULE_SHIPPING_TABLE_STATUS_' . $vendors_id, 'MODULE_SHIPPING_TABLE_COST_' . $vendors_id, 'MODULE_SHIPPING_TABLE_MODE_' . $vendors_id, 'MODULE_SHIPPING_TABLE_HANDLING_' . $vendors_id, 'MODULE_SHIPPING_TABLE_TAX_CLASS_' . $vendors_id, 'MODULE_SHIPPING_TABLE_ZONE_' . $vendors_id, 'MODULE_SHIPPING_TABLE_SORT_ORDER_' . $vendors_id);
}
 }
?>

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

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