You are here

function commerce_multicurrency_sync_exchange_rates_now in Commerce Multicurrency 7

Function to trigger the currency exchange rate synchronization.

1 call to commerce_multicurrency_sync_exchange_rates_now()
commerce_multicurrency_conversion_settings_form_submit in ./commerce_multicurrency.admin.inc
Submit handler for the conversion settings form.

File

./commerce_multicurrency.module, line 294
Enhancements for the commerce currency support.

Code

function commerce_multicurrency_sync_exchange_rates_now() {
  $queue = DrupalQueue::get('commerce_multicurrency_sync_exchange_rates');
  $queue
    ->createQueue();
  commerce_multicurrency_cron();

  // Build batch.
  $batch = array(
    'title' => t('Synchronize currency exchange rates.'),
    'operations' => array(),
    'init_message' => t('Synchronisation is starting.'),
    'progress_message' => t('Processed @current out of @total currencies.'),
    'error_message' => t('Synchronisation has encountered an error.'),
    'file' => drupal_get_path('module', 'commerce_multicurrency') . '/commerce_multicurrency.module',
  );

  // Register queue items to process in batch.
  while ($item = $queue
    ->claimItem()) {
    $batch['operations'][] = array(
      'commerce_multicurrency_sync_exchange_rates',
      array(
        $item->data,
      ),
    );
  }
  $queue
    ->deleteQueue();
  batch_set($batch);
}