You are here

function commerce_multicurrency_commerce_cart_line_item_refresh in Commerce Multicurrency 7

Implements hook_commerce_cart_line_item_refresh().

File

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

Code

function commerce_multicurrency_commerce_cart_line_item_refresh($line_item, $order_wrapper) {
  $line_item_wrapper = entity_metadata_wrapper('commerce_line_item', $line_item);
  $currency_code = commerce_multicurrency_get_user_currency_code();
  if ($line_item_wrapper->commerce_total->currency_code
    ->value() != $currency_code) {
    $amount = commerce_currency_convert($line_item_wrapper->commerce_total->amount
      ->value(), $line_item_wrapper->commerce_total->currency_code
      ->value(), $currency_code);
    $line_item_wrapper->commerce_total->amount = $amount;
    $line_item_wrapper->commerce_total->currency_code = $currency_code;
  }
}