Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Multi_Vendor_Shipping new thread


blucollarguy

Recommended Posts

Darn good point. I removed from the main shipping and low and behold, it followed the else statement. I will work with the code as you outlined.

 

Thanks.

 

 

MVS will never set MODULE_SHIPPING_INDVSHIP_STATUS. It will set MODULE_SHIPPING_INDVSHIP_STATUS_1 for vendor 1 (substitute the number of your vendor for the 1s here.) So, if you are setting the Individual Ship module in the Vendors section of the Admin, not the original Modules section, then you will need to add the vendors id to the end of every constant that you expect the module to set. So first make certain that you have all of the settings correct in the Vendors admin. You might want to disable the indvship module from the regular osCommerce side to make certain that your changes are reading the proper constants.

 

If everything in the Admin is set up correctly, then I would put in some test code to see if we can figure out what is or isn't getting set. Try adding this just above the foreach loop above the line that's giving the error (line 125 or so):

	print "<b>Global Variables: </b>\n";
print '<pre>';
print_r ($GLOBALS);  
print '</pre>';

That should give a whole list of module data. See if there is anything in the indvship section. I may be able to figure out where to look based on that information.

 

Regards

Jim

Link to comment
Share on other sites

It is part of IPS in the function: indvship_status.php

 

<?php
/*

Indvship

*/
?>
<?php


// BOF Indv Ship 
 function tep_get_configuration_key_value($lookup) {
$configuration_query_raw= tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key='" . $lookup . "'");
$configuration_query= tep_db_fetch_array($configuration_query_raw);
$lookup_value= $configuration_query['configuration_value'];
return $lookup_value;
 }
// EOF

?>

 

Um, when did this function get added?
Link to comment
Share on other sites

Thanks Jim for your help, but as it seems we are going down a rabbit hole here, is there any way you or anybody else knows of to specify that a shipping method for a vendor and if that is not set, display all the others? This would be a nice fix to trying to work with dimensions UPS XML.

Link to comment
Share on other sites

Marc is right; that function should not be there. It's redundant at best, and will fail with MVS since it doesn't include the values in the vendor_configuration table. All of the configuration values are set to constants in application_top.php, including the MVS ones. Just use the constant and your code should work fine.

 

Regards

Jim

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

Link to comment
Share on other sites

Ok then that is where I get lost , what is IPS? I have indvship.php files in my osC shop yet nowhere

do I have that function.

 

 

It is part of IPS in the function: indvship_status.php

 

<?php
/*

Indvship

*/
?>
<?php
// BOF Indv Ship 
 function tep_get_configuration_key_value($lookup) {
$configuration_query_raw= tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key='" . $lookup . "'");
$configuration_query= tep_db_fetch_array($configuration_query_raw);
$lookup_value= $configuration_query['configuration_value'];
return $lookup_value;
 }
// EOF

?>

Link to comment
Share on other sites

Thanks, JIm. That was what I thought. I haven't been in here for about a month and thought I was lost in space for a minute there! B)

 

I've been struggling with Individual Product Shipping (IPS) for a week and found that some versions of the contribution had that file in the fuction, I thought it was a fix to my problems, but I guess not :blush:

 

Sorry for any confusion.

Link to comment
Share on other sites

Thanks Jim for your help, but as it seems we are going down a rabbit hole here, is there any way you or anybody else knows of to specify that a shipping method for a vendor and if that is not set, display all the others? This would be a nice fix to trying to work with dimensions UPS XML.

MVS is down the rabbit hole? No wonder this whole business has gotten so surreal.

 

Seriously, though, I think you're on the right track. You could also do just the opposite of the second half of your if/else, like this:

		if (@constant ('MODULE_SHIPPING_INDVSHIP_STATUS_' . $vendors_id) and $shiptotal) {
		foreach ($installed_modules_array as $value) {
		  $class = substr($value, 0, strrpos($value, '.'));
		  // Do show Individual Shipping Module and no others
		  if ($class == 'indvship')  {
			$include_modules[] = array('class' => $class, 'file' => $value);
		}
	  }
	  } else {
		foreach ($installed_modules_array as $value) {
		  $class = substr($value, 0, strrpos($value, '.'));
		  // Don't show Individual Shipping Module
		  if ($class != 'indvship')  {
			$include_modules[] = array('class' => $class, 'file' => $value);
		}
	  }

And if anybody sees a white rabbit running around here, tell him I want my watch back. I need more hours in my days.

 

Regards

Jim

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

Link to comment
Share on other sites

Trying your above post, will get back to you.

 

 

So proving my green-ness to php, where do i set this in the constants?

 

In the vendor_shipping file at the top there is:

 

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

 

is the @constant where it should be set?

Edited by OS_Tim
Link to comment
Share on other sites

Trying your above post, will get back to you.

So proving my green-ness to php, where do i set this in the constants?

<snip>

No, that's reading the value that has already been set. The constants are set for you in application_top.php, with this code:

  $configuration_query = tep_db_query('select configuration_key as cfgKey, configuration_value as cfgValue from ' . TABLE_CONFIGURATION);
 while ($configuration = tep_db_fetch_array($configuration_query)) {
define($configuration['cfgKey'], $configuration['cfgValue']);
 }

That define statement is what defines the constant. In order to read back the value of the constant, you normally just print it out or use it in an equation, like so:

echo MODULE_VENDOR_SHIPPING_INSTALLED;
$test = MODULE_VENDOR_SHIPPING_INSTALLED;

The fun comes when you don't know the name of the constant. PHP allows you to get this name dynamically (You can think of this as a variable constant. If that's not too much like something the White Rabbit would say, anyway.) You do that with the constant statement. So we can do something like:

echo constant ('MODULE_SHIPPING_INDVSHIP_STATUS_' . $vendors_id);
$testy = constant ('MODULE_SHIPPING_INDVSHIP_STATUS_' . $vendors_id);

The at sign (@) in front of the statement just prevents PHP from throwing a warning if the constant is not defined. The statement will then fail silently, so you need to do your own error handling if that would cause problems in the code. Since the result of a failure here would be to just act like MVS was not set, that is probably OK.

 

I hope that I'm making sense. If not, take two aspirin and post more questions.

 

Regards

Jim

'

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

Link to comment
Share on other sites

MVS is down the rabbit hole? No wonder this whole business has gotten so surreal.

..........

And if anybody sees a white rabbit running around here, tell him I want my watch back. I need more hours in my days.

 

Regards

Jim

I think he meant that tis part of the thread is falling down the rabbit hole. Also, I would prefer adding more days to my hours.

 

Why the foreach instead of while ?

Link to comment
Share on other sites

I think he meant that tis part of the thread is falling down the rabbit hole. Also, I would prefer adding more days to my hours.

 

Why the foreach instead of while ?

 

I beleive I read foreach returns results faster??? But again, I'm green. Through my troubleshooting I have swapped out while and for each and they both work.

Link to comment
Share on other sites

I think he meant that tis part of the thread is falling down the rabbit hole. Also, I would prefer adding more days to my hours.

 

Why the foreach instead of while ?

The simplest (and probably most correct) answer is programmer style: I like Foreach loops. They give you a set of array values (and the keys if you want them) which can make the following code look cleaner and (hopefully) easier to understand. Foreach also resets the array pointer, which removes the need to remember to do this before starting the loop. While would work just as well, although you need to remember to reset if the array pointer could be somewhere you don't want it to be. I have no idea which is faster, although I suspect that While has less overhead.

 

And I completely agree about the additional days. Or nights; programmers are nocturnal anyway.

 

Regards

Jim

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

Link to comment
Share on other sites

The simplest (and probably most correct) answer is programmer style: I like Foreach loops. They give you a set of array values (and the keys if you want them) which can make the following code look cleaner and (hopefully) easier to understand. Foreach also resets the array pointer, which removes the need to remember to do this before starting the loop. While would work just as well, although you need to remember to reset if the array pointer could be somewhere you don't want it to be. I have no idea which is faster, although I suspect that While has less overhead.

 

And I completely agree about the additional days. Or nights; programmers are nocturnal anyway.

 

Regards

Jim

True enough and it follows the standards set by the osC team too I suppose for walking through arrays. Just so long as we remember not to fall in to the foreach trap.

With foreach and references, there is a super easy way to corrupt your data

 

see this test script:

<?php

$array = array(1,2,3);

foreach( $array as &$item );

foreach( $array as $item );

print_r( $array );

?>

 

You would imagine that it would have 1,2,3 but in reality, it outputs 1,2,2

 

The issue is that $item is a pointer to the last array value, and exists outside of the scope of the foreach, so the second foreach overwrites the value. If you would check what it gets set to in the second foreach loop, you would see that it gets set to 1 and then 2 and then 2 again.

But you can avoid it by destruction of the hard link $item

 

<?php

$array = array(1,2,3);

foreach( $array as &$item );

unset($item);

foreach( $array as $item );

print_r( $array );

?>

Edited by HallMarc
Link to comment
Share on other sites

True enough and it follows the standards set by the osC team too I suppose for walking through arrays. Just so long as we remember not to fall in to the foreach trap.

With foreach and references, there is a super easy way to corrupt your data

<snip>

True, that is one of many traps you can fall into. I can't really see the need to step through the same array as the outer loop is using. That seems to be an error in itself. I suppose this would also happen if you used the same $item pointer with two different arrays, but again that is an error in coding.

 

Developing good coding habits is important to avoiding errors like this. A lot of mine come as a result of making the error in the first place. Having to track down a corruption bug like this is a great way to learn to never do it again.

 

Regards

Jim

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

Link to comment
Share on other sites

I am also not able to view the order history product details admin/Invoice.php and account_history_info.php Any suggestions on a solution?

 

I'm getting a dash for all of the following (in both the invoice and account history It doesn't list each product that is being shipped.):

 

Products, Price (ex), Model, Price (inc), Total (ex), Total (inc)

 

It will list only shipper, method, ship cost, and tax.

 

Thanks!

 

 

Thanks, Craig... but that was the second thing I checked. Even tried overwriting them with fresh copies from the working site, even though I had checked and the existing ones were uncorrupted. No joy.

 

The information is in the database... the code that calls and displays the information is intact... but the information is not displayed. I am baffled, which is why I turned to you guys for help.

Link to comment
Share on other sites

I am also not able to view the order history product details admin/Invoice.php and account_history_info.php Any suggestions on a solution?

 

I'm getting a dash for all of the following (in both the invoice and account history It doesn't list each product that is being shipped.):

 

Products, Price (ex), Model, Price (inc), Total (ex), Total (inc)

 

It will list only shipper, method, ship cost, and tax.

 

Thanks!

 

Hi David

 

Check that the vendor's ID column in table order_products is being populated correctly.

Link to comment
Share on other sites

I am also not able to view the order history product details admin/Invoice.php and account_history_info.php Any suggestions on a solution?

 

I'm getting a dash for all of the following (in both the invoice and account history It doesn't list each product that is being shipped.):

 

Products, Price (ex), Model, Price (inc), Total (ex), Total (inc)

 

It will list only shipper, method, ship cost, and tax.

 

Thanks!

 

Hi there,

 

I've got exactly the same problem without the dashes.I cannot display the info.I checked if the data shows up in the database and yeas, everything is there.The vendors_id is corect , products_quantity field has the correct values inserted etc , etc.Also " Click to send Email " is just plain text , no active link.

Link to comment
Share on other sites

Hi there,

 

I've got exactly the same problem without the dashes.I cannot display the info.I checked if the data shows up in the database and yeas, everything is there.The vendors_id is corect , products_quantity field has the correct values inserted etc , etc.Also " Click to send Email " is just plain text , no active link.

What other contributions might you have installed alonmg with this one?

Link to comment
Share on other sites

What other contributions might you have installed alonmg with this one?

 

None,

 

I had installed the os 2.2 ms2 - 060817.

After that I uploaded the files from the version MVS-V1.1 of 1 April 2006 by blucollarguy.

 

By comparing the files i found out that some files were not modified , like for example :

in admin/includes/filenames.php ( included in this contribution ) the:

 

"define('FILENAME_VENDORS_EMAIL_SEND', 'vendor_email_send.php');"

 

was not present .Thats why I did reinstall the osc and on top of it the MVS contribution.Right now ,as I write ,I was checking the table orders_shipping and they are empty despite the fact that I placed a couples of orders. In the table orders_products i do have the correct data, including the vendors _id.Also , the send email to vendors function doesnt work at all.When a product is bought an email is sent to the owner of the site but not to the vendor in question.When I change the status of the order also an email is sent to the website owner but not to the vendor.

 

Did I miss something when I installed the contribution? Do I have to manually modify any more files after I uploaded the MVS contribution on top of the oscommerce files? the install instruction are not very clear and is somehow difficult to follow a time line looking at the supporting text files.

 

Thankx ,

Gabe

Edited by gabev
Link to comment
Share on other sites

None,

 

I had installed the os 2.2 ms2 - 060817.

After that I uploaded the files from the version MVS-V1.1 of 1 April 2006 by blucollarguy.

 

By comparing the files i found out that some files were not modified , like for example :

in admin/includes/filenames.php ( included in this contribution ) the:

 

"define('FILENAME_VENDORS_EMAIL_SEND', 'vendor_email_send.php');"

 

was not present .Thats why I did reinstall the osc and on top of it the MVS contribution.Right now ,as I write ,I was checking the table orders_shipping and they are empty despite the fact that I placed a couples of orders. In the table orders_products i do have the correct data, including the vendors _id.Also , the send email to vendors function doesnt work at all.When a product is bought an email is sent to the owner of the site but not to the vendor in question.When I change the status of the order also an email is sent to the website owner but not to the vendor.

 

Did I miss something when I installed the contribution? Do I have to manually modify any more files after I uploaded the MVS contribution on top of the oscommerce files? the install instruction are not very clear and is somehow difficult to follow a time line looking at the supporting text files.

 

Thankx ,

Gabe

First, did you enable MVS in the admin? Under admin->configuration->shipping/packaging.

 

Second:

 

this block of code is in admin/includes/filenames.php

   //MVS start
 define('FILENAME_VENDORS', 'vendors.php');
 define('FILENAME_VENDOR_MODULES', 'vendor_modules.php');
 define('FILENAME_PRODS_VENDORS', 'prods_by_vendor.php');
 define('FILENAME_ORDERS_VENDORS', 'orders_by_vendor.php');
 define('FILENAME_VENDORS_EMAIL_SEND', 'vendor_email_send.php');
 define('FILENAME_MOVE_VENDORS', 'move_vendor_prods.php');
  //MVS end

If this block of code was not in the file you uploaded, then you are not uploading the correct files. MVS V1.1 is the latest, it does have a few bugs that have been reported here, but I have not had the time to update and upload a new package yet. The instructions are very detailed, with a FEW mistakes, but most folks have been able to install on very heavily modified stores without much difficulty.

 

Make sure to read through the documentation and you should be fine. Sometimes this mod can be confusing, it is very large with a lot going on, stick with it and you'll get it.

 

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: [email protected]

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!

Link to comment
Share on other sites

I have installed MVS 1.1 and then installed Individual Shipping v1.2 for MVS v.1.1

 

The issue that I'm having is on the checkout shipping page the individual shipping cost is showing $0.00 .

 

The product that is in my cart I set to have a products_ship_price price of 5.00 .

 

I have made sure that the product in my admin is set to the vendor I have individual prices setup on.

 

Please let me know what i'm doing wrong.

Link to comment
Share on other sites

I noticed in April that some people here were working on a Zone module to work with States for zones rather then countries. Is this module available yet? If not does anyone have any suggestions on how to create shipping rates for each state or groups of states?

Thanks for any help.

Daniel

Link to comment
Share on other sites

I would like somebody out there to help me figure out how to configure shipping on a "per item" basis.

 

I am using UPS, calculating by weight and ZIP code.

 

Assuming 2 packages, 2 pounds each, I need UPS shipping to be billed for each 2 pound package, not one 4 pound package.

 

Any ideas?

Link to comment
Share on other sites

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