将下面的两段代码添加到你的子主题 functions.php 文件里。给你们的多站点站群安装了代码段插件,也可以复制进去,然后再对应的站中启用。
//WooCommerce 中文网关支持 PayPal
//本函数解决的问题:贝宝不支持你的商铺货币。 Gateway Disabled: PayPal does not support your store's currency.
add_filter( 'woocommerce_paypal_supported_currencies', 'enable_custom_currency' );
function enable_custom_currency($currency_array) {
$currency_array[] = 'CNY';
return $currency_array;
}
//WooCommerce 美元人民币转换,汇率可以自己定义
add_filter('woocommerce_paypal_args', 'convert_rmb_to_usd');
function convert_rmb_to_usd($paypal_args){
if ( $paypal_args['currency_code'] == 'CNY'){
$convert_rate = 6.7; //Set converting rate
$count = 1;
while( isset($paypal_args['amount_' . $count]) ){
$paypal_args['amount_' . $count] = round( $paypal_args['amount_' . $count] / $convert_rate, 2);
$count++;
}
}
return $paypal_args;
}