You are here

function commerce_shipping_get_shipping_methods_options in Commerce Shipping 7

Return an array of enabled shipping methods formatted as an options array used in FAPI.

Return value

array of shipping methods.

1 call to commerce_shipping_get_shipping_methods_options()
commerce_shipping_line_item_add_form in ./commerce_shipping.module
Returns the elements necessary to add a shipping line item through a line item manager widget.
1 string reference to 'commerce_shipping_get_shipping_methods_options'
commerce_shipping_line_item_configuration in ./commerce_shipping.module
Ensures the shipping line item type contains a field for shipping method.

File

./commerce_shipping.module, line 151
Defines the shipping system and checkout integration.

Code

function commerce_shipping_get_shipping_methods_options() {
  $options = array();

  // Create a fake order that can be used to attach the shipping methods to.
  $order = commerce_order_new();
  $order->commerce_shipping_methods = array();
  rules_invoke_all('commerce_shipping_methods', $order);
  foreach ($order->commerce_shipping_methods as $instance_id => $shipping_method) {
    $options[$instance_id] = $shipping_method['label'];
  }
  return $options;
}