Jump to content
blucollarguy

Multi_Vendor_Shipping new thread

Recommended Posts

another issue i have come across.

 

in the admin interface, under "Vendors Orders List", there is a column labelled "Email Sent?" and underneath, it shows "no" however, i do have automaticly send emails to vendors, which is not working. if i click "no" where shown above, i get the following error:

lines 244 thru 246 are as follows:

 

	  <?php } else { ?>
  <tr><?php echo tep_draw_form('mail', FILENAME_VENDORS_EMAIL_SEND,' . '&vID=' . $vendors_id . '&oID=' . $oID . '&vOS=' . $vOS); ?>
		<td><table border="0" width="100%" cellpadding="0" cellspacing="2">

 

any ideas?

ok, i completely missed the part where you have to activate the emails. i did that, and i get emails sent to 4 of the 5 vendors i have setup. the only one i do NOT get an email sent to is my vendor name, which replaced the 'default' vendor.

 

upon confirmation, the emails are sent. however, i still cannot manually send emails via admin panel. i still get the above error.

 

that, and i still cannot get USPS to show up. i went thru the module modification instructions, and ended up loading the backup file to the server, so i'm back to square one on that issue.

 

also, in the emails that are sent, it is VERY messy. i don't know if it's due to settings in my Outlook, or if there are changes that need made to the file that determine how the email looks. there is a lot of info that should be separated to different lines, but it runs together a lot, and is very difficult to read.

 

other than those few issues, everything else seems to be working great!

Edited by trustco

Share this post


Link to post
Share on other sites
It should, with one caveat: Since that contribution installs another shipping module, that module will have to be modified to work with MVS. There are modification instructions in the MVS distribution.

 

Regards

Jim

 

Thank you for your reply. I'm going to give it a go on my testing server now... If anyone has already modified the IPS module to work with MVS please do let me know...

 

Sam

Share this post


Link to post
Share on other sites
...I now see the entire list of shipping options but with Warnings messages.

 

At the very top of the list I receive;

 

Warning: constant(): Couldn't find constant MODULE_SHIPPING_CANADAPOST_ZONE_1 in /includes/modules/vendors_shipping/canadapost.php on line 85

 

The other warnings are listed next to each shipping option twice but goes away when I click on the install button to the right;

 

Warning: constant(): Couldn't find constant MODULE_SHIPPING_FEDEX1_SORT_ORDER_1 in /includes/modules/vendors_shipping/fedex1.php on line 120

 

Again, I have compared line 85 in the canadapost.php to the fedex1.php and again, do not see anything out of place.

 

Should I maybe post the canadapost.php file I put together using the instructions in module.txt in case someone following this thread is able to see an error?

 

I did get myself a book on PHP but it really isn't helping.

 

Andrew

These have been posted, but with this thread as big as it is, here it is again, add this: @ , before the word "constant" in each module. Like this:

 

from the "fedex1.php" file in catalog/includes/modules/vendors_shipping, abouit line 120(yours may be different)

	 $sort_order = constant ('MODULE_SHIPPING_FEDEX1_SORT_ORDER_' . $vendors_id);

should be changed to this:

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

 

This simply suppresses warnings that php wants to send out from the server on it's own. The messages will go away.

 

ok, i completely missed the part where you have to activate the emails. i did that, and i get emails sent to 4 of the 5 vendors i have setup. the only one i do NOT get an email sent to is my vendor name, which replaced the 'default' vendor.

 

upon confirmation, the emails are sent. however, i still cannot manually send emails via admin panel. i still get the above error.

 

that, and i still cannot get USPS to show up. i went thru the module modification instructions, and ended up loading the backup file to the server, so i'm back to square one on that issue.

 

also, in the emails that are sent, it is VERY messy. i don't know if it's due to settings in my Outlook, or if there are changes that need made to the file that determine how the email looks. there is a lot of info that should be separated to different lines, but it runs together a lot, and is very difficult to read.

 

other than those few issues, everything else seems to be working great!

 

First, USPS is an issue, some have been able to use it without any problems, but some(me for instance) haven't been able to get a quote without errors. I am working on that from scratch(sort of).

 

The email errors are a bit wierd. My guess on the look of them(being "messy") is that you don't have "HTML Email" installed on osC. It isn't in a stock store, and thinking of it right now, I don't think I added any notes or info on installing it in order to use the automatic email functions. My bad, another fix for the next version. The error message your getting doesn't make sense to me. I don't see anything wrong with the code there and I am using that same file on all my test AND production servers. Try uploading it again, perhaps you had some data corruption that added the dreaded UNSEEN lines or something.

 

Your 5th Vendor that is not getting the emails must be an addressing issue or something of that nature if the others seem to work otherwise.

 

Hope this helps, Craig :)

 

Sorry, I have been very busy and couldn't get back to you guys sooner.


Happy Coding!

Craig Garrison Sr

Anything worth having, is worth working for.

Multi Vendor Shipping V1.1 Demo Catalog

3 Vendors, each category, "buy" a product from each category to see how MVS works during checkout.

Multi Vendor Shipping V1.1 Demo Admin

login: webmaster@blucollarsales.com

pass: mvs_demo

MVS Thread:

Multi-Vendor Shipping

My contribs:

Download Multi Vendor Shipping V1.1

Vendor Email

Vendor Info in easypopulate

EZ Price Updater

And more to come!

Share this post


Link to post
Share on other sites

Well, I was almost ready to go live, when I found that I needed to add the "Add Weight To Products Attributes" contribution for some of my products. I followed all the instructions, as well as the changes from this Post 401. All seemed to be going well, but now I am getting this error on the checkout_shipping page:

 

Warning: Invalid argument supplied for foreach() in /xxx/catalog/includes/modules/vendor_shipping.php on line 97

 

This appears where the product description normally appears.

 

Here is my code around line 97:

 

 

<?php
  $products_ids = $vendor_data['products_id'];
  foreach ($products_ids as $product_id) {
	$products_query = tep_db_query("select products_name 
										  from " . TABLE_PRODUCTS_DESCRIPTION . " 
										  where products_id = '" . (int)$product_id . "' 
											and language_id = '" . (int)$languages_id . "'"
								  );
	$products = tep_db_fetch_array($products_query);
?>

 

I didn't change anything in this area. ARRRRGGHHH! What did I do!!! I thought I was almost done :wacko: but as with any great thing worth the attempt, there must be a pain equal to the gain (I hope to be looking forward to GREAT gains :D if all the programming is any indicator)!

 

Any help would be most graciously appreciated as to where to start looking.

 

John

Share this post


Link to post
Share on other sites

That is very odd. That error message normally occurs when the foreach() is trying to index on something that's not an array. I've done that often enough to know. But the value for $vendor_data['products_id'] comes (ultimately) from line 320 of includes/classes/shopping_cart.php, and that pretty much has to create an array, even if it contains only one element. Anything major enough to mess that line up should have caused errors long before this. If the shopping cart is empty, the method returns 0; if there are products, the array should be populated. As I said, very odd.

 

Try adding this in just above line 97 of includes/modules/vendor_shipping.php:

  print '<pre>';
 print_r ($products_ids);
 print '<pre>';

and see what you get. If it's not an array, at least we know where to start looking. If it is, I want to know what's causing that error message.

 

Regards

Jim'


See my profile for a list of my addons and ways to get support.

Share this post


Link to post
Share on other sites
These have been posted, but with this thread as big as it is, here it is again, add this: @ , before the word "constant" in each module. Like this:

 

from the "fedex1.php" file in catalog/includes/modules/vendors_shipping, abouit line 120(yours may be different)

	 $sort_order = constant ('MODULE_SHIPPING_FEDEX1_SORT_ORDER_' . $vendors_id);

should be changed to this:

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

 

This simply suppresses warnings that php wants to send out from the server on it's own. The messages will go away.

First, USPS is an issue, some have been able to use it without any problems, but some(me for instance) haven't been able to get a quote without errors. I am working on that from scratch(sort of).

 

The email errors are a bit wierd. My guess on the look of them(being "messy") is that you don't have "HTML Email" installed on osC. It isn't in a stock store, and thinking of it right now, I don't think I added any notes or info on installing it in order to use the automatic email functions. My bad, another fix for the next version. The error message your getting doesn't make sense to me. I don't see anything wrong with the code there and I am using that same file on all my test AND production servers. Try uploading it again, perhaps you had some data corruption that added the dreaded UNSEEN lines or something.

 

Your 5th Vendor that is not getting the emails must be an addressing issue or something of that nature if the others seem to work otherwise.

 

Hope this helps, Craig :)

 

Sorry, I have been very busy and couldn't get back to you guys sooner.

craig,

 

your response is appreciated. i thought the issue with the @constant was addressed, but i looked around but didn't see it. it is good now.

 

back to the emails. i have all 5 vendors set to their correct information, however each vendor has MY email addy, all 5 have the same addy, but i only get 4 of the 5 emails. very strange...

 

about USPS...

 

can someone who has this working, post up their code?

 

and how do i set email to html?

 

 

thanks again for the help...i'm taking baby steps towards a functioning store...

Share this post


Link to post
Share on other sites

Hello,

 

I have MVS working on my test site and all seems to be going well. The only problem is customising the INDV SHIP module to work with MVS. I've managed to customise the indvshp.php file as per the "modules" instructions with the package but I get an "undefined function" error message when I try to go through the checkout.

 

I believe this message is because the function it refers to get_shiptotal() has to be added to the classes/shipping.php manually as part of the integration for the INDVSHP contribution. As MVS doesn't load this shipping.php file and uses its own, I presume the vendor_shipping.php file will need to be customised to include this function.

 

I've been trying this customisation for the last few hours but I don't think I know enough about php to pull it off. Can anyone help me out?

 

The code in vendor_shipping.php is:

 

<?php
/*
 $Id: vendor_shipping.php,v 1.4 2005/04/20 jck Exp $
 $Modified_from: shipping.php,v 1.23 2003/06/29 11:22:05 hpdl Exp $

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

 Copyright (c) 2005 osCommerce

 Released under the GNU General Public License
*/

 class shipping {
var $modules;

////
// Find all of the modules and instantiate the module classes
function shipping($module = '') {
  global $language, $PHP_SELF;

  $installed_modules_array = array();
		//Get the vendors_id for each vendor in the database
  $vendors_data_query = tep_db_query("select vendors_id from " . TABLE_VENDORS);
  while ($vendors_data = tep_db_fetch_array($vendors_data_query)) {;
	$vendors_id = $vendors_data['vendors_id'];
	$installed_modules = @constant ('MODULE_VENDOR_SHIPPING_INSTALLED_' . $vendors_id);

	if (isset ($installed_modules) && tep_not_null ($installed_modules)) {
	  $modules_array = explode(';', $installed_modules);
	  $this->modules[$vendors_id] = $modules_array;

	  foreach ($modules_array as $module_name) {
		//if the module is not already in the array, add it in
		if (!in_array ($module_name, $installed_modules_array)) {  
		  $installed_modules_array[] = $module_name;
		}//if !in_array
	  }//foreach
	}//if isset
  }//while


  $include_modules = array();
  if ( (tep_not_null($module)) && (in_array(substr($module['id'], 0, strpos($module['id'], '_')) . '.' . substr($PHP_SELF, (strrpos($PHP_SELF, '.')+1)), $modules_array)) ) {
	$include_modules[] = array('class' => substr($module['id'], 0, strpos($module['id'], '_')), 
							   'file' => substr($module['id'], 0, strpos($module['id'], '_')) . '.' . substr($PHP_SELF, (strrpos($PHP_SELF, '.')+1)));
  } else {
	reset($modules_array);
	foreach ($installed_modules_array as $value) {
	  $class = substr($value, 0, strrpos($value, '.'));
	  $include_modules[] = array('class' => $class, 
								 'file' => $value);
	}//foreach
  }//if tep_not_null

  for ($i=0, $n=sizeof($include_modules); $i<$n; $i++) {
	include(DIR_WS_LANGUAGES . $language . '/modules/vendors_shipping/' . $include_modules[$i]['file']);
	include(DIR_WS_MODULES . 'vendors_shipping/' . $include_modules[$i]['file']);

	$GLOBALS[$include_modules[$i]['class']] = new $include_modules[$i]['class'];
  }//for
}//function

////
// Get a quote for one or many shipping methods, for a specific vendor
function quote($method = '', $module = '', $vendors_id='1') {
  global $shipping_quoted, $order, $cart, $shipping_num_boxes, $shipping_weight;

  $quotes_array = array();
  if (is_array($this->modules[$vendors_id])) {
	$shipping_quoted = '';
	$shipping_num_boxes = 1;

	$shipping_weight = $cart->vendor_shipping[$vendors_id]['weight'];
	$shipping_cost = $cart->vendor_shipping[$vendors_id]['cost'];
	$total_count = $cart->vendor_shipping[$vendors_id]['qty'];

	$vendors_data_query = tep_db_query("select percent_tare_weight, 
											   tare_weight, 
											   max_box_weight 
										from " . TABLE_VENDORS . " 
										where vendors_id = '" . (int)$vendors_id . "'"
									  );
	$vendors_data = tep_db_fetch_array($vendors_data_query);  //Only the row of the table that is for this vendor
	if ($vendors_data['max_box_weight'] == 0) $vendors_data['max_box_weight'] = 1000000;

	if ($vendor['tare_weight'] >= $shipping_weight*$vendors_data['percent_tare_weight']/100) {
	  $shipping_weight = $shipping_weight + $vendors_data['tare_weight'];
	} else {
	  $shipping_weight = $shipping_weight + ($shipping_weight*$vendors_data['percent_tare_weight']/100);
	}

	if ($shipping_weight > $vendors_data['max_box_weight']) { // Split into many boxes
	  $shipping_num_boxes = ceil($shipping_weight/$vendors_data['max_box_weight']);
	  $shipping_weight = $shipping_weight/$shipping_num_boxes;
	}

	$include_quotes = array();
	reset($this->modules[$vendors_id]);
	foreach ($this->modules[$vendors_id] as $value) {
	  $class = substr($value, 0, strrpos($value, '.'));  // $class is the filename without the .php
	  if (tep_not_null($module)) {
		if ( ($module == $class) && ($GLOBALS[$class]->enabled($vendors_id)) ) {
		  $include_quotes[] = $class;
		}
	  } elseif ($GLOBALS[$class]->enabled($vendors_id)) {  //Module is enabled for this vendor
		$include_quotes[] = $class;
	  }
	}

	reset($include_quotes);
	$size = sizeof($include_quotes);
	for ($i=0; $i<$size; $i++) {
	  $quotes = $GLOBALS[$include_quotes[$i]]->quote($method, '', $vendors_id);
	  if (is_array($quotes)) $quotes_array[] = $quotes;
	}
  }

  return $quotes_array;
}

////
//Find the cheapest shipping method for a specific vendor
function cheapest($vendors_id='1') {
  if (is_array($this->modules[$vendors_id])) {
	$rates = array();

	reset($this->modules[$vendors_id]);
	foreach ($this->modules[$vendors_id] as $value) {
	  $class = substr($value, 0, strrpos($value, '.'));

	  if ($GLOBALS[$class]->enabled($vendors_id)) {
		$quotes = $GLOBALS[$class]->quote('', '', $vendors_id);

		for ($i=0, $n=sizeof($quotes['methods']); $i<$n; $i++) {
		  if (isset($quotes['methods'][$i]['cost']) && tep_not_null($quotes['methods'][$i]['cost'])) {
			$rates[] = array('id' => $quotes['id'] . '_' . $quotes['methods'][$i]['id'],
							 'title' => $quotes['module'] . ' (' . $quotes['methods'][$i]['title'] . ')',
							 'cost' => $quotes['methods'][$i]['cost']);
		  }
		}
	  }
	}

	$cheapest = false;
	for ($i=0, $n=sizeof($rates); $i<$n; $i++) {
	  if (is_array($cheapest)) {
		if ($rates[$i]['cost'] < $cheapest['cost']) {
		  $cheapest = $rates[$i];
		}
	  } else {
		$cheapest = $rates[$i];
	  }
	}

	return $cheapest;
  }
}
 }
?>

 

and the instructions from the installation file for the INDVSHP contribution are:

 

line 19 change

global $language, $PHP_SELF; (some might have ,cart already)

to

global $language, $PHP_SELF, $cart;

// BOF: Indv Shipping Prices//phpmom.com

$products = $cart->get_products();

 

$shiptotal = $this->get_shiptotal();

$indvcount = $this->get_indvcount();

// EOF: Indv Shipping Prices

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

line 35(change from 4.2)

under reset($this->modules); CHANGE

while (list(, $value) = each($this->modules)) {

$class = substr($value, 0, strrpos($value, '.'));

$include_modules[] = array('class' => $class, 'file' => $value);

}

}

to

// BOF: PhpMom's Indv Shipping Prices

// Show either normal shipping modules or Individual shipping module when Individual Shipping Module is On

// Show Individual Shipping Only

if($indvcount==sizeof($products)){ //hadir

if ((tep_get_configuration_key_value('MODULE_SHIPPING_INDVSHIP_STATUS')) && ((tep_not_null($shiptotal)) || $shiptotal == 0)) {

$include_modules[] = array('class'=> 'indvship', 'file' => 'indvship.php');

}}

//START COMMENT IF YOU DO NOT HAVE FREE SHIPPING MODULE

// BOF: WebMakers.com Added: Downloads Controller - Free Shipping and Payments

// Show either normal shipping modules or free shipping module when Free Shipping Module is On

// Free Shipping Only

elseif ((tep_get_configuration_key_value('MODULE_SHIPPING_FREESHIPPER_STATUS')) && $cart->show_weight()==0 && ($shiptotal == '0' || !$shiptotal)) {

$include_modules[] = array('class'=> 'freeshipper', 'file' => 'freeshipper.php');

 

//END COMMENT IF YOU DO NOT HAVE FREE SHIPPING MODULE

// All Other Shipping Modules

} else { if(sizeof($products)>$indvcount){

while (list(, $value) = each($this->modules)) { //try foreach is faster//hadir

$class = substr($value, 0, strrpos($value, '.'));

// Don't show Free Shipping Module

if (($class !='freeshipper')/* && ($class != 'indvship')*/) {

$include_modules[] = array('class' => $class, 'file' => $value);

}

}

}

}//COMMENT IF YOU DO NOT HAVE FREE SHIPPING MODULE and you commented above

 

// EOF: Free Shipping and Payments// EOF: Indv Shipping Prices

}

 

 

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

line 114 UNDER (change from 4.2)

return $quotes_array;

}

add

//BOF Indv shipping modifications//Hadir@phpmom

function get_shiptotal() {

global $cart, $order;

$this->shiptotal = '';

$products = $cart->get_products();

for ($i=0, $n=sizeof($products); $i<$n; $i++) {

// mod indvship//modified hadir

if (tep_not_null($products[$i]['products_ship_price'])) {

$products_ship_price = $products[$i]['products_ship_price'];

$products_ship_price_two = $products[$i]['products_ship_price_two'];

$products_ship_zip = $products[$i]['products_ship_zip'];

$qty = $products[$i]['quantity'];

if(tep_not_null($products_ship_price) ||tep_not_null($products_ship_price_two)){

$this->shiptotal += ($products_ship_price);

if ($qty > 1) {

if (tep_not_null($products_ship_price_two)) {

$this->shiptotal += ($products_ship_price_two * ($qty-1));

} else {

$this->shiptotal += ($products_ship_price * ($qty-1));

}

}/////////////NOT HERE <<------------

}

}

}// CHECK TO SEE IF SHIPPING TO HOME COUNTRY, IF NOT INCREASE SHIPPING COSTS BY AMOUNT SET IN ADMIN/////////////move back here <<------------

if (($order->delivery['country']['id']) != INDIVIDUAL_SHIP_HOME_COUNTRY) {

if(INDIVIDUAL_SHIP_INCREASE > '0' || $this->shiptotal > '0')

$this->shiptotal *= INDIVIDUAL_SHIP_INCREASE;

else $this->shiptotal += INDIVIDUAL_SHIP_INCREASE * $this->get_indvcount();

}

return $this->shiptotal;

}

 

function get_indvcount() {

global $cart;

$this->indvcount = '';

$products = $cart->get_products();

for ($i=0, $n=sizeof($products); $i<$n; $i++) {

// mod indvship//modified hadir

if (tep_not_null($products[$i]['products_ship_price'])) {

$products_ship_price = $products[$i]['products_ship_price'];//}

$products_ship_price_two = $products[$i]['products_ship_price_two'];

if(is_numeric($products_ship_price)){

$this->indvcount += '1';

}

} } return $this->indvcount;

}

 

//EOF Indv shipping mod//Hadir@phpmom

 

The first and last sections of the instructions are easy enough, it's just the middle section I'm struggling with!

 

Thank you in advance!

 

Sam

Share this post


Link to post
Share on other sites
Hello,

 

I have MVS working on my test site and all seems to be going well. The only problem is customising the INDV SHIP module to work with MVS. I've managed to customise the indvshp.php file as per the "modules" instructions with the package but I get an "undefined function" error message when I try to go through the checkout.

 

I believe this message is because the function it refers to get_shiptotal() has to be added to the classes/shipping.php manually as part of the integration for the INDVSHP contribution. As MVS doesn't load this shipping.php file and uses its own, I presume the vendor_shipping.php file will need to be customised to include this function.

 

I've been trying this customisation for the last few hours but I don't think I know enough about php to pull it off. Can anyone help me out?

 

The code in vendor_shipping.php is:

 

<?php
/*
 $Id: vendor_shipping.php,v 1.4 2005/04/20 jck Exp $
 $Modified_from: shipping.php,v 1.23 2003/06/29 11:22:05 hpdl Exp $

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

 Copyright (c) 2005 osCommerce

 Released under the GNU General Public License
*/

 class shipping {
var $modules;

////
// Find all of the modules and instantiate the module classes
function shipping($module = '') {
  global $language, $PHP_SELF;

  $installed_modules_array = array();
		//Get the vendors_id for each vendor in the database
  $vendors_data_query = tep_db_query("select vendors_id from " . TABLE_VENDORS);
  while ($vendors_data = tep_db_fetch_array($vendors_data_query)) {;
	$vendors_id = $vendors_data['vendors_id'];
	$installed_modules = @constant ('MODULE_VENDOR_SHIPPING_INSTALLED_' . $vendors_id);

	if (isset ($installed_modules) && tep_not_null ($installed_modules)) {
	  $modules_array = explode(';', $installed_modules);
	  $this->modules[$vendors_id] = $modules_array;

	  foreach ($modules_array as $module_name) {
		//if the module is not already in the array, add it in
		if (!in_array ($module_name, $installed_modules_array)) {  
		  $installed_modules_array[] = $module_name;
		}//if !in_array
	  }//foreach
	}//if isset
  }//while


  $include_modules = array();
  if ( (tep_not_null($module)) && (in_array(substr($module['id'], 0, strpos($module['id'], '_')) . '.' . substr($PHP_SELF, (strrpos($PHP_SELF, '.')+1)), $modules_array)) ) {
	$include_modules[] = array('class' => substr($module['id'], 0, strpos($module['id'], '_')), 
							   'file' => substr($module['id'], 0, strpos($module['id'], '_')) . '.' . substr($PHP_SELF, (strrpos($PHP_SELF, '.')+1)));
  } else {
	reset($modules_array);
	foreach ($installed_modules_array as $value) {
	  $class = substr($value, 0, strrpos($value, '.'));
	  $include_modules[] = array('class' => $class, 
								 'file' => $value);
	}//foreach
  }//if tep_not_null

  for ($i=0, $n=sizeof($include_modules); $i<$n; $i++) {
	include(DIR_WS_LANGUAGES . $language . '/modules/vendors_shipping/' . $include_modules[$i]['file']);
	include(DIR_WS_MODULES . 'vendors_shipping/' . $include_modules[$i]['file']);

	$GLOBALS[$include_modules[$i]['class']] = new $include_modules[$i]['class'];
  }//for
}//function

////
// Get a quote for one or many shipping methods, for a specific vendor
function quote($method = '', $module = '', $vendors_id='1') {
  global $shipping_quoted, $order, $cart, $shipping_num_boxes, $shipping_weight;

  $quotes_array = array();
  if (is_array($this->modules[$vendors_id])) {
	$shipping_quoted = '';
	$shipping_num_boxes = 1;

	$shipping_weight = $cart->vendor_shipping[$vendors_id]['weight'];
	$shipping_cost = $cart->vendor_shipping[$vendors_id]['cost'];
	$total_count = $cart->vendor_shipping[$vendors_id]['qty'];

	$vendors_data_query = tep_db_query("select percent_tare_weight, 
											   tare_weight, 
											   max_box_weight 
										from " . TABLE_VENDORS . " 
										where vendors_id = '" . (int)$vendors_id . "'"
									  );
	$vendors_data = tep_db_fetch_array($vendors_data_query);  //Only the row of the table that is for this vendor
	if ($vendors_data['max_box_weight'] == 0) $vendors_data['max_box_weight'] = 1000000;

	if ($vendor['tare_weight'] >= $shipping_weight*$vendors_data['percent_tare_weight']/100) {
	  $shipping_weight = $shipping_weight + $vendors_data['tare_weight'];
	} else {
	  $shipping_weight = $shipping_weight + ($shipping_weight*$vendors_data['percent_tare_weight']/100);
	}

	if ($shipping_weight > $vendors_data['max_box_weight']) { // Split into many boxes
	  $shipping_num_boxes = ceil($shipping_weight/$vendors_data['max_box_weight']);
	  $shipping_weight = $shipping_weight/$shipping_num_boxes;
	}

	$include_quotes = array();
	reset($this->modules[$vendors_id]);
	foreach ($this->modules[$vendors_id] as $value) {
	  $class = substr($value, 0, strrpos($value, '.'));  // $class is the filename without the .php
	  if (tep_not_null($module)) {
		if ( ($module == $class) && ($GLOBALS[$class]->enabled($vendors_id)) ) {
		  $include_quotes[] = $class;
		}
	  } elseif ($GLOBALS[$class]->enabled($vendors_id)) {  //Module is enabled for this vendor
		$include_quotes[] = $class;
	  }
	}

	reset($include_quotes);
	$size = sizeof($include_quotes);
	for ($i=0; $i<$size; $i++) {
	  $quotes = $GLOBALS[$include_quotes[$i]]->quote($method, '', $vendors_id);
	  if (is_array($quotes)) $quotes_array[] = $quotes;
	}
  }

  return $quotes_array;
}

////
//Find the cheapest shipping method for a specific vendor
function cheapest($vendors_id='1') {
  if (is_array($this->modules[$vendors_id])) {
	$rates = array();

	reset($this->modules[$vendors_id]);
	foreach ($this->modules[$vendors_id] as $value) {
	  $class = substr($value, 0, strrpos($value, '.'));

	  if ($GLOBALS[$class]->enabled($vendors_id)) {
		$quotes = $GLOBALS[$class]->quote('', '', $vendors_id);

		for ($i=0, $n=sizeof($quotes['methods']); $i<$n; $i++) {
		  if (isset($quotes['methods'][$i]['cost']) && tep_not_null($quotes['methods'][$i]['cost'])) {
			$rates[] = array('id' => $quotes['id'] . '_' . $quotes['methods'][$i]['id'],
							 'title' => $quotes['module'] . ' (' . $quotes['methods'][$i]['title'] . ')',
							 'cost' => $quotes['methods'][$i]['cost']);
		  }
		}
	  }
	}

	$cheapest = false;
	for ($i=0, $n=sizeof($rates); $i<$n; $i++) {
	  if (is_array($cheapest)) {
		if ($rates[$i]['cost'] < $cheapest['cost']) {
		  $cheapest = $rates[$i];
		}
	  } else {
		$cheapest = $rates[$i];
	  }
	}

	return $cheapest;
  }
}
 }
?>

 

and the instructions from the installation file for the INDVSHP contribution are:

The first and last sections of the instructions are easy enough, it's just the middle section I'm struggling with!

 

Thank you in advance!

 

Sam

This will need to be a bit more in depth than I can get right now, Sam. But you will need to work through the common functioanlity of the code, not the code itself. As you already noted, MVS uses it's shipping functions, so this type of integration is significant. I think it would be a nice addon to MVS, but I don't have the time to get into it just yet, if I get the time I will let you know what I come up with.

 

Good luck, Craig :)


Happy Coding!

Craig Garrison Sr

Anything worth having, is worth working for.

Multi Vendor Shipping V1.1 Demo Catalog

3 Vendors, each category, "buy" a product from each category to see how MVS works during checkout.

Multi Vendor Shipping V1.1 Demo Admin

login: webmaster@blucollarsales.com

pass: mvs_demo

MVS Thread:

Multi-Vendor Shipping

My contribs:

Download Multi Vendor Shipping V1.1

Vendor Email

Vendor Info in easypopulate

EZ Price Updater

And more to come!

Share this post


Link to post
Share on other sites
That is very odd. That error message normally occurs when the foreach() is trying to index on something that's not an array. I've done that often enough to know. But the value for $vendor_data['products_id'] comes (ultimately) from line 320 of includes/classes/shopping_cart.php, and that pretty much has to create an array, even if it contains only one element. Anything major enough to mess that line up should have caused errors long before this. If the shopping cart is empty, the method returns 0; if there are products, the array should be populated. As I said, very odd.

 

Try adding this in just above line 97 of includes/modules/vendor_shipping.php:

  print '<pre>';
 print_r ($products_ids);
 print '<pre>';

and see what you get. If it's not an array, at least we know where to start looking. If it is, I want to know what's causing that error message.

 

Regards

Jim'

 

OK, tried your suggestion and here is what showed up in the box that shows the shipping method:

 

 

Array

(

[0] => 539

)

 

Lighted Collar

 

This is currently the only shipping method available to use on this order.

United Parcel Service (1 x 1lbs)

Next Day Air $18.56

2nd Day Air $10.41

Ground $5.30

 

The 539 is the product ID for the lighted collar, so I assume it is passing that OK. Let me give some more information that may or may not help. As I originally mentioned I was installing the Add weight to attributes functionality. I modified shopping_cart.php per post 401.

 

I tried some tests after making the changes, and everything seemed to work fine. Then as I added weights to my product attributes things seem to have gone south.

 

Now to add more mystery (and maybe this is where the problem lies) I also have Customer Group Discounts installed. If I send a product through on a customer WITHOUT a discount, it works fine - no error. But if I send the same product thru on a customer WITH discount, then I get the error. Coincidence?

 

The funny thing is, is that it DID work with the discount customer before I added weights to the products (at least that is when it seemed to happen).

 

One other thing, when I get the error, it gives me the message that indicates there is more than one product being shipped:

Shipping Method

 

Some products will be shipped from different locations. Please choose a shipping method for each group of products below.

 

 

 

Products

 

Warning: Invalid argument supplied for foreach() in /xxx/catalog/includes/modules/vendor_shipping.php on line 101

 

 

This is currently the only shipping method available to use on this order.

 

Don't know why that would be coming up with only one product in the basket.

 

Also, I replaced the shopping_cart.php file with my backup from before the changes, and I still get the same error. Now I am thinking I need to check some of the other files that were changed for the Add Weight contrib.

 

I'll keep looking, but if you have any more ideas with this new info, I sure would appreciate it.

 

John

Share this post


Link to post
Share on other sites
OK, tried your suggestion and here is what showed up in the box that shows the shipping method:

The 539 is the product ID for the lighted collar, so I assume it is passing that OK. Let me give some more information that may or may not help. As I originally mentioned I was installing the Add weight to attributes functionality. I modified shopping_cart.php per post 401.

 

I tried some tests after making the changes, and everything seemed to work fine. Then as I added weights to my product attributes things seem to have gone south.

 

Now to add more mystery (and maybe this is where the problem lies) I also have Customer Group Discounts installed. If I send a product through on a customer WITHOUT a discount, it works fine - no error. But if I send the same product thru on a customer WITH discount, then I get the error. Coincidence?

 

The funny thing is, is that it DID work with the discount customer before I added weights to the products (at least that is when it seemed to happen).

 

One other thing, when I get the error, it gives me the message that indicates there is more than one product being shipped:

Don't know why that would be coming up with only one product in the basket.

 

Also, I replaced the shopping_cart.php file with my backup from before the changes, and I still get the same error. Now I am thinking I need to check some of the other files that were changed for the Add Weight contrib.

 

I'll keep looking, but if you have any more ideas with this new info, I sure would appreciate it.

 

John

John, I had some of these strange errors while installing this on a customer's store as well, but was able to work through it. You are the one of several others who are asking for this contribution to be added to MVS so I will try very hard to put together some instrucions and code for what I did, I had offered to send this to another poster already and never got to it, so I will try to get it this weekend.

 

Craig :blush:


Happy Coding!

Craig Garrison Sr

Anything worth having, is worth working for.

Multi Vendor Shipping V1.1 Demo Catalog

3 Vendors, each category, "buy" a product from each category to see how MVS works during checkout.

Multi Vendor Shipping V1.1 Demo Admin

login: webmaster@blucollarsales.com

pass: mvs_demo

MVS Thread:

Multi-Vendor Shipping

My contribs:

Download Multi Vendor Shipping V1.1

Vendor Email

Vendor Info in easypopulate

EZ Price Updater

And more to come!

Share this post


Link to post
Share on other sites
John, I had some of these strange errors while installing this on a customer's store as well, but was able to work through it. You are the one of several others who are asking for this contribution to be added to MVS so I will try very hard to put together some instrucions and code for what I did, I had offered to send this to another poster already and never got to it, so I will try to get it this weekend.

 

Craig :blush:

 

Thanks Craig! As always if it weren't for the help of yourself, Jim, and everyone else I don't know where any of us would be (especially those of us just dangerous enough to hack our way through :-" but really aren't "guru's"). I look forward to whatever you can get out, whenever you can get it. I know how busy things get, and beggars can't be choosers!

 

I am going to keep playing with this, I'm sure it has to be in the shopping_cart.php class since that is the only script I touched. But why it worked a couple of times and then quit, I don't know. I may try removing all the product attributes and reverting back to the original scripts to see what happens.

 

Not sure I want to use the attributes anyway, as it doesn't allow me to track products with different models numbers for the different attributes (i.e. Small = productsmall, Medium=productmedium, etc.) That makes it difficult to track profit ratios, since the attributes only allows you to have one cost with multiple "sell" prices. If the different attributes costs are not the same incremental value as the sell price, then you don't get a true profit ratio. Maybe something else to think about incorporating down the road (unless I missed something, and it already has this capability?)

 

Thanks again!

 

John

Share this post


Link to post
Share on other sites

John: From what you described, it appears that you are getting a phantom second product with no data. This would explain the errors you are seeing. Try printing out the entire vendor_shipping method output from the shopping cart class. There is an example in the file of what it should look like. If there are entries with missing data, that gives you a clue of where to look.

 

In general, beware of any contribution that makes changes to the shopping cart class. We have added an entire method that these contributions will not address. This can cause all sorts of strange problems.

 

Regards

Jim


See my profile for a list of my addons and ways to get support.

Share this post


Link to post
Share on other sites
John: From what you described, it appears that you are getting a phantom second product with no data. This would explain the errors you are seeing. Try printing out the entire vendor_shipping method output from the shopping cart class. There is an example in the file of what it should look like. If there are entries with missing data, that gives you a clue of where to look.

 

In general, beware of any contribution that makes changes to the shopping cart class. We have added an entire method that these contributions will not address. This can cause all sorts of strange problems.

 

Regards

Jim

 

Thanks Jim! Your comment made me think of something. While I said that the only changes I made were to the shopping_cart class, I forgot that I was also playing around with the layout of my product_info page to put the attributes at the top of the page, instead of the bottom. When I reverted back to the original product_info, the error went away (I know - only change one thing at a time and test. I thought I did, but evidently not thorough enough :blush: ). Obviously the error is being caused by the change I made in product_info.

 

Somehow by moving the attributes to the top of the Product Info page it must be seeing what you are describing with the "second product".

 

Quick question: I see the example array in the shopping cart, but I am not quite sure how to get the array to print out. What and where would I put that line of code? If I can get it to print out the debug array, it might help with rearranging the product_info page so that I can that to work right.

 

Thanks again for everyone's help! You guys are great (and somewhat inspiring, really :D ).

 

John

Share this post


Link to post
Share on other sites

The shopping_cart class is instantiated as $cart on the products_info page, so you could put in something like this:

print '<pre>';
print_r ($cart);
print '<pre>';

to print the entire shopping_cart class. If you only want to look at the vendor_shipping() method of that class, use:

print '<pre>';
print_r ($cart->vendor_shipping);
print '<pre>';

The Print Array command (print_r) will actually print anything that is printable, and print out the data type of anything that is not printable. Very useful for debugging.

 

Regards

Jim


See my profile for a list of my addons and ways to get support.

Share this post


Link to post
Share on other sites
This will need to be a bit more in depth than I can get right now, Sam. But you will need to work through the common functioanlity of the code, not the code itself. As you already noted, MVS uses it's shipping functions, so this type of integration is significant. I think it would be a nice addon to MVS, but I don't have the time to get into it just yet, if I get the time I will let you know what I come up with.

 

Good luck, Craig :)

 

Thank you for your reply, I don't think I realised what I was getting myself into with all these contributions I've been installing.... I'm looking at other ways around the problem now rather than tying these two together.

Share this post


Link to post
Share on other sites
John, I had some of these strange errors while installing this on a customer's store as well, but was able to work through it. You are the one of several others who are asking for this contribution to be added to MVS so I will try very hard to put together some instrucions and code for what I did, I had offered to send this to another poster already and never got to it, so I will try to get it this weekend.

 

Craig :blush:

 

Hi,

 

I was wondering if you could help me with this error msg that I get on the checkout_shipping.php page on checkout:

 

United Parcel Service

We are unable to obtain a rate quote for UPS shipping.

Please contact the store if no other alternative is shown.

 

United Parcel Service (XML)

10002: The XML document is well formed but the document is not valid

 

I have no idea where to start.

 

Thanks

Share this post


Link to post
Share on other sites

That error message tells me that osCommerce is sending the correct format, but some of the data is incorrect. First, look at all of your settings for that vendor, including the information in the module setup. An invalid zip code would be enough to do this. Also, check your UPS Rates Access Key, username, and password against the ones UPS gave you.

 

If all of this is correct, then go to line 54 of includes/modules/vendors_shipping/upsxml.php and follow the instructions there to enable logging. Look at the logfile for missing or incorrect data. If you can't figure it out, post the log information here and we'll take a look at it.

 

Regards

Jim


See my profile for a list of my addons and ways to get support.

Share this post


Link to post
Share on other sites

well, i made a 2nd test store, and did this contribution again, to a stock copy, and it put me at the exact same status as before. USPS still won't give rates, and the email vendor function isn't working correctly...:(

Share this post


Link to post
Share on other sites

Does anyone have Authorize.net working with MVS? I thought I had this all working, but have run into a strange problem, most likely in the Authorize.net module or checkout_process.php, but as heavily as MVS integrates with this stuff, I am hoping there may be someone here that has run into this problem before. Here is what is happening:

 

1. Place an order using the credit card module (Authorize.net consolidated 1.8 (no longer listed on the contributions-don't know why it got pulled) - set to AUTHORIZE only, and in TEST mode).

2. Order appears to go through - Authorize.net shows the transaction came through with an order ID assigned.

3. Confirmation e-mail is sent to customer and store, however no order ID is referenced, but everything else looks right.

4. Assigned order ID does NOT show up in the ORDERS table.

5. Products ordered DO show up in the ORDERS_PRODUCTS, ORDERS_SHIPPING, ORDERS_STATUS_HISTORY, ORDERS_TOTAL tables - BUT the order ID is shown as "0".

6. This causes havoc with the database queries at this point. When you check your account, the order doesn't show up (no order_id in the database), but the products ordered on the phantom order now show up in the last GOOD order information.

 

If you continue this way (making orders using credit card), it compounds the products with an order_id of "0" to the last good order. The confirmation e-mails show the products from all previous failed orders, etc.

 

The only way to fix it, is to manually delete anything that references order_id of "0" in the database.

 

I thought that the order wasn't inserted into the database until after the CC authorization took place. I am not sure of the sequence of events after you enter the CC info on checkout_payment and then hit continue. It might help if I could print out the response code that is coming back from Authorize.net. I am assuming that it is "1" (normal authorization), since I don't get an error. Speaking of errors, it does this same thing if the card is declined (inserts phantom products in the database).

 

If anyone has Authorize.net working successfully with your store, I would love to compare the files to my own to see if there are any glaring errors, or if anyone has the answer off the top of their head, I would certainly love to find the answer! I was planning to go live this week, but not until this critical bug is fixed!

 

Thanks as usual for all the excellent suggestions and help!

 

John

Share this post


Link to post
Share on other sites

Hi guys... damsel in distress here, would appreciate some help....

 

I've just learned that my customers are getting the following error message when they log into their accounts and try to view their orders....

 

Fatal error: Using $this when not in object context in /home/mbeecouk/public_html/includes/vendor_order_data.php on line 18

Share this post


Link to post
Share on other sites

That's a bug. In includes/vendor_order_data.php, change all instances of $this->products to $these_products (or any other variable name of your choice.) This apparently only gets flagged by newer versions of PHP, so older versions will still work just fine. I would recommend that everyone make the change now, just to be prepared.

 

Regards

Jim

 

Edit: Not tested on all versions of PHP. Apply with care, and test thoroughly.

Edited by kymation

See my profile for a list of my addons and ways to get support.

Share this post


Link to post
Share on other sites

Cheers, Jim.... :wub: ....had to change all instances of $this in vendor_order_data.php and vendor_order_info.php, but it now works a treat.... brilliant contribution, fantastic support.... thanks again... :thumbsup:

Share this post


Link to post
Share on other sites

DOES ANYBODY HAVE USPS WORKING?

 

I AM NOT GETTING QUOTES!!

 

FEDEX WORKS AND I HAVEN'T TRIED UPS YET!

 

Please HELP ME!!

Share this post


Link to post
Share on other sites
DOES ANYBODY HAVE USPS WORKING?

 

I AM NOT GETTING QUOTES!!

 

FEDEX WORKS AND I HAVEN'T TRIED UPS YET!

 

Please HELP ME!!

 

I battled the same issue. I finally sent the request to USPS to activate my account on their production servers. After getting confirmation from them, I changed my USPS settings to "Production" and used my USPS Id for my "User Id" and "Password" fields. It works like a charm now.

 

I'm not sure why the "Test" server didn't work. Doesn't matter. I can "test" against their production servers.

 

Hope this helps.

 

Charley

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×