Hi

I have been adding a few new products to our site today and found a problem. Im sure this has only come about since 6.x2.2 was released as this was working fine before then...
Our products have their weight defined under the product information header when creating a product. The weight is key to shipping and we have Google Checkout configured to convert this weight value to a shipping cost within GC. Now today i have noticed that the incorrect weight is being sent through to GC from UC. The value is roughly half of what it should be defined as! Now having done a little routing around in ubercart/payment/uc_google_checkout/uc_google_checkout,module and notice that there is the following line:

$output .= 'weight * uc_weight_conversion($product->weight_units, 'lb') .'" />';

Would the presence of the LB for pounds affect the weight carried into the google checkout?? If 2.2lbs per kilo does this mean that GC thinks im working in pounds and not kilos?
Changing it to KG / kg just creates a blank screen :s

Help would be much apprieated with this as its on a production site and was working fine but now isnt.
I have had to double the weight of all our products to enable it calculate the correct weight for shipping.

Can anyone assist in this matter??
Thanks
Nippon Koi =)

Comments

tr’s picture

Category: bug » support

In the future, please wrap any code with <code></code> tags. That line of code really looks like this:

$output .= '<item-weight unit="LB" value="'. $product->weight * uc_weight_conversion($product->weight_units, 'lb') .'" />';

...and that code is correct. The unit="LB" is telling the Google server that the weight is being sent in units of pounds. The value sent is the product weight times a conversion factor which changes the product weight units into pounds.

So what you need to check is that your product weight units are set correctly for each product on the product page, and that the weights are entered correctly, and that the products are marked as "shippable" (since their weight won't count if they aren't being shipped).

kentjames1980’s picture

Yes, TR they are all all set up correctly to the right weight (well double at the moment to make it work!) and the settings for weight format is set to kg under store settings and the individual product weights are set to KG's and all the products are set to shippable.

It all works fine if you set the product weight to double the actual weight, otherwise it seems to halve the weight of the order and discount the shipping by half??

If it is converting it into pounds and sending it to google how can google work it out if its in pounds as google works in kilo's? If they are being sent in pounds to google then that would explain why the weight is being roughly halved? (1 pound = 0.45359237 kilo's) That might explain the problem would it not?

Thanks in advance TR!

tr’s picture

The unit="LB" is what tells Google the weight is in LB. And in fact, LB is the *only* units that Google supports. That line of code is correct - you can read for yourself at: http://code.google.com/apis/checkout/developer/Google_Checkout_XML_API_T...

So the only thing that could be wrong is $product->weight or $product->weight_units contains a wrong value. Print them out to see what they hold.

kentjames1980’s picture

TR

Thanks for your help with this so far.

Im sorry for my ignorance but im still new to drupal, when you say $product->weight or $product->weight_units contains a wrong value - where or what am i looking at exactly?

EDIT - TR - do you mean in the database?? - As i have found that on uc_products that weight_units is set to 'lb' as the default value? Is this wrong :-S

Thankyou
NipponKOi =)

kentjames1980’s picture

anyone got a solution to this please??

kentjames1980’s picture

Status: Active » Needs review
Island Usurper’s picture

Status: Needs review » Active

There is no patch to review.

kentjames1980’s picture

No But i was hoping it might prompt someone to figure this out!

Andy_Lowe’s picture

Status: Active » Postponed (maintainer needs more info)

Please insert the following code below the line described in #1

$debug_weight = print_r($product->weight,true);
watchdog('debug', $debug_weight, WATCHDOG_DEBUG);
$debug_weight_units = print_r($product->weight_units,true);
watchdog('debug', $debug_weight_units, WATCHDOG_DEBUG);

This will print the results to your logs. Then go to www.example.com/admin/reports/dblog to view the results and post them here.

nouriassafi’s picture

I have a related problem. Mine does not send weight information to GC at all. I followed Andy Lowe's instructions and had a look at the debug log. To my dismay the debug message field is empty; neither weight nor weight unit is printed. What could be behind this? Please note that I have GC payment option only with shipping quotes set up at GC's back-end only.
Your help would be much appreciated.

dariogcode’s picture

I also have the same problem. Google shipping quotes not changing if I change product weight.

damienmckenna’s picture

Version: 6.x-2.2 » 6.x-2.4

Am seeing this on a v6.x-2.4 site too.

damienmckenna’s picture

The $product object from line 467 of uc_google_checkout.module:

stdClass Object
(
    [cart_id] => 39a92672ff8e486c7614b29d45d57efa
    [nid] => 138
    [qty] => 1
    [changed] => 1290959525
    [data] => Array
        (
            [attributes] => Array
                (
                )
            [shippable] => 1
            [module] => uc_product
        )
    [cart_item_id] => 7890
    [title] => Greenies Petite Senior Treat-Pak
    [vid] => 138
    [cost] => 9.68
    [price] => 15.99
    [weight] => 12
    [module] => uc_product
    [model] => GRE04458
    [order_id] => 28019
    [manufacturer] => 
    [order_product_id] => 3938
)
damienmckenna’s picture

Category: support » bug
Status: Postponed (maintainer needs more info) » Active

Have changed the status & category of the ticket to match the issue.

tr’s picture

@DamienMcKenna: Can I assume that:

1) "12" is the correct product weight - that is, it's the weight you entered on the node/%/edit page for that product?

2) Your product weight_units is set to Kg ?

I'm guessing that the problem arises because the weight_units key doesn't appear in the dump of your product object - this results in uc_weight_conversion($product->weight_units, 'lb') returning "1", so your product weight doesn't get converted to "LB" as needed by Google Checkout. That would only show up as a problem if your product weight_units was set to something other than pounds.

So the thing to track down is why isn't weight_units set? Can you look at the uc_products table and tell me if there is an entry in the weight_units column for each of your products?

longwave’s picture

#631120: Weight conversion in uc_google_checkout.module silently fails is a duplicate, but is older than this issue and includes two possible patches.

tr’s picture

Thanks for finding that longwave. Yes, this seems to be a duplicate.

Can someone review the proposed patch in http://drupal.org/node/631120#comment-2349968 ?

longwave’s picture

Status: Active » Fixed

Patch in #631120 works and has been committed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.