Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

New UPS XML Shipping Module available


Recommended Posts

Go to ups.com and try to create a shipping label based on the same criteria and see what you get. You can also turn on logging (see the comments in upsxml.php) and examine the reply sent by the UPS server.

Link to comment
Share on other sites

Excellent work on this contrib, one problem though. I followed the instructions to the T, I am not using any of the admin stuff for dimensions. This is what happens:

 

If I put the correct username and password, I get the error:

10001: The XML document is not well formed

 

If I put no username and no password, i get the error:

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

 

If I use any username and password combination other than blank or correct - it works :huh:

 

So basically I was getting errors until just for spite, I tried making my username the letter "a" and the password the letter "a" and whalaa, it works.

 

I mean it's working, but should it? I just want to make sure it will continue to work with incorrect login information or try to fix it.

 

Thanks

Link to comment
Share on other sites

A little update to the problem above, the password I chose for UPS has html special characters in it, like &. the only way i can't get this module to work with my password it to use:

 

function upsxml() {
...
$this->access_password = htmlspecialchars(MODULE_SHIPPING_UPSXML_RATES_PASSWORD);
...
}

 

I don't know for sure if this actually fixed it because it was working with the wrong password before. But it is working this way regardless.

Link to comment
Share on other sites

I have a problem. I have installed the files according to readme.txt up through step 3 and I get this error when opening the shipping module

/*************************************/

Shipping Modules

 

Warning: require_once(includes/classes/xml_5.php) [function.require-once]: failed to open stream: No such file or directory in D:\wamp\www\str1\includes\modules\shipping\upsxml.php on line 25

 

Fatal error: require_once() [function.require]: Failed opening required 'includes/classes/xml_5.php' (include_path='.;C:\php5\pear') in D:\wamp\www\str1\includes\modules\shipping\upsxml.php on line 25

 

Modules Sort Order Action

Flat Rate 0

Per Item

Table Rate

/*************************************/

 

This is the failing code block from upsxml.php:

 

// Incorporate the XML conversion library

if (PHP_VERSION >= '5.0.0') { // PHP 5 does not need to use call-time pass by reference

require_once (DIR_WS_CLASSES . 'xml_5.php'); /* its failing here */

} else {

require_once (DIR_WS_CLASSES . 'xml.php');

}

 

 

I verfied that xml_5.php is located in "includes/classes" and even copied it to "includes\modules\shipping\" in hopes that would solve it. In the fatal error portion I do not know where (include_path='.;C:\php5\pear') comes from or if it is even an issue. There has never been such a folder on my system. I am running Wamp Server 2.0, PHP 5.25, MySql 5.045, Apache 2.2.6. I'm at a loss as to where to go. OSC was running fine until I added these ups files and the code in step 3. Suggestions? Probably something simple but I am new to this. ASP was my forte years ago. Maybe it needs a path defined in the require_once call? Idon't know enough about it.

 

Thanks.

Link to comment
Share on other sites

I have a problem. I have installed the files according to readme.txt up through step 3 and I get this error when opening the shipping module

/*************************************/

Shipping Modules

 

Warning: require_once(includes/classes/xml_5.php) [function.require-once]: failed to open stream: No such file or directory in D:\wamp\www\str1\includes\modules\shipping\upsxml.php on line 25

 

Fatal error: require_once() [function.require]: Failed opening required 'includes/classes/xml_5.php' (include_path='.;C:\php5\pear') in D:\wamp\www\str1\includes\modules\shipping\upsxml.php on line 25

 

Modules Sort Order Action

Flat Rate 0

Per Item

Table Rate

/*************************************/

 

This is the failing code block from upsxml.php:

 

// Incorporate the XML conversion library

if (PHP_VERSION >= '5.0.0') { // PHP 5 does not need to use call-time pass by reference

require_once (DIR_WS_CLASSES . 'xml_5.php'); /* its failing here */

} else {

require_once (DIR_WS_CLASSES . 'xml.php');

}

I verfied that xml_5.php is located in "includes/classes" and even copied it to "includes\modules\shipping\" in hopes that would solve it. In the fatal error portion I do not know where (include_path='.;C:\php5\pear') comes from or if it is even an issue. There has never been such a folder on my system. I am running Wamp Server 2.0, PHP 5.25, MySql 5.045, Apache 2.2.6. I'm at a loss as to where to go. OSC was running fine until I added these ups files and the code in step 3. Suggestions? Probably something simple but I am new to this. ASP was my forte years ago. Maybe it needs a path defined in the require_once call? Idon't know enough about it.

 

Thanks.

 

OK Problem resolved. It was scientifically my fault. What I did was get the two upsxml.php files mixed up. These files have different contents. This may be something common with PHP but not in my background. One of the files was copied into the incorrect location. I might strongly suggest that they be renamed if possible so that they are not of the same name. Thanks again and sorry for the trouble.

Link to comment
Share on other sites

Bug fix for 1.3.2:

 

Problem - if the delivery state/province contains an apostrophe, for example, Cote D'Or, a query which simply encloses the state value in apostrophes will fail with an SQL syntax error. Worse, this could possibly open one up to an SQL injection attack.

 

In catalog\includes\modules\shipping\upsxml.php on line 234, replace:

 

$zone_query = tep_db_query("select zone_code from " . TABLE_ZONES . " where zone_name = '" .  $order->delivery['state'] . "'");

 

with:

 

$zone_query = tep_db_query("select zone_code from " . TABLE_ZONES . " where zone_name = '" .  tep_db_input($order->delivery['state']) . "'");

 

I have found a couple of places in other contributions I use where there is similar code. The same fix applies. I don't think it's sufficient to use double-quotes instead of apostrophes.

Link to comment
Share on other sites

I wanted to add this module to the product_info.php page. I made a form and single field button for the customers zipcode. So that the customer can check the price for shipping before checkout. Basically I just want it return the first/cheapest element, which is normally ground. I was just wondering if this is the correct way to do it:

 

// shipping quote
$shipping_quote_price = '';
if (isset($HTTP_GET_VARS['zipcode']) && $HTTP_GET_VARS['zipcode'] != 'zipcode' && isset($HTTP_GET_VARS['products_id']) && is_numeric(preg_replace('/-/', "", $HTTP_GET_VARS['zipcode']))) {

$product_info_query = tep_db_query(" select p.products_weight, p.products_price from " . TABLE_PRODUCTS . " p where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' ");

$product_info = tep_db_fetch_array($product_info_query);

//$shipping_quote_price
include_once(DIR_WS_MODULES.'shipping/upsxml.php');
include_once(DIR_WS_INCLUDES.'languages/english/modules/shipping/upsxml.php');

$rate_ups = new upsxml; 
$rate_ups->_upsOrigin("", "", "", $products_supplier_info['suppliers_shipping_origin_zipcode']); // Use ISO country codes! 
$rate_ups->_upsDest("", "", "", $HTTP_GET_VARS['zipcode']);   // Use ISO country codes! 
$rate_ups->_addItem(0, 0, 0, $product_info['products_weight'], $product_info['products_price']);
$shipping_quote_ups = $rate_ups->_upsGetQuote(); 
//print_r($shipping_quote_ups);

// get the percentage increase
 $config = tep_db_fetch_array(tep_db_query(" select cfg.configuration_value from " . TABLE_CONFIGURATION . " cfg where cfg.configuration_key = 'MODULE_SHIPPING_UPSXML_RATES_HANDLING' "));
$shipping_handling_fee = $config['configuration_value'];

for($i=0, $n=sizeof($shipping_quote_ups); $i<$n; $i++) {
  foreach($shipping_quote_ups[$i] as $type => $rate) {
	  if (tep_not_null($type) && tep_not_null($rate)) {
		  $shipping_quote_price = $type . ' $' . number_format(((($shipping_handling_fee * $rate)/100) + $rate),2,'.','');
		  $end_loop = 'true';
		  break;
	  }
  }
  if ($end_loop == 'true') break;
}

} else {
if (isset($HTTP_GET_VARS['zipcode'])) {
	$shipping_quote_price = 'Invalid Zipcode'; // invalid zipcode
} else {
	$shipping_quote_price = 'Enter zipcode, Get Quote'; // default page load
}
}

 

 

<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td class="main" align="right" nowrap="true" valign="top">
	<?php 
		echo tep_draw_form('get_shipping_quote', tep_href_link(basename($PHP_SELF), tep_get_all_get_params() . 'action=get_shipping_quote', 'NONSSL', false), 'get'); 
		echo tep_draw_input_field('zipcode', 'zipcode', 'id="zipcode" size="10" onclick="clearField(this, \'zipcode\')" onblur="recallField(this,\'zipcode\')"'); 
	?>

</td>
<td class="main" align="left" width="100%" nowrap="true" valign="top">
	<?php
		//echo tep_draw_hidden_field('products_id', $HTTP_GET_VARS['products_id']) . tep_hide_session_id();
		echo tep_image_submit('button_get_quote.gif', 'Get Quote');
		echo '</form>';
	?>
</td>
</tr>
<tr>
 <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
</tr>
<tr>
<td class="main" align="right" nowrap="true" valign="top">
	Shipping: 
</td>
<td class="main" align="left" width="100%" nowrap="true" valign="top">
	<?php
		if ($shipping_quote_price != '') {
			echo '<b>' . $shipping_quote_price . '*</b>';
		}
	?>
</td>
</tr>
</table>

 

It works perfect, but I'm still learning. Just wonder if anyone would advise a different solution or not? Thanks.

Btw, this only works with percentage increase atm and not flat fee.

Link to comment
Share on other sites

Good evening. I am hoping someone can point me in the right direction. I have been using UPS XML v1.2.9 for some time now and it works great. Up until today my biz partner and I only allowed US shipping. However, I would think if someone from outside the US attempted to make a purchase it should still show the "Origin European Union", et al rates as well since I did not remove those from the php file (I did it that way rather than change varchar to 255 per the instructions). I can't figure out why other rates aren't showing up if they are from say, the UK. In fact I had a customer back out of a cart today because his rates never showed. All that shows is the description text stating "these are your only shipping options" but there aren't any choices. Additional info: I have my module set to US Origin...should this be changed? I guess any ideas would help. I have searched this thread and forum pretty well and read the readme file... and readmes for upgrades. Can't figure this out. here is a screenshot of what you see if you have an example address like UK:

screen.gif

Link to comment
Share on other sites

First, you'll get "This is currently the only shipping method" when there is not two or more choices. The symptom you have suggests to me that you have set the "shipping zone" for UPS to be US-only. This is a setting in the admin configuration for the module. This is not the same as "origin country".

 

Set it to "none" instead and you should get international rates.

Link to comment
Share on other sites

  • 3 weeks later...

UPS XML returns the correct rates, but displays this Warning on checkout_shipping.php

 

Warning: constant() [function.constant]: Couldn't find constant MODULE_SHIPPING_UPSXML_INSURE_ in /home/username/htdocs/includes/modules/vendors_shipping/upsxml.php on line 423

 

line 423-425 says

						if (constant('MODULE_SHIPPING_UPSXML_INSURE_' . $vendor_id) == 'False') {
		for ($i = 0; $i < $shipping_num_boxes; $i++) {
			  $this->_addItem(0, 0, 0, $shipping_weight, $this->pkgvalue);

This is not a common error, as I've searched everywhere for a solution. So, does anyone know what I missed?

 

Thanks,

EricK

Link to comment
Share on other sites

Hi Erick,

 

It looks like there error is telling you it's missing from your database so it can't find the value.

 

I think you missed a step on your database installation because you should have an entry in your configuration table with this configuration_key "MODULE_SHIPPING_UPSXML_INSURE". It's a pretty easy install as I remeber from the Admin panel but it's possible to have problems with the install.

 

It might be a problem you can see in Admin/modules/shipping/UPSxml as that is a setting for it.

John Wisdom

Link to comment
Share on other sites

It looks like there error is telling you it's missing from your database so it can't find the value.

Thanks, John. You pointed me in the right direction. In the upsxml.php file that supports Multi Vendor Shipping I replaced the following:

 

OLD CODE = 'MODULE_SHIPPING_UPSXML_INSURE_' . $vendor_id

 

NEW CODE = 'MODULE_SHIPPING_UPSXML_INSURE_' . $vendors_id

 

Thanks again,

EricK

Link to comment
Share on other sites

Ordering from the Netherlands Antilles, Curacao fail to give a quote. I guess it has something to do with postal (zip)code and the UPC site.

 

Anybody the same experience or solution?

 

Hanz

Grtz

 

HanZ

 

 

 

-----------

Life is simple, only people make it complicated...

Louis Couperus, Dutch writer (1863-1923)

Link to comment
Share on other sites

Some pages back Jan and I had an exchange regarding the very long DNS translate time for www.ups.com on my site. He suggested I replace that with the IP address, and that worked great - until today when UPS changed the IP! Luckily I found that I can now use the hostname without a delay...

 

HanZ - can you give us some more details? Perhaps a test address to try out?

Link to comment
Share on other sites

HanZ - can you give us some more details? Perhaps a test address to try out?

 

Have 3 to test out (fake but close)

 

Jan Sofat (aka Jan Zoutvat) E-26, Curaçao, Netherlands Antilles

Kaya Mendelssohn 4, Curaçao, 000000, Netherlands Antilles

Kaya Moises 37, Curaçao, Netherlands Antilles

 

UPS customerservice told me; postcodes are not in use on the Netherlands Antilles, it goes by city, village, town etc.

 

Customers fill in something like 000000 for a postcode (cause it's mandatory) and no quote will return from UPS, this cost me several customers already, please help in finding a solution or workaround.

Grtz

 

HanZ

 

 

 

-----------

Life is simple, only people make it complicated...

Louis Couperus, Dutch writer (1863-1923)

Link to comment
Share on other sites

Is "E-26" the street address?

 

I guess/think it's the home number, Jan Sofat is the streetname (or in Dutch 'Jan Zoutvat')

Edited by HanZ

Grtz

 

HanZ

 

 

 

-----------

Life is simple, only people make it complicated...

Louis Couperus, Dutch writer (1863-1923)

Link to comment
Share on other sites

I just tried the second address and had no problems getting a UPS quote. I put in N/A for the state and 00000 for the postcode.

 

Strange, on every possible combination I provide I don't receive any quote

Grtz

 

HanZ

 

 

 

-----------

Life is simple, only people make it complicated...

Louis Couperus, Dutch writer (1863-1923)

Link to comment
Share on other sites

I suggest then that you turn on the debugging setting in the module's admin and look to see what the UPS response is.

 

On the UPS quotation site it works on CURACAO or JAN ZOUTVAT but my shop fails, this is the UPS reply:

 

UPSXML TimeInTransit Error: 270007: Invalid Destination Country City in TimeInTransit experienced by customer with id 265 on 2008-02-02 00:39:27

 

using this address Kaya Mendelssohn 4, CURACAO, 00000 OO, Netherlands Antilles

 

Any idea what this means?

Edited by HanZ

Grtz

 

HanZ

 

 

 

-----------

Life is simple, only people make it complicated...

Louis Couperus, Dutch writer (1863-1923)

Link to comment
Share on other sites

Hmm - try disabling the Time in Transit display - I don't use that.

 

One odd thing about UPS is that they have different servers for the different types of query. Standard rates are handled differently from negotiated rates and have different rules for addresses. You may be encountering yet another odd combination.

Link to comment
Share on other sites

Hmm - try disabling the Time in Transit display - I don't use that.

 

One odd thing about UPS is that they have different servers for the different types of query. Standard rates are handled differently from negotiated rates and have different rules for addresses. You may be encountering yet another odd combination.

 

 

Disabled now, still no quote (straight rates for us, no fancy stuff)

 

 

when I unmark SAVER I receive a quot doh.

Edited by HanZ

Grtz

 

HanZ

 

 

 

-----------

Life is simple, only people make it complicated...

Louis Couperus, Dutch writer (1863-1923)

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