You are here

function hook_uc_shipping_method in Ubercart 7.3

Defines callbacks and service options for shipping methods.

Return value

An array of shipping methods, keyed by the unique method ID, and with the following members:

  • id: The unique method ID, the same as the array key for this method.
  • module: The name of the implementing module.
  • title: The shipping method title.
  • description: (optional) A short description of the shipping method.
  • operations: (optional) A set of links that can be used to edit or configure the shipping method, suitable for passing to theme_links().
  • quote: (optional) An associative array, with the following members:
    • type: The quote and shipping types are ids of the product shipping type that these methods apply to. type may also be 'order' which indicates that the quote applies to the entire order, regardless of the shipping types of its products. This is used by quote methods that are based on the location of the customer rather than their purchase.
    • callback: The function that is called by uc_quote when a shipping quote is requested. Its arguments are the array of products and an array of order details (the shipping address). The return value is an array representing the rates quoted and errors returned (if any) for each option in the accessorials array.
    • file: (optional) The name of the file that contains the callback function.
    • accessorials: This array represents the different options the customer may choose for their shipment. The callback function should generate a quote for each option in accessorials and return them via an array.
return array(
  '03' => array(
    'rate' => 15.75,
    'option_label' => t('UPS Ground'),
    'error' => 'Additional handling charge applied.',
  ),
  '14' => array(
    'error' => 'Invalid package type.',
  ),
  '59' => array(
    'rate' => 26.03,
    'option_label' => t('UPS 2nd Day'),
  ),
);
  • pkg_types: The list of package types that the shipping method can handle. This should be an associative array that can be used as the #options of a select form element. It is recommended that a function be written to output this array so the method doesn't need to be found just for the package types.
  • ship: (optional) An associative array, in the same format as 'quote'.
  • enabled: (optional) Whether the method should be enabled by default. Defaults to FALSE.
  • weight: (optional) The default position of the method in the list of shipping quotes. Defaults to 0.
4 functions implement hook_uc_shipping_method()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

uc_flatrate_uc_shipping_method in shipping/uc_flatrate/uc_flatrate.module
Implements hook_uc_shipping_method().
uc_ups_uc_shipping_method in shipping/uc_ups/uc_ups.module
Implements hook_uc_shipping_method().
uc_usps_uc_shipping_method in shipping/uc_usps/uc_usps.module
Implements hook_uc_shipping_method().
uc_weightquote_uc_shipping_method in shipping/uc_weightquote/uc_weightquote.module
Implements hook_uc_shipping_method().
13 invocations of hook_uc_shipping_method()
uc_quote_condition_order_shipping_method in shipping/uc_quote/uc_quote.rules.inc
Checks an order's shipping method.
uc_quote_condition_order_shipping_method_options in shipping/uc_quote/uc_quote.rules.inc
Options callback.
uc_quote_default_rules_configuration in shipping/uc_quote/uc_quote.rules_defaults.inc
Implements hook_default_rules_configuration().
uc_quote_methods in shipping/uc_quote/uc_quote.module
Returns an array of available shipping quote methods.
uc_quote_method_settings in shipping/uc_quote/uc_quote.admin.inc
Settings for the shipping quote methods.

... See full list

File

shipping/uc_quote/uc_quote.api.php, line 60
Hooks provided by the Shipping Quotes module.

Code

function hook_uc_shipping_method() {
  $methods = array();
  $methods['ups'] = array(
    'id' => 'ups',
    'title' => t('UPS'),
    'quote' => array(
      'type' => 'small package',
      'callback' => 'uc_ups_quote',
      'accessorials' => array(
        '03' => t('UPS Ground'),
        '11' => t('UPS Standard'),
        '01' => t('UPS Next Day Air'),
        '13' => t('UPS Next Day Air Saver'),
        '14' => t('UPS Next Day Early A.M.'),
        '02' => t('UPS 2nd Day Air'),
        '59' => t('UPS 2nd Day Air A.M.'),
        '12' => t('UPS 3-Day Select'),
      ),
    ),
    'ship' => array(
      'type' => 'small package',
      'callback' => 'uc_ups_fulfill_order',
      'pkg_types' => array(
        '01' => t('UPS Letter'),
        '02' => t('Customer Supplied Package'),
        '03' => t('Tube'),
        '04' => t('PAK'),
        '21' => t('UPS Express Box'),
        '24' => t('UPS 25KG Box'),
        '25' => t('UPS 10KG Box'),
        '30' => t('Pallet'),
      ),
    ),
  );
  return $methods;
}