Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Multi_Vendor_Shipping new thread


blucollarguy

Recommended Posts

Paul: I have no idea why your module isn't working when it comes up first. I would suggest that you put in some Print statements to show all of the data that it is using. Perhaps some variable is not being set properly the first time. The shipping options are presented in order by vendors ID, so changing which vendor uses this module would be a temporary fix.

 

Phil: The options are in the individual modules. If you are using UPS, the options will be in the UPS or UPSXML module, depending on which you are using. Not all modules allow you to select which options are presented to the customer.

 

Regards

Jim

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

Link to comment
Share on other sites

Phil: The options are in the individual modules. If you are using UPS, the options will be in the UPS or UPSXML module, depending on which you are using. Not all modules allow you to select which options are presented to the customer.

 

Regards

Jim

for the USPS module, where do i change what options are listed in the admin panel? i've looked all thru the module in vendors shipping, and i can't find anywhere that changes what's listed on the admin side.

Link to comment
Share on other sites

USPS does not have the capability of selecting the services to be displayed. This is a function of the original osCommerce module. The functionality could be added, similar to the UPS Choice module, but I'm not aware of anybody having done so. The services are listed in includes/modules/vendor_shipping/usps.php, lines 56-70. You could edit these to include or exclude whatever you want. However, these changes will be effective for all vendors.

 

Regards

Jim

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

Link to comment
Share on other sites

USPS does not have the capability of selecting the services to be displayed. This is a function of the original osCommerce module. The functionality could be added, similar to the UPS Choice module, but I'm not aware of anybody having done so. The services are listed in includes/modules/vendor_shipping/usps.php, lines 56-70. You could edit these to include or exclude whatever you want. However, these changes will be effective for all vendors.

 

Regards

Jim

Jim,

 

I'm sorry, but i beg to differ. with the MVS contribution added, under "manage vendors" in the admin panel, in the USPS setup, you can select which services to return rates for. this option is NOT in the original osCommerce, correct, but it was added with MVS.

 

take a look:

 

usps-shipping-error-3.JPG

 

 

and jsut for reference:

 

usps-shipping-error-4.JPG

 

this is what the stock osCommerce USPS module looks like

Link to comment
Share on other sites

You are entirely correct. I was looking in the wrong place. Sorry about the mis-information.

 

In that case, the information should come from the arrays in lines 56-70 of includes/modules/vendors_shipping/usps.php. I may be wrong on that, considering my previous goof, so you should probably test this before making any significant changes.

 

Regards

Jim

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

Link to comment
Share on other sites

You are entirely correct. I was looking in the wrong place. Sorry about the mis-information.

 

In that case, the information should come from the arrays in lines 56-70 of includes/modules/vendors_shipping/usps.php. I may be wrong on that, considering my previous goof, so you should probably test this before making any significant changes.

 

Regards

Jim

it's ok jim, we all make mistakes!

 

as for lines 56-70, no matter what changes i do there, it does not affect the admin side.

 

now, for an observation i have had.

 

my live store, does not use MVS, but it uses flat rate boxes with no issues. there are no shipping options on the admin side. to select what i want, like you stated, you have to comment/uncomment the methods in the module.

 

my test store, has only mvs added to it, but i cannot get any other method except the four listed on the admin side. turning these options on/off in the admin panel works, with no change to the coding on the catalog side.

 

 

i'm thinking that where ever those four options are actually coded in, that is limiting what we can return as far as rates. does that make sense?

Link to comment
Share on other sites

Paul: I have no idea why your module isn't working when it comes up first. I would suggest that you put in some Print statements to show all of the data that it is using. Perhaps some variable is not being set properly the first time. The shipping options are presented in order by vendors ID, so changing which vendor uses this module would be a temporary fix.

 

Interesting, I have found that the vendor order is determined by the products order in cart. For instance, only one set of products requires a seperate shipping vendor. If that product is added to the cart as the first product, then in the shipping the vendor for that product shows up first, if however its added to the cart last, or after any of the other products, then its shipping option shows up second in the list of vendors shipping. Very strange. I only have one shipping option per vendor, so it just shows the products and the shipping option per vendor. But depending on what order they are in the cart determines which vendor is listed first.

Link to comment
Share on other sites

Phil: Apparently the Admin selections are hard-coded in instead of reading the array. You will need to change the array and lines 269-270 as well. The module will need to be reinstalled after these changes, since these values are stored in the database when the module is installed.

 

Also apparently my brain was not working at all yesterday. :blush:

 

Paul: You are also correct. The array is being read in the order it was built, which is the order the products are added to the cart. You can change this behavior by finding the following code in checkout_shipping.php (Line 85):

	  $total_shipping_cost = 0;
  $shipping_title = MULTIPLE_SHIP_METHODS_TITLE;
  $vendor_shipping = $cart->vendor_shipping;

then add the following after that code:

	  ksort ($vendor_shipping);

That should provide a temporary fix for your problem.

 

Now I'm going to try to forget that yesterday ever happened. :blush:

 

Regards

Jim

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

Link to comment
Share on other sites

It doesnt stop the actual display order of the vendors shipping options, however it does now work.

 

Incidently I used krsort to get what i needed. Seems to be working well.

 

Great :D

Link to comment
Share on other sites

i got great news!

 

no, i did not save a bunch of money by switching to geigo. i did however get flat rate boxes to show, along with ANY method listed near the beginning of the file. usps rates no longer depend on what method is selected in the admin panel.

 

the only thing i have to figure out, is why it lists both types of flat rate boxes as one option. my live store simply displays "flat rate box" whereas my test store displays "Priority Mail Flat Rate Box (11.25" x 8.75" x 6")7.70Priority Mail Flat Rate Box (14" x 12" x 3.5")"

 

so i have to figure this out, then i'll post up the code changes to be reviewed.

Link to comment
Share on other sites

here is what the XML data returns *note, this is being called via coding, not the call of "all" as mentioned above*

 

<?xml version="1.0"?> 
<RateV2Response>
<Package ID="0">
<ZipOrigination>46815</ZipOrigination>
<ZipDestination>46815</ZipDestination>
<Pounds>1</Pounds>
<Ounces>0</Ounces>
<Size>REGULAR</Size>
<Zone>1, local</Zone>
<Postage>
<MailService>Express Mail PO to Addressee</MailService>
<Rate>17.85</Rate>
</Postage>
</Package>

<Package ID="1">
<ZipOrigination>46815</ZipOrigination>
<ZipDestination>46815</ZipDestination>
<Pounds>1</Pounds>
<Ounces>0</Ounces>
<Container>FLAT RATE ENVELOPE</Container>
<Size>REGULAR</Size>
<Zone>1, local</Zone>
<Postage>
<MailService>Express Mail Flat Rate Envelope (12.5" x 9.5")</MailService>
<Rate>13.65</Rate>
</Postage>
</Package>

<Package ID="2">
<Error>
<Number>-2147219434</Number>
<Source>DomesticRatesV2::clsRateV2ValidateWeight;RateEngineV2.ProcessRequest</Source>
<Description>First Class mail must weigh 13 ounces or less.</Description>
<HelpFile></HelpFile>
<HelpContext>1000440</HelpContext>
</Error>
</Package>

<Package ID="3">
<ZipOrigination>46815</ZipOrigination>
<ZipDestination>46815</ZipDestination>
<Pounds>1</Pounds>
<Ounces>0</Ounces>
<Size>REGULAR</Size>
<Zone>1, local</Zone>
<Postage>
<MailService>Priority Mail</MailService>
<Rate>3.85</Rate>
</Postage>
</Package>

<Package ID="4">
<ZipOrigination>46815</ZipOrigination>
<ZipDestination>46815</ZipDestination>
<Pounds>1</Pounds>
<Ounces>0</Ounces>
<Container>FLAT RATE BOX</Container>
<Size>REGULAR</Size>
<Zone>1, local</Zone>
<Postage>
<MailService>Priority Mail Flat Rate Box (11.25" x 8.75" x 6")</MailService>
<Rate>7.70</Rate>
</Postage>
<Postage>
<MailService>Priority Mail Flat Rate Box (14" x 12" x 3.5")</MailService>
<Rate>7.70</Rate>
</Postage>
</Package>

<Package ID="5">
<ZipOrigination>46815</ZipOrigination>
<ZipDestination>46815</ZipDestination>
<Pounds>1</Pounds>
<Ounces>0</Ounces>
<Size>REGULAR</Size>
<Machinable>FALSE</Machinable>
<Zone>1, local</Zone>
<Postage>
<MailService>Parcel Post</MailService>
<Rate>4.16</Rate>
</Postage>
</Package>

<Package ID="6">
<ZipOrigination>46815</ZipOrigination>
<ZipDestination>46815</ZipDestination>
<Pounds>1</Pounds>
<Ounces>0</Ounces>
<Size>REGULAR</Size>
<Zone>1, local</Zone>
<Postage>
<MailService>Bound Printed Matter</MailService>
<Rate>1.87</Rate>
</Postage>
</Package>

<Package ID="7">
<ZipOrigination>46815</ZipOrigination>
<ZipDestination>46815</ZipDestination>
<Pounds>1</Pounds>
<Ounces>0</Ounces>
<Size>REGULAR</Size>
<Zone>1, local</Zone>
<Postage>
<MailService>Library Mail</MailService>
<Rate>1.35</Rate>
</Postage>
</Package>

<Package ID="8">
<ZipOrigination>46815</ZipOrigination>
<ZipDestination>46815</ZipDestination>
<Pounds>1</Pounds>
<Ounces>0</Ounces>
<Size>REGULAR</Size>
<Zone>1, local</Zone>
<Postage>
<MailService>Media Mail</MailService>
<Rate>1.42</Rate>
</Postage>
</Package>
</RateV2Response>

 

if you noticed on package id 4, there are two calls for postage, which is returning the following response:

 

Priority Mail Flat Rate Box (11.25" x 8.75" x 6")7.70Priority Mail Flat Rate Box (14" x 12" x 3.5")

 

i've been comparing the mvs (catalog/includes/modules/vendors_shipping/usps.php) against the USPSMethods 2.7 (catalog/includes/modules/shipping/usps.php) and i noticed the USPSMethods 2.7 has three lines of code to remove duplicates, however i just cannot get them to work correctly.

 

the lines are as follows

 

$rates[$MailService] = array($MailService => $Rate); // trick to remove duplicates

$rates[$SvcDescription] = array($SvcDescription => $Postage); // trick to remove duplicates

$rates=array_values($rates); // trick to remove duplicates

 

 

i'm going to continue to try and figure this out, but if anybody has a suggestion, please suggest!

Link to comment
Share on other sites

Hi guys.... I could really use some help.... again.... :blush:

 

I have a small problem that I need to resolve. Each of my vendors offers only one shipping method, and some will only ship to certain areas. If a customer selects a shipping destination outside the prescribed zone, I have a situation where there is no valid shipping method.... the customer sees a box saying simply "This is currently the only shipping method available to use on this order.", and is then able to checkout without shipping charges.

 

I don't know how to go about modifying the flat rate and table rate modules so that in those circumstances, the box displays a message advising that the product cannot be shipped to the chosen address.... would appreciate some (preferably idiot-proof, as I've addled my brain trying to figure this out :lol: ) advice... :blush:

Link to comment
Share on other sites

ROCK ON!!

 

i asked a friend to look over the code, and see what he can come up with.

 

well, he only came up with one thing...THE RIGHT DISPLAY!!

 

i'm gonna gather up the changes from the stock MVS file, and post it up here in a bit...

 

i'm so happy :)

Link to comment
Share on other sites

here we go...bear with me, it's a few changes...

 

 

open catalog/includes/modules/vendors_shipping/usps.php

 

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

 

Find at line 57:

 

	  $this->types = array('Express' => 'Express Mail',
					   'First Class' => 'First-Class Mail',
					   'Priority' => 'Priority Mail',
					   'Parcel' => 'Parcel Post');

 

Replace with:

 

$this->types = array(
					   'Express' => 'Express Mail',
					   'First Class' => 'First Class Mail',
					   'Priority' => 'Priority Mail',
					   'Parcel' => 'Parcel Post',
					   'BPM' => 'Bound Printed Matter',
		   'Library' => 'Library Mail',
		   'Media' => 'Media Mail'
				   	);

// make queries for these specific package types, as well as none
  $this->containers = array (	'Express'  => array('Flat Rate Envelope'),
				'Priority' => array('Flat Rate Box'));

  $this->intl_types = array(	'package',
				'envelope',
				'postcards or aerogrammes',
				'matter for the blind'
						  );

 

 

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

 

Find at line 154:

 

	  if ( tep_not_null($method) && (isset($this->types[$method]) || in_array($method, $this->intl_types)) ) {
	$this->_setService($method);
  }

 

Add below it:

 

if ($method) $this->_setService($method);

 

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

 

Find at line 159:

 

$this->_setContainer('None');

 

Replace it with:

 

$this->_setContainer('');

 

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

 

Find at line 329:

 

$this->service = $service;

 

Replace with:

 

$this->service = stripslashes($service);

 

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

 

Find at line 345:

 

function _setMachinable($machinable) {
  $this->machinable = $machinable;
}

 

Add below it:

 

function _dom2array($node) {
  $result=array();
   foreach ($node->child_nodes() as $child) {
		 switch ($child->node_type()) {
		 case XML_TEXT_NODE: {
			   return($child->get_content());
			   break;
		 }
		 case XML_ELEMENT_NODE: {
			   $result[$child->tagname] = $this->_dom2array($child); // recurse!
			   break;
		 }
	   }
   }
   return($result);
 }

 

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

 

Find at line 364:

 

$request  = '<RateRequest USERID="' . constant('MODULE_SHIPPING_USPS_USERID_' . $vendors_id) . '" PASSWORD="' . constant('MODULE_SHIPPING_USPS_PASSWORD_' . $vendors_id) . '">';

 

Replace it with:

 

$request  = '<RateV2Request USERID="' . constant('MODULE_SHIPPING_USPS_USERID_' . $vendors_id) . '" PASSWORD="' . constant('MODULE_SHIPPING_USPS_PASSWORD_' . $vendors_id) . '">';

 

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

 

Find at line 374:

 

reset($this->types);

 

Replace it with:

 

foreach (array_keys($this->types) as $type) {
	  $containers = array('');
	  if (array_key_exists($type,$this->containers)) $containers=array_merge($containers,$this->containers[$type]);

	 foreach ($containers as $container) {
	 //		reset($this->types);

 

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

 

Find at line 376 and comment both lines out:

 

$allowed_types = explode(", ", constant('MODULE_SHIPPING_USPS_TYPES_' . $vendors_id));
	while (list($key, $value) = each($this->types)) {

 

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

 

Find at line 379 and comment this line out:

 

if ( !in_array($key, $allowed_types) ) continue;

 

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

 

Find at line 381:

 

'<Service>' . $key . '</Service>' .

 

Replace it with:

 

'<Service>' . $type . '</Service>' .

 

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

 

Find at line 386:

 

'<Container>' . $this->container . '</Container>' .

 

Replace it with:

 

'<Container>' . $container . '</Container>' .

 

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

 

Find at line 416:

 

$request .= '</RateRequest>';

 

Replace it with:

 

}
	$request .= '</RateV2Request>';

 

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

 

Find at line 418:

 

$request = 'API=Rate&XML=' . urlencode($request);

 

Replace it with:

 

$request = 'API=RateV2&XML=' . urlencode($request);

 

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

 

Find at line 424:

 

'<MailType>Package</MailType>' .

 

Replace it with:

 

'<MailType>' . $this->intl_types[$services_count] . '</MailType>' .

 

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

 

Find at line 465:

 

$response = array();
  while (true) {
	if ($start = strpos($body, '<Package ID=')) {
	  $body = substr($body, $start);
	  $end = strpos($body, '</Package>');
	  $response[] = substr($body, 0, $end+10);
	  $body = substr($body, $end+9);
	} else {
	  break;
	}

 

Replace it with:

 

$responsedoc = new DomDocument($body);
  $root = $responsedoc->document_element();
  if ($root->first_child->tagname == "Error") {
	 $errordetails=$this->_dom2array($responseroot->first_child);
	 return array('error' => $errordetails['Number'] . ' - ' . $errordetails['Description']);

 

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

 

Find at line 479:

 

if (sizeof($response) == '1') {
	  if (ereg('<Error>', $response[0])) {
		$number = ereg('<Number>(.*)</Number>', $response[0], $regs);
		$number = $regs[1];
		$description = ereg('<Description>(.*)</Description>', $response[0], $regs);
		$description = $regs[1];

		return array('error' => $number . ' - ' . $description);
	  }

 

Replace it with:

 

$postages = $root->get_elements_by_tagname("Postage");
	foreach ($postages as $postage) {
		$postagedetails=$this->_dom2array($postage);
		 // strip size info. On domestic these do not change rate and inch " quotes screw up display with backslashes
		$MailService = preg_replace('/\s*\(.*\).*$/','',$postagedetails['MailService']);
		$Rate=$postagedetails['Rate'];
		if (isset($this->service) && ($MailService != $this->service) ) continue;
		$rates[$MailService] = array($MailService => $Rate); // trick to remove duplicates

 

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

 

Find at line 490 and comment it out:

 

$n = sizeof($response);
	for ($i=0; $i<$n; $i++) {
	  if (strpos($response[$i], '<Postage>')) {
		$service = ereg('<Service>(.*)</Service>', $response[$i], $regs);
		$service = $regs[1];
		$postage = ereg('<Postage>(.*)</Postage>', $response[$i], $regs);
		$postage = $regs[1];

		$rates[] = array($service => $postage);

 

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

 

Find at line 536:

 

if ($time != '') $transittime[$service] = ' (' . $time . ')';
		}
// EOF: UPS USPS
	  }
	}

 

Replace it with:

 

if ($time != '') $transittime[$service] = ' (' . $time . ')';
		}
// EOF: UPS USPS

 

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

 

Find at line 542:

 

if (ereg('<Error>', $response[0])) {
	  $number = ereg('<Number>(.*)</Number>', $response[0], $regs);
	  $number = $regs[1];
	  $description = ereg('<Description>(.*)</Description>', $response[0], $regs);
	  $description = $regs[1];

	  return array('error' => $number . ' - ' . $description);
	} else {
	  $body = $response[0];
	  $services = array();
	  while (true) {
		if ($start = strpos($body, '<Service ID=')) {
		  $body = substr($body, $start);
		  $end = strpos($body, '</Service>');
		  $services[] = substr($body, 0, $end+10);
		  $body = substr($body, $end+9);
		} else {
		  break;
		}

 

Replace it with:

 

$services = $root->get_elements_by_tagname("Service");
	  foreach ($services as $service) {
		  $servicedetails=$this->_dom2array($service);
		$SvcDescription = $servicedetails['SvcDescription'] . ' ('. $servicedetails['SvcCommitments'] . ')';
		$Postage=$servicedetails['Postage'];
		if (isset($this->service) && ($SvcDescription != $this->service) ) continue;
		$rates[$SvcDescription] = array($SvcDescription => $Postage); // trick to remove duplicates

 

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

 

Find at line 568 and comment these lines out:

 

		  $size = sizeof($services);
	  for ($i=0, $n=$size; $i<$n; $i++) {
		if (strpos($services[$i], '<Postage>')) {
		  $service = ereg('<SvcDescription>(.*)</SvcDescription>', $services[$i], $regs);
		  $service = $regs[1];
		  $postage = ereg('<Postage>(.*)</Postage>', $services[$i], $regs);
		  $postage = $regs[1];

 

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

 

Find at line 590:

 

if ($time != '') $transittime[$service] = ' (' . $time . ')';
// EOF: UPS USPS
		}
	  }
	}
  }

 

Replace it with:

 

if ($time != '') $transittime[$service] = ' (' . $time . ')';
// EOF: UPS USPS
	  }
	  $rates=array_values($rates); // trick to remove duplicates

 

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

 

 

now, this gets USPS working, and in what appears a correct manner.

Link to comment
Share on other sites

 

	United Parcel Service United Parcel Service	  
We are unable to obtain a rate quote for UPS shipping.
Please contact the store if no other alternative is shown.

 

Hi, I get the above problem when I use UPS? I looked though the forum - but could not find anything. Do you have any suggestions?

 

You will see it is you go to http://www.homehealthresource.net/store/pr...roducts_id=6090 and add the product to the cart - then checkout.

 

It only does not show shipping if I assign the product to a vendor.

 

Thanks,

Philip

Link to comment
Share on other sites

First, check your information in your vendor and the module setup. You must have a valid zip code for UPS to calculate shipping rates. If that doesn't do it, please tell us which UPS module you are using.

 

Regards

Jim

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

Link to comment
Share on other sites

The next step would be to find out what UPS is returning. Find this code at about line 355 of includes/modules/vendor_shipping/ups.php:

	  $body_array = explode("\n", $body);

and add this after it:

	  print '<pre>';
  print_r ($body_array);
  print '</pre>';

That will display the raw data returned from UPS, which should give us an idea of what is going wrong.

 

Regards

Jim

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

Link to comment
Share on other sites

Hey Craig and Jim-

 

I just today noticed that product attributes are not showing up properly on admin/invoice.php. Only the first product listed shows it's attributes properly, and any additional products with attributes only show "Style: " without the rest of the information. The data is being written to the database properly; it shows up on the "Edit" page.

 

Is this a known bug or maybe I missed something?

 

Thanks

Stew

Do, or do not. There is no try.

 

Order Editor 5.0.6 "Ultra Violet" is now available!

For support or to post comments, suggestions, etc, please visit the Order Editor support thread.

Link to comment
Share on other sites

Is this a known bug or maybe I missed something?

Not known to me. I just ran an order on my test site and the Invoice looks fine. I suggest that you check your code changes again.

 

Regards

Jim

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

Link to comment
Share on other sites

Gak- I swear product attributes are the bane of my existence.

 

I uploaded the admin/invoice.php that comes with MVS to my site and got the same results:

 

 

snap.jpg

 

Brickle frickle! It's been like this for many moons- I've been living with it this way on my packing slips, but, as you can imagine, it was a royal pain during the week leading up to Thanksgiving. Suddenly today it dawned on me that I took the code I use in packingslip.php directlty from invoice.php, and so turned there only to find the same problem.

 

I can't think of what this could be caused by. Something wrong with my database? I looked at the invoices of a couple old pre-MVS orders with multiple products, attributes show up ok in those. Bizarre.

 

Weirder still- it only happens with this one vendor. Products with attributes from other vendors show up fine.

Do, or do not. There is no try.

 

Order Editor 5.0.6 "Ultra Violet" is now available!

For support or to post comments, suggestions, etc, please visit the Order Editor support thread.

Link to comment
Share on other sites

Weirder still- it only happens with this one vendor. Products with attributes from other vendors show up fine.

I can't think of any reason shy this should stop working for only one vendor. Weird. I'll take a closer look in a few minutes; I'm just finishing up some code changes on something else right now. I'll let you know if I find anything.

 

Regards

Jim

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

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