Rate Quote Shipping Module


Assigns a shipping rate based on order total. Define ranges of total price and a shipping quote for the ranges.

To install, unzip the attached zip file under your modules folder, and enable the Rate Quote module here...

then enable the Rate Quote Shipping Method here...

and define your shipping quotes here...

Example: to give free shipping to orders of $100 or more. define a range $0.00 to $99.99 and give it your regular flat shipping rate, then define another range from $100 to a very large number (like $1000000) and set the shipping rate to 0.

uc_ratequote.zip3.3 KB
Chad_Dupuis@drupal.org's picture
Joined: 08/28/2007
Juice: 57
Re: Rate Quote Shipping Module

Thank you for this module David! It seems to work well. I wonder if this should be rolled into the main package download and/or into the flat rate quote module as additional functionality. When I downloaded the flat rate module I just assumed that you could set multiple flat rates based on order totals or total weight which you cannot - at this time anyhow. In my mind, there are very few instances where a single flat rate for an entire store is all that useful.

spiderman's picture
Bug FinderGetting busy with the Ubercode.
Joined: 08/17/2007
Juice: 61
alpha7c update

seems that the shipping_method callback methods now (as of alpha7c) expect a slightly different return value. i had to patch my ratequote module in the uc_ratequote_quote and uc_ratequote_quote_order functions, making this simple change:

-  return drupal_to_js($quotes);
+  return
spiderman's picture
Bug FinderGetting busy with the Ubercode.
Joined: 08/17/2007
Juice: 61
patch: support for percentage-based tables

this module has proven extremely useful in working through a fairly complex table-based shipping rates scenario for a soon-to-be-live site i've been working on.

attached is a patch which extends the basic functionality of the module to support percentage-based shipping rates in the table. the feature is very simplistic, merely adding a 'percent' field to the table entries, which gets used if the 'amount' is left blank (0):

-ur orig/uc_ratequote/uc_ratequote.install uc_ratequote/uc_ratequote.install
--- orig/uc_ratequote/uc_ratequote.install      2007-08-02 12:32:04.000000000 -0400
+++ uc_ratequote/uc_ratequote.install   2007-09-17 01:50:30.000000000 -0400
@@ -9,7 +9,8 @@
min` float NOT NULL default '0',
max` float NOT NULL default '0',
-        `
rate` float NOT NULL default '0'
+        `rate` float NOT NULL default '0',
+       `
percent` float NOT NULL default '0'
) /*!40100 DEFAULT CHARACTER SET UTF8 */ ;");
     case 'pgsql':
@@ -19,3 +20,9 @@
function uc_ratequote_uninstall(){
DROP TABLE IF EXISTS {uc_ratequotes}");
+function uc_ratequote_update_1() {
$items = array();
$items[] = update_sql("ALTER TABLE add percent float NOT NULL default '0'");
+  return
diff -ur orig/uc_ratequote/uc_ratequote.module uc_ratequote/uc_ratequote.module
--- orig/uc_ratequote/uc_ratequote.module       2007-08-01 14:49:08.000000000 -0400
+++ uc_ratequote/uc_ratequote.module    2007-09-17 01:55:29.000000000 -0400
@@ -142,6 +142,12 @@
     '#field_prefix' => variable_get('uc_sign_after_amount', FALSE) ? '' : variable_get('uc_currency_sign', '$'),
     '#field_suffix' => variable_get('uc_sign_after_amount', FALSE) ? variable_get('uc_currency_sign', '$') : '',
$form['uc_ratequote']['uc_ratequote_order_percent'] = array('#type' => 'textfield',
+    '#title' => t('Shipping Percentage'),
+    '#default_value' => variable_get('uc_ratequote_order_percent', 0),
+    '#size' => 12,
+    '#field_suffix' => variable_get('uc_percentage_sign', '%'),
+  );
$form['buttons']['submit'] = array('#type' => 'submit', '#value' => t('Submit Changes') );
@@ -153,8 +159,9 @@
     form_set_error('uc_ratequote_order_minimum', t('Order Minimum must be a number not less than 0.'));
   if (
$form_values['uc_ratequote_order_maximum'] < 0 || !is_numeric($form_values['uc_ratequote_order_maximum']))
     form_set_error('uc_ratequote_order_maximum', t('Order Maximum must be a number greater than 0.'));
-  if (
$form_values['uc_ratequote_order_rate'] < 0 || !is_numeric($form_values['uc_ratequote_order_rate']))
-    form_set_error('uc_ratequote_order_rate', t('Shipping rate must be a number not less than 0.'));
+  if ( (
$form_values['uc_ratequote_order_rate'] < 0 && $form_values['uc_ratequote_order_percent'] < 0) ||
+       (!is_numeric(
$form_values['uc_ratequote_order_rate']) && !is_numeric($form_values['uc_ratequote_order_percent'])) )
+    form_set_error('uc_ratequote_order_rate', t('Shipping rate or percent must be a number not less than 0.'));
   // check that max is bigger than min
   if (
$form_values['uc_ratequote_order_maximum'] < $form_values['uc_ratequote_order_minimum'])
@@ -182,23 +189,25 @@
   // check for and insert new rate quote
   if (
$form_values['uc_ratequote_order_maximum'] > $form_values['uc_ratequote_order_minimum'] && $form_values['uc_ratequote_order_maximum'] > 0){
-    db_query("
INSERT INTO {uc_ratequotes} (min, max, rate) VALUES (%f, %f, %f)", $form_values['uc_ratequote_order_minimum'], $form_values['uc_ratequote_order_maximum'], $form_values['uc_ratequote_order_rate']);
+    db_query("
INSERT INTO {uc_ratequotes} (min, max, rate, percent) VALUES (%f, %f, %f, %f)", $form_values['uc_ratequote_order_minimum'], $form_values['uc_ratequote_order_maximum'], $form_values['uc_ratequote_order_rate'], $form_values['uc_ratequote_order_percent']);
   drupal_set_message(t('The configuration options have been saved.'));

function theme_uc_ratequote_admin_settings(

$header = array(t('Delete'), t('Order Minimum'), t('Order Maximum'), t('Shipping Rate'));
$header = array(t('Delete'), t('Order Minimum'), t('Order Maximum'), t('Shipping Rate'), t('Shipping Percentage'));
$result = db_query("SELECT * FROM {uc_ratequotes} ORDER BY min");
   while (
$r = db_fetch_object($result)) {
$row = array();
$qid = $r->qid;
$r->rate > 0 ? $rate = uc_currency_format($r->rate) : $rate = 'Free';
$r->percent > 0 ? $percent = $r->percent . "%" : $percent = 'Free';
$row[] = drupal_render($form['rates'][$qid]['delete']);
$row[] = uc_currency_format($r->min);
$row[] = uc_currency_format($r->max);
$row[] = $rate;
$row[] = $percent;
$rows[] = $row;
$output .= theme('table', $header, $rows);
@@ -234,22 +243,35 @@
$result = db_query("SELECT * FROM {uc_ratequotes}");
   while (
$r = db_fetch_object($result)) {
-    if(
$total <= $r->max && $total >= $r->min)
+    if(
$total <= $r->max && $total >= $r->min) {
$rate = $r->rate;
$percent = $r->percent;
+# debug
+#      ob_start(); print_r(
+#      drupal_set_message(ob_get_contents());
+#      ob_end_clean();
+    }
$method = uc_ratequote_shipping_method();
$quotes[] = array('rate' => $rate, 'format' => uc_currency_format($rate), 'option_label' => $method['ratequote']['quote']['accessorials'][0]);
+  if (
$rate > 0) {
$quotes[] = array('rate' => $rate, 'format' => uc_currency_format($rate), 'option_label' => $method['ratequote']['quote']['accessorials'][0]);
+  } else {
$rate = $total * ($percent / 100);
$quotes[] = array('rate' => $rate, 'format' => uc_currency_format($rate), 'option_label' => $method['ratequote']['quote']['accessorials'][0]);
+  }

+# unused? mebbe not..
function uc_ratequote_quote_order(

$products, $details){
$method = uc_ratequote_shipping_method();
$rate = variable_get('uc_ratequote_order_rate', 0);
$percent = variable_get('uc_ratequote_order_percent', 0);
$quotes[] = array('rate' => $rate, 'format' => uc_currency_format($rate), 'option_label' => $method['order_rate']['quote']['accessorials'][0]);
-  return drupal_to_js(

please excuse the debug info, and the (possibly?) crufty bits leftover from the alpha7c updates..

uc_ratequote.percentage.diff 5.73 KB
spiderman's picture
Bug FinderGetting busy with the Ubercode.
Joined: 08/17/2007
Juice: 61
patch: adding accessorials for multiple shipping methods

here's some critical feedback on the ratequote module, but also on the shipping API in general, and how it could work better. this is based on our experience implementing the shipping quotes feature for SCW, who have an existing set of options used by customers ordering through their catalog.

DISCLAIMER: the following patch is a one-off solution to the requirements of the client we built this site for! DO NOT apply this patch unless you understand how to subsequently modify the relevant code to apply to your site! Also note that the patch was rolled after the one above which adds percentage-based rates, so you may have to tweak it manually if you are not using that patch.

the ratequote module posted above did most of what we needed, except for the option of calculating percentage-based rates for certain ranges, and also offering multiple shipping options, including Rush/Overnight as well as different rates for Canada and International shipping addresses. The final thing we needed was integration with the discounts module.

to accomplish this, i added elements to the array of 'accessorials' provided by the module (see hook_shipping_method, one for each available shipping option. then in the "quote" callback, we determine which methods apply (based on the country of the delivery address), and return an array of quotes based on these.

the quotes themselves are all based on the table rates defined by the module, but all the "nonstandard" options have a fixed rate added to this (+$15 for Rush, +$30 for Overnight, +$12 for Canada, +$40 for Int'l). in the case of US-based shipping, customers are provided 3 different options, whereas Canada/International don't have rush/overnight options.

important to note here is that the new per-country functionality implemented in the alpha7c updates to the shipping methods API/UI was not so useful to us, since it did not allow us to define a group of countries as "other" for the International shipping rates (ie. anything that's not Canada/US). also, the geoshipping module looks promising, but didn't provide the core "table rate" functionality we needed from this module.

ideally, this would be accomplished in a more elegant/abstract way, so that the administrator could define the different 'accessorial' options, and their effect. at base, being able to add a fixed amount to the table rate would be good; being able to define different table rates per option would be better. also, the admin should be able to define "regions" and then map these different options onto them at the more fine-grained level, rather than at the level of the entire quote module.

finally, the attached patch adds a bit of code to calculate the shipping rate on the order total *after* discounts are applied. again, this is a specific requirement of the SCW site, and should probably be a configurable weight/ordering feature, if the discounts module is enabled. this bit of code was stolen from here, and seems to work nicely so far.

anyway, we hope this proves useful to somebody, and welcome feedback, especially in terms of alternative approaches or ways to integrate these ideas into ubercart/uc_ratequote going forward. i noticed as i was writing this that there's a new worldquotes module released which appears to do some of what we wanted here- the question still seems to be integrating the two (apparently) different methods in the way we've accomplished here. Smiling

uc_ratequote.ubercart.diff 3.46 KB
webmasterkai's picture
Uber DonorBug Finder
Joined: 08/09/2007
Juice: 302
Updated Quote Module on the way

We will be applying the above patches and features as much as possible for a new version. Stay tuned, in the next day or so.

webmasterkai's picture
Uber DonorBug Finder
Joined: 08/09/2007
Juice: 302
updated module

I forgot to post the updated module.

uc_ratequote.zip 9.32 KB
spiderman's picture
Bug FinderGetting busy with the Ubercode.
Joined: 08/17/2007
Juice: 61
anybody using ratequote with alpha8 or beyond?

i've finally gotten around to updating our site to alpha8 (trying to catch up to beta7!), and have found myself stuck trying to get the ratequote module to behave nicely with the new workflow_ng module integration. has anyone been able to make this work?

following lyle's suggestion, i've stolen the uc_usps_configuration hook and replaces usps with ratequote, but when i go to the checkout, i see no quote methods returned. any hints or insight on how to debug this or what might be going wrong here are greatly appreciated!

i promise to post a fresh and working copy of the module when i get these issues sorted out!


spydor@drupal.org's picture
Joined: 01/19/2008
Juice: 50
Fix quotes for kits and other

This module is great. I'm testing it out on D5, UC1rc4.

The way it was set up, it was doing a node_load and then pulling the "sell_price" from the nodes. This didn't work for me as the total was off when kits were in the cart and thus shipping was off.

I changed some of the logic to just use the price * qty. This gives me the correct shipping quote on both kits and regular products.

I also moved the logic from PHP to SQL to get the rate within the min/max parameters. This seems to work for me, your feedback would be very welcomed.


uc_ratequote_fixkits.diff 1.51 KB
oliver coleman's picture
Bug Finder
Joined: 01/09/2008
Juice: 212

Tried using the latest version (http://www.ubercart.org/contrib/355#comment-5313) in Drupal 5.5 with Ubercart 1.0RC4 with two options:

min     max         flat  percent
0.00    99.99       5     0
100.00  1000000.00  0     0

However it would only ever pick the first option regardless of the order total.

Interestingly, after applying the patch in http://www.ubercart.org/contrib/355#comment-17550 it now works.

freixas's picture
Getting busy with the Ubercode.
Joined: 05/06/2008
Juice: 119
A fix? Maybe someone can explain this to me...


I'm setting up a store where the only shipping method is Rate Quote. I'm using ubercart-5.x-1.0-rc4 with Rate Quote 1.01. When I tried placing my first order and pressing "Click to calculate shipping", I kept getting a vague error. Flat rate shipping worked, so I started comparing the two modules.

One thing that was missing was a section called Workflow-ng hooks. I took the code out of the flat rate module and modified it for the rate quote module and I got my shipping quotes to come out. To be honest, I don't know what exactly all this code does, I just narrowed the problem area and make a reasonable guess at adapting the code. Here's what I added to uc_ratequote.module in case it helps anyone else out. Also in case this is not the best solution Smiling

 * Workflow-ng Hooks                                                          *

 * Implementation of hook_configuration().
 * Connect the quote action with the quote event.
function uc_ratequote_configuration() {
  $enabled = variable_get('uc_quote_enabled', array());
  $configurations = array();
  $action = workflow_ng_use_action('uc_quote_action_get_quote', array(
    '#label' => t('Fetch a shipping quote'),

  $configurations['uc_ratequote_get_quote'] = array(
      '#label' => t('Shipping quote via Rate Quote Shipping'),
      '#event' => 'get_quote_from_ratequote',
      '#module' => 'uc_ratequote',
      '#active' => $enabled['ratequote'],
  $configurations['uc_ratequote_get_quote'] = workflow_ng_configure($configurations['uc_ratequote_get_quote'], $action);

  return $configurations;

goodeit's picture
Joined: 05/28/2008
Juice: 321
Re: Rate Quote Shipping Module

This module works fine for me, Ubercart 1.0, Ratequote 1.01 with the shipping percentage patch, and the new uc_ratequote_configuration() {not sure if it made a difference).


If anyone is looking for an easy way to do BOTH flat rate AND a percentage fee, after applying the patch, open uc_ratequote.module and starting at line 287 comment out the if/else statements and add "$rate + " to the front of the $rate = declaration.

CODE (bold text is what is not commented):
# if ($rate > 0) {
# $quotes[] = array('rate' => $rate, 'format' => uc_currency_format($rate), 'option_label' => $method['ratequote']['quote']['accessorials'][0]);
# } else {
# $rate = $total * ($percent / 100);
$rate = $rate + ( $total * ($percent / 100) );
$quotes[] = array('rate' => $rate, 'format' => uc_currency_format($rate), 'option_label' => $method['ratequote']['quote']['accessorials'][0]);

# }

enli's picture
Joined: 07/25/2008
Juice: 2
module working fine for me

I'm using this contrib's version posted by webmasterkai on Tue, 10/23/2007, with drupal 5.9 and ubercart 5.x-1.0.

Unfortunately I couldn't get the module to work, since I got the following error, when I try to put Order Minimum: € 0.00, Order Maximum: € 49.99, Shipping Rate: € 10.00, Shipping Percentage: % 0. For Euro values, it is ok to use the decimal separator "."; I am also getting errors in the Checkout Page:

user warning: Unknown column 'percent' in 'field list' query: INSERT INTO shop_uc_ratequotes (min, max, rate, percent) VALUES (0, 49.99, 10, 0) in /var/www/vhosts/mywebsite.com/subdomains/shop/httpdocs/includes/database.mysql.inc on line 172.

I had a previous version of this module installed and forgot running update.php. So the problem was solved running update.php. Module is now working fine.

fmrandd's picture
Joined: 09/04/2008
Juice: 21
I must be missing something...

I don't even see the percentage field on the Rate Quote page. What am I forgetting to do? I have uploaded the files to the modules folder, and when I went to the update.php file, it says there are no updates available for this module.

Any suggestions?

fmrandd's picture
Joined: 09/04/2008
Juice: 21
Umm...yeah...about that...

I had enabled the Flat Rate module instead of the Rate Quote module. Working like a charm for me now. Sticking out tongue

doomed@drupal.org's picture
Bug Finder
Joined: 04/05/2008
Juice: 334
Whats the current status?

Whats the current status on this module?

Last time i used it, it needed patching and whatnot. But this was May 2008, and ubercart was still on RC4 or RC5.

Did anything change?

adrpo's picture
Joined: 06/21/2010
Juice: 60
Re: Rate Quote Shipping Module

Where can I find Drupal 6 version for this module? Ubercart Percent Rate with Minimum Rate quotations are not reliable jet.