When Tablequote compares weights it seems to be using the default weight unit for all products, causing inaccurate analysis of weight bands.

For example, in my site, the default units are grams and a single 400g product falls into the 201-500 weight band whereas a single 1.5kg product is quoted in the 0-200 band.

I plan to try and fix this for myself, if I succeed I will supply a patch.

Comments

autopoietic’s picture

Status: Needs review » Active
StatusFileSize
new913 bytes

I have created a patch against (6.x-2.0) which I think resolves this problem. The code is pretty much straight from the uc_weight module, instead of checking item weights from uc_cart_get_contents() I have used the $products object passed into the quote function.

After applying this patch Table Quote should convert product weights to use the store's default weight format before adding up the order's total weight.

IMPORTANT: this does mean that if the sites default weight unit is changed the rates returned by the Table Quote module will be drastically affected.

I suggest this should be resolved by either of the following options:

  1. Add a field to uc_tablequote_methods to store weight units, configured from the table's form.
  2. Amend all tablequote rates to match the store default when it is changed.

I prefer 1) as it may help administrators to set tables up according to different mail companies default weight unit.

autopoietic’s picture

Status: Active » Needs review
anrikun’s picture

Assigned: Unassigned » anrikun
Priority: Normal » Critical
Status: Active » Needs review
StatusFileSize
new12.06 KB

Nice patch but there are still mistakes:
- function signature is wrong. It should be:

<?php
// this is wrong: function uc_tablequote_quote(&$form_state, $products, $details){
function uc_tablequote_quote($products, $details) {
}
?>

- default uc_weight_unit should be "lb" (not "kg") like in other uc modules

This module is very useful but has many bugs, and some of them are critical.
Here is a patch that addresses several issues at once:
- fixes uc_tablequote_quote function signature
- adds autopoietic's patch (see above)
- adds #461444: Spelling mistake in module patch
- allows ranges like 'from 50kg to 60kg' next to 'from 60kg to 70kg', without complaining about them overlapping: min value is inclusive, max value is exclusive.
- fixes indentation, converting tabs to spaces
- fixes the critical #768924: Security bug: Module does not check any limit

anrikun’s picture

These changes have been committed to the new 6.x-2.x-dev (http://drupal.org/node/772292).

plach’s picture

These changes have been committed to the new 6.x-2.x-dev

Should not the issue status be changed to fixed then?

anrikun’s picture

Status: Needs review » Fixed

You're right! :-)

Status: Fixed » Closed (fixed)

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