uc_quote.api.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <?php
  2. /**
  3. * @file
  4. * Hooks provided by the Shipping Quotes module.
  5. */
  6. /**
  7. * @addtogroup hooks
  8. * @{
  9. */
  10. /**
  11. * Defines callbacks and service options for shipping methods.
  12. *
  13. * @return
  14. * An array of shipping methods, keyed by the unique method ID, and with the
  15. * following members:
  16. * - id: The unique method ID, the same as the array key for this method.
  17. * - module: The name of the implementing module.
  18. * - title: The shipping method title.
  19. * - description: (optional) A short description of the shipping method.
  20. * - operations: (optional) A set of links that can be used to edit or
  21. * configure the shipping method, suitable for passing to theme_links().
  22. * - quote: (optional) An associative array, with the following members:
  23. * - type: The quote and shipping types are ids of the product shipping type
  24. * that these methods apply to. type may also be 'order' which indicates
  25. * that the quote applies to the entire order, regardless of the shipping
  26. * types of its products. This is used by quote methods that are based on
  27. * the location of the customer rather than their purchase.
  28. * - callback: The function that is called by uc_quote when a shipping quote
  29. * is requested. Its arguments are the array of products and an array of
  30. * order details (the shipping address). The return value is an array
  31. * representing the rates quoted and errors returned (if any) for each
  32. * option in the accessorials array.
  33. * - file: (optional) The name of the file that contains the callback
  34. * function.
  35. * - accessorials: This array represents the different options the customer
  36. * may choose for their shipment. The callback function should generate a
  37. * quote for each option in accessorials and return them via an array.
  38. * @code
  39. * return array(
  40. * '03' => array('rate' => 15.75, 'option_label' => t('UPS Ground'),
  41. * 'error' => 'Additional handling charge applied.'),
  42. * '14' => array('error' => 'Invalid package type.'),
  43. * '59' => array('rate' => 26.03, 'option_label' => t('UPS 2nd Day'))
  44. * );
  45. * @endcode
  46. * - pkg_types: The list of package types that the shipping method can
  47. * handle. This should be an associative array that can be used as the
  48. * #options of a select form element. It is recommended that a function
  49. * be written to output this array so the method doesn't need to be found
  50. * just for the package types.
  51. * - ship: (optional) An associative array, in the same format as 'quote'.
  52. * - enabled: (optional) Whether the method should be enabled by default.
  53. * Defaults to FALSE.
  54. * - weight: (optional) The default position of the method in the list of
  55. * shipping quotes. Defaults to 0.
  56. */
  57. function hook_uc_shipping_method() {
  58. $methods = array();
  59. $methods['ups'] = array(
  60. 'id' => 'ups',
  61. 'title' => t('UPS'),
  62. 'quote' => array(
  63. 'type' => 'small package',
  64. 'callback' => 'uc_ups_quote',
  65. 'accessorials' => array(
  66. '03' => t('UPS Ground'),
  67. '11' => t('UPS Standard'),
  68. '01' => t('UPS Next Day Air'),
  69. '13' => t('UPS Next Day Air Saver'),
  70. '14' => t('UPS Next Day Early A.M.'),
  71. '02' => t('UPS 2nd Day Air'),
  72. '59' => t('UPS 2nd Day Air A.M.'),
  73. '12' => t('UPS 3-Day Select'),
  74. ),
  75. ),
  76. 'ship' => array(
  77. 'type' => 'small package',
  78. 'callback' => 'uc_ups_fulfill_order',
  79. 'pkg_types' => array(
  80. '01' => t('UPS Letter'),
  81. '02' => t('Customer Supplied Package'),
  82. '03' => t('Tube'),
  83. '04' => t('PAK'),
  84. '21' => t('UPS Express Box'),
  85. '24' => t('UPS 25KG Box'),
  86. '25' => t('UPS 10KG Box'),
  87. '30' => t('Pallet'),
  88. ),
  89. ),
  90. );
  91. return $methods;
  92. }
  93. /**
  94. * Defines shipping types for shipping methods.
  95. *
  96. * This hook defines a shipping type that this module is designed to handle.
  97. * These types are specified by a machine- and human-readable name called 'id',
  98. * and 'title' respectively. Shipping types may be set for individual products,
  99. * manufacturers, and for the entire store catalog. Shipping modules should be
  100. * careful to use the same shipping type ids as other similar shipping modules
  101. * (i.e., FedEx and UPS both operate on "small package" shipments). Modules that
  102. * do not fulfill orders may not need to implement this hook.
  103. *
  104. * @return
  105. * An array of shipping types keyed by a machine-readable name.
  106. */
  107. function hook_uc_shipping_type() {
  108. $weight = variable_get('uc_quote_type_weight', array('small_package' => 0));
  109. $types = array();
  110. $types['small_package'] = array(
  111. 'id' => 'small_package',
  112. 'title' => t('Small package'),
  113. 'weight' => $weight['small_package'],
  114. );
  115. return $types;
  116. }
  117. /**
  118. * @} End of "addtogroup hooks".
  119. */