Ubercart3(Drupal7)有没有什么解决方案(比如Drupal Ubercart: multi-currency? )或者更好的实现这些东西的小贴士?
发布于 2012-02-10 07:16:44
我不建议你硬编码它。在下一次更新时,您将丢失所有更改。请尝试查看此主题:http://drupal.org/node/1434470#comment-5582812
发布于 2011-10-30 05:47:02
作为解决方案之一,我找到并使用了以下内容:
在ubercart/store/uc_store.module中添加新定义,例如
define('RUR',0.33);其中0.33 -是默认货币和新货币(RUR)之间的差异。rur/美元= 0.33
并在uc_currency_format函数中添加以下内容:
global $language;
if ($language->language=='ru') {
$sign = ' RUB';
$thou = ',';
$dec = '.';
$value = $value / RUR;
$sign_after = FALSE;
};和完整的功能:
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;
}https://stackoverflow.com/questions/7688662
复制相似问题