【问题标题】:woocommerce PayPal link error - comma instead of dotwoocommerce PayPal 链接错误 - 逗号而不是点
【发布时间】:2017-05-26 17:13:33
【问题描述】:

我正在使用最新版本的 WooCoomerce 和 Wordpress。最重要的是我安装了德国市场。我输入我的价格,例如 24,99 欧元。小数位用“,”分隔,千位分隔符用“.”分隔。 我还尝试将小数点设置为“。”和千到“”(空)

支付网关是 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 链接中?

提前致谢

【问题讨论】:

  • 如果您禁用德国市场插件,问题是否仍然存在?
  • @helgatheviking 是的
  • 您是否在 WooCommerce 设置中设置了货币选项?您使用的是哪个版本的 PayPal?我刚刚将我的测试站点切换为逗号小数,无法重现;由 PayPal 标准生成的链接(包含在 WooCommerce 中)看起来像 webscr?cmd=_flow&SESSION=ABCD 并且 GET 变量不是人类可读的。
  • 是的,我在 WooCommerce 中设置了选项。我在哪里可以找到 PayPal 版本?它是 woocommerce 中集成的。
  • 如果您没有添加单独的 PayPal 插件,那么您使用的是 WooCommerce 中包含的 PayPal 标准;我刚刚用here 测试过的相同版本。我建议您禁用所有其他插件,并切换到二十十六主题。我只能猜测你有某种冲突。

标签: php wordpress paypal woocommerce


【解决方案1】:

通过使用 Paypal 的默认 woo commerce 钩子,在不更改 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);

【讨论】:

  • 正确的答案实际上是我自己的 - 你的只是让它保存更新的方法;)
  • 你的答案可能是对的,但最好扩展钩子而不是更改为插件的核心文件。
【解决方案2】:

我在
plugins/woocommerce/includes/gateways/paypal/includes/class-wc-gateway-paypal-request.php311 行编辑了文件:

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

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-09-12
    • 1970-01-01
    • 2021-06-28
    • 2016-07-01
    • 2012-06-09
    • 1970-01-01
    相关资源
    最近更新 更多