Shipping Quote Problem

Project: 
Ubercart
Category: 
bug report
Priority: 
normal
Assigned: 
Unassigned
Status: 
active

Hello,

After using shipping quotes for several weeks with no problems I am suddenly getting these errors when checking out with shipping quotes. I have created a custom flat rate quote with the propper workflow-ng. The shipping quote progress bar just keeps moving and checkout hangs. The data I collected from firebird is:

Error 1:

{ "flatrate_43---0": { "rate": 30, "format": "$30.00", "option_label": "Ground S...

invalid label
https://www.example.com/sites/www.example.com/modules/ubercart/payment/u...
Line 131

Error 2:

syntax error
https://www.example.com/misc/jquery.js
Line 3

Any help would be greatly appreciated.

Thanks,

Patrick

Re: Shipping Quote Problem

What's the part after "option_label"? I've got a feeling that's where the problem lies. Also, what version are you on? Getting an error like that on line 131 doesn't make sense in the Bazaar version.

Re: Re: Shipping Quote Problem

The part after option_label is "Ground Shipping". I don't know what follows in the string, I had problems with dumping the whole string in Firebird. Do you have any debug tips to display all of the variable information? I am using ubercart-5.x-1.0-rc4. I looked at the code and thought that the error on line 131 didn't make sense as well. Below is the debug info I copied from the Firefox error console:

Error: invalid label
Source File: https://drupal.rustridge.com/misc/jquery.js
Line: 3, Column: 19
Source Code:
{ "flatrate_43---0": { "rate": 30, "format": "$30.00", "option_label": "Ground Shipping" }, "flatrate_79---0": { "rate": 51.92, "format": "$51.92", "option_label": "Air Shipping" } }

The error aero for both flatrate quotes points to "option_label". Also, totally unrelated, I noticed this error as well for Ubercart.

Error: __utmSetVar is not defined
Source File: http://www.ubercart.org/
Line: 250

Patrick

I use Firebug for my

I use Firebug for my debugging. I can usually get it to display the entirety of what it shows me in some way.

The whole line is {

The whole line is

{ "flatrate_43---0": { "rate": 30, "format": "$30.00", "option_label": "Ground Shipping" }, "flatrate_79---0": { "rate": 51.92, "format": "$51.92", "option_label": "Air Shipping" } }

All of the data here looks correct to me. The error that is being reported is the "option_type" which I think maps to "Line item label:" under "Store administration » Configuration » Shipping quote settings » Edit flat rate method". I do not see anything wrong with this variable. In Firebug I have found the following:

1) The shipping quote status bar is moving even before I type in a shipping or billing address.
2) The payment method status bar is moving even before I type in a shipping or billing address and before I can select a shipping method.

I have downgraded to Ubercart-5.x-1.0-rc2 to see if this fixed things but it did not. While still running Ubercart-5.x-1.0-rc2 I get an error in the function uc_payments.js lines 116 to 127. One error seems to be that the variable "details" is undefined. This results in the execution of $("#payment_details").empty().append(details); which I think appends garbage. I don't know if "details" is supposed to be undefined here but it might be a problem. (See *** next to lines in question)

function get_payment_details(path) {
///
/// Skip some code
///
*** function (details) {
if (this_update.getTime() == payment_update) {
*** if (details == "") {
$("#payment_details").empty().html(def_payment_msg);
} else {
*** $("#payment_details").empty().append(details);
}
}

There seems to be a problem in uc_quote.js as well. The following function uses the variable "i" before it is defined (see *** by the lines in question). This function always seems to return FALSE.

function quoteCallback(products) {
///
/// Skip some code
///
*** $("select[@name*=delivery_]").each(function (i) {
details["details[" + $(this).attr("name").split("delivery_")[1].replace(/]/, "") + "]"] = $(this).val();
});
*** $("input[@name*=delivery_]").each(function (i) {
details["details[" + $(this).attr("name").split("delivery_")[1].replace(/]/, "") + "]"] = $(this).val();
});

if (!!products) {
details.products = products;
} else {
products = "";
*** var i = 0;
///
///Skip some code
///

return false;
}

Also I have received a bunch of these messages

Element referenced by ID/NAME in the global scope. Use W3C standard document.getElementById() instead.

I do not know exactly the flow of these functions so I am hesitant to try to fix them (if indead there is something wrong with them).

If you could let me know if I am on the right track that would be great!

Thanks,

Patrick

Re: The whole line is {

details and i are both parameters passed to the anonymous functions, so they are defined as whatever gets passed into them by the jQuery function that the anonymous function gets passed into in the code above. (confused yet?) Regardless, JavaScript doesn't care if a variable was ever defined before you use it, it'll just give you one with a value of undefined, which is slightly different from null. There is some advantage to defining the variables with var but that has to do with scope and not really important here.

So, basically, I'm saying I don't see anything wrong with the code. You might try getting the latest code from http://bazaar.ubercart.org/, though. There have been a few fixes since RC4, but not many significant ones.

Re: Re: The whole line is {

I tried the code from bazzar but the problem still persists. The shipping quote function returns this

{ "flatrate_43---0": { "rate": 30, "format": "$30.00", "option_label": "Ground Shipping" }, "flatrate_79---0": { "rate": 51.92, "format": "$51.92", "option_label": "Air Shipping" } }

I have narrowed the problem down to right after the line items post call. The process keeps failing with this error in the console:

invalid label
{ "flatrate_43---0": { "rate": 30, "format": "$30.00", "option_label": "Ground S...
https://drupal.rustridge.com/sites/drupal.rustridge.com/modules/ubercart...
Line 131

It seems to be failing at remove_order_save_hold(); in uc_payments.js.

I think the shipping quotes is working fine but it is not displaying the shipping options because it fails at this point before it can display the shipping quotes. I do not know why it dumps out the invalid lable above and uc_orders.js is not a choice in Firebug for debugging.

Any ideas you might have would be helpful.

Patrick

Getting closer

I am getting an error remove_order_save_hold(); is not defined! in the footer of Firefox from Firebug.

Any idea why I would be getting this error?

Thanks again for the help,

Patrick

Re: Getting closer

I think there's some versions of JavaScript that have a hard time with try/catch blocks and undefined functions inside them. There was some code I had changed in uc_quote.js, and I think we can try the same thing here.

On line 130 of uc_payment.js and following, change:

      try {
        remove_order_save_hold();
      }
      catch (err) {}

to
      if (window.remove_order_save_hold) {
        remove_order_save_hold();
      }

That should keep that function from being called except on the pages that uc_order.js is available which ought to prevent the error in the first place.

Hello Lyle, I tried your

Hello Lyle,

I tried your change but it did not seem to make any difference. Over the weekend I created a local test environment so I could get instant access to the logs. For some reason I am getting this error from mod_security

[05/May/2008:12:39:36 --0500] [local.rustridge.com/sid#b892b610][rid#b8e1ae50][/cart/checkout/payment_details/credit][1] Access denied with code 501 (phase 2). Match of "rx (?:^(?:application\\/x-www-form-urlencoded(?:;(?:\\s?charset\\s?=\\s?[\\w\\d\\-]{1,18})?)??$|multipart/form-data;)|text/xml)" against "REQUEST_HEADERS:Content-Type" required. [id "960010"] [msg "Request content type is not allowed by policy"] [severity "WARNING"]

I have not made any material changes to the configuration / environment so I do not know why I would all of a sudden get this error. I have updated some modules. Maybe there were some changes there.

Any Idea what might be causing this?

Thanks,

Patrick

Issue solved

I have solved the issue but it was not what it seemed to be. There was a simple module I was using which created the problem. I do have to admit that I wrote the module so I am completely to blame. The module is an age verification form which requires the visitor to enter their date of birth before they get redirected to the catalog. The bug in the module was that I used $form = array(); in the following function. When I deleted this line everything worked fine again.

<?php
function age_verification_form($form_values = NULL) {
  
$form = array();

   include_once(
drupal_get_path('module', 'date_api') .'/date.inc');
  
$params = array(
     
'label' => 'Date of Birth',
     
'granularity' => array('M', 'D', 'Y'),
     
'year_range' => '-100:0',
     
'text_parts' => array(),
   );

  
$form['date'] = date_select_input($params);

  
$form['submit'] = array(
     
'#type' => 'submit',
     
'#value' => t('Verify you are over 21'),
   );

   return
$form;
}
?>

Even if I never visited this form it would somehow cause all of the problems with regard to shipping costs and payments on the checkout page. I do not quite understand why this would be the case unless it was loaded anyway and somehow the reference to an array was overwriting the data of other modules. I would think that other modules data would be more protected from this bug.

Thanks for the help Lyle and I am sorry I wasted your time on a bug I created,

Patrick