Does any solutions for Ubercart 3 (drupal 7) exist (like Drupal Ubercart: multi-currency? ) or tips for better realisation of such thing?
Asked
Active
Viewed 2,694 times
3
-
1Been there my friend, I'm afraid there's absolutely nothing out there at the moment. Closest you'll get is performing a custom port of the [Multi-currency Support for Ubercart](http://drupal.org/project/multicurrency) module to Drupal 7 – Clive Oct 07 '11 at 15:19
-
Seems so. Only solution i make - is hack uc_store.module file to give something like multicurrency – m0rg0t Oct 29 '11 at 21:55
2 Answers
1
As one of solutions, i find and use this:
in ubercart/store/uc_store.module add new define, for example
define('RUR',0.33);
where 0.33 - is difference between default currency and new currency (RUR). rur/dollar = 0.33
and in uc_currency_format function add this:
global $language;
if ($language->language=='ru') {
$sign = ' RUB';
$thou = ',';
$dec = '.';
$value = $value / RUR;
$sign_after = FALSE;
};
And full function:
function uc_currency_format($value, $sign = NULL, $thou = NULL, $dec = NULL) {
if ($value === NULL) {
return NULL;
}
$output = '';
$sign_after = variable_get('uc_sign_after_amount', FALSE);
$prec = variable_get('uc_currency_prec', 2);
if (is_null($sign)) {
$sign = variable_get('uc_currency_sign', '$');
}
if (is_null($thou)) {
$thou = variable_get('uc_currency_thou', ',');
}
if (is_null($dec)) {
$dec = variable_get('uc_currency_dec', '.');
};
// If the value is significantly less than the minimum precision, zero it.
if ($prec > 0 && round(abs($value), $prec + 1) < pow(10, -$prec)) {
$value = 0;
}
global $language;
if ($language->language=='ru') {
$sign = '$';
$thou = ',';
$dec = '.';
$value = $value / RUR;
$sign_after = FALSE;
};
// Force the price to a positive value and add a negative sign if necessary.
if ($value < 0) {
$value = abs($value);
$output .= '-';
}
// Add the currency sign first if specified.
if ($sign && !$sign_after) {
$output .= $sign;
}
// Format the number, like 1234.567 => 1,234.57
$output .= number_format($value, $prec, $dec, $thou);
// Add the currency sign last if specified.
if ($sign && $sign_after) {
$output .= $sign;
};
if ($value=='0') {
$output = t('free');
};
return $output;
}

m0rg0t
- 132
- 2
- 11
-
110x for this solution. Look so simple & clean. Are there disadvantages using this method? – Dec 03 '11 at 10:40
-
disadvantages: in this example it's core changes. Also in admin and other parts of Ubercart it's stil default curency of store. – m0rg0t Dec 04 '11 at 19:16
1
I do not recommend that you hardcode it. You would loose all your changes with next update. Try to check this topic: http://drupal.org/node/1434470#comment-5582812

MPeli
- 570
- 1
- 8
- 19