Hi,

I am not still sure how to modify currency sign for different languages. Is there anything like hook for uc_currency_format?

In the meanwhile, I would like to use variables uc_currency_code, uc_currency_sign... as multilangual variables. I wrote a small piece code. I was wondering whether it would possible to implement it into uc_store.

file uc_store.module
/**
 * Implements hook_init().
 */
function uc_store_init() {

.....
	
  $conf['i18n_variables'][] = 'uc_currency_code';
  $conf['i18n_variables'][] = 'uc_currency_sign';
  $conf['i18n_variables'][] = 'uc_currency_thou';
  $conf['i18n_variables'][] = 'uc_currency_dec';
  $conf['i18n_variables'][] = 'uc_currency_prec';
  $conf['i18n_variables'][] = 'uc_sign_after_amount';
}

I wrote some code which connects mentioned variables with module Variable.

Comments

tr’s picture

Those should not be multilingual variables. Language has little or no correspondence to currency. For example, what currency should be associated with English? USD, CAD, GBP, EUR ? All of those, and more, are in use in English-speaking countries.

MPeli’s picture

Category: feature » support

Ok, I understand.

The best way would be to create a custom module. I still can not figure out how to change currency in a custom module. Is there anything like hook for uc_currency_format? Or what approach should I use?

Thanks, Martin.

MPeli’s picture

I might get it. I assume that with this approach I can alter sign and price of all products.

/**
 * Implements hook_node_load().
 */
function NAME_OF_MY_MODULE_node_load($nodes, $types) {
	$language = $GLOBALS['language']->language;
	
	if($language == 'en') {
		$variables['uc_currency_code'] = 'EUR';
		$variables['uc_currency_sign'] = '€';
		$variables['uc_currency_thou'] = ' ';
		$variables['uc_currency_dec'] = ',';
		$variables['uc_currency_prec'] = '2';
		$variables['uc_sign_after_amount'] = 1;

 		variable_realm_switch('currency', 'eur', $variables);
	
		// increase price by 1000
		foreach($nodes as $key => $value) {
			if(isset($value->price)) {
				$nodes[$key]->price += 1000;
				$nodes[$key]->sell_price += 1000;
			}
		}
	}
}

Requires Variable module. I hope it helps.

longwave’s picture

Status: Active » Fixed

As noted this isn't the right approach for true multicurrency, but this might work for some cases as an stopgap solution.

MPeli’s picture

StatusFileSize
new5.38 KB
new156.47 KB

Hi,

I have put together a small multicurrency module. It allows you to assign a currency for each language. I hope it will inspire somebody to create a real multicurrency module.

Martin.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

BenLalleke’s picture

Status: Closed (fixed) » Active

Hello Martin,

I'm trying to implement your solution as a workaround for the missing multicurrency problem in drupal 7. I installed en enabled the module (also the variable and variable_realm modules) and changed the settings.. I have two languages in my website, for test purposes I assigned dollar (USD with the $ sign) to my language "dutch" (nl) en left my default language (English) with the currency EUR. However, when I open my website in dutch (which is triggered by surfing to my website /nl) my prices are still in euro and not in dollar. I don't understand where the problem might be, you have any ideas? Thanks!

tr’s picture

Status: Active » Closed (fixed)

@BenLalleke: The Ubercart issue queue is not the place to hold discussions on the development of modules other than core Ubercart. You can pursue this question on ubercart.org, by private communications, or by creating a sandbox project on drupal.org to use for your work.