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