You are here

public function CommerceGuysMarketplaceAddonManager::getPromotions in Commerce Guys Marketplace 7

Returns an array of all defined addon promotions.

Parameters

$reset: Boolean indicating whether or not the cache should be reset, causing data to be refetched from the remote service.

Return value

An array of promotions.

File

includes/commerceguys_marketplace.addon.inc, line 131

Class

CommerceGuysMarketplaceAddonManager
Defines the manager class for interacting with remote marketplace addons.

Code

public function getPromotions($reset = FALSE) {
  if (!$reset && ($cached_data = cache_get('marketplace_addon_promotions'))) {
    $promotions = $cached_data->data;
  }
  else {
    $response = drupal_http_request($this->endpoint . '/addon_promotions');
    $promotions = json_decode($response->data);
    cache_set('marketplace_addon_categories', $promotions, CACHE_TEMPORARY);
  }
  return $promotions;
}