2011-10-07 64 views
3

是否存在Ubercart 3(drupal 7)的任何解决方案(如Drupal Ubercart: multi-currency?)或更好地实现此类事件的提示?Ubercart 3(Drupal 7)的多元化

+1

在那里我的朋友,恐怕目前没有什么东西在那里。最近你会得到一个自定义的端口[Ubercart的多货币支持](http://drupal.org/project/multicurrency)模块到Drupal 7 – Clive

+0

似乎是这样。唯一的解决方案 - 是破解uc_store.module文件,为多解决方案提供多种货币 – m0rg0t

回答

1

作为解决方案之一,我找到并使用此:

中的Ubercart /存储/ uc_store.module添加新的定义,例如

define('RUR',0.33); 

其中0.33 - 是默认的货币和新之间的区别货币(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; 
} 
+1

10x。 看起来很简单,干净。 使用这种方法有缺点吗? – 2011-12-03 10:40:13

+0

缺点: 在这个例子中它是核心变化。 同样在Ubercart的管理员和其他部分,它是商店的默认固有特性。 – m0rg0t