woocommerce PayPal链接错误 - 逗号而不是点

时间:2017-01-11 19:11:48

标签: php wordpress paypal woocommerce

我在最新版本中使用WooCoomerce和Wordpress。最重要的是我安装了德国市场。我输入的价格是24,99欧元。小数位置由","分隔开。 "和#34;千分隔符。" 我还尝试将小数设置为"。"和千#"" (空)

支付网关是PayPal。在结账并点击" Pay with PayPal"链接出现以下错误:

The link you have used to enter the PayPal system contains an incorrectly formatted item amount.

我将其缩小为amount_1=49,98内的分号/逗号 (...quantity_1=1&amount_1=49,98&item_number_1=5381

逗号未在链接中工作。如果我把它改成点,它就可以了。

不幸的是我在整个代码或Wordpress设置区找不到任何可以编辑PayPal行为的地方。 有没有人知道如何改变","到了"。"在PayPal链接中?

提前致谢

2 个答案:

答案 0 :(得分:1)

通过使用Paypal的默认woo commerce hook,尝试挂钩您的函数文件而无需更改woo commerce插件的核心文件,

'woocommerce_paypal_args'

your_function_name($array){
    global $woocommerce;
    //Edit your price to send to Paypal

    return $array;
}
add_filter( 'woocommerce_paypal_args','your_function_name',10,1);

答案 1 :(得分:0)

我在 311

的行中plugins/woocommerce/includes/gateways/paypal/includes/class-wc-gateway-paypal-request.php编辑了该文件

FROM:
$this->line_items[ 'amount_' . $index ] = (float) $amount;

TO:
$this->line_items[ 'amount_' . $index ] = (string) str_replace(",", ".", $amount);

现在每个逗号都转换成一个点,一切正常:) 重要 如果存在woocommerce更新,您可能必须重置此项。