Quote Method Callbacks

Shipping methods return shipping rates through the use of a callback function. This function receives the customer and product details that are needed to give an accurate quote. The function foot print looks like this:
function uc_ups_quote($products, $details);
The products in the $products array contain data as the $order object sees it, not like the {uc_product} table. This basically means that the model number, price, and weight have been changed by the customer's attribute choices by the time the quote system sees them. Any other modules that affect a product's data when it is added to the cart have also already made their changes. $details is a copy of the data that is currently in the Delivery Information pane. It is in the standard Ãœbercart address format, which contains the following keys.
  • first_name
  • last_name
  • company
  • street1
  • street2
  • city
  • zone*
  • postal_code
  • country*
  • phone
* These elements are passed as the zone_id or country_id, so use uc_get_zone_code() or uc_get_country_data() to get human-readable data. The quote callback should return an array of shipping quotes. The keys of the array aren't important to the Quote system, but it is useful if they are the corresponding keys to the method's accessorials. This helps keep track of the shipping options that the customer requests. Each quote contains information that the quote system can use to build a selection form for the customer.
Key Type Description
rate* float The numeric amount that will charged as the shipping cost to the customer, in the store's currency. If an error occurs and a rate is not available, rate, format, and option_label are not required.
format* string Drupal functions can't be called from Javascript, so call uc_currency_format($rate) here. This will be displayed as the amount to be charged as the shipping cost.
option_label* string The localized description of the shipping service. This may be as simple as "Shipping Rate", or contain a company's logo and the description of the accessorial.
error* string Errors that are generated in the process of getting a quote may be passed on to the customer, or sent to the error log. The rate and error keys are not mutually exclusive, but at least one must be present in each quote.
debug* string This value can be used to ensure that the method module is receiving the correct information. Because sensitive information like account numbers or passwords can be accidentally included, make sure you only add this key for users with the "configure quotes" permission.
* Key is optional.