You are here

function uc_quote_condition_order_shipping_method in Ubercart 6.2

Same name and namespace in other branches
  1. 5 shipping/uc_quote/uc_quote.module \uc_quote_condition_order_shipping_method()
  2. 7.3 shipping/uc_quote/uc_quote.rules.inc \uc_quote_condition_order_shipping_method()

Checks an order's shipping method.

See also

uc_quote_condition_order_shipping_method_form()

1 string reference to 'uc_quote_condition_order_shipping_method'
uc_quote_ca_condition in shipping/uc_quote/uc_quote.module
Implements hook_ca_condition().

File

shipping/uc_quote/uc_quote.module, line 340
The controller module for fulfillment modules that process physical goods.

Code

function uc_quote_condition_order_shipping_method($order, $settings) {

  // Check the easy way first.
  if (is_array($order->quote)) {
    return $order->quote['method'] == $settings['method'];
  }

  // Otherwise, look harder.
  if (is_array($order->line_items)) {
    $methods = module_invoke_all('shipping_method');
    $accessorials = $methods[$settings['method']]['quote']['accessorials'];
    foreach ($order->line_items as $line_item) {
      if ($line_item['type'] == 'shipping' && in_array($line_item['title'], $accessorials)) {
        return TRUE;
      }
    }
  }
  return FALSE;
}