You are here

function commerce_shipping_rates_cache_get in Commerce Shipping 7.2

Retrieves cached shipping rates for an order.

Parameters

string $method: The name of the shipping method the rates are being cached for.

object $order: The order the rates were calculated for.

int $timeout: Number of seconds after which cached rates should be considered invalid. Defaults to 0, meaning cached rates are only good for the current page request.

Return value

array|bool A cached array of base rate price arrays keyed by shipping service name or FALSE if no cache existed or the cache is invalid based on the timeout parameter if specified.

File

./commerce_shipping.module, line 699
Defines a system for calculating shipping costs associated with an order.

Code

function commerce_shipping_rates_cache_get($method, $order, $timeout = 0) {
  $cache = cache_get($order->order_id . ':' . $method, 'cache_commerce_shipping_rates');

  // If no data was retrieved, return FALSE.
  if (empty($cache)) {
    return FALSE;
  }

  // If a timeout value was specified...
  if ($cache->created < REQUEST_TIME - $timeout) {
    return FALSE;
  }
  return $cache->data;
}