function commerce_shipping_method_collect_rates in Commerce Shipping 7.2
Collects available shipping services of the specified method for an order.
This function is typically called via the Rules action "Collect rates for a shipping method" attached to a default Rule.
Parameters
string $method: The machine-name of the shipping method whose services should be collected.
object $order: The order to which the services should be made available.
1 string reference to 'commerce_shipping_method_collect_rates'
File
- ./
commerce_shipping.module, line 539 - Defines a system for calculating shipping costs associated with an order.
Code
function commerce_shipping_method_collect_rates($method, $order) {
// Load all the rule components.
$components = rules_get_components(FALSE, 'action');
// Loop over each shipping service in search of matching components.
foreach (commerce_shipping_services() as $name => $shipping_service) {
// If the current service matches the method and specifies
// a default component...
if ($shipping_service['shipping_method'] == $method && $shipping_service['rules_component']) {
$component_name = 'commerce_shipping_service_' . $name;
// If we found the current service's component...
if (!empty($components[$component_name])) {
// Invoke it with the order.
rules_invoke_component($component_name, $order);
}
}
}
// Allow modules handling shipping service calculation on their own to return
// services for this method, too.
module_invoke_all('commerce_shipping_method_collect_rates', $method, $order);
}